System.Data.SQLite

Check-in [50be008078]
Login

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

Overview
Comment:Update SQLite core library to the latest trunk code. Update version history docs.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 50be0080788246eb6c3a654f29ec4913c42f71bb
User & Date: mistachkin 2018-05-28 23:30:03.263
Context
2018-05-28
23:41
Fix compilation issues due to internal changes in the SQLite core library. check-in: fb73a8c990 user: mistachkin tags: trunk
23:30
Update SQLite core library to the latest trunk code. Update version history docs. check-in: 50be008078 user: mistachkin tags: trunk
2018-05-25
03:29
Pickup changes to Eagle script library in externals. check-in: c5879a3ba6 user: mistachkin tags: trunk
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to Doc/Extra/Provider/version.html.
39
40
41
42
43
44
45
46

47
48

49
50
51
52
53
54
55
39
40
41
42
43
44
45

46
47

48
49
50
51
52
53
54
55







-
+

-
+







          </td>
        </tr>
      </table>
    </div>
    <div id="mainSection">
    <div id="mainBody">
    <h1 class="heading">Version History</h1>
    <p><b>1.0.109.0 - May XX, 2018 <font color="red">(release scheduled)</font></b></p>
    <p><b>1.0.109.0 - June XX, 2018 <font color="red">(release scheduled)</font></b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/releaselog/3_23_2.html">SQLite 3.23.2</a>.</li>
      <li>Updated to <a href="https://www.sqlite.org/draft/releaselog/3_24_0.html">SQLite 3.24.0</a>.</li>
      <li>Prevent GetSchemaTable from throwing InvalidCastException. Fix for <a href="https://system.data.sqlite.org/index.html/info/baf42ee135">[baf42ee135]</a>.</li>
      <li>Add preliminary support for the .NET Framework 4.7.2.</li>
      <li>Add preliminary support for .NET Core 2.0 and the .NET Standard 2.0. Pursuant to <a href="https://system.data.sqlite.org/index.html/info/5c89cecd1b">[5c89cecd1b]</a>.</li>
      <li>Add simpler overload for the SQLiteBlob.Create method. Pursuant to <a href="https://system.data.sqlite.org/index.html/info/dfc8133ba2">[dfc8133ba2]</a>.</li>
      <li>Add GetFieldAffinity method to the SQLiteDataReader class.</li>
    </ul>
    <p><b>1.0.108.0 - March 2, 2018</b></p>
Changes to SQLite.Interop/props/sqlite3.props.
1
2
3
4
5
6
7
8
9
10
11
12
13


14
15
16
17
18
19
20
1
2
3
4
5
6
7
8
9
10
11


12
13
14
15
16
17
18
19
20











-
-
+
+







<?xml version="1.0" encoding="utf-8"?>
<!--
 *
 * sqlite3.props -
 *
 * Written by Joe Mistachkin.
 * Released to the public domain, use at your own risk!
 *
-->
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup Label="UserMacros">
    <SQLITE_MANIFEST_VERSION>3.23.2.0</SQLITE_MANIFEST_VERSION>
    <SQLITE_RC_VERSION>3,23,2,0</SQLITE_RC_VERSION>
    <SQLITE_MANIFEST_VERSION>3.24.0.0</SQLITE_MANIFEST_VERSION>
    <SQLITE_RC_VERSION>3,24,0,0</SQLITE_RC_VERSION>
    <SQLITE_COMMON_DEFINES>_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;SQLITE_THREADSAFE=1;SQLITE_USE_URI=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_STAT4=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_LOAD_EXTENSION=1;SQLITE_ENABLE_RTREE=1;SQLITE_SOUNDEX=1;SQLITE_ENABLE_MEMORY_MANAGEMENT=1;SQLITE_ENABLE_API_ARMOR=1;SQLITE_ENABLE_DBSTAT_VTAB=1;SQLITE_ENABLE_STMTVTAB=1</SQLITE_COMMON_DEFINES>
    <SQLITE_EXTRA_DEFINES>SQLITE_PLACEHOLDER=1;SQLITE_HAS_CODEC=1</SQLITE_EXTRA_DEFINES>
    <SQLITE_WINCE_200X_DEFINES>SQLITE_OMIT_WAL=1</SQLITE_WINCE_200X_DEFINES>
    <SQLITE_WINCE_2013_DEFINES>HAVE_ERRNO_H=1;SQLITE_MSVC_LOCALTIME_API=1</SQLITE_WINCE_2013_DEFINES>
    <SQLITE_DEBUG_DEFINES>SQLITE_DEBUG=1;SQLITE_MEMDEBUG=1;SQLITE_ENABLE_EXPENSIVE_ASSERT=1</SQLITE_DEBUG_DEFINES>
    <SQLITE_RELEASE_DEFINES>SQLITE_WIN32_MALLOC=1</SQLITE_RELEASE_DEFINES>
    <SQLITE_DISABLE_WARNINGS>4055;4100;4127;4146;4210;4232;4244;4245;4267;4306;4389;4701;4703;4706</SQLITE_DISABLE_WARNINGS>
Changes to SQLite.Interop/props/sqlite3.vsprops.
10
11
12
13
14
15
16
17

18
19
20
21
22

23
24
25
26
27
28
29
10
11
12
13
14
15
16

17
18
19
20
21

22
23
24
25
26
27
28
29







-
+




-
+







<VisualStudioPropertySheet
	ProjectType="Visual C++"
	Version="8.00"
	Name="sqlite3"
	>
	<UserMacro
		Name="SQLITE_MANIFEST_VERSION"
		Value="3.23.2.0"
		Value="3.24.0.0"
		PerformEnvironmentSet="true"
	/>
	<UserMacro
		Name="SQLITE_RC_VERSION"
		Value="3,23,2,0"
		Value="3,24,0,0"
		PerformEnvironmentSet="true"
	/>
	<UserMacro
		Name="SQLITE_COMMON_DEFINES"
		Value="_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;SQLITE_THREADSAFE=1;SQLITE_USE_URI=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_STAT4=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_LOAD_EXTENSION=1;SQLITE_ENABLE_RTREE=1;SQLITE_SOUNDEX=1;SQLITE_ENABLE_MEMORY_MANAGEMENT=1;SQLITE_ENABLE_API_ARMOR=1;SQLITE_ENABLE_DBSTAT_VTAB=1;SQLITE_ENABLE_STMTVTAB=1"
		PerformEnvironmentSet="true"
	/>
Changes to SQLite.Interop/src/core/sqlite3.c.
1
2
3

4
5
6
7
8
9
10
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.2.  By combining all the individual C code files into this
** version 3.24.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
306
307
308
309
310
311
312



313
314
315
316
317
318
319
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322







+
+
+







  "ENABLE_SELECTTRACE",
#endif
#if SQLITE_ENABLE_SESSION
  "ENABLE_SESSION",
#endif
#if SQLITE_ENABLE_SNAPSHOT
  "ENABLE_SNAPSHOT",
#endif
#if SQLITE_ENABLE_SORTER_REFERENCES
  "ENABLE_SORTER_REFERENCES",
#endif
#if SQLITE_ENABLE_SQLLOG
  "ENABLE_SQLLOG",
#endif
#if defined(SQLITE_ENABLE_STAT4)
  "ENABLE_STAT4",
#elif defined(SQLITE_ENABLE_STAT3)
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152



1153
1154
1155
1156
1157
1158
1159
1146
1147
1148
1149
1150
1151
1152



1153
1154
1155
1156
1157
1158
1159
1160
1161
1162







-
-
-
+
+
+







** 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.2"
#define SQLITE_VERSION_NUMBER 3023002
#define SQLITE_SOURCE_ID      "2018-04-28 01:48:40 f677065aab61037914fc980456caaa60132a19b387d6d717ec1a6b6fa7c6alt1"
#define SQLITE_VERSION        "3.24.0"
#define SQLITE_VERSION_NUMBER 3024000
#define SQLITE_SOURCE_ID      "2018-05-28 18:29:46 469a62ca33081854e54f3af6d93ab5a350484b149c8c8c4ee8be0ae5418382d9"

/*
** 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
1524
1525
1526
1527
1528
1529
1530

1531
1532
1533
1534
1535
1536
1537

1538
1539
1540
1541
1542
1543
1544
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549







+







+







#define SQLITE_IOERR_CONVPATH          (SQLITE_IOERR | (26<<8))
#define SQLITE_IOERR_VNODE             (SQLITE_IOERR | (27<<8))
#define SQLITE_IOERR_AUTH              (SQLITE_IOERR | (28<<8))
#define SQLITE_IOERR_BEGIN_ATOMIC      (SQLITE_IOERR | (29<<8))
#define SQLITE_IOERR_COMMIT_ATOMIC     (SQLITE_IOERR | (30<<8))
#define SQLITE_IOERR_ROLLBACK_ATOMIC   (SQLITE_IOERR | (31<<8))
#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))
#define SQLITE_LOCKED_VTAB             (SQLITE_LOCKED |  (2<<8))
#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
#define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))
#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))
#define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))
#define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))
#define SQLITE_CANTOPEN_CONVPATH       (SQLITE_CANTOPEN | (4<<8))
#define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))
#define SQLITE_CORRUPT_SEQUENCE        (SQLITE_CORRUPT | (2<<8))
#define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))
#define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))
#define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))
#define SQLITE_READONLY_DBMOVED        (SQLITE_READONLY | (4<<8))
#define SQLITE_READONLY_CANTINIT       (SQLITE_READONLY | (5<<8))
#define SQLITE_READONLY_DIRECTORY      (SQLITE_READONLY | (6<<8))
#define SQLITE_ABORT_ROLLBACK          (SQLITE_ABORT | (2<<8))
2950
2951
2952
2953
2954
2955
2956
















2957
2958
2959
2960
2961
2962
2963
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







** Or if the threshold is -1, statement journals are always held
** exclusively in memory.
** Since many statement journals never become large, setting the spill
** threshold to a value such as 64KiB can greatly reduce the amount of
** I/O required to support statement rollback.
** The default value for this setting is controlled by the
** [SQLITE_STMTJRNL_SPILL] compile-time option.
**
** [[SQLITE_CONFIG_SORTERREF_SIZE]]
** <dt>SQLITE_CONFIG_SORTERREF_SIZE
** <dd>The SQLITE_CONFIG_SORTERREF_SIZE option accepts a single parameter
** of type (int) - the new value of the sorter-reference size threshold.
** Usually, when SQLite uses an external sort to order records according
** to an ORDER BY clause, all fields required by the caller are present in the
** sorted records. However, if SQLite determines based on the declared type
** of a table column that its values are likely to be very large - larger
** than the configured sorter-reference size threshold - then a reference
** is stored in each sorted record and the required column values loaded
** from the database as records are returned in sorted order. The default
** value for this option is to never use this optimization. Specifying a 
** negative value for this option restores the default behaviour.
** This option is only available if SQLite is compiled with the
** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.
** </dl>
*/
#define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
#define SQLITE_CONFIG_MULTITHREAD   2  /* nil */
#define SQLITE_CONFIG_SERIALIZED    3  /* nil */
#define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */
#define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */
2979
2980
2981
2982
2983
2984
2985

2986
2987
2988
2989
2990
2991
2992
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014







+







#define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */
#define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */
#define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */
#define SQLITE_CONFIG_PCACHE_HDRSZ        24  /* int *psz */
#define SQLITE_CONFIG_PMASZ               25  /* unsigned int szPma */
#define SQLITE_CONFIG_STMTJRNL_SPILL      26  /* int nByte */
#define SQLITE_CONFIG_SMALL_MALLOC        27  /* boolean */
#define SQLITE_CONFIG_SORTERREF_SIZE      28  /* int nByte */

/*
** CAPI3REF: Database Connection Configuration Options
**
** These constants are the available integer configuration options that
** can be passed as the second argument to the [sqlite3_db_config()] interface.
**
3115
3116
3117
3118
3119
3120
3121















3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132

3133

3134
3135
3136
3137
3138
3139
3140
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170

3171
3172
3173
3174
3175
3176
3177
3178







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+











+
-
+







** behavior. The first parameter passed to this operation is an integer -
** positive to enable output for trigger programs, or zero to disable it,
** or negative to leave the setting unchanged.
** The second parameter is a pointer to an integer into which is written 
** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if 
** it is not disabled, 1 if it is.  
** </dd>
**
** <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
** [VACUUM] in order to reset a database back to an empty database
** with no schema and no content. The following process works even for
** a badly corrupted database file:
** <ol>
** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
** <li> [sqlite3_exec](db, "[VACUUM]", 0, 0, 0);
** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
** </ol>
** Because resetting a database is destructive and irreversible, the
** process requires the use of this obscure API and multiple steps to help
** ensure that it does not happen by accident.
** </dd>
** </dl>
*/
#define SQLITE_DBCONFIG_MAINDBNAME            1000 /* const char* */
#define SQLITE_DBCONFIG_LOOKASIDE             1001 /* void* int int */
#define SQLITE_DBCONFIG_ENABLE_FKEY           1002 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_TRIGGER        1003 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE      1006 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_QPSG           1007 /* int int* */
#define SQLITE_DBCONFIG_TRIGGER_EQP           1008 /* int int* */
#define SQLITE_DBCONFIG_RESET_DATABASE        1009 /* int int* */
#define SQLITE_DBCONFIG_MAX                   1008 /* Largest DBCONFIG */
#define SQLITE_DBCONFIG_MAX                   1009 /* Largest DBCONFIG */

/*
** CAPI3REF: Enable Or Disable Extended Result Codes
** METHOD: sqlite3
**
** ^The sqlite3_extended_result_codes() routine enables or disables the
** [extended result codes] feature of SQLite. ^The extended result
7279
7280
7281
7282
7283
7284
7285




7286
7287
7288
7289
7290
7291
7292
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334







+
+
+
+







  int idxFlags;              /* Mask of SQLITE_INDEX_SCAN_* flags */
  /* Fields below are only available in SQLite 3.10.0 and later */
  sqlite3_uint64 colUsed;    /* Input: Mask of columns used by statement */
};

/*
** CAPI3REF: Virtual Table Scan Flags
**
** Virtual table implementations are allowed to set the 
** [sqlite3_index_info].idxFlags field to some combination of
** these bits.
*/
#define SQLITE_INDEX_SCAN_UNIQUE      1     /* Scan visits at most 1 row */

/*
** CAPI3REF: Virtual Table Constraint Operator Codes
**
** These macros defined the allowed values for the
8054
8055
8056
8057
8058
8059
8060
8061

8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074























































































































































































8075
8076
8077
8078
8079
8080
8081
8096
8097
8098
8099
8100
8101
8102

8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306







-
+













+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







#define SQLITE_TESTCTRL_FAULT_INSTALL            9
#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS     10
#define SQLITE_TESTCTRL_PENDING_BYTE            11
#define SQLITE_TESTCTRL_ASSERT                  12
#define SQLITE_TESTCTRL_ALWAYS                  13
#define SQLITE_TESTCTRL_RESERVE                 14
#define SQLITE_TESTCTRL_OPTIMIZATIONS           15
#define SQLITE_TESTCTRL_ISKEYWORD               16
#define SQLITE_TESTCTRL_ISKEYWORD               16  /* NOT USED */
#define SQLITE_TESTCTRL_SCRATCHMALLOC           17  /* NOT USED */
#define SQLITE_TESTCTRL_LOCALTIME_FAULT         18
#define SQLITE_TESTCTRL_EXPLAIN_STMT            19  /* NOT USED */
#define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD    19
#define SQLITE_TESTCTRL_NEVER_CORRUPT           20
#define SQLITE_TESTCTRL_VDBE_COVERAGE           21
#define SQLITE_TESTCTRL_BYTEORDER               22
#define SQLITE_TESTCTRL_ISINIT                  23
#define SQLITE_TESTCTRL_SORTER_MMAP             24
#define SQLITE_TESTCTRL_IMPOSTER                25
#define SQLITE_TESTCTRL_PARSER_COVERAGE         26
#define SQLITE_TESTCTRL_LAST                    26  /* Largest TESTCTRL */

/*
** CAPI3REF: SQL Keyword Checking
**
** These routines provide access to the set of SQL language keywords 
** recognized by SQLite.  Applications can uses these routines to determine
** whether or not a specific identifier needs to be escaped (for example,
** by enclosing in double-quotes) so as not to confuse the parser.
**
** The sqlite3_keyword_count() interface returns the number of distinct
** keywords understood by SQLite.
**
** The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and
** makes *Z point to that keyword expressed as UTF8 and writes the number
** of bytes in the keyword into *L.  The string that *Z points to is not
** zero-terminated.  The sqlite3_keyword_name(N,Z,L) routine returns
** SQLITE_OK if N is within bounds and SQLITE_ERROR if not. If either Z
** or L are NULL or invalid pointers then calls to
** sqlite3_keyword_name(N,Z,L) result in undefined behavior.
**
** The sqlite3_keyword_check(Z,L) interface checks to see whether or not
** the L-byte UTF8 identifier that Z points to is a keyword, returning non-zero
** if it is and zero if not.
**
** The parser used by SQLite is forgiving.  It is often possible to use
** a keyword as an identifier as long as such use does not result in a
** parsing ambiguity.  For example, the statement
** "CREATE TABLE BEGIN(REPLACE,PRAGMA,END);" is accepted by SQLite, and
** creates a new table named "BEGIN" with three columns named
** "REPLACE", "PRAGMA", and "END".  Nevertheless, best practice is to avoid
** using keywords as identifiers.  Common techniques used to avoid keyword
** name collisions include:
** <ul>
** <li> Put all identifier names inside double-quotes.  This is the official
**      SQL way to escape identifier names.
** <li> Put identifier names inside &#91;...&#93;.  This is not standard SQL,
**      but it is what SQL Server does and so lots of programmers use this
**      technique.
** <li> Begin every identifier with the letter "Z" as no SQL keywords start
**      with "Z".
** <li> Include a digit somewhere in every identifier name.
** </ul>
**
** Note that the number of keywords understood by SQLite can depend on
** compile-time options.  For example, "VACUUM" is not a keyword if
** SQLite is compiled with the [-DSQLITE_OMIT_VACUUM] option.  Also,
** new keywords may be added to future releases of SQLite.
*/
SQLITE_API int sqlite3_keyword_count(void);
SQLITE_API int sqlite3_keyword_name(int,const char**,int*);
SQLITE_API int sqlite3_keyword_check(const char*,int);

/*
** CAPI3REF: Dynamic String Object
** KEYWORDS: {dynamic string}
**
** An instance of the sqlite3_str object contains a dynamically-sized
** string under construction.
**
** The lifecycle of an sqlite3_str object is as follows:
** <ol>
** <li> ^The sqlite3_str object is created using [sqlite3_str_new()].
** <li> ^Text is appended to the sqlite3_str object using various
** methods, such as [sqlite3_str_appendf()].
** <li> ^The sqlite3_str object is destroyed and the string it created
** is returned using the [sqlite3_str_finish()] interface.
** </ol>
*/
typedef struct sqlite3_str sqlite3_str;

/*
** CAPI3REF: Create A New Dynamic String Object
** CONSTRUCTOR: sqlite3_str
**
** ^The [sqlite3_str_new(D)] interface allocates and initializes
** a new [sqlite3_str] object.  To avoid memory leaks, the object returned by
** [sqlite3_str_new()] must be freed by a subsequent call to 
** [sqlite3_str_finish(X)].
**
** ^The [sqlite3_str_new(D)] interface always returns a pointer to a
** valid [sqlite3_str] object, though in the event of an out-of-memory
** error the returned object might be a special singleton that will
** silently reject new text, always return SQLITE_NOMEM from 
** [sqlite3_str_errcode()], always return 0 for 
** [sqlite3_str_length()], and always return NULL from
** [sqlite3_str_finish(X)].  It is always safe to use the value
** returned by [sqlite3_str_new(D)] as the sqlite3_str parameter
** to any of the other [sqlite3_str] methods.
**
** The D parameter to [sqlite3_str_new(D)] may be NULL.  If the
** D parameter in [sqlite3_str_new(D)] is not NULL, then the maximum
** length of the string contained in the [sqlite3_str] object will be
** the value set for [sqlite3_limit](D,[SQLITE_LIMIT_LENGTH]) instead
** of [SQLITE_MAX_LENGTH].
*/
SQLITE_API sqlite3_str *sqlite3_str_new(sqlite3*);

/*
** CAPI3REF: Finalize A Dynamic String
** DESTRUCTOR: sqlite3_str
**
** ^The [sqlite3_str_finish(X)] interface destroys the sqlite3_str object X
** and returns a pointer to a memory buffer obtained from [sqlite3_malloc64()]
** that contains the constructed string.  The calling application should
** pass the returned value to [sqlite3_free()] to avoid a memory leak.
** ^The [sqlite3_str_finish(X)] interface may return a NULL pointer if any
** errors were encountered during construction of the string.  ^The
** [sqlite3_str_finish(X)] interface will also return a NULL pointer if the
** string in [sqlite3_str] object X is zero bytes long.
*/
SQLITE_API char *sqlite3_str_finish(sqlite3_str*);

/*
** CAPI3REF: Add Content To A Dynamic String
** METHOD: sqlite3_str
**
** These interfaces add content to an sqlite3_str object previously obtained
** from [sqlite3_str_new()].
**
** ^The [sqlite3_str_appendf(X,F,...)] and 
** [sqlite3_str_vappendf(X,F,V)] interfaces uses the [built-in printf]
** functionality of SQLite to append formatted text onto the end of 
** [sqlite3_str] object X.
**
** ^The [sqlite3_str_append(X,S,N)] method appends exactly N bytes from string S
** onto the end of the [sqlite3_str] object X.  N must be non-negative.
** S must contain at least N non-zero bytes of content.  To append a
** zero-terminated string in its entirety, use the [sqlite3_str_appendall()]
** method instead.
**
** ^The [sqlite3_str_appendall(X,S)] method appends the complete content of
** zero-terminated string S onto the end of [sqlite3_str] object X.
**
** ^The [sqlite3_str_appendchar(X,N,C)] method appends N copies of the
** single-byte character C onto the end of [sqlite3_str] object X.
** ^This method can be used, for example, to add whitespace indentation.
**
** ^The [sqlite3_str_reset(X)] method resets the string under construction
** inside [sqlite3_str] object X back to zero bytes in length.  
**
** These methods do not return a result code.  ^If an error occurs, that fact
** is recorded in the [sqlite3_str] object and can be recovered by a
** subsequent call to [sqlite3_str_errcode(X)].
*/
SQLITE_API void sqlite3_str_appendf(sqlite3_str*, const char *zFormat, ...);
SQLITE_API void sqlite3_str_vappendf(sqlite3_str*, const char *zFormat, va_list);
SQLITE_API void sqlite3_str_append(sqlite3_str*, const char *zIn, int N);
SQLITE_API void sqlite3_str_appendall(sqlite3_str*, const char *zIn);
SQLITE_API void sqlite3_str_appendchar(sqlite3_str*, int N, char C);
SQLITE_API void sqlite3_str_reset(sqlite3_str*);

/*
** CAPI3REF: Status Of A Dynamic String
** METHOD: sqlite3_str
**
** These interfaces return the current status of an [sqlite3_str] object.
**
** ^If any prior errors have occurred while constructing the dynamic string
** in sqlite3_str X, then the [sqlite3_str_errcode(X)] method will return
** an appropriate error code.  ^The [sqlite3_str_errcode(X)] method returns
** [SQLITE_NOMEM] following any out-of-memory error, or
** [SQLITE_TOOBIG] if the size of the dynamic string exceeds
** [SQLITE_MAX_LENGTH], or [SQLITE_OK] if there have been no errors.
**
** ^The [sqlite3_str_length(X)] method returns the current length, in bytes,
** of the dynamic string under construction in [sqlite3_str] object X.
** ^The length returned by [sqlite3_str_length(X)] does not include the
** zero-termination byte.
**
** ^The [sqlite3_str_value(X)] method returns a pointer to the current
** content of the dynamic string under construction in X.  The value
** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X
** and might be freed or altered by any subsequent method on the same
** [sqlite3_str] object.  Applications must not used the pointer returned
** [sqlite3_str_value(X)] after any subsequent method call on the same
** object.  ^Applications may change the content of the string returned
** by [sqlite3_str_value(X)] as long as they do not write into any bytes
** outside the range of 0 to [sqlite3_str_length(X)] and do not read or
** write any byte after any subsequent sqlite3_str method call.
*/
SQLITE_API int sqlite3_str_errcode(sqlite3_str*);
SQLITE_API int sqlite3_str_length(sqlite3_str*);
SQLITE_API char *sqlite3_str_value(sqlite3_str*);

/*
** CAPI3REF: SQLite Runtime Status
**
** ^These interfaces are used to retrieve runtime status information
** about the performance of SQLite, and optionally to reset various
** highwater marks.  ^The first argument is an integer code for
** the specific parameter to measure.  ^(Recognized integer codes
9337
9338
9339
9340
9341
9342
9343
9344
9345


9346
9347
9348

9349
9350
9351
9352
9353
9354
9355
9562
9563
9564
9565
9566
9567
9568


9569
9570
9571
9572

9573
9574
9575
9576
9577
9578
9579
9580







-
-
+
+


-
+







/*
** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE
**
** If the sqlite3_vtab_nochange(X) routine is called within the [xColumn]
** method of a [virtual table], then it returns true if and only if the
** column is being fetched as part of an UPDATE operation during which the
** column value will not change.  Applications might use this to substitute
** a lighter-weight value to return that the corresponding [xUpdate] method
** understands as a "no-change" value.
** a return value that is less expensive to compute and that the corresponding
** [xUpdate] method understands as a "no-change" value.
**
** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that
** the column is not changed by the UPDATE statement, they the xColumn
** the column is not changed by the UPDATE statement, then the xColumn
** method can optionally return without setting a result, without calling
** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].
** In that case, [sqlite3_value_nochange(X)] will return true for the
** same column in the [xUpdate] method.
*/
SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);

12972
12973
12974
12975
12976
12977
12978

12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024















































13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079























































13080
13081
13082
13083
13084
13085
13086
13197
13198
13199
13200
13201
13202
13203
13204














































13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251























































13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313







+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







#define TK_GT                              54
#define TK_LE                              55
#define TK_LT                              56
#define TK_GE                              57
#define TK_ESCAPE                          58
#define TK_ID                              59
#define TK_COLUMNKW                        60
#define TK_DO                              61
#define TK_FOR                             61
#define TK_IGNORE                          62
#define TK_INITIALLY                       63
#define TK_INSTEAD                         64
#define TK_NO                              65
#define TK_KEY                             66
#define TK_OF                              67
#define TK_OFFSET                          68
#define TK_PRAGMA                          69
#define TK_RAISE                           70
#define TK_RECURSIVE                       71
#define TK_REPLACE                         72
#define TK_RESTRICT                        73
#define TK_ROW                             74
#define TK_TRIGGER                         75
#define TK_VACUUM                          76
#define TK_VIEW                            77
#define TK_VIRTUAL                         78
#define TK_WITH                            79
#define TK_REINDEX                         80
#define TK_RENAME                          81
#define TK_CTIME_KW                        82
#define TK_ANY                             83
#define TK_BITAND                          84
#define TK_BITOR                           85
#define TK_LSHIFT                          86
#define TK_RSHIFT                          87
#define TK_PLUS                            88
#define TK_MINUS                           89
#define TK_STAR                            90
#define TK_SLASH                           91
#define TK_REM                             92
#define TK_CONCAT                          93
#define TK_COLLATE                         94
#define TK_BITNOT                          95
#define TK_INDEXED                         96
#define TK_STRING                          97
#define TK_JOIN_KW                         98
#define TK_CONSTRAINT                      99
#define TK_DEFAULT                        100
#define TK_NULL                           101
#define TK_PRIMARY                        102
#define TK_UNIQUE                         103
#define TK_CHECK                          104
#define TK_REFERENCES                     105
#define TK_AUTOINCR                       106
#define TK_FOR                             62
#define TK_IGNORE                          63
#define TK_INITIALLY                       64
#define TK_INSTEAD                         65
#define TK_NO                              66
#define TK_KEY                             67
#define TK_OF                              68
#define TK_OFFSET                          69
#define TK_PRAGMA                          70
#define TK_RAISE                           71
#define TK_RECURSIVE                       72
#define TK_REPLACE                         73
#define TK_RESTRICT                        74
#define TK_ROW                             75
#define TK_TRIGGER                         76
#define TK_VACUUM                          77
#define TK_VIEW                            78
#define TK_VIRTUAL                         79
#define TK_WITH                            80
#define TK_REINDEX                         81
#define TK_RENAME                          82
#define TK_CTIME_KW                        83
#define TK_ANY                             84
#define TK_BITAND                          85
#define TK_BITOR                           86
#define TK_LSHIFT                          87
#define TK_RSHIFT                          88
#define TK_PLUS                            89
#define TK_MINUS                           90
#define TK_STAR                            91
#define TK_SLASH                           92
#define TK_REM                             93
#define TK_CONCAT                          94
#define TK_COLLATE                         95
#define TK_BITNOT                          96
#define TK_ON                              97
#define TK_INDEXED                         98
#define TK_STRING                          99
#define TK_JOIN_KW                        100
#define TK_CONSTRAINT                     101
#define TK_DEFAULT                        102
#define TK_NULL                           103
#define TK_PRIMARY                        104
#define TK_UNIQUE                         105
#define TK_CHECK                          106
#define TK_REFERENCES                     107
#define TK_AUTOINCR                       108
#define TK_ON                             107
#define TK_INSERT                         108
#define TK_DELETE                         109
#define TK_UPDATE                         110
#define TK_SET                            111
#define TK_DEFERRABLE                     112
#define TK_FOREIGN                        113
#define TK_DROP                           114
#define TK_UNION                          115
#define TK_ALL                            116
#define TK_EXCEPT                         117
#define TK_INTERSECT                      118
#define TK_SELECT                         119
#define TK_VALUES                         120
#define TK_DISTINCT                       121
#define TK_DOT                            122
#define TK_FROM                           123
#define TK_JOIN                           124
#define TK_USING                          125
#define TK_ORDER                          126
#define TK_GROUP                          127
#define TK_HAVING                         128
#define TK_LIMIT                          129
#define TK_WHERE                          130
#define TK_INTO                           131
#define TK_FLOAT                          132
#define TK_BLOB                           133
#define TK_INTEGER                        134
#define TK_VARIABLE                       135
#define TK_CASE                           136
#define TK_WHEN                           137
#define TK_THEN                           138
#define TK_ELSE                           139
#define TK_INDEX                          140
#define TK_ALTER                          141
#define TK_ADD                            142
#define TK_TRUEFALSE                      143
#define TK_ISNOT                          144
#define TK_FUNCTION                       145
#define TK_COLUMN                         146
#define TK_AGG_FUNCTION                   147
#define TK_AGG_COLUMN                     148
#define TK_UMINUS                         149
#define TK_UPLUS                          150
#define TK_TRUTH                          151
#define TK_REGISTER                       152
#define TK_VECTOR                         153
#define TK_SELECT_COLUMN                  154
#define TK_IF_NULL_ROW                    155
#define TK_ASTERISK                       156
#define TK_SPAN                           157
#define TK_END_OF_FILE                    158
#define TK_UNCLOSED_STRING                159
#define TK_SPACE                          160
#define TK_ILLEGAL                        161
#define TK_INSERT                         109
#define TK_DELETE                         110
#define TK_UPDATE                         111
#define TK_SET                            112
#define TK_DEFERRABLE                     113
#define TK_FOREIGN                        114
#define TK_DROP                           115
#define TK_UNION                          116
#define TK_ALL                            117
#define TK_EXCEPT                         118
#define TK_INTERSECT                      119
#define TK_SELECT                         120
#define TK_VALUES                         121
#define TK_DISTINCT                       122
#define TK_DOT                            123
#define TK_FROM                           124
#define TK_JOIN                           125
#define TK_USING                          126
#define TK_ORDER                          127
#define TK_GROUP                          128
#define TK_HAVING                         129
#define TK_LIMIT                          130
#define TK_WHERE                          131
#define TK_INTO                           132
#define TK_NOTHING                        133
#define TK_FLOAT                          134
#define TK_BLOB                           135
#define TK_INTEGER                        136
#define TK_VARIABLE                       137
#define TK_CASE                           138
#define TK_WHEN                           139
#define TK_THEN                           140
#define TK_ELSE                           141
#define TK_INDEX                          142
#define TK_ALTER                          143
#define TK_ADD                            144
#define TK_TRUEFALSE                      145
#define TK_ISNOT                          146
#define TK_FUNCTION                       147
#define TK_COLUMN                         148
#define TK_AGG_FUNCTION                   149
#define TK_AGG_COLUMN                     150
#define TK_UMINUS                         151
#define TK_UPLUS                          152
#define TK_TRUTH                          153
#define TK_REGISTER                       154
#define TK_VECTOR                         155
#define TK_SELECT_COLUMN                  156
#define TK_IF_NULL_ROW                    157
#define TK_ASTERISK                       158
#define TK_SPAN                           159
#define TK_END_OF_FILE                    160
#define TK_UNCLOSED_STRING                161
#define TK_SPACE                          162
#define TK_ILLEGAL                        163

/* The token codes above must all fit in 8 bits */
#define TKFLG_MASK           0xff  

/* Flags that can be added to a token code when it is not
** being stored in a u8: */
#define TKFLG_DONTFOLD       0x100  /* Omit constant folding optimizations */
13192
13193
13194
13195
13196
13197
13198







13199
13200
13201
13202
13203
13204
13205
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439







+
+
+
+
+
+
+







** The default value of "20" was choosen to minimize the run-time of the
** speedtest1 test program with options: --shrink-memory --reprepare
*/
#ifndef SQLITE_DEFAULT_PCACHE_INITSZ
# define SQLITE_DEFAULT_PCACHE_INITSZ 20
#endif

/*
** Default value for the SQLITE_CONFIG_SORTERREF_SIZE option.
*/
#ifndef SQLITE_DEFAULT_SORTERREF_SIZE
# define SQLITE_DEFAULT_SORTERREF_SIZE 0x7fffffff
#endif

/*
** The compile-time options SQLITE_MMAP_READWRITE and 
** SQLITE_ENABLE_BATCH_ATOMIC_WRITE are not compatible with one another.
** You must choose one or the other (or neither) but not both.
*/
#if defined(SQLITE_MMAP_READWRITE) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
#error Cannot use both SQLITE_MMAP_READWRITE and SQLITE_ENABLE_BATCH_ATOMIC_WRITE
13641
13642
13643
13644
13645
13646
13647
13648

13649
13650
13651
13652
13653
13654
13655
13656

13657
13658
13659
13660
13661
13662
13663
13875
13876
13877
13878
13879
13880
13881

13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898







-
+








+







typedef struct PrintfArguments PrintfArguments;
typedef struct RowSet RowSet;
typedef struct Savepoint Savepoint;
typedef struct Select Select;
typedef struct SQLiteThread SQLiteThread;
typedef struct SelectDest SelectDest;
typedef struct SrcList SrcList;
typedef struct StrAccum StrAccum;
typedef struct sqlite3_str StrAccum; /* Internal alias for sqlite3_str */
typedef struct Table Table;
typedef struct TableLock TableLock;
typedef struct Token Token;
typedef struct TreeView TreeView;
typedef struct Trigger Trigger;
typedef struct TriggerPrg TriggerPrg;
typedef struct TriggerStep TriggerStep;
typedef struct UnpackedRecord UnpackedRecord;
typedef struct Upsert Upsert;
typedef struct VTable VTable;
typedef struct VtabCtx VtabCtx;
typedef struct Walker Walker;
typedef struct WhereInfo WhereInfo;
typedef struct With With;

/* A VList object records a mapping between parameters/variables/wildcards
13932
13933
13934
13935
13936
13937
13938
13939
13940




13941
13942
13943
13944
13945













13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956

13957
13958
13959
13960
13961
13962
13963
14167
14168
14169
14170
14171
14172
14173


14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205

14206
14207
14208
14209
14210
14211
14212
14213







-
-
+
+
+
+





+
+
+
+
+
+
+
+
+
+
+
+
+










-
+







#define BTREE_AUXDELETE    0x04  /* not the primary delete operation */
#define BTREE_APPEND       0x08  /* Insert is likely an append */

/* An instance of the BtreePayload object describes the content of a single
** entry in either an index or table btree.
**
** Index btrees (used for indexes and also WITHOUT ROWID tables) contain
** an arbitrary key and no data.  These btrees have pKey,nKey set to their
** key and pData,nData,nZero set to zero.
** an arbitrary key and no data.  These btrees have pKey,nKey set to the
** key and the pData,nData,nZero fields are uninitialized.  The aMem,nMem
** fields give an array of Mem objects that are a decomposition of the key.
** The nMem field might be zero, indicating that no decomposition is available.
**
** Table btrees (used for rowid tables) contain an integer rowid used as
** the key and passed in the nKey field.  The pKey field is zero.  
** pData,nData hold the content of the new entry.  nZero extra zero bytes
** are appended to the end of the content when constructing the entry.
** The aMem,nMem fields are uninitialized for table btrees.
**
** Field usage summary:
**
**               Table BTrees                   Index Btrees
**
**   pKey        always NULL                    encoded key
**   nKey        the ROWID                      length of pKey
**   pData       data                           not used
**   aMem        not used                       decomposed key value
**   nMem        not used                       entries in aMem
**   nData       length of pData                not used
**   nZero       extra zeros after pData        not used
**
** This object is used to pass information into sqlite3BtreeInsert().  The
** same information used to be passed as five separate parameters.  But placing
** the information into this object helps to keep the interface more 
** organized and understandable, and it also helps the resulting code to
** run a little faster by using fewer registers for parameter passing.
*/
struct BtreePayload {
  const void *pKey;       /* Key content for indexes.  NULL for tables */
  sqlite3_int64 nKey;     /* Size of pKey for indexes.  PRIMARY KEY for tabs */
  const void *pData;      /* Data for tables.  NULL for indexes */
  const void *pData;      /* Data for tables. */
  sqlite3_value *aMem;    /* First of nMem value in the unpacked pKey */
  u16 nMem;               /* Number of aMem[] value.  Might be zero */
  int nData;              /* Size of pData.  0 if none. */
  int nZero;              /* Extra zero data appended after pData,nData */
};

SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
14307
14308
14309
14310
14311
14312
14313

14314
14315
14316
14317
14318
14319
14320
14321
14322
14323










14324
14325
14326
14327
14328
14329





14330
14331
14332
14333
14334
14335
14336
14557
14558
14559
14560
14561
14562
14563
14564










14565
14566
14567
14568
14569
14570
14571
14572
14573
14574






14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586







+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+







#define OP_IntCopy        77 /* synopsis: r[P2]=r[P1]                      */
#define OP_ResultRow      78 /* synopsis: output=r[P1@P2]                  */
#define OP_CollSeq        79
#define OP_AddImm         80 /* synopsis: r[P1]=r[P1]+P2                   */
#define OP_RealAffinity   81
#define OP_Cast           82 /* synopsis: affinity(r[P1])                  */
#define OP_Permutation    83
#define OP_Compare        84 /* synopsis: r[P1@P3] <-> r[P2@P3]            */
#define OP_BitAnd         84 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
#define OP_BitOr          85 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
#define OP_ShiftLeft      86 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
#define OP_ShiftRight     87 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
#define OP_Add            88 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
#define OP_Subtract       89 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
#define OP_Multiply       90 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
#define OP_Divide         91 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
#define OP_Remainder      92 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
#define OP_Concat         93 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
#define OP_BitAnd         85 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
#define OP_BitOr          86 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
#define OP_ShiftLeft      87 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
#define OP_ShiftRight     88 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
#define OP_Add            89 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
#define OP_Subtract       90 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
#define OP_Multiply       91 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
#define OP_Divide         92 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
#define OP_Remainder      93 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
#define OP_Concat         94 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
#define OP_Compare        94 /* synopsis: r[P1@P3] <-> r[P2@P3]            */
#define OP_BitNot         95 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
#define OP_IsTrue         96 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
#define OP_String8        97 /* same as TK_STRING, synopsis: r[P2]='P4'    */
#define OP_Offset         98 /* synopsis: r[P3] = sqlite_offset(P1)        */
#define OP_Column         99 /* synopsis: r[P3]=PX                         */
#define OP_IsTrue         95 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
#define OP_BitNot         96 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
#define OP_Offset         97 /* synopsis: r[P3] = sqlite_offset(P1)        */
#define OP_Column         98 /* synopsis: r[P3]=PX                         */
#define OP_String8        99 /* same as TK_STRING, synopsis: r[P2]='P4'    */
#define OP_Affinity      100 /* synopsis: affinity(r[P1@P2])               */
#define OP_MakeRecord    101 /* synopsis: r[P3]=mkrec(r[P1@P2])            */
#define OP_Count         102 /* synopsis: r[P2]=count()                    */
#define OP_ReadCookie    103
#define OP_SetCookie     104
#define OP_ReopenIdx     105 /* synopsis: root=P2 iDb=P3                   */
#define OP_OpenRead      106 /* synopsis: root=P2 iDb=P3                   */
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364



14365
14366
14367
14368
14369
14370
14371
14605
14606
14607
14608
14609
14610
14611



14612
14613
14614
14615
14616
14617
14618
14619
14620
14621







-
-
-
+
+
+







#define OP_Rowid         125 /* synopsis: r[P2]=rowid                      */
#define OP_NullRow       126
#define OP_SeekEnd       127
#define OP_SorterInsert  128 /* synopsis: key=r[P2]                        */
#define OP_IdxInsert     129 /* synopsis: key=r[P2]                        */
#define OP_IdxDelete     130 /* synopsis: key=r[P2@P3]                     */
#define OP_DeferredSeek  131 /* synopsis: Move P3 to P1.rowid if needed    */
#define OP_Real          132 /* same as TK_FLOAT, synopsis: r[P2]=P4       */
#define OP_IdxRowid      133 /* synopsis: r[P2]=rowid                      */
#define OP_Destroy       134
#define OP_IdxRowid      132 /* synopsis: r[P2]=rowid                      */
#define OP_Destroy       133
#define OP_Real          134 /* same as TK_FLOAT, synopsis: r[P2]=P4       */
#define OP_Clear         135
#define OP_ResetSorter   136
#define OP_CreateBtree   137 /* synopsis: r[P2]=root iDb=P1 flags=P3       */
#define OP_SqlExec       138
#define OP_ParseSchema   139
#define OP_LoadAnalysis  140
#define OP_DropTable     141
14394
14395
14396
14397
14398
14399
14400

14401
14402
14403
14404
14405
14406
14407
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658







+







#define OP_Function0     164 /* synopsis: r[P3]=func(r[P2@P5])             */
#define OP_PureFunc      165
#define OP_Function      166 /* synopsis: r[P3]=func(r[P2@P5])             */
#define OP_Trace         167
#define OP_CursorHint    168
#define OP_Noop          169
#define OP_Explain       170
#define OP_Abortable     171

/* Properties such as "out2" or "jump" that are specified in
** comments following the "case" for each opcode in the vdbe.c
** are encoded into bitvectors as follows:
*/
#define OPFLG_JUMP        0x01  /* jump:  P2 holds jmp target */
#define OPFLG_IN1         0x02  /* in1:   P1 is an input */
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425



14426
14427
14428
14429
14430
14431
14432
14433
14434

14435
14436
14437
14438
14439
14440
14441
14667
14668
14669
14670
14671
14672
14673



14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684

14685
14686
14687
14688
14689
14690
14691
14692







-
-
-
+
+
+








-
+







/*  24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\
/*  32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
/*  40 */ 0x01, 0x01, 0x23, 0x26, 0x26, 0x0b, 0x01, 0x01,\
/*  48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
/*  56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x02,\
/*  64 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\
/*  72 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
/*  80 */ 0x02, 0x02, 0x02, 0x00, 0x26, 0x26, 0x26, 0x26,\
/*  88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\
/*  96 */ 0x12, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10,\
/*  80 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x26, 0x26, 0x26,\
/*  88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x12,\
/*  96 */ 0x12, 0x20, 0x00, 0x10, 0x00, 0x00, 0x10, 0x10,\
/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
/* 128 */ 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00,\
/* 136 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00,\
/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 160 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 168 */ 0x00, 0x00, 0x00,}
/* 168 */ 0x00, 0x00, 0x00, 0x00,}

/* The sqlite3P2Values() routine is able to run faster if it knows
** the value of the largest JUMP opcode.  The smaller the maximum
** JUMP opcode the better, so the mkopcodeh.tcl script that
** generated this include file strives to group all JUMP opcodes
** together near the beginning of the list.
*/
14469
14470
14471
14472
14473
14474
14475





14476













14477
14478
14479
14480
14481
14482
14483
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731

14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751







+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+







#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)
SQLITE_PRIVATE   void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N);
SQLITE_PRIVATE   void sqlite3VdbeVerifyNoResultRow(Vdbe *p);
#else
# define sqlite3VdbeVerifyNoMallocRequired(A,B)
# define sqlite3VdbeVerifyNoResultRow(A)
#endif
#if defined(SQLITE_DEBUG)
SQLITE_PRIVATE   void sqlite3VdbeVerifyAbortable(Vdbe *p, int);
#else
# define sqlite3VdbeVerifyAbortable(A,B)
#endif
SQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno);
SQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp,int iLineno);
#ifndef SQLITE_OMIT_EXPLAIN
SQLITE_PRIVATE   void sqlite3VdbeExplain(Parse*,u8,const char*,...);
SQLITE_PRIVATE   void sqlite3VdbeExplainPop(Parse*);
SQLITE_PRIVATE   int sqlite3VdbeExplainParent(Parse*);
# define ExplainQueryPlan(P)        sqlite3VdbeExplain P
# define ExplainQueryPlanPop(P)     sqlite3VdbeExplainPop(P)
# define ExplainQueryPlanParent(P)  sqlite3VdbeExplainParent(P)
#else
# define ExplainQueryPlan(P)
# define ExplainQueryPlanPop(P)
# define ExplainQueryPlanParent(P) 0
#endif
SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);
SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8);
SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1);
SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2);
SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3);
SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5);
SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr);
14492
14493
14494
14495
14496
14497
14498



14499
14500
14501
14502
14503
14504
14505
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776







+
+
+







SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3*,Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,Parse*);
SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);
#ifdef SQLITE_COVERAGE_TEST
SQLITE_PRIVATE   int sqlite3VdbeLabelHasBeenResolved(Vdbe*,int);
#endif
SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);
#ifdef SQLITE_DEBUG
SQLITE_PRIVATE   int sqlite3VdbeAssertMayAbort(Vdbe *, int);
#endif
SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe*);
SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
15626
15627
15628
15629
15630
15631
15632
15633

15634
15635
15636
15637
15638
15639
15640
15897
15898
15899
15900
15901
15902
15903

15904
15905
15906
15907
15908
15909
15910
15911







-
+







  u8 bBenignMalloc;             /* Do not require OOMs if true */
  u8 dfltLockMode;              /* Default locking-mode for attached dbs */
  signed char nextAutovac;      /* Autovac setting after VACUUM if >=0 */
  u8 suppressErr;               /* Do not issue error messages if true */
  u8 vtabOnConflict;            /* Value to return for s3_vtab_on_conflict() */
  u8 isTransactionSavepoint;    /* True if the outermost savepoint is a TS */
  u8 mTrace;                    /* zero or more SQLITE_TRACE flags */
  u8 skipBtreeMutex;            /* True if no shared-cache backends */
  u8 noSharedCache;             /* True if no shared-cache backends */
  u8 nSqlExec;                  /* Number of pending OP_SqlExec opcodes */
  int nextPagesize;             /* Pagesize after VACUUM if >0 */
  u32 magic;                    /* Magic number for detect library misuse */
  int nChange;                  /* Value returned by sqlite3_changes() */
  int nTotalChange;             /* Value returned by sqlite3_total_changes() */
  int aLimit[SQLITE_N_LIMIT];   /* Limits */
  int nMaxSorterMmap;           /* Maximum size of regions mapped by sorter */
15770
15771
15772
15773
15774
15775
15776

15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792

15793
15794
15795
15796
15797
15798
15799
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072







+
















+







#define SQLITE_EnableTrigger  0x00040000  /* True to enable triggers */
#define SQLITE_DeferFKs       0x00080000  /* Defer all FK constraints */
#define SQLITE_QueryOnly      0x00100000  /* Disable database changes */
#define SQLITE_CellSizeCk     0x00200000  /* Check btree cell sizes on load */
#define SQLITE_Fts3Tokenizer  0x00400000  /* Enable fts3_tokenizer(2) */
#define SQLITE_EnableQPSG     0x00800000  /* Query Planner Stability Guarantee*/
#define SQLITE_TriggerEQP     0x01000000  /* Show trigger EXPLAIN QUERY PLAN */
#define SQLITE_ResetDatabase  0x02000000  /* Reset the database */

/* Flags used only if debugging */
#ifdef SQLITE_DEBUG
#define SQLITE_SqlTrace       0x08000000  /* Debug print SQL as it executes */
#define SQLITE_VdbeListing    0x10000000  /* Debug listings of VDBE programs */
#define SQLITE_VdbeTrace      0x20000000  /* True to trace VDBE execution */
#define SQLITE_VdbeAddopTrace 0x40000000  /* Trace sqlite3VdbeAddOp() calls */
#define SQLITE_VdbeEQP        0x80000000  /* Debug EXPLAIN QUERY PLAN */
#endif

/*
** Allowed values for sqlite3.mDbFlags
*/
#define DBFLAG_SchemaChange   0x0001  /* Uncommitted Hash table changes */
#define DBFLAG_PreferBuiltin  0x0002  /* Preference to built-in funcs */
#define DBFLAG_Vacuum         0x0004  /* Currently in a VACUUM */
#define DBFLAG_SchemaKnownOk  0x0008  /* Schema is known to be valid */

/*
** Bits of the sqlite3.dbOptFlags field that are used by the
** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
** selectively disable various optimizations.
*/
#define SQLITE_QueryFlattener 0x0001   /* Query flattening */
16031
16032
16033
16034
16035
16036
16037

16038
16039
16040
16041
16042
16043
16044
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318







+








/* Allowed values for Column.colFlags:
*/
#define COLFLAG_PRIMKEY  0x0001    /* Column is part of the primary key */
#define COLFLAG_HIDDEN   0x0002    /* A hidden column in a virtual table */
#define COLFLAG_HASTYPE  0x0004    /* Type name follows column name */
#define COLFLAG_UNIQUE   0x0008    /* Column def contains "UNIQUE" or "PK" */
#define COLFLAG_SORTERREF 0x0010   /* Use sorter-refs with this column */

/*
** A "Collating Sequence" is defined by an instance of the following
** structure. Conceptually, a collating sequence consists of a name and
** a comparison routine that defines the order of that sequence.
**
** If CollSeq.xCmp is NULL, it means that the
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329





16330
16331

16332
16333
16334
16335
16336
16337
16338
16592
16593
16594
16595
16596
16597
16598





16599
16600
16601
16602
16603


16604
16605
16606
16607
16608
16609
16610
16611







-
-
-
-
-
+
+
+
+
+
-
-
+







*/
#define OE_None     0   /* There is no constraint to check */
#define OE_Rollback 1   /* Fail the operation and rollback the transaction */
#define OE_Abort    2   /* Back out changes but do no rollback transaction */
#define OE_Fail     3   /* Stop the operation but leave all prior changes */
#define OE_Ignore   4   /* Ignore the error. Do not do the INSERT or UPDATE */
#define OE_Replace  5   /* Delete existing record, then do INSERT or UPDATE */

#define OE_Restrict 6   /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */
#define OE_SetNull  7   /* Set the foreign key value to NULL */
#define OE_SetDflt  8   /* Set the foreign key value to its default */
#define OE_Cascade  9   /* Cascade the changes */
#define OE_Update   6   /* Process as a DO UPDATE in an upsert */
#define OE_Restrict 7   /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */
#define OE_SetNull  8   /* Set the foreign key value to NULL */
#define OE_SetDflt  9   /* Set the foreign key value to its default */
#define OE_Cascade  10  /* Cascade the changes */

#define OE_Default  10  /* Do whatever the default action is */
#define OE_Default  11  /* Do whatever the default action is */


/*
** An instance of the following structure is passed as the first
** argument to sqlite3VdbeKeyCompare and is used to control the
** comparison of the two index keys.
**
16771
16772
16773
16774
16775
16776
16777

16778
16779
16780
16781
16782
16783
16784
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058







+







    Expr *pExpr;            /* The parse tree for this expression */
    char *zName;            /* Token associated with this expression */
    char *zSpan;            /* Original text of the expression */
    u8 sortOrder;           /* 1 for DESC or 0 for ASC */
    unsigned done :1;       /* A flag to indicate when processing is finished */
    unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */
    unsigned reusable :1;   /* Constant expression is reusable */
    unsigned bSorterRef :1; /* Defer evaluation until after sorting */
    union {
      struct {
        u16 iOrderByCol;      /* For ORDER BY, column number in result set */
        u16 iAlias;           /* Index into Parse.aAlias[] for zName */
      } x;
      int iConstExprReg;      /* Register in which Expr value is cached */
    } u;
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
17144
17145
17146
17147
17148
17149
17150



17151
17152
17153
17154
17155
17156
17157







-
-
-







      unsigned notIndexed :1;    /* True if there is a NOT INDEXED clause */
      unsigned isIndexedBy :1;   /* True if there is an INDEXED BY clause */
      unsigned isTabFunc :1;     /* True if table-valued-function syntax */
      unsigned isCorrelated :1;  /* True if sub-query is correlated */
      unsigned viaCoroutine :1;  /* Implemented as a co-routine */
      unsigned isRecursive :1;   /* True for recursive reference in WITH */
    } fg;
#ifndef SQLITE_OMIT_EXPLAIN
    u8 iSelectId;     /* If pSelect!=0, the id of the sub-select in EQP */
#endif
    int iCursor;      /* The VDBE cursor number used to access this table */
    Expr *pOn;        /* The ON clause of a join */
    IdList *pUsing;   /* The USING clause of a join */
    Bitmask colUsed;  /* Bit N (1<<N) set if column N of pTab is used */
    union {
      char *zIndexedBy;    /* Identifier from "INDEXED BY <zIndex>" clause */
      ExprList *pFuncArg;  /* Arguments to table-valued-function */
16954
16955
16956
16957
16958
16959
16960

16961
16962




16963
16964
16965
16966
16967
16968
16969
17225
17226
17227
17228
17229
17230
17231
17232


17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243







+
-
-
+
+
+
+







** NameContext in the parent query.  Thus the process of scanning the
** NameContext list corresponds to searching through successively outer
** subqueries looking for a match.
*/
struct NameContext {
  Parse *pParse;       /* The parser */
  SrcList *pSrcList;   /* One or more tables used to resolve names */
  union {
  ExprList *pEList;    /* Optional list of result-set columns */
  AggInfo *pAggInfo;   /* Information about aggregates at this level */
    ExprList *pEList;    /* Optional list of result-set columns */
    AggInfo *pAggInfo;   /* Information about aggregates at this level */
    Upsert *pUpsert;     /* ON CONFLICT clause information from an upsert */
  } uNC;
  NameContext *pNext;  /* Next outer name context.  NULL for outermost */
  int nRef;            /* Number of names resolved by this context */
  int nErr;            /* Number of errors encountered while resolving names */
  u16 ncFlags;         /* Zero or more NC_* flags defined below */
};

/*
16977
16978
16979
16980
16981
16982
16983



16984
16985






























16986
16987
16988
16989
16990
16991

16992
16993
16994

16995
16996
16997
16998
16999
17000
17001
17002
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297

17298



17299

17300
17301
17302
17303
17304
17305
17306







+
+
+


+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+





-
+
-
-
-
+
-







#define NC_AllowAgg  0x0001  /* Aggregate functions are allowed here */
#define NC_PartIdx   0x0002  /* True if resolving a partial index WHERE */
#define NC_IsCheck   0x0004  /* True if resolving names in a CHECK constraint */
#define NC_InAggFunc 0x0008  /* True if analyzing arguments to an agg func */
#define NC_HasAgg    0x0010  /* One or more aggregate functions seen */
#define NC_IdxExpr   0x0020  /* True if resolving columns of CREATE INDEX */
#define NC_VarSelect 0x0040  /* A correlated subquery has been seen */
#define NC_UEList    0x0080  /* True if uNC.pEList is used */
#define NC_UAggInfo  0x0100  /* True if uNC.pAggInfo is used */
#define NC_UUpsert   0x0200  /* True if uNC.pUpsert is used */
#define NC_MinMaxAgg 0x1000  /* min/max aggregates seen.  See note above */
#define NC_Complex   0x2000  /* True if a function or subquery seen */

/*
** An instance of the following object describes a single ON CONFLICT
** clause in an upsert.
**
** The pUpsertTarget field is only set if the ON CONFLICT clause includes
** conflict-target clause.  (In "ON CONFLICT(a,b)" the "(a,b)" is the
** conflict-target clause.)  The pUpsertTargetWhere is the optional
** WHERE clause used to identify partial unique indexes.
**
** pUpsertSet is the list of column=expr terms of the UPDATE statement. 
** The pUpsertSet field is NULL for a ON CONFLICT DO NOTHING.  The
** pUpsertWhere is the WHERE clause for the UPDATE and is NULL if the
** WHERE clause is omitted.
*/
struct Upsert {
  ExprList *pUpsertTarget;  /* Optional description of conflicting index */
  Expr *pUpsertTargetWhere; /* WHERE clause for partial index targets */
  ExprList *pUpsertSet;     /* The SET clause from an ON CONFLICT UPDATE */
  Expr *pUpsertWhere;       /* WHERE clause for the ON CONFLICT UPDATE */
  /* The fields above comprise the parse tree for the upsert clause.
  ** The fields below are used to transfer information from the INSERT
  ** processing down into the UPDATE processing while generating code.
  ** Upsert owns the memory allocated above, but not the memory below. */
  Index *pUpsertIdx;        /* Constraint that pUpsertTarget identifies */
  SrcList *pUpsertSrc;      /* Table to be updated */
  int regData;              /* First register holding array of VALUES */
  int iDataCur;             /* Index of the data cursor */
  int iIdxCur;              /* Index of the first index cursor */
};

/*
** An instance of the following structure contains all information
** needed to generate code for a single SELECT statement.
**
** nLimit is set to -1 if there is no LIMIT clause.  nOffset is set to 0.
** See the header comment on the computeLimitRegisters() routine for a
** If there is a LIMIT clause, the parser sets nLimit to the value of the
** limit and nOffset to the value of the offset (or 0 if there is not
** offset).  But later on, nLimit and nOffset become the memory locations
** detailed description of the meaning of the iLimit and iOffset fields.
** in the VDBE that record the limit and offset counters.
**
** addrOpenEphm[] entries contain the address of OP_OpenEphemeral opcodes.
** These addresses must be stored so that we can go back and fill in
** the P4_KEYINFO and P2 parameters later.  Neither the KeyInfo nor
** the number of columns in P2 can be computed at the same time
** as the OP_OpenEphm instruction is coded because not
** enough information about the compound query is known at that point.
17048
17049
17050
17051
17052
17053
17054
17055

17056
17057
17058
17059
17060
17061
17062
17063
17352
17353
17354
17355
17356
17357
17358

17359

17360
17361
17362
17363
17364
17365
17366







-
+
-







#define SF_NestedFrom     0x00800  /* Part of a parenthesized FROM clause */
#define SF_MinMaxAgg      0x01000  /* Aggregate containing min() or max() */
#define SF_Recursive      0x02000  /* The recursive part of a recursive CTE */
#define SF_FixedLimit     0x04000  /* nSelectRow set by a constant LIMIT */
#define SF_MaybeConvert   0x08000  /* Need convertCompoundSelectToSubquery() */
#define SF_Converted      0x10000  /* By convertCompoundSelectToSubquery() */
#define SF_IncludeHidden  0x20000  /* Include hidden columns in output */
#define SF_ComplexResult  0x40000  /* Result set contains subquery or function */
#define SF_ComplexResult  0x40000  /* Result contains subquery or function */


/*
** The results of a SELECT can be distributed in several ways, as defined
** by one of the following macros.  The "SRT" prefix means "SELECT Result
** Type".
**
**     SRT_Union       Store results as a key in a temporary index
17319
17320
17321
17322
17323
17324
17325
17326

17327
17328
17329
17330
17331
17332
17333
17334
17622
17623
17624
17625
17626
17627
17628

17629

17630
17631
17632
17633
17634
17635
17636







-
+
-







  u8 explain;               /* True if the EXPLAIN flag is found on the query */
#ifndef SQLITE_OMIT_VIRTUALTABLE
  u8 declareVtab;           /* True if inside sqlite3_declare_vtab() */
  int nVtabLock;            /* Number of virtual tables to lock */
#endif
  int nHeight;              /* Expression tree height of current sub-select */
#ifndef SQLITE_OMIT_EXPLAIN
  int iSelectId;            /* ID of current select for EXPLAIN output */
  int addrExplain;          /* Address of current OP_Explain opcode */
  int iNextSelectId;        /* Next available select ID for EXPLAIN output */
#endif
  VList *pVList;            /* Mapping between variable names and numbers */
  Vdbe *pReprepare;         /* VM being reprepared (sqlite3Reprepare()) */
  const char *zTail;        /* All SQL text past the last semicolon parsed */
  Table *pNewTable;         /* A table being constructed by CREATE TABLE */
  Trigger *pNewTrigger;     /* Trigger under construct by a CREATE TRIGGER */
  const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */
17479
17480
17481
17482
17483
17484
17485
17486

17487

17488
17489
17490
17491
17492
17493
17494
17781
17782
17783
17784
17785
17786
17787

17788
17789
17790
17791
17792
17793
17794
17795
17796
17797







-
+

+







struct TriggerStep {
  u8 op;               /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */
  u8 orconf;           /* OE_Rollback etc. */
  Trigger *pTrig;      /* The trigger that this step is a part of */
  Select *pSelect;     /* SELECT statement or RHS of INSERT INTO SELECT ... */
  char *zTarget;       /* Target table for DELETE, UPDATE, INSERT */
  Expr *pWhere;        /* The WHERE clause for DELETE or UPDATE steps */
  ExprList *pExprList; /* SET clause for UPDATE. */
  ExprList *pExprList; /* SET clause for UPDATE */
  IdList *pIdList;     /* Column names for INSERT */
  Upsert *pUpsert;     /* Upsert clauses on an INSERT */
  char *zSpan;         /* Original SQL text of this command */
  TriggerStep *pNext;  /* Next in the link-list */
  TriggerStep *pLast;  /* Last element in link-list. Valid for 1st elem only */
};

/*
** The following structure contains information used by the sqliteFix...
17505
17506
17507
17508
17509
17510
17511
17512

17513
17514
17515
17516
17517
17518

17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17808
17809
17810
17811
17812
17813
17814

17815
17816
17817
17818
17819
17820

17821
17822
17823


17824
17825
17826
17827
17828
17829
17830







-
+





-
+


-
-







  const Token *pName; /* Name of the container - used for error messages */
};

/*
** An objected used to accumulate the text of a string where we
** do not necessarily know how big the string will be in the end.
*/
struct StrAccum {
struct sqlite3_str {
  sqlite3 *db;         /* Optional database for lookaside.  Can be NULL */
  char *zText;         /* The string collected so far */
  u32  nAlloc;         /* Amount of space allocated in zText */
  u32  mxAlloc;        /* Maximum allowed allocation.  0 for no malloc usage */
  u32  nChar;          /* Length of the string so far */
  u8   accError;       /* STRACCUM_NOMEM or STRACCUM_TOOBIG */
  u8   accError;       /* SQLITE_NOMEM or SQLITE_TOOBIG */
  u8   printfFlags;    /* SQLITE_PRINTF flags below */
};
#define STRACCUM_NOMEM   1
#define STRACCUM_TOOBIG  2
#define SQLITE_PRINTF_INTERNAL 0x01  /* Internal-use-only converters allowed */
#define SQLITE_PRINTF_SQLFUNC  0x02  /* SQL function arguments to VXPrintf */
#define SQLITE_PRINTF_MALLOCED 0x04  /* True if xText is allocated space */

#define isMalloced(X)  (((X)->printfFlags & SQLITE_PRINTF_MALLOCED)!=0)


17592
17593
17594
17595
17596
17597
17598

17599
17600
17601
17602
17603
17604
17605
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907







+







  void *pVdbeBranchArg;                                     /* 1st argument */
#endif
#ifndef SQLITE_UNTESTABLE
  int (*xTestCallback)(int);        /* Invoked by sqlite3FaultSim() */
#endif
  int bLocaltimeFault;              /* True to fail localtime() calls */
  int iOnceResetThreshold;          /* When to reset OP_Once counters */
  u32 szSorterRef;                  /* Min size in bytes to use sorter-refs */
};

/*
** This macro is used inside of assert() statements to indicate that
** the assert is only valid on a well-formed database.  Instead of:
**
**     assert( X );
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
18185
18186
18187
18188
18189
18190
18191


18192
18193
18194
18195
18196
18197
18198







-
-







*/
struct PrintfArguments {
  int nArg;                /* Total number of arguments */
  int nUsed;               /* Number of arguments used so far */
  sqlite3_value **apArg;   /* The argument values */
};

SQLITE_PRIVATE void sqlite3VXPrintf(StrAccum*, const char*, va_list);
SQLITE_PRIVATE void sqlite3XPrintf(StrAccum*, const char*, ...);
SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);
SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
SQLITE_PRIVATE   void sqlite3DebugPrintf(const char*, ...);
#endif
#if defined(SQLITE_TEST)
SQLITE_PRIVATE   void *sqlite3TestTextToPtr(const char*);
18012
18013
18014
18015
18016
18017
18018
18019

18020
18021
18022
18023
18024
18025
18026
18312
18313
18314
18315
18316
18317
18318

18319
18320
18321
18322
18323
18324
18325
18326







-
+







#ifndef SQLITE_OMIT_AUTOINCREMENT
SQLITE_PRIVATE   void sqlite3AutoincrementBegin(Parse *pParse);
SQLITE_PRIVATE   void sqlite3AutoincrementEnd(Parse *pParse);
#else
# define sqlite3AutoincrementBegin(X)
# define sqlite3AutoincrementEnd(X)
#endif
SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int);
SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*);
SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);
SQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*);
SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*);
SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int);
SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*);
SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,
                                      Token*, Select*, Expr*, IdList*);
18042
18043
18044
18045
18046
18047
18048
18049


18050
18051
18052
18053
18054
18055
18056
18342
18343
18344
18345
18346
18347
18348

18349
18350
18351
18352
18353
18354
18355
18356
18357







-
+
+







SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);
SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int);
SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
#endif
SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*);
SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*);
SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*,
                   Upsert*);
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*);
SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo*);
SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*);
18135
18136
18137
18138
18139
18140
18141
18142

18143
18144
18145
18146
18147
18148
18149
18436
18437
18438
18439
18440
18441
18442

18443
18444
18445
18446
18447
18448
18449
18450







-
+







SQLITE_PRIVATE int sqlite3IsRowid(const char*);
SQLITE_PRIVATE void sqlite3GenerateRowDelete(
    Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int);
SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
                                     u8,u8,int,int*,int*);
                                     u8,u8,int,int*,int*,Upsert*);
#ifdef SQLITE_ENABLE_NULL_TRIM
SQLITE_PRIVATE   void sqlite3SetMakeRecordP5(Vdbe*,Table*);
#else
# define sqlite3SetMakeRecordP5(A,B)
#endif
SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);
SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*);
18188
18189
18190
18191
18192
18193
18194

18195

18196
18197
18198
18199
18200
18201
18202
18489
18490
18491
18492
18493
18494
18495
18496

18497
18498
18499
18500
18501
18502
18503
18504







+
-
+







                            int, int, int);
SQLITE_PRIVATE   void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
  void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
SQLITE_PRIVATE   void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
SQLITE_PRIVATE   TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*,
                                        const char*,const char*);
SQLITE_PRIVATE   TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,
                                        Select*,u8,Upsert*,
                                        Select*,u8,const char*,const char*);
                                        const char*,const char*);
SQLITE_PRIVATE   TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8,
                                        const char*,const char*);
SQLITE_PRIVATE   TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*,
                                        const char*,const char*);
SQLITE_PRIVATE   void sqlite3DeleteTrigger(sqlite3*, Trigger*);
SQLITE_PRIVATE   void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
SQLITE_PRIVATE   u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
18374
18375
18376
18377
18378
18379
18380
18381

18382
18383
18384
18385
18386
18387
18388
18676
18677
18678
18679
18680
18681
18682

18683
18684
18685
18686
18687
18688
18689
18690







-
+







SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
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 char sqlite3AffinityType(const char*, Column*);
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*);
18399
18400
18401
18402
18403
18404
18405

18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714



18715

18716
18717
18718
18719
18720
18721
18722







+






-
-
-

-







SQLITE_PRIVATE int sqlite3KeyInfoIsWriteable(KeyInfo*);
#endif
SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
  void (*)(sqlite3_context*,int,sqlite3_value **),
  void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
  FuncDestructor *pDestructor
);
SQLITE_PRIVATE void sqlite3NoopDestructor(void*);
SQLITE_PRIVATE void sqlite3OomFault(sqlite3*);
SQLITE_PRIVATE void sqlite3OomClear(sqlite3*);
SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);
SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);

SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum*,const char*,int);
SQLITE_PRIVATE void sqlite3StrAccumAppendAll(StrAccum*,const char*);
SQLITE_PRIVATE void sqlite3AppendChar(StrAccum*,int,char);
SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);
SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum*);
SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);
SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);

SQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *);
SQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);

#ifndef SQLITE_OMIT_SUBQUERY
18436
18437
18438
18439
18440
18441
18442
18443

18444
18445
18446

18447
18448
18449
18450
18451
18452
18453
18735
18736
18737
18738
18739
18740
18741

18742
18743
18744

18745
18746
18747
18748
18749
18750
18751
18752







-
+


-
+







SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3*, Index*, int);
#endif

/*
** The interface to the LEMON-generated parser
*/
#ifndef SQLITE_AMALGAMATION
SQLITE_PRIVATE   void *sqlite3ParserAlloc(void*(*)(u64));
SQLITE_PRIVATE   void *sqlite3ParserAlloc(void*(*)(u64), Parse*);
SQLITE_PRIVATE   void sqlite3ParserFree(void*, void(*)(void*));
#endif
SQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*);
SQLITE_PRIVATE void sqlite3Parser(void*, int, Token);
#ifdef YYTRACKMAXSTACKDEPTH
SQLITE_PRIVATE   int sqlite3ParserStackPeak(void*);
#endif

SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3*);
#ifndef SQLITE_OMIT_LOAD_EXTENSION
SQLITE_PRIVATE   void sqlite3CloseExtensions(sqlite3*);
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18804
18805
18806
18807
18808
18809
18810

18811
18812
18813
18814
18815
18816
18817







-







SQLITE_PRIVATE void sqlite3VtabArgInit(Parse*);
SQLITE_PRIVATE void sqlite3VtabArgExtend(Parse*, Token*);
SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);
SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
SQLITE_PRIVATE void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value**);
SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
SQLITE_PRIVATE void sqlite3ParserReset(Parse*);
SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);
SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
18527
18528
18529
18530
18531
18532
18533












18534
18535
18536
18537
18538
18539
18540
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850







+
+
+
+
+
+
+
+
+
+
+
+







SQLITE_PRIVATE   With *sqlite3WithAdd(Parse*,With*,Token*,ExprList*,Select*);
SQLITE_PRIVATE   void sqlite3WithDelete(sqlite3*,With*);
SQLITE_PRIVATE   void sqlite3WithPush(Parse*, With*, u8);
#else
#define sqlite3WithPush(x,y,z)
#define sqlite3WithDelete(x,y)
#endif
#ifndef SQLITE_OMIT_UPSERT
SQLITE_PRIVATE   Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*);
SQLITE_PRIVATE   void sqlite3UpsertDelete(sqlite3*,Upsert*);
SQLITE_PRIVATE   Upsert *sqlite3UpsertDup(sqlite3*,Upsert*);
SQLITE_PRIVATE   int sqlite3UpsertAnalyzeTarget(Parse*,SrcList*,Upsert*);
SQLITE_PRIVATE   void sqlite3UpsertDoUpdate(Parse*,Upsert*,Table*,Index*,int);
#else
#define sqlite3UpsertNew(v,w,x,y,z) ((Upsert*)0)
#define sqlite3UpsertDelete(x,y)
#define sqlite3UpsertDup(x,y)       ((Upsert*)0)
#endif


/* Declarations for functions in fkey.c. All of these are replaced by
** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
** key functionality is available. If OMIT_TRIGGER is defined but
** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In
** this case foreign keys are parsed, but no other functionality is
** provided (enforcement of FK constraints requires the triggers sub-system).
18959
18960
18961
18962
18963
18964
18965
18966


18967
18968
18969
18970
18971
18972
18973
19269
19270
19271
19272
19273
19274
19275

19276
19277
19278
19279
19280
19281
19282
19283
19284







-
+
+







   0,                         /* xVdbeBranch */
   0,                         /* pVbeBranchArg */
#endif
#ifndef SQLITE_UNTESTABLE
   0,                         /* xTestCallback */
#endif
   0,                         /* bLocaltimeFault */
   0x7ffffffe                 /* iOnceResetThreshold */
   0x7ffffffe,                /* iOnceResetThreshold */
   SQLITE_DEFAULT_SORTERREF_SIZE   /* szSorterRef */
};

/*
** Hash table for global functions - functions common to all
** database connections.  After initialization, this table is
** read-only.
*/
19422
19423
19424
19425
19426
19427
19428

19429
19430
19431
19432
19433
19434
19435
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747







+







  VList *pVList;          /* Name of variables */
#ifndef SQLITE_OMIT_TRACE
  i64 startTime;          /* Time when query started - used for profiling */
#endif
  int nOp;                /* Number of instructions in the program */
#ifdef SQLITE_DEBUG
  int rcApp;              /* errcode set by sqlite3_result_error_code() */
  u32 nWrite;             /* Number of write operations that have occurred */
#endif
  u16 nResColumn;         /* Number of columns in one row of the result set */
  u8 errorAction;         /* Recovery action to do in case of an error */
  u8 minWriteFileFormat;  /* Minimum file format for writable database files */
  u8 prepFlags;           /* SQLITE_PREPARE_* flags */
  bft expired:1;          /* True if the VM needs to be recompiled */
  bft doingRerun:1;       /* True if rerunning after an auto-reprepare */
19556
19557
19558
19559
19560
19561
19562








19563
19564
19565
19566
19567
19568
19569
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889







+
+
+
+
+
+
+
+







SQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *);
SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *);
SQLITE_PRIVATE int sqlite3VdbeSorterRewind(const VdbeCursor *, int *);
SQLITE_PRIVATE int sqlite3VdbeSorterWrite(const VdbeCursor *, Mem *);
SQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int, int *);

#ifdef SQLITE_DEBUG
SQLITE_PRIVATE   void sqlite3VdbeIncrWriteCounter(Vdbe*, VdbeCursor*);
SQLITE_PRIVATE   void sqlite3VdbeAssertAbortable(Vdbe*);
#else
# define sqlite3VdbeIncrWriteCounter(V,C)
# define sqlite3VdbeAssertAbortable(V)
#endif

#if !defined(SQLITE_OMIT_SHARED_CACHE) 
SQLITE_PRIVATE   void sqlite3VdbeEnter(Vdbe*);
#else
# define sqlite3VdbeEnter(X)
#endif

24249
24250
24251
24252
24253
24254
24255
24256
24257
24258
24259
24260
24261
24262
24263
24569
24570
24571
24572
24573
24574
24575

24576
24577
24578
24579
24580
24581
24582







-







  assert( p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld );
  return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
}
#endif

#endif /* !defined(SQLITE_MUTEX_OMIT) */


/************** End of mutex.c ***********************************************/
/************** Begin file mutex_noop.c **************************************/
/*
** 2008 October 07
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
26413
26414
26415
26416
26417
26418
26419
26420

26421
26422
26423
26424
26425
26426
26427
26732
26733
26734
26735
26736
26737
26738

26739
26740
26741
26742
26743
26744
26745
26746







-
+







}
#endif /* SQLITE_OMIT_FLOATING_POINT */

/*
** Set the StrAccum object to an error mode.
*/
static void setStrAccumError(StrAccum *p, u8 eError){
  assert( eError==STRACCUM_NOMEM || eError==STRACCUM_TOOBIG );
  assert( eError==SQLITE_NOMEM || eError==SQLITE_TOOBIG );
  p->accError = eError;
  p->nAlloc = 0;
}

/*
** Extra argument values from a PrintfArguments object
*/
26447
26448
26449
26450
26451
26452
26453
26454
26455


26456
26457
26458
26459
26460
26461
26462
26766
26767
26768
26769
26770
26771
26772


26773
26774
26775
26776
26777
26778
26779
26780
26781







-
-
+
+







# define SQLITE_PRINT_BUF_SIZE 70
#endif
#define etBUFSIZE SQLITE_PRINT_BUF_SIZE  /* Size of the output buffer */

/*
** Render a string given by "fmt" into the StrAccum object.
*/
SQLITE_PRIVATE void sqlite3VXPrintf(
  StrAccum *pAccum,          /* Accumulate results here */
SQLITE_API void sqlite3_str_vappendf(
  sqlite3_str *pAccum,       /* Accumulate results here */
  const char *fmt,           /* Format string */
  va_list ap                 /* arguments */
){
  int c;                     /* Next character in the format string */
  char *bufpt;               /* Pointer to the conversion buffer */
  int precision;             /* Precision of the current field */
  int length;                /* Length of the field */
26505
26506
26507
26508
26509
26510
26511
26512

26513
26514
26515
26516

26517
26518
26519
26520
26521
26522
26523
26824
26825
26826
26827
26828
26829
26830

26831
26832
26833
26834

26835
26836
26837
26838
26839
26840
26841
26842







-
+



-
+







    if( c!='%' ){
      bufpt = (char *)fmt;
#if HAVE_STRCHRNUL
      fmt = strchrnul(fmt, '%');
#else
      do{ fmt++; }while( *fmt && *fmt != '%' );
#endif
      sqlite3StrAccumAppend(pAccum, bufpt, (int)(fmt - bufpt));
      sqlite3_str_append(pAccum, bufpt, (int)(fmt - bufpt));
      if( *fmt==0 ) break;
    }
    if( (c=(*++fmt))==0 ){
      sqlite3StrAccumAppend(pAccum, "%", 1);
      sqlite3_str_append(pAccum, "%", 1);
      break;
    }
    /* Find out what flags are present */
    flag_leftjustify = flag_prefix = cThousand =
     flag_alternateform = flag_altform2 = flag_zeropad = 0;
    done = 0;
    do{
26687
26688
26689
26690
26691
26692
26693
26694

26695
26696
26697
26698
26699
26700
26701
27006
27007
27008
27009
27010
27011
27012

27013
27014
27015
27016
27017
27018
27019
27020







-
+







        if( precision<etBUFSIZE-10-etBUFSIZE/3 ){
          nOut = etBUFSIZE;
          zOut = buf;
        }else{
          u64 n = (u64)precision + 10 + precision/3;
          zOut = zExtra = sqlite3Malloc( n );
          if( zOut==0 ){
            setStrAccumError(pAccum, STRACCUM_NOMEM);
            setStrAccumError(pAccum, SQLITE_NOMEM);
            return;
          }
          nOut = (int)n;
        }
        bufpt = &zOut[nOut-1];
        if( xtype==etORDINAL ){
          static const char zOrd[] = "thstndrd";
26812
26813
26814
26815
26816
26817
26818
26819

26820
26821
26822
26823
26824
26825
26826
27131
27132
27133
27134
27135
27136
27137

27138
27139
27140
27141
27142
27143
27144
27145







-
+







        }else{
          e2 = exp;
        }
        if( MAX(e2,0)+(i64)precision+(i64)width > etBUFSIZE - 15 ){
          bufpt = zExtra 
              = sqlite3Malloc( MAX(e2,0)+(i64)precision+(i64)width+15 );
          if( bufpt==0 ){
            setStrAccumError(pAccum, STRACCUM_NOMEM);
            setStrAccumError(pAccum, SQLITE_NOMEM);
            return;
          }
        }
        zOut = bufpt;
        nsd = 16 + flag_altform2*10;
        flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
        /* The sign in front of the number */
26944
26945
26946
26947
26948
26949
26950
26951

26952
26953
26954
26955

26956
26957
26958
26959
26960
26961
26962
27263
27264
27265
27266
27267
27268
27269

27270
27271
27272
27273

27274
27275
27276
27277
27278
27279
27280
27281







-
+



-
+







            buf[3] = 0x80 + (u8)(ch & 0x3f);
            length = 4;
          }
        }
        if( precision>1 ){
          width -= precision-1;
          if( width>1 && !flag_leftjustify ){
            sqlite3AppendChar(pAccum, width-1, ' ');
            sqlite3_str_appendchar(pAccum, width-1, ' ');
            width = 0;
          }
          while( precision-- > 1 ){
            sqlite3StrAccumAppend(pAccum, buf, length);
            sqlite3_str_append(pAccum, buf, length);
          }
        }
        bufpt = buf;
        flag_altform2 = 1;
        goto adjust_width_for_utf8;
      case etSTRING:
      case etDYNSTRING:
27034
27035
27036
27037
27038
27039
27040
27041

27042
27043
27044
27045
27046
27047
27048
27353
27354
27355
27356
27357
27358
27359

27360
27361
27362
27363
27364
27365
27366
27367







-
+







          }
        }
        needQuote = !isnull && xtype==etSQLESCAPE2;
        n += i + 3;
        if( n>etBUFSIZE ){
          bufpt = zExtra = sqlite3Malloc( n );
          if( bufpt==0 ){
            setStrAccumError(pAccum, STRACCUM_NOMEM);
            setStrAccumError(pAccum, SQLITE_NOMEM);
            return;
          }
        }else{
          bufpt = buf;
        }
        j = 0;
        if( needQuote ) bufpt[j++] = q;
27058
27059
27060
27061
27062
27063
27064
27065

27066
27067
27068
27069
27070
27071
27072
27073
27074
27075
27076
27077
27078
27079
27080
27081
27082


27083
27084

27085
27086
27087
27088
27089
27090
27091
27092
27093
27094
27095
27096
27097
27098
27099
27100
27101
27102
27103
27104
27105



27106
27107

27108
27109
27110
27111
27112
27113
27114
27115
27116
27117
27118
27119
27120
27121
27122
27123
27124
27125
27126
27127
27128
27129


27130
27131
27132
27133
27134

27135
27136
27137
27138
27139
27140
27141
27142
27143
27144
27145
27146
27147


27148
27149
27150
27151
27152
27153
27154
27155
27156
27157
27158
27159
27160
27161
27162
27163
27164
27165


27166
27167
27168
27169
27170
27171
27172
27173
27174
27175

27176
27177
27178
27179
27180
27181
27182
27183
27184
27185
27186
27187

27188
27189

27190
27191
27192
27193
27194
27195
27196
27197
27198
27199
27200
27201
27202
27203

27204
27205
27206
27207
27208
27209
27210
27211
27212
27213
27214
27215
27216
27217
27218
27219
27220
27221


27222
27223
27224
27225
27226
27227
27228
27229
27230
27231
27232
27233
27234
27235
27236
27237
27238

27239
27240
27241
27242
27243
27244
27245
27246
27247
27248
27249
27250
27251
27252
27253








































27254
27255
27256

27257
27258
27259
27260


27261
27262
27263
27264
27265
27266
27267
27377
27378
27379
27380
27381
27382
27383

27384
27385
27386
27387
27388
27389
27390
27391
27392
27393
27394
27395
27396
27397
27398
27399


27400
27401
27402

27403
27404
27405
27406
27407
27408
27409
27410
27411
27412
27413
27414
27415
27416
27417
27418
27419
27420
27421



27422
27423
27424
27425

27426
27427
27428
27429
27430
27431
27432
27433
27434
27435
27436
27437
27438
27439
27440
27441
27442
27443
27444
27445
27446


27447
27448
27449
27450
27451
27452

27453
27454
27455
27456
27457
27458
27459
27460
27461
27462
27463
27464


27465
27466
27467
27468
27469
27470
27471
27472
27473
27474
27475
27476
27477
27478
27479
27480
27481
27482


27483
27484
27485
27486
27487
27488
27489
27490
27491
27492
27493

27494
27495
27496
27497
27498
27499
27500
27501
27502
27503
27504
27505

27506
27507

27508
27509
27510
27511
27512
27513
27514
27515
27516
27517
27518
27519
27520
27521

27522
27523
27524
27525
27526
27527
27528
27529
27530
27531
27532
27533
27534
27535
27536
27537
27538


27539
27540
27541
27542
27543
27544
27545
27546
27547
27548
27549
27550
27551
27552
27553
27554
27555
27556

27557
27558
27559
27560
27561
27562
27563
27564
27565
27566
27567
27568
27569
27570
27571
27572
27573
27574
27575
27576
27577
27578
27579
27580
27581
27582
27583
27584
27585
27586
27587
27588
27589
27590
27591
27592
27593
27594
27595
27596
27597
27598
27599
27600
27601
27602
27603
27604
27605
27606
27607
27608
27609
27610
27611
27612
27613
27614

27615
27616
27617
27618
27619
27620
27621
27622
27623
27624
27625
27626
27627
27628







-
+















-
-
+
+

-
+


















-
-
-
+
+
+

-
+




















-
-
+
+




-
+











-
-
+
+
















-
-
+
+









-
+











-
+

-
+













-
+
















-
-
+
+
















-
+















+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


-
+




+
+







      }
      case etTOKEN: {
        Token *pToken;
        if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return;
        pToken = va_arg(ap, Token*);
        assert( bArgList==0 );
        if( pToken && pToken->n ){
          sqlite3StrAccumAppend(pAccum, (const char*)pToken->z, pToken->n);
          sqlite3_str_append(pAccum, (const char*)pToken->z, pToken->n);
        }
        length = width = 0;
        break;
      }
      case etSRCLIST: {
        SrcList *pSrc;
        int k;
        struct SrcList_item *pItem;
        if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return;
        pSrc = va_arg(ap, SrcList*);
        k = va_arg(ap, int);
        pItem = &pSrc->a[k];
        assert( bArgList==0 );
        assert( k>=0 && k<pSrc->nSrc );
        if( pItem->zDatabase ){
          sqlite3StrAccumAppendAll(pAccum, pItem->zDatabase);
          sqlite3StrAccumAppend(pAccum, ".", 1);
          sqlite3_str_appendall(pAccum, pItem->zDatabase);
          sqlite3_str_append(pAccum, ".", 1);
        }
        sqlite3StrAccumAppendAll(pAccum, pItem->zName);
        sqlite3_str_appendall(pAccum, pItem->zName);
        length = width = 0;
        break;
      }
      default: {
        assert( xtype==etINVALID );
        return;
      }
    }/* End switch over the format type */
    /*
    ** The text of the conversion is pointed to by "bufpt" and is
    ** "length" characters long.  The field width is "width".  Do
    ** the output.  Both length and width are in bytes, not characters,
    ** at this point.  If the "!" flag was present on string conversions
    ** indicating that width and precision should be expressed in characters,
    ** then the values have been translated prior to reaching this point.
    */
    width -= length;
    if( width>0 ){
      if( !flag_leftjustify ) sqlite3AppendChar(pAccum, width, ' ');
      sqlite3StrAccumAppend(pAccum, bufpt, length);
      if( flag_leftjustify ) sqlite3AppendChar(pAccum, width, ' ');
      if( !flag_leftjustify ) sqlite3_str_appendchar(pAccum, width, ' ');
      sqlite3_str_append(pAccum, bufpt, length);
      if( flag_leftjustify ) sqlite3_str_appendchar(pAccum, width, ' ');
    }else{
      sqlite3StrAccumAppend(pAccum, bufpt, length);
      sqlite3_str_append(pAccum, bufpt, length);
    }

    if( zExtra ){
      sqlite3DbFree(pAccum->db, zExtra);
      zExtra = 0;
    }
  }/* End for loop over the format string */
} /* End of function */

/*
** Enlarge the memory allocation on a StrAccum object so that it is
** able to accept at least N more bytes of text.
**
** Return the number of bytes of text that StrAccum is able to accept
** after the attempted enlargement.  The value returned might be zero.
*/
static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
  char *zNew;
  assert( p->nChar+(i64)N >= p->nAlloc ); /* Only called if really needed */
  if( p->accError ){
    testcase(p->accError==STRACCUM_TOOBIG);
    testcase(p->accError==STRACCUM_NOMEM);
    testcase(p->accError==SQLITE_TOOBIG);
    testcase(p->accError==SQLITE_NOMEM);
    return 0;
  }
  if( p->mxAlloc==0 ){
    N = p->nAlloc - p->nChar - 1;
    setStrAccumError(p, STRACCUM_TOOBIG);
    setStrAccumError(p, SQLITE_TOOBIG);
    return N;
  }else{
    char *zOld = isMalloced(p) ? p->zText : 0;
    i64 szNew = p->nChar;
    szNew += N + 1;
    if( szNew+p->nChar<=p->mxAlloc ){
      /* Force exponential buffer size growth as long as it does not overflow,
      ** to avoid having to call this routine too often */
      szNew += p->nChar;
    }
    if( szNew > p->mxAlloc ){
      sqlite3StrAccumReset(p);
      setStrAccumError(p, STRACCUM_TOOBIG);
      sqlite3_str_reset(p);
      setStrAccumError(p, SQLITE_TOOBIG);
      return 0;
    }else{
      p->nAlloc = (int)szNew;
    }
    if( p->db ){
      zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc);
    }else{
      zNew = sqlite3_realloc64(zOld, p->nAlloc);
    }
    if( zNew ){
      assert( p->zText!=0 || p->nChar==0 );
      if( !isMalloced(p) && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar);
      p->zText = zNew;
      p->nAlloc = sqlite3DbMallocSize(p->db, zNew);
      p->printfFlags |= SQLITE_PRINTF_MALLOCED;
    }else{
      sqlite3StrAccumReset(p);
      setStrAccumError(p, STRACCUM_NOMEM);
      sqlite3_str_reset(p);
      setStrAccumError(p, SQLITE_NOMEM);
      return 0;
    }
  }
  return N;
}

/*
** Append N copies of character c to the given string buffer.
*/
SQLITE_PRIVATE void sqlite3AppendChar(StrAccum *p, int N, char c){
SQLITE_API void sqlite3_str_appendchar(sqlite3_str *p, int N, char c){
  testcase( p->nChar + (i64)N > 0x7fffffff );
  if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){
    return;
  }
  while( (N--)>0 ) p->zText[p->nChar++] = c;
}

/*
** The StrAccum "p" is not large enough to accept N new bytes of z[].
** So enlarge if first, then do the append.
**
** This is a helper routine to sqlite3StrAccumAppend() that does special-case
** This is a helper routine to sqlite3_str_append() that does special-case
** work (enlarging the buffer) using tail recursion, so that the
** sqlite3StrAccumAppend() routine can use fast calling semantics.
** sqlite3_str_append() routine can use fast calling semantics.
*/
static void SQLITE_NOINLINE enlargeAndAppend(StrAccum *p, const char *z, int N){
  N = sqlite3StrAccumEnlarge(p, N);
  if( N>0 ){
    memcpy(&p->zText[p->nChar], z, N);
    p->nChar += N;
  }
}

/*
** Append N bytes of text from z to the StrAccum object.  Increase the
** size of the memory allocation for StrAccum if necessary.
*/
SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
SQLITE_API void sqlite3_str_append(sqlite3_str *p, const char *z, int N){
  assert( z!=0 || N==0 );
  assert( p->zText!=0 || p->nChar==0 || p->accError );
  assert( N>=0 );
  assert( p->accError==0 || p->nAlloc==0 );
  if( p->nChar+N >= p->nAlloc ){
    enlargeAndAppend(p,z,N);
  }else if( N ){
    assert( p->zText );
    p->nChar += N;
    memcpy(&p->zText[p->nChar-N], z, N);
  }
}

/*
** Append the complete text of zero-terminated string z[] to the p string.
*/
SQLITE_PRIVATE void sqlite3StrAccumAppendAll(StrAccum *p, const char *z){
  sqlite3StrAccumAppend(p, z, sqlite3Strlen30(z));
SQLITE_API void sqlite3_str_appendall(sqlite3_str *p, const char *z){
  sqlite3_str_append(p, z, sqlite3Strlen30(z));
}


/*
** Finish off a string by making sure it is zero-terminated.
** Return a pointer to the resulting string.  Return a NULL
** pointer if any kind of error was encountered.
*/
static SQLITE_NOINLINE char *strAccumFinishRealloc(StrAccum *p){
  char *zText;
  assert( p->mxAlloc>0 && !isMalloced(p) );
  zText = sqlite3DbMallocRaw(p->db, p->nChar+1 );
  if( zText ){
    memcpy(zText, p->zText, p->nChar+1);
    p->printfFlags |= SQLITE_PRINTF_MALLOCED;
  }else{
    setStrAccumError(p, STRACCUM_NOMEM);
    setStrAccumError(p, SQLITE_NOMEM);
  }
  p->zText = zText;
  return zText;
}
SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum *p){
  if( p->zText ){
    p->zText[p->nChar] = 0;
    if( p->mxAlloc>0 && !isMalloced(p) ){
      return strAccumFinishRealloc(p);
    }
  }
  return p->zText;
}

/*
** This singleton is an sqlite3_str object that is returned if
** sqlite3_malloc() fails to provide space for a real one.  This
** sqlite3_str object accepts no new text and always returns
** an SQLITE_NOMEM error.
*/
static sqlite3_str sqlite3OomStr = {
   0, 0, 0, 0, 0, SQLITE_NOMEM
};

/* Finalize a string created using sqlite3_str_new().
*/
SQLITE_API char *sqlite3_str_finish(sqlite3_str *p){
  char *z;
  if( p!=0 && p!=&sqlite3OomStr ){
    z = sqlite3StrAccumFinish(p);
    sqlite3_free(p);
  }else{
    z = 0;
  }
  return z;
}

/* Return any error code associated with p */
SQLITE_API int sqlite3_str_errcode(sqlite3_str *p){
  return p ? p->accError : SQLITE_NOMEM;
}

/* Return the current length of p in bytes */
SQLITE_API int sqlite3_str_length(sqlite3_str *p){
  return p ? p->nChar : 0;
}

/* Return the current value for p */
SQLITE_API char *sqlite3_str_value(sqlite3_str *p){
  if( p==0 || p->nChar==0 ) return 0;
  p->zText[p->nChar] = 0;
  return p->zText;
}

/*
** Reset an StrAccum string.  Reclaim all malloced memory.
*/
SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum *p){
SQLITE_API void sqlite3_str_reset(StrAccum *p){
  if( isMalloced(p) ){
    sqlite3DbFree(p->db, p->zText);
    p->printfFlags &= ~SQLITE_PRINTF_MALLOCED;
  }
  p->nAlloc = 0;
  p->nChar = 0;
  p->zText = 0;
}

/*
** Initialize a string accumulator.
**
** p:     The accumulator to be initialized.
27280
27281
27282
27283
27284
27285
27286












27287
27288
27289
27290
27291
27292
27293
27294
27295
27296
27297
27298
27299
27300

27301
27302

27303
27304
27305
27306
27307
27308
27309
27641
27642
27643
27644
27645
27646
27647
27648
27649
27650
27651
27652
27653
27654
27655
27656
27657
27658
27659
27660
27661
27662
27663
27664
27665
27666
27667
27668
27669
27670
27671
27672

27673
27674

27675
27676
27677
27678
27679
27680
27681
27682







+
+
+
+
+
+
+
+
+
+
+
+













-
+

-
+







  p->db = db;
  p->nAlloc = n;
  p->mxAlloc = mx;
  p->nChar = 0;
  p->accError = 0;
  p->printfFlags = 0;
}

/* Allocate and initialize a new dynamic string object */
SQLITE_API sqlite3_str *sqlite3_str_new(sqlite3 *db){
  sqlite3_str *p = sqlite3_malloc64(sizeof(*p));
  if( p ){
    sqlite3StrAccumInit(p, 0, 0, 0,
            db ? db->aLimit[SQLITE_LIMIT_LENGTH] : SQLITE_MAX_LENGTH);
  }else{
    p = &sqlite3OomStr;
  }
  return p;
}

/*
** Print into memory obtained from sqliteMalloc().  Use the internal
** %-conversion extensions.
*/
SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){
  char *z;
  char zBase[SQLITE_PRINT_BUF_SIZE];
  StrAccum acc;
  assert( db!=0 );
  sqlite3StrAccumInit(&acc, db, zBase, sizeof(zBase),
                      db->aLimit[SQLITE_LIMIT_LENGTH]);
  acc.printfFlags = SQLITE_PRINTF_INTERNAL;
  sqlite3VXPrintf(&acc, zFormat, ap);
  sqlite3_str_vappendf(&acc, zFormat, ap);
  z = sqlite3StrAccumFinish(&acc);
  if( acc.accError==STRACCUM_NOMEM ){
  if( acc.accError==SQLITE_NOMEM ){
    sqlite3OomFault(db);
  }
  return z;
}

/*
** Print into memory obtained from sqliteMalloc().  Use the internal
27333
27334
27335
27336
27337
27338
27339
27340

27341
27342
27343
27344
27345
27346
27347
27706
27707
27708
27709
27710
27711
27712

27713
27714
27715
27716
27717
27718
27719
27720







-
+







    return 0;
  }
#endif
#ifndef SQLITE_OMIT_AUTOINIT
  if( sqlite3_initialize() ) return 0;
#endif
  sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), SQLITE_MAX_LENGTH);
  sqlite3VXPrintf(&acc, zFormat, ap);
  sqlite3_str_vappendf(&acc, zFormat, ap);
  z = sqlite3StrAccumFinish(&acc);
  return z;
}

/*
** Print into memory obtained from sqlite3_malloc()().  Omit the internal
** %-conversion extensions.
27378
27379
27380
27381
27382
27383
27384
27385

27386
27387
27388
27389
27390
27391
27392
27751
27752
27753
27754
27755
27756
27757

27758
27759
27760
27761
27762
27763
27764
27765







-
+







  if( zBuf==0 || zFormat==0 ) {
    (void)SQLITE_MISUSE_BKPT;
    if( zBuf ) zBuf[0] = 0;
    return zBuf;
  }
#endif
  sqlite3StrAccumInit(&acc, 0, zBuf, n, 0);
  sqlite3VXPrintf(&acc, zFormat, ap);
  sqlite3_str_vappendf(&acc, zFormat, ap);
  zBuf[acc.nChar] = 0;
  return zBuf;
}
SQLITE_API char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
  char *z;
  va_list ap;
  va_start(ap,zFormat);
27400
27401
27402
27403
27404
27405
27406
27407

27408
27409
27410
27411
27412
27413
27414
27415
27416
27417

27418
27419
27420
27421
27422
27423
27424
27773
27774
27775
27776
27777
27778
27779

27780
27781
27782
27783
27784
27785
27786
27787
27788
27789

27790
27791
27792
27793
27794
27795
27796
27797







-
+









-
+







** We house it in a separate routine from sqlite3_log() to avoid using
** stack space on small-stack systems when logging is disabled.
**
** sqlite3_log() must render into a static buffer.  It cannot dynamically
** allocate memory because it might be called while the memory allocator
** mutex is held.
**
** sqlite3VXPrintf() might ask for *temporary* memory allocations for
** sqlite3_str_vappendf() might ask for *temporary* memory allocations for
** certain format characters (%q) or for very large precisions or widths.
** Care must be taken that any sqlite3_log() calls that occur while the
** memory mutex is held do not use these mechanisms.
*/
static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){
  StrAccum acc;                          /* String accumulator */
  char zMsg[SQLITE_PRINT_BUF_SIZE*3];    /* Complete log message */

  sqlite3StrAccumInit(&acc, 0, zMsg, sizeof(zMsg), 0);
  sqlite3VXPrintf(&acc, zFormat, ap);
  sqlite3_str_vappendf(&acc, zFormat, ap);
  sqlite3GlobalConfig.xLog(sqlite3GlobalConfig.pLogArg, iErrCode,
                           sqlite3StrAccumFinish(&acc));
}

/*
** Format and write a message to the log if logging is enabled.
*/
27439
27440
27441
27442
27443
27444
27445
27446

27447
27448
27449
27450
27451
27452
27453
27454
27455
27456
27457
27458
27459
27460
27461
27462
27463

27464
27465
27466

27467
27468
27469

27470
27471
27472
27473
27474
27475
27476
27812
27813
27814
27815
27816
27817
27818

27819
27820
27821
27822
27823
27824
27825
27826
27827
27828
27829
27830
27831
27832
27833
27834
27835

27836
27837
27838

27839
27840
27841

27842
27843
27844
27845
27846
27847
27848
27849







-
+
















-
+


-
+


-
+







*/
SQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){
  va_list ap;
  StrAccum acc;
  char zBuf[500];
  sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
  va_start(ap,zFormat);
  sqlite3VXPrintf(&acc, zFormat, ap);
  sqlite3_str_vappendf(&acc, zFormat, ap);
  va_end(ap);
  sqlite3StrAccumFinish(&acc);
#ifdef SQLITE_OS_TRACE_PROC
  {
    extern void SQLITE_OS_TRACE_PROC(const char *zBuf, int nBuf);
    SQLITE_OS_TRACE_PROC(zBuf, sizeof(zBuf));
  }
#else
  fprintf(stdout,"%s", zBuf);
  fflush(stdout);
#endif
}
#endif


/*
** variable-argument wrapper around sqlite3VXPrintf().  The bFlags argument
** variable-argument wrapper around sqlite3_str_vappendf(). The bFlags argument
** can contain the bit SQLITE_PRINTF_INTERNAL enable internal formats.
*/
SQLITE_PRIVATE void sqlite3XPrintf(StrAccum *p, const char *zFormat, ...){
SQLITE_API void sqlite3_str_appendf(StrAccum *p, const char *zFormat, ...){
  va_list ap;
  va_start(ap,zFormat);
  sqlite3VXPrintf(p, zFormat, ap);
  sqlite3_str_vappendf(p, zFormat, ap);
  va_end(ap);
}

/************** End of printf.c **********************************************/
/************** Begin file treeview.c ****************************************/
/*
** 2015-06-08
27528
27529
27530
27531
27532
27533
27534
27535

27536
27537

27538

27539
27540
27541
27542
27543






27544
27545
27546
27547
27548
27549
27550
27901
27902
27903
27904
27905
27906
27907

27908
27909

27910
27911
27912





27913
27914
27915
27916
27917
27918
27919
27920
27921
27922
27923
27924
27925







-
+

-
+

+
-
-
-
-
-
+
+
+
+
+
+







  va_list ap;
  int i;
  StrAccum acc;
  char zBuf[500];
  sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
  if( p ){
    for(i=0; i<p->iLevel && i<sizeof(p->bLine)-1; i++){
      sqlite3StrAccumAppend(&acc, p->bLine[i] ? "|   " : "    ", 4);
      sqlite3_str_append(&acc, p->bLine[i] ? "|   " : "    ", 4);
    }
    sqlite3StrAccumAppend(&acc, p->bLine[i] ? "|-- " : "'-- ", 4);
    sqlite3_str_append(&acc, p->bLine[i] ? "|-- " : "'-- ", 4);
  }
  if( zFormat!=0 ){
  va_start(ap, zFormat);
  sqlite3VXPrintf(&acc, zFormat, ap);
  va_end(ap);
  assert( acc.nChar>0 );
  if( zBuf[acc.nChar-1]!='\n' ) sqlite3StrAccumAppend(&acc, "\n", 1);
    va_start(ap, zFormat);
    sqlite3_str_vappendf(&acc, zFormat, ap);
    va_end(ap);
    assert( acc.nChar>0 );
    sqlite3_str_append(&acc, "\n", 1);
  }
  sqlite3StrAccumFinish(&acc);
  fprintf(stdout,"%s", zBuf);
  fflush(stdout);
}

/*
** Shorthand for starting a new tree item that consists of a single label
27569
27570
27571
27572
27573
27574
27575
27576

27577
27578
27579
27580
27581

27582
27583
27584

27585
27586

27587
27588
27589
27590
27591
27592
27593
27944
27945
27946
27947
27948
27949
27950

27951
27952
27953
27954
27955

27956
27957
27958

27959
27960

27961
27962
27963
27964
27965
27966
27967
27968







-
+




-
+


-
+

-
+







  if( pWith->nCte>0 ){
    pView = sqlite3TreeViewPush(pView, 1);
    for(i=0; i<pWith->nCte; i++){
      StrAccum x;
      char zLine[1000];
      const struct Cte *pCte = &pWith->a[i];
      sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
      sqlite3XPrintf(&x, "%s", pCte->zName);
      sqlite3_str_appendf(&x, "%s", pCte->zName);
      if( pCte->pCols && pCte->pCols->nExpr>0 ){
        char cSep = '(';
        int j;
        for(j=0; j<pCte->pCols->nExpr; j++){
          sqlite3XPrintf(&x, "%c%s", cSep, pCte->pCols->a[j].zName);
          sqlite3_str_appendf(&x, "%c%s", cSep, pCte->pCols->a[j].zName);
          cSep = ',';
        }
        sqlite3XPrintf(&x, ")");
        sqlite3_str_appendf(&x, ")");
      }
      sqlite3XPrintf(&x, " AS");
      sqlite3_str_appendf(&x, " AS");
      sqlite3StrAccumFinish(&x);
      sqlite3TreeViewItem(pView, zLine, i<pWith->nCte-1);
      sqlite3TreeViewSelect(pView, pCte->pSelect, 0);
      sqlite3TreeViewPop(pView);
    }
    sqlite3TreeViewPop(pView);
  }
27644
27645
27646
27647
27648
27649
27650
27651

27652
27653

27654
27655

27656
27657
27658

27659
27660
27661

27662
27663
27664

27665
27666
27667
27668
27669
27670
27671
28019
28020
28021
28022
28023
28024
28025

28026
28027

28028
28029

28030
28031
28032

28033
28034
28035

28036
28037
28038

28039
28040
28041
28042
28043
28044
28045
28046







-
+

-
+

-
+


-
+


-
+


-
+







      pView = sqlite3TreeViewPush(pView, (n--)>0);
      sqlite3TreeViewLine(pView, "FROM");
      for(i=0; i<p->pSrc->nSrc; i++){
        struct SrcList_item *pItem = &p->pSrc->a[i];
        StrAccum x;
        char zLine[100];
        sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
        sqlite3XPrintf(&x, "{%d,*}", pItem->iCursor);
        sqlite3_str_appendf(&x, "{%d,*}", pItem->iCursor);
        if( pItem->zDatabase ){
          sqlite3XPrintf(&x, " %s.%s", pItem->zDatabase, pItem->zName);
          sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName);
        }else if( pItem->zName ){
          sqlite3XPrintf(&x, " %s", pItem->zName);
          sqlite3_str_appendf(&x, " %s", pItem->zName);
        }
        if( pItem->pTab ){
          sqlite3XPrintf(&x, " tabname=%Q", pItem->pTab->zName);
          sqlite3_str_appendf(&x, " tabname=%Q", pItem->pTab->zName);
        }
        if( pItem->zAlias ){
          sqlite3XPrintf(&x, " (AS %s)", pItem->zAlias);
          sqlite3_str_appendf(&x, " (AS %s)", pItem->zAlias);
        }
        if( pItem->fg.jointype & JT_LEFT ){
          sqlite3XPrintf(&x, " LEFT-JOIN");
          sqlite3_str_appendf(&x, " LEFT-JOIN");
        }
        sqlite3StrAccumFinish(&x);
        sqlite3TreeViewItem(pView, zLine, i<p->pSrc->nSrc-1); 
        if( pItem->pSelect ){
          sqlite3TreeViewSelect(pView, pItem->pSelect, 0);
        }
        if( pItem->fg.isTabFunc ){
28006
28007
28008
28009
28010
28011
28012

28013
28014

28015
28016
28017
28018
28019
28020
28021
28022












28023
28024
28025
28026
28027
28028
28029
28381
28382
28383
28384
28385
28386
28387
28388
28389

28390








28391
28392
28393
28394
28395
28396
28397
28398
28399
28400
28401
28402
28403
28404
28405
28406
28407
28408
28409







+

-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+







    sqlite3TreeViewLine(pView, "%s (empty)", zLabel);
  }else{
    int i;
    sqlite3TreeViewLine(pView, "%s", zLabel);
    for(i=0; i<pList->nExpr; i++){
      int j = pList->a[i].u.x.iOrderByCol;
      char *zName = pList->a[i].zName;
      int moreToFollow = i<pList->nExpr - 1;
      if( j || zName ){
        sqlite3TreeViewPush(pView, 0);
        sqlite3TreeViewPush(pView, moreToFollow);
      }
      if( zName ){
        sqlite3TreeViewLine(pView, "AS %s", zName);
      }
      if( j ){
        sqlite3TreeViewLine(pView, "iOrderByCol=%d", j);
      }
      sqlite3TreeViewExpr(pView, pList->a[i].pExpr, i<pList->nExpr-1);
        moreToFollow = 0;
        sqlite3TreeViewLine(pView, 0);
        if( zName ){
          fprintf(stdout, "AS %s ", zName);
        }
        if( j ){
          fprintf(stdout, "iOrderByCol=%d", j);
        }
        fprintf(stdout, "\n");
        fflush(stdout);
      }
      sqlite3TreeViewExpr(pView, pList->a[i].pExpr, moreToFollow);
      if( j || zName ){
        sqlite3TreeViewPop(pView);
      }
    }
  }
}
SQLITE_PRIVATE void sqlite3TreeViewExprList(
30981
30982
30983
30984
30985
30986
30987

30988
30989
30990
30991
30992
30993
30994
30995
30996
30997










30998
30999
31000
31001
31002
31003





31004
31005
31006
31007
31008
31009
31010
31361
31362
31363
31364
31365
31366
31367
31368










31369
31370
31371
31372
31373
31374
31375
31376
31377
31378






31379
31380
31381
31382
31383
31384
31385
31386
31387
31388
31389
31390







+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+







    /*  77 */ "IntCopy"          OpHelp("r[P2]=r[P1]"),
    /*  78 */ "ResultRow"        OpHelp("output=r[P1@P2]"),
    /*  79 */ "CollSeq"          OpHelp(""),
    /*  80 */ "AddImm"           OpHelp("r[P1]=r[P1]+P2"),
    /*  81 */ "RealAffinity"     OpHelp(""),
    /*  82 */ "Cast"             OpHelp("affinity(r[P1])"),
    /*  83 */ "Permutation"      OpHelp(""),
    /*  84 */ "Compare"          OpHelp("r[P1@P3] <-> r[P2@P3]"),
    /*  84 */ "BitAnd"           OpHelp("r[P3]=r[P1]&r[P2]"),
    /*  85 */ "BitOr"            OpHelp("r[P3]=r[P1]|r[P2]"),
    /*  86 */ "ShiftLeft"        OpHelp("r[P3]=r[P2]<<r[P1]"),
    /*  87 */ "ShiftRight"       OpHelp("r[P3]=r[P2]>>r[P1]"),
    /*  88 */ "Add"              OpHelp("r[P3]=r[P1]+r[P2]"),
    /*  89 */ "Subtract"         OpHelp("r[P3]=r[P2]-r[P1]"),
    /*  90 */ "Multiply"         OpHelp("r[P3]=r[P1]*r[P2]"),
    /*  91 */ "Divide"           OpHelp("r[P3]=r[P2]/r[P1]"),
    /*  92 */ "Remainder"        OpHelp("r[P3]=r[P2]%r[P1]"),
    /*  93 */ "Concat"           OpHelp("r[P3]=r[P2]+r[P1]"),
    /*  85 */ "BitAnd"           OpHelp("r[P3]=r[P1]&r[P2]"),
    /*  86 */ "BitOr"            OpHelp("r[P3]=r[P1]|r[P2]"),
    /*  87 */ "ShiftLeft"        OpHelp("r[P3]=r[P2]<<r[P1]"),
    /*  88 */ "ShiftRight"       OpHelp("r[P3]=r[P2]>>r[P1]"),
    /*  89 */ "Add"              OpHelp("r[P3]=r[P1]+r[P2]"),
    /*  90 */ "Subtract"         OpHelp("r[P3]=r[P2]-r[P1]"),
    /*  91 */ "Multiply"         OpHelp("r[P3]=r[P1]*r[P2]"),
    /*  92 */ "Divide"           OpHelp("r[P3]=r[P2]/r[P1]"),
    /*  93 */ "Remainder"        OpHelp("r[P3]=r[P2]%r[P1]"),
    /*  94 */ "Concat"           OpHelp("r[P3]=r[P2]+r[P1]"),
    /*  94 */ "Compare"          OpHelp("r[P1@P3] <-> r[P2@P3]"),
    /*  95 */ "BitNot"           OpHelp("r[P1]= ~r[P1]"),
    /*  96 */ "IsTrue"           OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
    /*  97 */ "String8"          OpHelp("r[P2]='P4'"),
    /*  98 */ "Offset"           OpHelp("r[P3] = sqlite_offset(P1)"),
    /*  99 */ "Column"           OpHelp("r[P3]=PX"),
    /*  95 */ "IsTrue"           OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
    /*  96 */ "BitNot"           OpHelp("r[P1]= ~r[P1]"),
    /*  97 */ "Offset"           OpHelp("r[P3] = sqlite_offset(P1)"),
    /*  98 */ "Column"           OpHelp("r[P3]=PX"),
    /*  99 */ "String8"          OpHelp("r[P2]='P4'"),
    /* 100 */ "Affinity"         OpHelp("affinity(r[P1@P2])"),
    /* 101 */ "MakeRecord"       OpHelp("r[P3]=mkrec(r[P1@P2])"),
    /* 102 */ "Count"            OpHelp("r[P2]=count()"),
    /* 103 */ "ReadCookie"       OpHelp(""),
    /* 104 */ "SetCookie"        OpHelp(""),
    /* 105 */ "ReopenIdx"        OpHelp("root=P2 iDb=P3"),
    /* 106 */ "OpenRead"         OpHelp("root=P2 iDb=P3"),
31029
31030
31031
31032
31033
31034
31035
31036
31037
31038



31039
31040
31041
31042
31043
31044
31045
31409
31410
31411
31412
31413
31414
31415



31416
31417
31418
31419
31420
31421
31422
31423
31424
31425







-
-
-
+
+
+







    /* 125 */ "Rowid"            OpHelp("r[P2]=rowid"),
    /* 126 */ "NullRow"          OpHelp(""),
    /* 127 */ "SeekEnd"          OpHelp(""),
    /* 128 */ "SorterInsert"     OpHelp("key=r[P2]"),
    /* 129 */ "IdxInsert"        OpHelp("key=r[P2]"),
    /* 130 */ "IdxDelete"        OpHelp("key=r[P2@P3]"),
    /* 131 */ "DeferredSeek"     OpHelp("Move P3 to P1.rowid if needed"),
    /* 132 */ "Real"             OpHelp("r[P2]=P4"),
    /* 133 */ "IdxRowid"         OpHelp("r[P2]=rowid"),
    /* 134 */ "Destroy"          OpHelp(""),
    /* 132 */ "IdxRowid"         OpHelp("r[P2]=rowid"),
    /* 133 */ "Destroy"          OpHelp(""),
    /* 134 */ "Real"             OpHelp("r[P2]=P4"),
    /* 135 */ "Clear"            OpHelp(""),
    /* 136 */ "ResetSorter"      OpHelp(""),
    /* 137 */ "CreateBtree"      OpHelp("r[P2]=root iDb=P1 flags=P3"),
    /* 138 */ "SqlExec"          OpHelp(""),
    /* 139 */ "ParseSchema"      OpHelp(""),
    /* 140 */ "LoadAnalysis"     OpHelp(""),
    /* 141 */ "DropTable"        OpHelp(""),
31068
31069
31070
31071
31072
31073
31074

31075
31076
31077
31078
31079
31080
31081
31448
31449
31450
31451
31452
31453
31454
31455
31456
31457
31458
31459
31460
31461
31462







+







    /* 164 */ "Function0"        OpHelp("r[P3]=func(r[P2@P5])"),
    /* 165 */ "PureFunc"         OpHelp(""),
    /* 166 */ "Function"         OpHelp("r[P3]=func(r[P2@P5])"),
    /* 167 */ "Trace"            OpHelp(""),
    /* 168 */ "CursorHint"       OpHelp(""),
    /* 169 */ "Noop"             OpHelp(""),
    /* 170 */ "Explain"          OpHelp(""),
    /* 171 */ "Abortable"        OpHelp(""),
  };
  return azName[i];
}
#endif

/************** End of opcodes.c *********************************************/
/************** Begin file os_unix.c *****************************************/
61530
61531
61532
61533
61534
61535
61536
61537

61538
61539
61540

61541
61542
61543
61544
61545
61546
61547
61548
61549
61550
61551
61552

61553
61554
61555
61556
61557
61558
61559
61911
61912
61913
61914
61915
61916
61917

61918
61919
61920

61921
61922
61923
61924
61925
61926
61927
61928
61929
61930
61931
61932

61933
61934
61935
61936
61937
61938
61939
61940







-
+


-
+











-
+







  for(i=0; i<db->nDb; i++){
    p = db->aDb[i].pBt;
    if( p && p->sharable ){
      sqlite3BtreeEnter(p);
      skipOk = 0;
    }
  }
  db->skipBtreeMutex = skipOk;
  db->noSharedCache = skipOk;
}
SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){
  if( db->skipBtreeMutex==0 ) btreeEnterAll(db);
  if( db->noSharedCache==0 ) btreeEnterAll(db);
}
static void SQLITE_NOINLINE btreeLeaveAll(sqlite3 *db){
  int i;
  Btree *p;
  assert( sqlite3_mutex_held(db->mutex) );
  for(i=0; i<db->nDb; i++){
    p = db->aDb[i].pBt;
    if( p ) sqlite3BtreeLeave(p);
  }
}
SQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3 *db){
  if( db->skipBtreeMutex==0 ) btreeLeaveAll(db);
  if( db->noSharedCache==0 ) btreeLeaveAll(db);
}

#ifndef NDEBUG
/*
** Return true if the current thread holds the database connection
** mutex and all required BtShared mutexes.
**
64617
64618
64619
64620
64621
64622
64623




64624
64625
64626
64627
64628
64629
64630
64998
64999
65000
65001
65002
65003
65004
65005
65006
65007
65008
65009
65010
65011
65012
65013
65014
65015







+
+
+
+







          pDb->safety_level | (db->flags & PAGER_FLAGS_MASK));
    }
  }
}
#else
# define setDefaultSyncFlag(pBt,safety_level)
#endif

/* Forward declaration */
static int newDatabase(BtShared*);


/*
** Get a reference to pPage1 of the database file.  This will
** also acquire a readlock on that file.
**
** SQLITE_OK is returned on success.  If the file is not a
** well-formed database file, then SQLITE_CORRUPT is returned.
64648
64649
64650
64651
64652
64653
64654



64655
64656
64657
64658
64659
64660
64661
65033
65034
65035
65036
65037
65038
65039
65040
65041
65042
65043
65044
65045
65046
65047
65048
65049







+
+
+







  /* Do some checking to help insure the file we opened really is
  ** a valid database file. 
  */
  nPage = nPageHeader = get4byte(28+(u8*)pPage1->aData);
  sqlite3PagerPagecount(pBt->pPager, &nPageFile);
  if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){
    nPage = nPageFile;
  }
  if( (pBt->db->flags & SQLITE_ResetDatabase)!=0 ){
    nPage = 0;
  }
  if( nPage>0 ){
    u32 pageSize;
    u32 usableSize;
    u8 *page1 = pPage1->aData;
    rc = SQLITE_NOTADB;
    /* EVIDENCE-OF: R-43737-39999 Every valid SQLite database file begins
67865
67866
67867
67868
67869
67870
67871

67872


67873
67874
67875
67876
67877
67878
67879
68253
68254
68255
68256
68257
68258
68259
68260

68261
68262
68263
68264
68265
68266
68267
68268
68269







+
-
+
+







  u32 ovflPageSize;

  assert( sqlite3_mutex_held(pPage->pBt->mutex) );
  pPage->xParseCell(pPage, pCell, pInfo);
  if( pInfo->nLocal==pInfo->nPayload ){
    return SQLITE_OK;  /* No overflow pages. Return without doing anything */
  }
  testcase( pCell + pInfo->nSize == pPage->aDataEnd );
  if( pCell+pInfo->nSize-1 > pPage->aData+pPage->maskPage ){
  testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd );
  if( pCell + pInfo->nSize > pPage->aDataEnd ){
    /* Cell extends past end of page */
    return SQLITE_CORRUPT_PAGE(pPage);
  }
  ovflPgno = get4byte(pCell + pInfo->nSize - 4);
  pBt = pPage->pBt;
  assert( pBt->usableSize > 4 );
  ovflPageSize = pBt->usableSize - 4;
69791
69792
69793
69794
69795
69796
69797
























































































69798
69799
69800
69801
69802
69803
69804
70181
70182
70183
70184
70185
70186
70187
70188
70189
70190
70191
70192
70193
70194
70195
70196
70197
70198
70199
70200
70201
70202
70203
70204
70205
70206
70207
70208
70209
70210
70211
70212
70213
70214
70215
70216
70217
70218
70219
70220
70221
70222
70223
70224
70225
70226
70227
70228
70229
70230
70231
70232
70233
70234
70235
70236
70237
70238
70239
70240
70241
70242
70243
70244
70245
70246
70247
70248
70249
70250
70251
70252
70253
70254
70255
70256
70257
70258
70259
70260
70261
70262
70263
70264
70265
70266
70267
70268
70269
70270
70271
70272
70273
70274
70275
70276
70277
70278
70279
70280
70281
70282







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+








  if( pFree ){
    sqlite3PageFree(pFree);
  }
  return rc;
}

/* Overwrite content from pX into pDest.  Only do the write if the
** content is different from what is already there.
*/
static int btreeOverwriteContent(
  MemPage *pPage,           /* MemPage on which writing will occur */
  u8 *pDest,                /* Pointer to the place to start writing */
  const BtreePayload *pX,   /* Source of data to write */
  int iOffset,              /* Offset of first byte to write */
  int iAmt                  /* Number of bytes to be written */
){
  int nData = pX->nData - iOffset;
  if( nData<=0 ){
    /* Overwritting with zeros */
    int i;
    for(i=0; i<iAmt && pDest[i]==0; i++){}
    if( i<iAmt ){
      int rc = sqlite3PagerWrite(pPage->pDbPage);
      if( rc ) return rc;
      memset(pDest + i, 0, iAmt - i);
    }
  }else{
    if( nData<iAmt ){
      /* Mixed read data and zeros at the end.  Make a recursive call
      ** to write the zeros then fall through to write the real data */
      int rc = btreeOverwriteContent(pPage, pDest+nData, pX, iOffset+nData,
                                 iAmt-nData);
      if( rc ) return rc;
      iAmt = nData;
    }
    if( memcmp(pDest, ((u8*)pX->pData) + iOffset, iAmt)!=0 ){
      int rc = sqlite3PagerWrite(pPage->pDbPage);
      if( rc ) return rc;
      memcpy(pDest, ((u8*)pX->pData) + iOffset, iAmt);
    }
  }
  return SQLITE_OK;
}

/*
** Overwrite the cell that cursor pCur is pointing to with fresh content
** contained in pX.
*/
static int btreeOverwriteCell(BtCursor *pCur, const BtreePayload *pX){
  int iOffset;                        /* Next byte of pX->pData to write */
  int nTotal = pX->nData + pX->nZero; /* Total bytes of to write */
  int rc;                             /* Return code */
  MemPage *pPage = pCur->pPage;       /* Page being written */
  BtShared *pBt;                      /* Btree */
  Pgno ovflPgno;                      /* Next overflow page to write */
  u32 ovflPageSize;                   /* Size to write on overflow page */

  if( pCur->info.pPayload + pCur->info.nLocal > pPage->aDataEnd ){
    return SQLITE_CORRUPT_BKPT;
  }
  /* Overwrite the local portion first */
  rc = btreeOverwriteContent(pPage, pCur->info.pPayload, pX,
                             0, pCur->info.nLocal);
  if( rc ) return rc;
  if( pCur->info.nLocal==nTotal ) return SQLITE_OK;

  /* Now overwrite the overflow pages */
  iOffset = pCur->info.nLocal;
  assert( nTotal>=0 );
  assert( iOffset>=0 );
  ovflPgno = get4byte(pCur->info.pPayload + iOffset);
  pBt = pPage->pBt;
  ovflPageSize = pBt->usableSize - 4;
  do{
    rc = btreeGetPage(pBt, ovflPgno, &pPage, 0);
    if( rc ) return rc;
    if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 ){
      rc = SQLITE_CORRUPT_BKPT;
    }else{
      if( iOffset+ovflPageSize<(u32)nTotal ){
        ovflPgno = get4byte(pPage->aData);
      }else{
        ovflPageSize = nTotal - iOffset;
      }
      rc = btreeOverwriteContent(pPage, pPage->aData+4, pX,
                                 iOffset, ovflPageSize);
    }
    sqlite3PagerUnref(pPage->pDbPage);
    if( rc ) return rc;
    iOffset += ovflPageSize;
  }while( iOffset<nTotal );
  return SQLITE_OK;    
}


/*
** Insert a new record into the BTree.  The content of the new record
** is described by the pX object.  The pCur cursor is used only to
** define what table the record should be inserted into, and is left
** pointing at a random location.
**
69881
69882
69883
69884
69885
69886
69887
69888
69889
69890
69891
69892
69893
69894















69895









69896

69897




69898
69899
69900













69901
69902
69903
69904
69905
69906
69907
69908
69909
69910
69911
69912
69913
69914
69915
69916

































69917
69918
69919
69920
69921
69922
69923
70359
70360
70361
70362
70363
70364
70365







70366
70367
70368
70369
70370
70371
70372
70373
70374
70375
70376
70377
70378
70379
70380
70381
70382
70383
70384
70385
70386
70387
70388
70389
70390

70391
70392
70393
70394
70395
70396
70397
70398
70399
70400
70401
70402
70403
70404
70405
70406
70407
70408
70409
70410
70411
70412
















70413
70414
70415
70416
70417
70418
70419
70420
70421
70422
70423
70424
70425
70426
70427
70428
70429
70430
70431
70432
70433
70434
70435
70436
70437
70438
70439
70440
70441
70442
70443
70444
70445
70446
70447
70448
70449
70450
70451
70452







-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+
+
+
+
+
-
+

+
+
+
+



+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  if( pCur->pKeyInfo==0 ){
    assert( pX->pKey==0 );
    /* If this is an insert into a table b-tree, invalidate any incrblob 
    ** cursors open on the row being replaced */
    invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0);

    /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing 
    ** to a row with the same key as the new entry being inserted.  */
    assert( (flags & BTREE_SAVEPOSITION)==0 || 
            ((pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey) );

    /* If the cursor is currently on the last row and we are appending a
    ** new row onto the end, set the "loc" to avoid an unnecessary
    ** btreeMoveto() call */
    ** to a row with the same key as the new entry being inserted.
    */
#ifdef SQLITE_DEBUG
    if( flags & BTREE_SAVEPOSITION ){
      assert( pCur->curFlags & BTCF_ValidNKey );
      assert( pX->nKey==pCur->info.nKey );
      assert( pCur->info.nSize!=0 );
      assert( loc==0 );
    }
#endif

    /* On the other hand, BTREE_SAVEPOSITION==0 does not imply
    ** that the cursor is not pointing to a row to be overwritten.
    ** So do a complete check.
    */
    if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey ){
      /* The cursor is pointing to the entry that is to be
      ** overwritten */
      assert( pX->nData>=0 && pX->nZero>=0 );
      if( pCur->info.nSize!=0
       && pCur->info.nPayload==(u32)pX->nData+pX->nZero
      ){
        /* New entry is the same size as the old.  Do an overwrite */
        return btreeOverwriteCell(pCur, pX);
      }
      loc = 0;
      assert( loc==0 );
    }else if( loc==0 ){
      /* The cursor is *not* pointing to the cell to be overwritten, nor
      ** to an adjacent cell.  Move the cursor so that it is pointing either
      ** to the cell to be overwritten or an adjacent cell.
      */
      rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, flags!=0, &loc);
      if( rc ) return rc;
    }
  }else{
    /* This is an index or a WITHOUT ROWID table */

    /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing 
    ** to a row with the same key as the new entry being inserted.
    */
    assert( (flags & BTREE_SAVEPOSITION)==0 || loc==0 );

    /* If the cursor is not already pointing either to the cell to be
    ** overwritten, or if a new cell is being inserted, if the cursor is
    ** not pointing to an immediately adjacent cell, then move the cursor
    ** so that it does.
    */
  }else if( loc==0 && (flags & BTREE_SAVEPOSITION)==0 ){
    if( pX->nMem ){
      UnpackedRecord r;
      r.pKeyInfo = pCur->pKeyInfo;
      r.aMem = pX->aMem;
      r.nField = pX->nMem;
      r.default_rc = 0;
      r.errCode = 0;
      r.r1 = 0;
      r.r2 = 0;
      r.eqSeen = 0;
      rc = sqlite3BtreeMovetoUnpacked(pCur, &r, 0, flags!=0, &loc);
    }else{
      rc = btreeMoveto(pCur, pX->pKey, pX->nKey, flags!=0, &loc);
    }
    if( rc ) return rc;
    if( loc==0 && (flags & BTREE_SAVEPOSITION)==0 ){
      if( pX->nMem ){
        UnpackedRecord r;
        r.pKeyInfo = pCur->pKeyInfo;
        r.aMem = pX->aMem;
        r.nField = pX->nMem;
        r.default_rc = 0;
        r.errCode = 0;
        r.r1 = 0;
        r.r2 = 0;
        r.eqSeen = 0;
        rc = sqlite3BtreeMovetoUnpacked(pCur, &r, 0, flags!=0, &loc);
      }else{
        rc = btreeMoveto(pCur, pX->pKey, pX->nKey, flags!=0, &loc);
      }
      if( rc ) return rc;
    }

    /* If the cursor is currently pointing to an entry to be overwritten
    ** and the new content is the same as as the old, then use the
    ** overwrite optimization.
    */
    if( loc==0 ){
      getCellInfo(pCur);
      if( pCur->info.nKey==pX->nKey ){
        BtreePayload x2;
        x2.pData = pX->pKey;
        x2.nData = pX->nKey;
        x2.nZero = 0;
        return btreeOverwriteCell(pCur, &x2);
      }
    }

  }
  assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );

  pPage = pCur->pPage;
  assert( pPage->intKey || pX->nKey>=0 );
  assert( pPage->leaf || !pPage->intKey );

70748
70749
70750
70751
70752
70753
70754
70755

70756
70757
70758

70759
70760

70761
70762

70763
70764
70765
70766
70767
70768
70769
71277
71278
71279
71280
71281
71282
71283

71284
71285
71286

71287
71288

71289
71290

71291
71292
71293
71294
71295
71296
71297
71298







-
+


-
+

-
+

-
+







){
  va_list ap;
  if( !pCheck->mxErr ) return;
  pCheck->mxErr--;
  pCheck->nErr++;
  va_start(ap, zFormat);
  if( pCheck->errMsg.nChar ){
    sqlite3StrAccumAppend(&pCheck->errMsg, "\n", 1);
    sqlite3_str_append(&pCheck->errMsg, "\n", 1);
  }
  if( pCheck->zPfx ){
    sqlite3XPrintf(&pCheck->errMsg, pCheck->zPfx, pCheck->v1, pCheck->v2);
    sqlite3_str_appendf(&pCheck->errMsg, pCheck->zPfx, pCheck->v1, pCheck->v2);
  }
  sqlite3VXPrintf(&pCheck->errMsg, zFormat, ap);
  sqlite3_str_vappendf(&pCheck->errMsg, zFormat, ap);
  va_end(ap);
  if( pCheck->errMsg.accError==STRACCUM_NOMEM ){
  if( pCheck->errMsg.accError==SQLITE_NOMEM ){
    pCheck->mallocFailed = 1;
  }
}
#endif /* SQLITE_OMIT_INTEGRITY_CHECK */

#ifndef SQLITE_OMIT_INTEGRITY_CHECK

71339
71340
71341
71342
71343
71344
71345
71346

71347
71348
71349
71350

71351
71352
71353
71354
71355
71356
71357
71868
71869
71870
71871
71872
71873
71874

71875
71876
71877
71878

71879
71880
71881
71882
71883
71884
71885
71886







-
+



-
+








  /* Clean  up and report errors.
  */
integrity_ck_cleanup:
  sqlite3PageFree(sCheck.heap);
  sqlite3_free(sCheck.aPgRef);
  if( sCheck.mallocFailed ){
    sqlite3StrAccumReset(&sCheck.errMsg);
    sqlite3_str_reset(&sCheck.errMsg);
    sCheck.nErr++;
  }
  *pnErr = sCheck.nErr;
  if( sCheck.nErr==0 ) sqlite3StrAccumReset(&sCheck.errMsg);
  if( sCheck.nErr==0 ) sqlite3_str_reset(&sCheck.errMsg);
  /* Make sure this analysis did not leave any unref() pages. */
  assert( nRef==sqlite3PagerRefcount(pBt->pPager) );
  sqlite3BtreeLeave(p);
  return sqlite3StrAccumFinish(&sCheck.errMsg);
}
#endif /* SQLITE_OMIT_INTEGRITY_CHECK */

73243
73244
73245
73246
73247
73248
73249
73250

73251
73252
73253
73254
73255
73256
73257
73772
73773
73774
73775
73776
73777
73778

73779
73780
73781
73782
73783
73784
73785
73786







-
+







  }else{
    pMem->u.i = val;
    pMem->flags = MEM_Int;
  }
}

/* A no-op destructor */
static void sqlite3NoopDestructor(void *p){ UNUSED_PARAMETER(p); }
SQLITE_PRIVATE void sqlite3NoopDestructor(void *p){ UNUSED_PARAMETER(p); }

/*
** Set the value stored in *pMem should already be a NULL.
** Also store a pointer to go with it.
*/
SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(
  Mem *pMem,
73921
73922
73923
73924
73925
73926
73927
73928
73929
73930
73931
73932
73933





73934
73935
73936
73937
73938
73939
73940
74450
74451
74452
74453
74454
74455
74456

74457
74458
74459
74460
74461
74462
74463
74464
74465
74466
74467
74468
74469
74470
74471
74472
74473







-





+
+
+
+
+







    zVal = &pExpr->u.zToken[2];
    nVal = sqlite3Strlen30(zVal)-1;
    assert( zVal[nVal]=='\'' );
    sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,
                         0, SQLITE_DYNAMIC);
  }
#endif

#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  else if( op==TK_FUNCTION && pCtx!=0 ){
    rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);
  }
#endif
  else if( op==TK_TRUEFALSE ){
     pVal = valueNew(db, pCtx);
     pVal->flags = MEM_Int;
     pVal->u.i = pExpr->u.zToken[4]==0;
  }

  *ppVal = pVal;
  return rc;

no_mem:
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  if( pCtx==0 || pCtx->pParse->nErr==0 )
74585
74586
74587
74588
74589
74590
74591











































74592
74593
74594
74595
74596
74597
74598
75118
75119
75120
75121
75122
75123
75124
75125
75126
75127
75128
75129
75130
75131
75132
75133
75134
75135
75136
75137
75138
75139
75140
75141
75142
75143
75144
75145
75146
75147
75148
75149
75150
75151
75152
75153
75154
75155
75156
75157
75158
75159
75160
75161
75162
75163
75164
75165
75166
75167
75168
75169
75170
75171
75172
75173
75174







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  int p4type          /* P4 operand type */
){
  char *p4copy = sqlite3DbMallocRawNN(sqlite3VdbeDb(p), 8);
  if( p4copy ) memcpy(p4copy, zP4, 8);
  return sqlite3VdbeAddOp4(p, op, p1, p2, p3, p4copy, p4type);
}

#ifndef SQLITE_OMIT_EXPLAIN
/*
** Return the address of the current EXPLAIN QUERY PLAN baseline.
** 0 means "none".
*/
SQLITE_PRIVATE int sqlite3VdbeExplainParent(Parse *pParse){
  VdbeOp *pOp;
  if( pParse->addrExplain==0 ) return 0;
  pOp = sqlite3VdbeGetOp(pParse->pVdbe, pParse->addrExplain);
  return pOp->p2;
}

/*
** Add a new OP_Explain opcode.
**
** If the bPush flag is true, then make this opcode the parent for
** subsequent Explains until sqlite3VdbeExplainPop() is called.
*/
SQLITE_PRIVATE void sqlite3VdbeExplain(Parse *pParse, u8 bPush, const char *zFmt, ...){
  if( pParse->explain==2 ){
    char *zMsg;
    Vdbe *v = pParse->pVdbe;
    va_list ap;
    int iThis;
    va_start(ap, zFmt);
    zMsg = sqlite3VMPrintf(pParse->db, zFmt, ap);
    va_end(ap);
    v = pParse->pVdbe;
    iThis = v->nOp;
    sqlite3VdbeAddOp4(v, OP_Explain, iThis, pParse->addrExplain, 0,
                      zMsg, P4_DYNAMIC);
    if( bPush) pParse->addrExplain = iThis;
  }
}

/*
** Pop the EXPLAIN QUERY PLAN stack one level.
*/
SQLITE_PRIVATE void sqlite3VdbeExplainPop(Parse *pParse){
  pParse->addrExplain = sqlite3VdbeExplainParent(pParse);
}
#endif /* SQLITE_OMIT_EXPLAIN */

/*
** Add an OP_ParseSchema opcode.  This routine is broken out from
** sqlite3VdbeAddOp4() since it needs to also needs to mark all btrees
** as having been used.
**
** The zWhere string must have been obtained from sqlite3_malloc().
** This routine will take ownership of the allocated memory.
74674
74675
74676
74677
74678
74679
74680






74681
74682
74683
74684













74685
74686
74687
74688
74689
74690
74691
75250
75251
75252
75253
75254
75255
75256
75257
75258
75259
75260
75261
75262
75263
75264
75265
75266
75267
75268
75269
75270
75271
75272
75273
75274
75275
75276
75277
75278
75279
75280
75281
75282
75283
75284
75285
75286







+
+
+
+
+
+




+
+
+
+
+
+
+
+
+
+
+
+
+







SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *v, int x){
  Parse *p = v->pParse;
  int j = ADDR(x);
  assert( v->magic==VDBE_MAGIC_INIT );
  assert( j<p->nLabel );
  assert( j>=0 );
  if( p->aLabel ){
#ifdef SQLITE_DEBUG
    if( p->db->flags & SQLITE_VdbeAddopTrace ){
      printf("RESOLVE LABEL %d to %d\n", x, v->nOp);
    }
#endif
    assert( p->aLabel[j]==(-1) ); /* Labels may only be resolved once */
    p->aLabel[j] = v->nOp;
  }
}

#ifdef SQLITE_COVERAGE_TEST
/*
** Return TRUE if and only if the label x has already been resolved.
** Return FALSE (zero) if label x is still unresolved.
**
** This routine is only used inside of testcase() macros, and so it
** only exists when measuring test coverage.
*/
SQLITE_PRIVATE int sqlite3VdbeLabelHasBeenResolved(Vdbe *v, int x){
  return v->pParse->aLabel && v->pParse->aLabel[ADDR(x)]>=0;
}
#endif /* SQLITE_COVERAGE_TEST */

/*
** Mark the VDBE as one that can only be run one time.
*/
SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){
  p->runOnlyOnce = 1;
}

74822
74823
74824
74825
74826
74827
74828


























74829
74830
74831
74832
74833
74834
74835
75417
75418
75419
75420
75421
75422
75423
75424
75425
75426
75427
75428
75429
75430
75431
75432
75433
75434
75435
75436
75437
75438
75439
75440
75441
75442
75443
75444
75445
75446
75447
75448
75449
75450
75451
75452
75453
75454
75455
75456







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  ** through all opcodes and hasAbort may be set incorrectly. Return
  ** true for this case to prevent the assert() in the callers frame
  ** from failing.  */
  return ( v->db->mallocFailed || hasAbort==mayAbort || hasFkCounter
              || (hasCreateTable && hasInitCoroutine) );
}
#endif /* SQLITE_DEBUG - the sqlite3AssertMayAbort() function */

#ifdef SQLITE_DEBUG
/*
** Increment the nWrite counter in the VDBE if the cursor is not an
** ephemeral cursor, or if the cursor argument is NULL.
*/
SQLITE_PRIVATE void sqlite3VdbeIncrWriteCounter(Vdbe *p, VdbeCursor *pC){
  if( pC==0
   || (pC->eCurType!=CURTYPE_SORTER
       && pC->eCurType!=CURTYPE_PSEUDO
       && !pC->isEphemeral)
  ){
    p->nWrite++;
  }
}
#endif

#ifdef SQLITE_DEBUG
/*
** Assert if an Abort at this point in time might result in a corrupt
** database.
*/
SQLITE_PRIVATE void sqlite3VdbeAssertAbortable(Vdbe *p){
  assert( p->nWrite==0 || p->usesStmtJournal );
}
#endif

/*
** This routine is called after all opcodes have been inserted.  It loops
** through all the opcodes and fixes up some details.
**
** (1) For each jump instruction with a negative P2 value (a label)
**     resolve the P2 value to an actual address.
74982
74983
74984
74985
74986
74987
74988











74989
74990
74991
74992
74993
74994
74995
75603
75604
75605
75606
75607
75608
75609
75610
75611
75612
75613
75614
75615
75616
75617
75618
75619
75620
75621
75622
75623
75624
75625
75626
75627







+
+
+
+
+
+
+
+
+
+
+







  int i;
  for(i=0; i<p->nOp; i++){
    assert( p->aOp[i].opcode!=OP_ResultRow );
  }
}
#endif

/*
** Generate code (a single OP_Abortable opcode) that will
** verify that the VDBE program can safely call Abort in the current
** context.
*/
#if defined(SQLITE_DEBUG)
SQLITE_PRIVATE void sqlite3VdbeVerifyAbortable(Vdbe *p, int onError){
  if( onError==OE_Abort ) sqlite3VdbeAddOp0(p, OP_Abortable);
}
#endif

/*
** This function returns a pointer to the array of opcodes associated with
** the Vdbe passed as the first argument. It is the callers responsibility
** to arrange for the returned array to be eventually freed using the 
** vdbeFreeOpArray() function.
**
** Before returning, *pnOp is set to the number of entries in the returned
75526
75527
75528
75529
75530
75531
75532
75533

75534
75535
75536

75537
75538
75539

75540
75541
75542

75543
75544
75545
75546
75547

75548
75549

75550
75551
75552
75553
75554
75555
75556
76158
76159
76160
76161
76162
76163
76164

76165
76166
76167

76168
76169
76170

76171
76172
76173

76174
76175
76176
76177
76178

76179
76180

76181
76182
76183
76184
76185
76186
76187
76188







-
+


-
+


-
+


-
+




-
+

-
+







** Translate the P4.pExpr value for an OP_CursorHint opcode into text
** that can be displayed in the P4 column of EXPLAIN output.
*/
static void displayP4Expr(StrAccum *p, Expr *pExpr){
  const char *zOp = 0;
  switch( pExpr->op ){
    case TK_STRING:
      sqlite3XPrintf(p, "%Q", pExpr->u.zToken);
      sqlite3_str_appendf(p, "%Q", pExpr->u.zToken);
      break;
    case TK_INTEGER:
      sqlite3XPrintf(p, "%d", pExpr->u.iValue);
      sqlite3_str_appendf(p, "%d", pExpr->u.iValue);
      break;
    case TK_NULL:
      sqlite3XPrintf(p, "NULL");
      sqlite3_str_appendf(p, "NULL");
      break;
    case TK_REGISTER: {
      sqlite3XPrintf(p, "r[%d]", pExpr->iTable);
      sqlite3_str_appendf(p, "r[%d]", pExpr->iTable);
      break;
    }
    case TK_COLUMN: {
      if( pExpr->iColumn<0 ){
        sqlite3XPrintf(p, "rowid");
        sqlite3_str_appendf(p, "rowid");
      }else{
        sqlite3XPrintf(p, "c%d", (int)pExpr->iColumn);
        sqlite3_str_appendf(p, "c%d", (int)pExpr->iColumn);
      }
      break;
    }
    case TK_LT:      zOp = "LT";      break;
    case TK_LE:      zOp = "LE";      break;
    case TK_GT:      zOp = "GT";      break;
    case TK_GE:      zOp = "GE";      break;
75574
75575
75576
75577
75578
75579
75580
75581

75582
75583
75584
75585
75586

75587
75588
75589

75590
75591
75592

75593
75594
75595
75596
75597
75598
75599
75600
75601
75602
75603
75604
75605
75606
75607
75608
75609
75610
75611
75612
75613

75614
75615
75616
75617

75618

75619
75620

75621
75622
75623
75624
75625
75626
75627
75628
75629
75630
75631

75632
75633
75634
75635
75636

75637
75638
75639
75640
75641
75642

75643
75644
75645
75646
75647

75648
75649
75650
75651

75652
75653
75654
75655

75656
75657
75658
75659
75660
75661
75662
75663

75664
75665

75666
75667
75668
75669
75670
75671
75672
75673
75674
75675
75676
75677

75678
75679
75680
75681
75682
75683
75684
75685
75686
75687

75688
75689
75690

75691
75692
75693
75694

75695
75696
75697
75698
75699
75700
75701
75702
75703

75704
75705
75706
75707
75708
75709
75710
76206
76207
76208
76209
76210
76211
76212

76213
76214
76215
76216
76217

76218
76219
76220

76221
76222
76223

76224
76225
76226
76227
76228
76229
76230
76231
76232
76233
76234
76235
76236
76237
76238
76239
76240
76241
76242
76243
76244

76245
76246
76247
76248
76249
76250

76251
76252

76253
76254
76255
76256
76257
76258
76259
76260
76261
76262
76263

76264
76265
76266
76267
76268

76269
76270
76271
76272
76273
76274

76275
76276
76277
76278
76279

76280
76281
76282
76283

76284
76285
76286
76287

76288
76289
76290
76291
76292
76293
76294
76295

76296
76297

76298
76299
76300
76301
76302
76303
76304
76305
76306
76307
76308
76309

76310
76311
76312
76313
76314
76315
76316
76317
76318
76319

76320
76321
76322

76323
76324
76325
76326

76327
76328
76329
76330
76331
76332
76333
76334
76335

76336
76337
76338
76339
76340
76341
76342
76343







-
+




-
+


-
+


-
+




















-
+




+
-
+

-
+










-
+




-
+





-
+




-
+



-
+



-
+







-
+

-
+











-
+









-
+


-
+



-
+








-
+







    case TK_UPLUS:   zOp = "PLUS";    break;
    case TK_BITNOT:  zOp = "BITNOT";  break;
    case TK_NOT:     zOp = "NOT";     break;
    case TK_ISNULL:  zOp = "ISNULL";  break;
    case TK_NOTNULL: zOp = "NOTNULL"; break;

    default:
      sqlite3XPrintf(p, "%s", "expr");
      sqlite3_str_appendf(p, "%s", "expr");
      break;
  }

  if( zOp ){
    sqlite3XPrintf(p, "%s(", zOp);
    sqlite3_str_appendf(p, "%s(", zOp);
    displayP4Expr(p, pExpr->pLeft);
    if( pExpr->pRight ){
      sqlite3StrAccumAppend(p, ",", 1);
      sqlite3_str_append(p, ",", 1);
      displayP4Expr(p, pExpr->pRight);
    }
    sqlite3StrAccumAppend(p, ")", 1);
    sqlite3_str_append(p, ")", 1);
  }
}
#endif /* VDBE_DISPLAY_P4 && defined(SQLITE_ENABLE_CURSOR_HINTS) */


#if VDBE_DISPLAY_P4
/*
** Compute a string that describes the P4 parameter for an opcode.
** Use zTemp for any required temporary buffer space.
*/
static char *displayP4(Op *pOp, char *zTemp, int nTemp){
  char *zP4 = zTemp;
  StrAccum x;
  assert( nTemp>=20 );
  sqlite3StrAccumInit(&x, 0, zTemp, nTemp, 0);
  switch( pOp->p4type ){
    case P4_KEYINFO: {
      int j;
      KeyInfo *pKeyInfo = pOp->p4.pKeyInfo;
      assert( pKeyInfo->aSortOrder!=0 );
      sqlite3XPrintf(&x, "k(%d", pKeyInfo->nKeyField);
      sqlite3_str_appendf(&x, "k(%d", pKeyInfo->nKeyField);
      for(j=0; j<pKeyInfo->nKeyField; j++){
        CollSeq *pColl = pKeyInfo->aColl[j];
        const char *zColl = pColl ? pColl->zName : "";
        if( strcmp(zColl, "BINARY")==0 ) zColl = "B";
        sqlite3_str_appendf(&x, ",%s%s", 
        sqlite3XPrintf(&x, ",%s%s", pKeyInfo->aSortOrder[j] ? "-" : "", zColl);
               pKeyInfo->aSortOrder[j] ? "-" : "", zColl);
      }
      sqlite3StrAccumAppend(&x, ")", 1);
      sqlite3_str_append(&x, ")", 1);
      break;
    }
#ifdef SQLITE_ENABLE_CURSOR_HINTS
    case P4_EXPR: {
      displayP4Expr(&x, pOp->p4.pExpr);
      break;
    }
#endif
    case P4_COLLSEQ: {
      CollSeq *pColl = pOp->p4.pColl;
      sqlite3XPrintf(&x, "(%.20s)", pColl->zName);
      sqlite3_str_appendf(&x, "(%.20s)", pColl->zName);
      break;
    }
    case P4_FUNCDEF: {
      FuncDef *pDef = pOp->p4.pFunc;
      sqlite3XPrintf(&x, "%s(%d)", pDef->zName, pDef->nArg);
      sqlite3_str_appendf(&x, "%s(%d)", pDef->zName, pDef->nArg);
      break;
    }
#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
    case P4_FUNCCTX: {
      FuncDef *pDef = pOp->p4.pCtx->pFunc;
      sqlite3XPrintf(&x, "%s(%d)", pDef->zName, pDef->nArg);
      sqlite3_str_appendf(&x, "%s(%d)", pDef->zName, pDef->nArg);
      break;
    }
#endif
    case P4_INT64: {
      sqlite3XPrintf(&x, "%lld", *pOp->p4.pI64);
      sqlite3_str_appendf(&x, "%lld", *pOp->p4.pI64);
      break;
    }
    case P4_INT32: {
      sqlite3XPrintf(&x, "%d", pOp->p4.i);
      sqlite3_str_appendf(&x, "%d", pOp->p4.i);
      break;
    }
    case P4_REAL: {
      sqlite3XPrintf(&x, "%.16g", *pOp->p4.pReal);
      sqlite3_str_appendf(&x, "%.16g", *pOp->p4.pReal);
      break;
    }
    case P4_MEM: {
      Mem *pMem = pOp->p4.pMem;
      if( pMem->flags & MEM_Str ){
        zP4 = pMem->z;
      }else if( pMem->flags & MEM_Int ){
        sqlite3XPrintf(&x, "%lld", pMem->u.i);
        sqlite3_str_appendf(&x, "%lld", pMem->u.i);
      }else if( pMem->flags & MEM_Real ){
        sqlite3XPrintf(&x, "%.16g", pMem->u.r);
        sqlite3_str_appendf(&x, "%.16g", pMem->u.r);
      }else if( pMem->flags & MEM_Null ){
        zP4 = "NULL";
      }else{
        assert( pMem->flags & MEM_Blob );
        zP4 = "(blob)";
      }
      break;
    }
#ifndef SQLITE_OMIT_VIRTUALTABLE
    case P4_VTAB: {
      sqlite3_vtab *pVtab = pOp->p4.pVtab->pVtab;
      sqlite3XPrintf(&x, "vtab:%p", pVtab);
      sqlite3_str_appendf(&x, "vtab:%p", pVtab);
      break;
    }
#endif
    case P4_INTARRAY: {
      int i;
      int *ai = pOp->p4.ai;
      int n = ai[0];   /* The first element of an INTARRAY is always the
                       ** count of the number of elements to follow */
      for(i=1; i<=n; i++){
        sqlite3XPrintf(&x, ",%d", ai[i]);
        sqlite3_str_appendf(&x, ",%d", ai[i]);
      }
      zTemp[0] = '[';
      sqlite3StrAccumAppend(&x, "]", 1);
      sqlite3_str_append(&x, "]", 1);
      break;
    }
    case P4_SUBPROGRAM: {
      sqlite3XPrintf(&x, "program");
      sqlite3_str_appendf(&x, "program");
      break;
    }
    case P4_DYNBLOB:
    case P4_ADVANCE: {
      zTemp[0] = 0;
      break;
    }
    case P4_TABLE: {
      sqlite3XPrintf(&x, "%s", pOp->p4.pTab->zName);
      sqlite3_str_appendf(&x, "%s", pOp->p4.pTab->zName);
      break;
    }
    default: {
      zP4 = pOp->p4.z;
      if( zP4==0 ){
        zP4 = zTemp;
        zTemp[0] = 0;
75908
75909
75910
75911
75912
75913
75914



75915
75916
75917
75918
75919
75920
75921
76541
76542
76543
76544
76545
76546
76547
76548
76549
76550
76551
76552
76553
76554
76555
76556
76557







+
+
+







** running the code, it invokes the callback once for each instruction.
** This feature is used to implement "EXPLAIN".
**
** When p->explain==1, each instruction is listed.  When
** p->explain==2, only OP_Explain instructions are listed and these
** are shown in a different format.  p->explain==2 is used to implement
** EXPLAIN QUERY PLAN.
** 2018-04-24:  In p->explain==2 mode, the OP_Init opcodes of triggers
** are also shown, so that the boundaries between the main program and
** each trigger are clear.
**
** When p->explain==1, first the main program is listed, then each of
** the trigger subprograms are listed one by one.
*/
SQLITE_PRIVATE int sqlite3VdbeList(
  Vdbe *p                   /* The VDBE */
){
75970
75971
75972
75973
75974
75975
75976
75977

75978
75979
75980
75981
75982
75983
75984
76606
76607
76608
76609
76610
76611
76612

76613
76614
76615
76616
76617
76618
76619
76620







-
+







      apSub = (SubProgram **)pSub->z;
    }
    for(i=0; i<nSub; i++){
      nRow += apSub[i]->nOp;
    }
  }

  do{
  while(1){  /* Loop exits via break */
    i = p->pc++;
    if( i>=nRow ){
      p->rc = SQLITE_OK;
      rc = SQLITE_DONE;
      break;
    }
    if( i<p->nOp ){
76016
76017
76018
76019
76020
76021
76022
76023




76024
76025
76026
76027
76028
76029
76030
76652
76653
76654
76655
76656
76657
76658

76659
76660
76661
76662
76663
76664
76665
76666
76667
76668
76669







-
+
+
+
+







        apSub = (SubProgram **)pSub->z;
        apSub[nSub++] = pOp->p4.pProgram;
        pSub->flags |= MEM_Blob;
        pSub->n = nSub*sizeof(SubProgram*);
        nRow += pOp->p4.pProgram->nOp;
      }
    }
  }while( p->explain==2 && pOp->opcode!=OP_Explain );
    if( p->explain<2 ) break;
    if( pOp->opcode==OP_Explain ) break;
    if( pOp->opcode==OP_Init && p->pc>1 ) break;
  }

  if( rc==SQLITE_OK ){
    if( db->u1.isInterrupted ){
      p->rc = SQLITE_INTERRUPT;
      rc = SQLITE_ERROR;
      sqlite3VdbeError(p, sqlite3ErrStr(p->rc));
    }else{
77208
77209
77210
77211
77212
77213
77214



77215
77216
77217
77218
77219
77220
77221
77847
77848
77849
77850
77851
77852
77853
77854
77855
77856
77857
77858
77859
77860
77861
77862
77863







+
+
+







  if( p->aMem ){
    for(i=0; i<p->nMem; i++) assert( p->aMem[i].flags==MEM_Undefined );
  }
#endif
  sqlite3DbFree(db, p->zErrMsg);
  p->zErrMsg = 0;
  p->pResultSet = 0;
#ifdef SQLITE_DEBUG
  p->nWrite = 0;
#endif

  /* Save profiling information from this VDBE run.
  */
#ifdef VDBE_PROFILE
  {
    FILE *out = fopen("vdbe_profile.out", "a");
    if( out ){
78130
78131
78132
78133
78134
78135
78136
78137

78138
78139
78140

78141
78142
78143
78144
78145
78146
78147
78148
78149
78150
78772
78773
78774
78775
78776
78777
78778

78779
78780
78781

78782



78783
78784
78785
78786
78787
78788
78789







-
+


-
+
-
-
-







    if( x<r ) return -1;
    if( x>r ) return +1;
    return 0;
  }else{
    i64 y;
    double s;
    if( r<-9223372036854775808.0 ) return +1;
    if( r>9223372036854775807.0 ) return -1;
    if( r>=9223372036854775808.0 ) return -1;
    y = (i64)r;
    if( i<y ) return -1;
    if( i>y ){
    if( i>y ) return +1;
      if( y==SMALLEST_INT64 && r>0.0 ) return -1;
      return +1;
    }
    s = (double)i;
    if( s<r ) return -1;
    if( s>r ) return +1;
    return 0;
  }
}

79814
79815
79816
79817
79818
79819
79820
79821
79822
79823
79824
79825
79826
79827
79828
79829
79830
79831
79832
79833
79834
79835
79836
79837
79838
79839
79840
79841
79842
79843
79844
79845
79846
79847
79848
79849
80453
80454
80455
80456
80457
80458
80459






















80460
80461
80462
80463
80464
80465
80466







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







  if( *piTime==0 ){
    rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime);
    if( rc ) *piTime = 0;
  }
  return *piTime;
}

/*
** The following is the implementation of an SQL function that always
** fails with an error message stating that the function is used in the
** wrong context.  The sqlite3_overload_function() API might construct
** SQL function that use this routine so that the functions will exist
** for name resolution but are actually overloaded by the xFindFunction
** method of virtual tables.
*/
SQLITE_PRIVATE void sqlite3InvalidFunction(
  sqlite3_context *context,  /* The function calling context */
  int NotUsed,               /* Number of arguments to the function */
  sqlite3_value **NotUsed2   /* Value of each argument */
){
  const char *zName = context->pFunc->zName;
  char *zErr;
  UNUSED_PARAMETER2(NotUsed, NotUsed2);
  zErr = sqlite3_mprintf(
      "unable to use function %s in the requested context", zName);
  sqlite3_result_error(context, zErr, -1);
  sqlite3_free(zErr);
}

/*
** Create a new aggregate context for p and return a pointer to
** its pMem->z element.
*/
static SQLITE_NOINLINE void *createAggContext(sqlite3_context *p, int nByte){
  Mem *pMem = p->pMem;
  assert( (pMem->flags & MEM_Agg)==0 );
81103
81104
81105
81106
81107
81108
81109
81110

81111
81112

81113
81114
81115

81116
81117
81118
81119
81120

81121
81122
81123
81124
81125
81126
81127
81720
81721
81722
81723
81724
81725
81726

81727
81728

81729
81730
81731

81732
81733
81734
81735
81736

81737
81738
81739
81740
81741
81742
81743
81744







-
+

-
+


-
+




-
+







  db = p->db;
  sqlite3StrAccumInit(&out, 0, zBase, sizeof(zBase), 
                      db->aLimit[SQLITE_LIMIT_LENGTH]);
  if( db->nVdbeExec>1 ){
    while( *zRawSql ){
      const char *zStart = zRawSql;
      while( *(zRawSql++)!='\n' && *zRawSql );
      sqlite3StrAccumAppend(&out, "-- ", 3);
      sqlite3_str_append(&out, "-- ", 3);
      assert( (zRawSql - zStart) > 0 );
      sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart));
      sqlite3_str_append(&out, zStart, (int)(zRawSql-zStart));
    }
  }else if( p->nVar==0 ){
    sqlite3StrAccumAppend(&out, zRawSql, sqlite3Strlen30(zRawSql));
    sqlite3_str_append(&out, zRawSql, sqlite3Strlen30(zRawSql));
  }else{
    while( zRawSql[0] ){
      n = findNextHostParameter(zRawSql, &nToken);
      assert( n>0 );
      sqlite3StrAccumAppend(&out, zRawSql, n);
      sqlite3_str_append(&out, zRawSql, n);
      zRawSql += n;
      assert( zRawSql[0] || nToken==0 );
      if( nToken==0 ) break;
      if( zRawSql[0]=='?' ){
        if( nToken>1 ){
          assert( sqlite3Isdigit(zRawSql[1]) );
          sqlite3GetInt32(&zRawSql[1], &idx);
81139
81140
81141
81142
81143
81144
81145
81146

81147
81148

81149
81150

81151
81152
81153
81154
81155
81156
81157
81158
81159
81160

81161
81162
81163
81164
81165
81166
81167
81168
81169
81170
81171
81172
81173

81174
81175
81176

81177
81178
81179
81180
81181
81182
81183

81184
81185
81186
81187

81188
81189
81190
81191
81192
81193

81194
81195

81196
81197
81198

81199
81200
81201
81202
81203
81204

81205
81206
81207
81208
81209
81210
81211
81756
81757
81758
81759
81760
81761
81762

81763
81764

81765
81766

81767
81768
81769
81770
81771
81772
81773
81774
81775
81776

81777
81778
81779
81780
81781
81782
81783
81784
81785
81786
81787
81788
81789

81790
81791
81792

81793
81794
81795
81796
81797
81798
81799

81800
81801
81802
81803

81804
81805
81806
81807
81808
81809

81810
81811

81812
81813
81814

81815
81816
81817
81818
81819
81820

81821
81822
81823
81824
81825
81826
81827
81828







-
+

-
+

-
+









-
+












-
+


-
+






-
+



-
+





-
+

-
+


-
+





-
+







        assert( idx>0 );
      }
      zRawSql += nToken;
      nextIndex = idx + 1;
      assert( idx>0 && idx<=p->nVar );
      pVar = &p->aVar[idx-1];
      if( pVar->flags & MEM_Null ){
        sqlite3StrAccumAppend(&out, "NULL", 4);
        sqlite3_str_append(&out, "NULL", 4);
      }else if( pVar->flags & MEM_Int ){
        sqlite3XPrintf(&out, "%lld", pVar->u.i);
        sqlite3_str_appendf(&out, "%lld", pVar->u.i);
      }else if( pVar->flags & MEM_Real ){
        sqlite3XPrintf(&out, "%!.15g", pVar->u.r);
        sqlite3_str_appendf(&out, "%!.15g", pVar->u.r);
      }else if( pVar->flags & MEM_Str ){
        int nOut;  /* Number of bytes of the string text to include in output */
#ifndef SQLITE_OMIT_UTF16
        u8 enc = ENC(db);
        if( enc!=SQLITE_UTF8 ){
          memset(&utf8, 0, sizeof(utf8));
          utf8.db = db;
          sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);
          if( SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){
            out.accError = STRACCUM_NOMEM;
            out.accError = SQLITE_NOMEM;
            out.nAlloc = 0;
          }
          pVar = &utf8;
        }
#endif
        nOut = pVar->n;
#ifdef SQLITE_TRACE_SIZE_LIMIT
        if( nOut>SQLITE_TRACE_SIZE_LIMIT ){
          nOut = SQLITE_TRACE_SIZE_LIMIT;
          while( nOut<pVar->n && (pVar->z[nOut]&0xc0)==0x80 ){ nOut++; }
        }
#endif    
        sqlite3XPrintf(&out, "'%.*q'", nOut, pVar->z);
        sqlite3_str_appendf(&out, "'%.*q'", nOut, pVar->z);
#ifdef SQLITE_TRACE_SIZE_LIMIT
        if( nOut<pVar->n ){
          sqlite3XPrintf(&out, "/*+%d bytes*/", pVar->n-nOut);
          sqlite3_str_appendf(&out, "/*+%d bytes*/", pVar->n-nOut);
        }
#endif
#ifndef SQLITE_OMIT_UTF16
        if( enc!=SQLITE_UTF8 ) sqlite3VdbeMemRelease(&utf8);
#endif
      }else if( pVar->flags & MEM_Zero ){
        sqlite3XPrintf(&out, "zeroblob(%d)", pVar->u.nZero);
        sqlite3_str_appendf(&out, "zeroblob(%d)", pVar->u.nZero);
      }else{
        int nOut;  /* Number of bytes of the blob to include in output */
        assert( pVar->flags & MEM_Blob );
        sqlite3StrAccumAppend(&out, "x'", 2);
        sqlite3_str_append(&out, "x'", 2);
        nOut = pVar->n;
#ifdef SQLITE_TRACE_SIZE_LIMIT
        if( nOut>SQLITE_TRACE_SIZE_LIMIT ) nOut = SQLITE_TRACE_SIZE_LIMIT;
#endif
        for(i=0; i<nOut; i++){
          sqlite3XPrintf(&out, "%02x", pVar->z[i]&0xff);
          sqlite3_str_appendf(&out, "%02x", pVar->z[i]&0xff);
        }
        sqlite3StrAccumAppend(&out, "'", 1);
        sqlite3_str_append(&out, "'", 1);
#ifdef SQLITE_TRACE_SIZE_LIMIT
        if( nOut<pVar->n ){
          sqlite3XPrintf(&out, "/*+%d bytes*/", pVar->n-nOut);
          sqlite3_str_appendf(&out, "/*+%d bytes*/", pVar->n-nOut);
        }
#endif
      }
    }
  }
  if( out.accError ) sqlite3StrAccumReset(&out);
  if( out.accError ) sqlite3_str_reset(&out);
  return sqlite3StrAccumFinish(&out);
}

#endif /* #ifndef SQLITE_OMIT_TRACE */

/************** End of vdbetrace.c *******************************************/
/************** Begin file vdbe.c ********************************************/
82211
82212
82213
82214
82215
82216
82217



82218
82219
82220
82221
82222
82223
82224
82828
82829
82830
82831
82832
82833
82834
82835
82836
82837
82838
82839
82840
82841
82842
82843
82844







+
+
+







** Check the value in register P3.  If it is NULL then Halt using
** parameter P1, P2, and P4 as if this were a Halt instruction.  If the
** value in register P3 is not NULL, then this routine is a no-op.
** The P5 parameter should be 1.
*/
case OP_HaltIfNull: {      /* in3 */
  pIn3 = &aMem[pOp->p3];
#ifdef SQLITE_DEBUG
  if( pOp->p2==OE_Abort ){ sqlite3VdbeAssertAbortable(p); }
#endif
  if( (pIn3->flags & MEM_Null)==0 ) break;
  /* Fall through into OP_Halt */
}

/* Opcode:  Halt P1 P2 * P4 P5
**
** Exit immediately.  All open cursors, etc are closed
82250
82251
82252
82253
82254
82255
82256



82257
82258
82259
82260
82261
82262
82263
82870
82871
82872
82873
82874
82875
82876
82877
82878
82879
82880
82881
82882
82883
82884
82885
82886







+
+
+







** is the same as executing Halt.
*/
case OP_Halt: {
  VdbeFrame *pFrame;
  int pcx;

  pcx = (int)(pOp - aOp);
#ifdef SQLITE_DEBUG
  if( pOp->p2==OE_Abort ){ sqlite3VdbeAssertAbortable(p); }
#endif
  if( pOp->p1==SQLITE_OK && p->pFrame ){
    /* Halt the sub-program. Return control to the parent frame. */
    pFrame = p->pFrame;
    p->pFrame = pFrame->pParent;
    p->nFrame--;
    sqlite3VdbeSetChanges(db, p->nChange);
    pcx = sqlite3VdbeFrameRestore(pFrame);
84620
84621
84622
84623
84624
84625
84626


84627
84628
84629
84630
84631
84632
84633
85243
85244
85245
85246
85247
85248
85249
85250
85251
85252
85253
85254
85255
85256
85257
85258







+
+







** size, and so forth.  P1==0 is the main database file and P1==1 is the 
** database file used to store temporary tables.
**
** A transaction must be started before executing this opcode.
*/
case OP_SetCookie: {
  Db *pDb;

  sqlite3VdbeIncrWriteCounter(p, 0);
  assert( pOp->p2<SQLITE_N_BTREE_META );
  assert( pOp->p1>=0 && pOp->p1<db->nDb );
  assert( DbMaskTest(p->btreeMask, pOp->p1) );
  assert( p->readOnly==0 );
  pDb = &db->aDb[pOp->p1];
  assert( pDb->pBt!=0 );
  assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) );
85583
85584
85585
85586
85587
85588
85589
85590
85591
85592
85593
85594

85595
85596
85597
85598
85599
85600
85601
86208
86209
86210
86211
86212
86213
86214




86215
86216
86217
86218
86219
86220
86221
86222
86223







-
-
-
-

+







  VdbeFrame *pFrame;     /* Root frame of VDBE */

  v = 0;
  res = 0;
  pOut = out2Prerelease(p, pOp);
  assert( pOp->p1>=0 && pOp->p1<p->nCursor );
  pC = p->apCsr[pOp->p1];
  if( !pC->isTable ){
    rc = SQLITE_CORRUPT_BKPT;
    goto abort_due_to_error;
  }
  assert( pC!=0 );
  assert( pC->isTable );
  assert( pC->eCurType==CURTYPE_BTREE );
  assert( pC->uc.pCursor!=0 );
  {
    /* The next rowid or record number (different terms for the same
    ** thing) is obtained in a two-step algorithm.
    **
    ** First we attempt to find the largest existing rowid and add one
85756
85757
85758
85759
85760
85761
85762

85763
85764
85765
85766
85767
85768
85769
86378
86379
86380
86381
86382
86383
86384
86385
86386
86387
86388
86389
86390
86391
86392







+







  pC = p->apCsr[pOp->p1];
  assert( pC!=0 );
  assert( pC->eCurType==CURTYPE_BTREE );
  assert( pC->uc.pCursor!=0 );
  assert( (pOp->p5 & OPFLAG_ISNOOP) || pC->isTable );
  assert( pOp->p4type==P4_TABLE || pOp->p4type>=P4_STATIC );
  REGISTER_TRACE(pOp->p2, pData);
  sqlite3VdbeIncrWriteCounter(p, pC);

  if( pOp->opcode==OP_Insert ){
    pKey = &aMem[pOp->p3];
    assert( pKey->flags & MEM_Int );
    assert( memIsValid(pKey) );
    REGISTER_TRACE(pOp->p3, pKey);
    x.nKey = pKey->u.i;
85870
85871
85872
85873
85874
85875
85876

85877
85878
85879
85880
85881
85882
85883
86493
86494
86495
86496
86497
86498
86499
86500
86501
86502
86503
86504
86505
86506
86507







+







  opflags = pOp->p2;
  assert( pOp->p1>=0 && pOp->p1<p->nCursor );
  pC = p->apCsr[pOp->p1];
  assert( pC!=0 );
  assert( pC->eCurType==CURTYPE_BTREE );
  assert( pC->uc.pCursor!=0 );
  assert( pC->deferredMoveto==0 );
  sqlite3VdbeIncrWriteCounter(p, pC);

#ifdef SQLITE_DEBUG
  if( pOp->p4type==P4_TABLE && HasRowid(pOp->p4.pTab) && pOp->p5==0 ){
    /* If p5 is zero, the seek operation that positioned the cursor prior to
    ** OP_Delete will have also set the pC->movetoTarget field to the rowid of
    ** the row that is being deleted */
    i64 iKey = sqlite3BtreeIntegerKey(pC->uc.pCursor);
86488
86489
86490
86491
86492
86493
86494

86495
86496
86497
86498
86499
86500
86501
87112
87113
87114
87115
87116
87117
87118
87119
87120
87121
87122
87123
87124
87125
87126







+







case OP_SorterInsert:       /* in2 */
case OP_IdxInsert: {        /* in2 */
  VdbeCursor *pC;
  BtreePayload x;

  assert( pOp->p1>=0 && pOp->p1<p->nCursor );
  pC = p->apCsr[pOp->p1];
  sqlite3VdbeIncrWriteCounter(p, pC);
  assert( pC!=0 );
  assert( isSorter(pC)==(pOp->opcode==OP_SorterInsert) );
  pIn2 = &aMem[pOp->p2];
  assert( pIn2->flags & MEM_Blob );
  if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
  assert( pC->eCurType==CURTYPE_BTREE || pOp->opcode==OP_SorterInsert );
  assert( pC->isTable==0 );
86534
86535
86536
86537
86538
86539
86540

86541
86542
86543
86544
86545
86546
86547
87159
87160
87161
87162
87163
87164
87165
87166
87167
87168
87169
87170
87171
87172
87173







+








  assert( pOp->p3>0 );
  assert( pOp->p2>0 && pOp->p2+pOp->p3<=(p->nMem+1 - p->nCursor)+1 );
  assert( pOp->p1>=0 && pOp->p1<p->nCursor );
  pC = p->apCsr[pOp->p1];
  assert( pC!=0 );
  assert( pC->eCurType==CURTYPE_BTREE );
  sqlite3VdbeIncrWriteCounter(p, pC);
  pCrsr = pC->uc.pCursor;
  assert( pCrsr!=0 );
  assert( pOp->p5==0 );
  r.pKeyInfo = pC->pKeyInfo;
  r.nField = (u16)pOp->p3;
  r.default_rc = 0;
  r.aMem = &aMem[pOp->p2];
86756
86757
86758
86759
86760
86761
86762

86763
86764
86765
86766
86767
86768
86769
87382
87383
87384
87385
87386
87387
87388
87389
87390
87391
87392
87393
87394
87395
87396







+







**
** See also: Clear
*/
case OP_Destroy: {     /* out2 */
  int iMoved;
  int iDb;

  sqlite3VdbeIncrWriteCounter(p, 0);
  assert( p->readOnly==0 );
  assert( pOp->p1>1 );
  pOut = out2Prerelease(p, pOp);
  pOut->flags = MEM_Null;
  if( db->nVdbeRead > db->nVDestroy+1 ){
    rc = SQLITE_LOCKED;
    p->errorAction = OE_Abort;
86805
86806
86807
86808
86809
86810
86811

86812
86813
86814
86815
86816
86817
86818
87432
87433
87434
87435
87436
87437
87438
87439
87440
87441
87442
87443
87444
87445
87446







+







** also incremented by the number of rows in the table being cleared.
**
** See also: Destroy
*/
case OP_Clear: {
  int nChange;
 
  sqlite3VdbeIncrWriteCounter(p, 0);
  nChange = 0;
  assert( p->readOnly==0 );
  assert( DbMaskTest(p->btreeMask, pOp->p2) );
  rc = sqlite3BtreeClearTable(
      db->aDb[pOp->p2].pBt, pOp->p1, (pOp->p3 ? &nChange : 0)
  );
  if( pOp->p3 ){
86861
86862
86863
86864
86865
86866
86867

86868
86869
86870
86871
86872
86873
86874
86875
86876
86877
86878
86879
86880
86881
86882
86883
86884
86885
86886

86887
86888
86889
86890
86891
86892
86893
87489
87490
87491
87492
87493
87494
87495
87496
87497
87498
87499
87500
87501
87502
87503
87504
87505
87506
87507
87508
87509
87510
87511
87512
87513
87514
87515
87516
87517
87518
87519
87520
87521
87522
87523







+



















+







** it must be 2 (BTREE_BLOBKEY) for a index or WITHOUT ROWID table.
** The root page number of the new b-tree is stored in register P2.
*/
case OP_CreateBtree: {          /* out2 */
  int pgno;
  Db *pDb;

  sqlite3VdbeIncrWriteCounter(p, 0);
  pOut = out2Prerelease(p, pOp);
  pgno = 0;
  assert( pOp->p3==BTREE_INTKEY || pOp->p3==BTREE_BLOBKEY );
  assert( pOp->p1>=0 && pOp->p1<db->nDb );
  assert( DbMaskTest(p->btreeMask, pOp->p1) );
  assert( p->readOnly==0 );
  pDb = &db->aDb[pOp->p1];
  assert( pDb->pBt!=0 );
  rc = sqlite3BtreeCreateTable(pDb->pBt, &pgno, pOp->p3);
  if( rc ) goto abort_due_to_error;
  pOut->u.i = pgno;
  break;
}

/* Opcode: SqlExec * * * P4 *
**
** Run the SQL statement or statements specified in the P4 string.
*/
case OP_SqlExec: {
  sqlite3VdbeIncrWriteCounter(p, 0);
  db->nSqlExec++;
  rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0);
  db->nSqlExec--;
  if( rc ) goto abort_due_to_error;
  break;
}

86969
86970
86971
86972
86973
86974
86975

86976
86977
86978
86979
86980
86981
86982
86983
86984
86985
86986
86987
86988

86989
86990
86991
86992
86993
86994
86995
86996
86997
86998
86999
87000
87001

87002
87003
87004
87005
87006
87007
87008
87599
87600
87601
87602
87603
87604
87605
87606
87607
87608
87609
87610
87611
87612
87613
87614
87615
87616
87617
87618
87619
87620
87621
87622
87623
87624
87625
87626
87627
87628
87629
87630
87631
87632
87633
87634
87635
87636
87637
87638
87639
87640
87641







+













+













+







** Remove the internal (in-memory) data structures that describe
** the table named P4 in database P1.  This is called after a table
** is dropped from disk (using the Destroy opcode) in order to keep 
** the internal representation of the
** schema consistent with what is on disk.
*/
case OP_DropTable: {
  sqlite3VdbeIncrWriteCounter(p, 0);
  sqlite3UnlinkAndDeleteTable(db, pOp->p1, pOp->p4.z);
  break;
}

/* Opcode: DropIndex P1 * * P4 *
**
** Remove the internal (in-memory) data structures that describe
** the index named P4 in database P1.  This is called after an index
** is dropped from disk (using the Destroy opcode)
** in order to keep the internal representation of the
** schema consistent with what is on disk.
*/
case OP_DropIndex: {
  sqlite3VdbeIncrWriteCounter(p, 0);
  sqlite3UnlinkAndDeleteIndex(db, pOp->p1, pOp->p4.z);
  break;
}

/* Opcode: DropTrigger P1 * * P4 *
**
** Remove the internal (in-memory) data structures that describe
** the trigger named P4 in database P1.  This is called after a trigger
** is dropped from disk (using the Destroy opcode) in order to keep 
** the internal representation of the
** schema consistent with what is on disk.
*/
case OP_DropTrigger: {
  sqlite3VdbeIncrWriteCounter(p, 0);
  sqlite3UnlinkAndDeleteTrigger(db, pOp->p1, pOp->p4.z);
  break;
}


#ifndef SQLITE_OMIT_INTEGRITY_CHECK
/* Opcode: IntegrityCk P1 P2 P3 P4 P5
88041
88042
88043
88044
88045
88046
88047
88048

88049
88050
88051
88052
88053
88054
88055
88674
88675
88676
88677
88678
88679
88680

88681
88682
88683
88684
88685
88686
88687
88688







-
+







**
** Store in register P3 the value of the P2-th column of
** the current row of the virtual-table of cursor P1.
**
** If the VColumn opcode is being used to fetch the value of
** an unchanging column during an UPDATE operation, then the P5
** value is 1.  Otherwise, P5 is 0.  The P5 value is returned
** by sqlite3_vtab_nochange() routine can can be used
** by sqlite3_vtab_nochange() routine and can be used
** by virtual table implementations to return special "no-change"
** marks which can be more efficient, depending on the virtual table.
*/
case OP_VColumn: {
  sqlite3_vtab *pVtab;
  const sqlite3_module *pModule;
  Mem *pDest;
88204
88205
88206
88207
88208
88209
88210

88211
88212
88213
88214
88215
88216
88217
88837
88838
88839
88840
88841
88842
88843
88844
88845
88846
88847
88848
88849
88850
88851







+







  Mem **apArg;
  Mem *pX;

  assert( pOp->p2==1        || pOp->p5==OE_Fail   || pOp->p5==OE_Rollback 
       || pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace
  );
  assert( p->readOnly==0 );
  sqlite3VdbeIncrWriteCounter(p, 0);
  pVtab = pOp->p4.pVtab->pVtab;
  if( pVtab==0 || NEVER(pVtab->pModule==0) ){
    rc = SQLITE_LOCKED;
    goto abort_due_to_error;
  }
  pModule = pVtab->pModule;
  nArg = pOp->p2;
88520
88521
88522
88523
88524
88525
88526
















88527
88528
88529
88530
88531
88532
88533
88534
88535
88536
88537
88538
88539

88540

88541
88542
88543
88544
88545
88546
88547
89154
89155
89156
89157
89158
89159
89160
89161
89162
89163
89164
89165
89166
89167
89168
89169
89170
89171
89172
89173
89174
89175
89176
89177
89178
89179
89180
89181
89182
89183
89184
89185
89186
89187
89188

89189
89190
89191
89192
89193
89194
89195
89196
89197
89198







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+












-
+

+







    assert( pC->eCurType==CURTYPE_BTREE );
    sqlite3BtreeCursorHint(pC->uc.pCursor, BTREE_HINT_RANGE,
                           pOp->p4.pExpr, aMem);
  }
  break;
}
#endif /* SQLITE_ENABLE_CURSOR_HINTS */

#ifdef SQLITE_DEBUG
/* Opcode:  Abortable   * * * * *
**
** Verify that an Abort can happen.  Assert if an Abort at this point
** might cause database corruption.  This opcode only appears in debugging
** builds.
**
** An Abort is safe if either there have been no writes, or if there is
** an active statement journal.
*/
case OP_Abortable: {
  sqlite3VdbeAssertAbortable(p);
  break;
}
#endif

/* Opcode: Noop * * * * *
**
** Do nothing.  This instruction is often useful as a jump
** destination.
*/
/*
** The magic Explain opcode are only inserted when explain==2 (which
** is to say when the EXPLAIN QUERY PLAN syntax is used.)
** This opcode records information from the optimizer.  It is the
** the same as a no-op.  This opcodesnever appears in a real VM program.
*/
default: {          /* This is really OP_Noop and OP_Explain */
default: {          /* This is really OP_Noop, OP_Explain */
  assert( pOp->opcode==OP_Noop || pOp->opcode==OP_Explain );

  break;
}

/*****************************************************************************
** The cases of the switch statement above this line should all be indented
** by 6 spaces.  But the left-most 6 spaces have been removed to improve the
** readability.  From this point on down, the normal indentation rules are
92694
92695
92696
92697
92698
92699
92700
92701

92702
92703
92704
92705
92706
92707
92708
93345
93346
93347
93348
93349
93350
93351

93352
93353
93354
93355
93356
93357
93358
93359







-
+







  int cntTab = 0;                   /* Number of matching table names */
  int nSubquery = 0;                /* How many levels of subquery */
  sqlite3 *db = pParse->db;         /* The database connection */
  struct SrcList_item *pItem;       /* Use for looping over pSrcList items */
  struct SrcList_item *pMatch = 0;  /* The matching pSrcList item */
  NameContext *pTopNC = pNC;        /* First namecontext in the list */
  Schema *pSchema = 0;              /* Schema of the expression */
  int isTrigger = 0;                /* True if resolved to a trigger column */
  int eNewExprOp = TK_COLUMN;       /* New value for pExpr->op on success */
  Table *pTab = 0;                  /* Table hold the row */
  Column *pCol;                     /* A column of pTab */

  assert( pNC );     /* the name context cannot be NULL. */
  assert( zCol );    /* The Z in X.Y.Z cannot be NULL */
  assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );

92799
92800
92801
92802
92803
92804
92805
92806

92807
92808


92809
92810
92811
92812
92813
92814
92815
92816
92817
92818
92819
92820
92821
























92822
92823
92824
92825
92826
92827
92828
92829
92830
92831
92832
92833
92834
92835
92836
92837
92838
92839
92840









92841
92842
92843
92844
92845
92846
92847
92848
92849
92850
92851
92852
92853














92854
92855
92856
92857
92858






92859
92860
92861
92862
92863
92864
92865
93450
93451
93452
93453
93454
93455
93456

93457
93458

93459
93460
93461












93462
93463
93464
93465
93466
93467
93468
93469
93470
93471
93472
93473
93474
93475
93476
93477
93478
93479
93480
93481
93482
93483
93484
93485
93486
93487
93488
93489
93490
93491
93492
93493
93494
93495
93496
93497
93498
93499
93500
93501
93502
93503
93504
93505
93506
93507
93508
93509
93510
93511
93512
93513













93514
93515
93516
93517
93518
93519
93520
93521
93522
93523
93524
93525
93526
93527





93528
93529
93530
93531
93532
93533
93534
93535
93536
93537
93538
93539
93540







-
+

-
+
+

-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+



















+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+







        if( (pMatch->fg.jointype & JT_LEFT)!=0 ){
          ExprSetProperty(pExpr, EP_CanBeNull);
        }
        pSchema = pExpr->pTab->pSchema;
      }
    } /* if( pSrcList ) */

#ifndef SQLITE_OMIT_TRIGGER
#if !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT)
    /* If we have not already resolved the name, then maybe 
    ** it is a new.* or old.* trigger argument reference
    ** it is a new.* or old.* trigger argument reference.  Or
    ** maybe it is an excluded.* from an upsert.
    */
    if( zDb==0 && zTab!=0 && cntTab==0 && pParse->pTriggerTab!=0 ){
      int op = pParse->eTriggerOp;
      assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT );
      if( op!=TK_DELETE && sqlite3StrICmp("new",zTab) == 0 ){
        pExpr->iTable = 1;
        pTab = pParse->pTriggerTab;
      }else if( op!=TK_INSERT && sqlite3StrICmp("old",zTab)==0 ){
        pExpr->iTable = 0;
        pTab = pParse->pTriggerTab;
      }else{
        pTab = 0;
      }
    if( zDb==0 && zTab!=0 && cntTab==0 ){
      pTab = 0;
#ifndef SQLITE_OMIT_TRIGGER
      if( pParse->pTriggerTab!=0 ){
        int op = pParse->eTriggerOp;
        assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT );
        if( op!=TK_DELETE && sqlite3StrICmp("new",zTab) == 0 ){
          pExpr->iTable = 1;
          pTab = pParse->pTriggerTab;
        }else if( op!=TK_INSERT && sqlite3StrICmp("old",zTab)==0 ){
          pExpr->iTable = 0;
          pTab = pParse->pTriggerTab;
        }
      }
#endif /* SQLITE_OMIT_TRIGGER */
#ifndef SQLITE_OMIT_UPSERT
      if( (pNC->ncFlags & NC_UUpsert)!=0 ){
        Upsert *pUpsert = pNC->uNC.pUpsert;
        if( pUpsert && sqlite3StrICmp("excluded",zTab)==0 ){
          pTab = pUpsert->pUpsertSrc->a[0].pTab;
          pExpr->iTable = 2;
        }
      }
#endif /* SQLITE_OMIT_UPSERT */

      if( pTab ){ 
        int iCol;
        pSchema = pTab->pSchema;
        cntTab++;
        for(iCol=0, pCol=pTab->aCol; iCol<pTab->nCol; iCol++, pCol++){
          if( sqlite3StrICmp(pCol->zName, zCol)==0 ){
            if( iCol==pTab->iPKey ){
              iCol = -1;
            }
            break;
          }
        }
        if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) && VisibleRowid(pTab) ){
          /* IMP: R-51414-32910 */
          iCol = -1;
        }
        if( iCol<pTab->nCol ){
          cnt++;
#ifndef SQLITE_OMIT_UPSERT
          if( pExpr->iTable==2 ){
            testcase( iCol==(-1) );
            pExpr->iTable = pNC->uNC.pUpsert->regData + iCol;
            eNewExprOp = TK_REGISTER;
          }else
#endif /* SQLITE_OMIT_UPSERT */
          {
#ifndef SQLITE_OMIT_TRIGGER
          if( iCol<0 ){
            pExpr->affinity = SQLITE_AFF_INTEGER;
          }else if( pExpr->iTable==0 ){
            testcase( iCol==31 );
            testcase( iCol==32 );
            pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
          }else{
            testcase( iCol==31 );
            testcase( iCol==32 );
            pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
          }
          pExpr->iColumn = (i16)iCol;
          pExpr->pTab = pTab;
            if( iCol<0 ){
              pExpr->affinity = SQLITE_AFF_INTEGER;
            }else if( pExpr->iTable==0 ){
              testcase( iCol==31 );
              testcase( iCol==32 );
              pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
            }else{
              testcase( iCol==31 );
              testcase( iCol==32 );
              pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
            }
            pExpr->pTab = pTab;
            pExpr->iColumn = (i16)iCol;
            eNewExprOp = TK_TRIGGER;
          isTrigger = 1;
        }
      }
    }
#endif /* !defined(SQLITE_OMIT_TRIGGER) */
#endif /* SQLITE_OMIT_TRIGGER */
          }
        }
      }
    }
#endif /* !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT) */

    /*
    ** Perhaps the name is a reference to the ROWID
    */
    if( cnt==0
     && cntTab==1
     && pMatch
92886
92887
92888
92889
92890
92891
92892
92893

92894
92895

92896


92897
92898
92899
92900
92901
92902
92903
93561
93562
93563
93564
93565
93566
93567

93568

93569
93570
93571
93572
93573
93574
93575
93576
93577
93578
93579
93580







-
+
-

+

+
+







    **
    ** The ability to use an output result-set column in the WHERE, GROUP BY,
    ** or HAVING clauses, or as part of a larger expression in the ORDER BY
    ** clause is not standard SQL.  This is a (goofy) SQLite extension, that
    ** is supported for backwards compatibility only. Hence, we issue a warning
    ** on sqlite3_log() whenever the capability is used.
    */
    if( (pEList = pNC->pEList)!=0
    if( (pNC->ncFlags & NC_UEList)!=0
     && zTab==0
     && cnt==0
     && zTab==0
    ){
      pEList = pNC->uNC.pEList;
      assert( pEList!=0 );
      for(j=0; j<pEList->nExpr; j++){
        char *zAs = pEList->a[j].zName;
        if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){
          Expr *pOrig;
          assert( pExpr->pLeft==0 && pExpr->pRight==0 );
          assert( pExpr->x.pList==0 );
          assert( pExpr->x.pSelect==0 );
92986
92987
92988
92989
92990
92991
92992
92993

92994
92995
92996
92997
92998
92999
93000
93663
93664
93665
93666
93667
93668
93669

93670
93671
93672
93673
93674
93675
93676
93677







-
+








  /* Clean up and return
  */
  sqlite3ExprDelete(db, pExpr->pLeft);
  pExpr->pLeft = 0;
  sqlite3ExprDelete(db, pExpr->pRight);
  pExpr->pRight = 0;
  pExpr->op = (isTrigger ? TK_TRIGGER : TK_COLUMN);
  pExpr->op = eNewExprOp;
  ExprSetProperty(pExpr, EP_Leaf);
lookupname_end:
  if( cnt==1 ){
    assert( pNC!=0 );
    if( !ExprHasProperty(pExpr, EP_Alias) ){
      sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList);
    }
93418
93419
93420
93421
93422
93423
93424
93425
93426


93427
93428
93429
93430
93431
93432
93433
94095
94096
94097
94098
94099
94100
94101


94102
94103
94104
94105
94106
94107
94108
94109
94110







-
-
+
+







  pEList = pSelect->pEList;

  /* Resolve all names in the ORDER BY term expression
  */
  memset(&nc, 0, sizeof(nc));
  nc.pParse = pParse;
  nc.pSrcList = pSelect->pSrc;
  nc.pEList = pEList;
  nc.ncFlags = NC_AllowAgg;
  nc.uNC.pEList = pEList;
  nc.ncFlags = NC_AllowAgg|NC_UEList;
  nc.nErr = 0;
  db = pParse->db;
  savedSuppErr = db->suppressErr;
  db->suppressErr = 1;
  rc = sqlite3ResolveExprNames(&nc, pE);
  db->suppressErr = savedSuppErr;
  if( rc ) return 0;
93802
93803
93804
93805
93806
93807
93808

93809


93810
93811
93812
93813
93814
93815
93816
94479
94480
94481
94482
94483
94484
94485
94486

94487
94488
94489
94490
94491
94492
94493
94494
94495







+
-
+
+







    ** other expressions in the SELECT statement. This is so that
    ** expressions in the WHERE clause (etc.) can refer to expressions by
    ** aliases in the result set.
    **
    ** Minor point: If this is the case, then the expression will be
    ** re-evaluated for each reference to it.
    */
    assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert))==0 );
    sNC.pEList = p->pEList;
    sNC.uNC.pEList = p->pEList;
    sNC.ncFlags |= NC_UEList;
    if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
    if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;

    /* Resolve names in table-valued-function arguments */
    for(i=0; i<p->pSrc->nSrc; i++){
      struct SrcList_item *pItem = &p->pSrc->a[i];
      if( pItem->fg.isTabFunc
94035
94036
94037
94038
94039
94040
94041
94042

94043
94044
94045
94046
94047
94048
94049
94714
94715
94716
94717
94718
94719
94720

94721
94722
94723
94724
94725
94726
94727
94728







-
+







** Any errors cause an error message to be set in pParse.
*/
SQLITE_PRIVATE void sqlite3ResolveSelfReference(
  Parse *pParse,      /* Parsing context */
  Table *pTab,        /* The table being referenced */
  int type,           /* NC_IsCheck or NC_PartIdx or NC_IdxExpr */
  Expr *pExpr,        /* Expression to resolve.  May be NULL. */
  ExprList *pList     /* Expression list to resolve.  May be NUL. */
  ExprList *pList     /* Expression list to resolve.  May be NULL. */
){
  SrcList sSrc;                   /* Fake SrcList for pParse->pNewTable */
  NameContext sNC;                /* Name context for pParse->pNewTable */

  assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr );
  memset(&sNC, 0, sizeof(sNC));
  memset(&sSrc, 0, sizeof(sSrc));
95421
95422
95423
95424
95425
95426
95427

95428
95429
95430
95431
95432
95433
95434
96100
96101
96102
96103
96104
96105
96106
96107
96108
96109
96110
96111
96112
96113
96114







+







      }
    }
    pItem->zName = sqlite3DbStrDup(db, pOldItem->zName);
    pItem->zSpan = sqlite3DbStrDup(db, pOldItem->zSpan);
    pItem->sortOrder = pOldItem->sortOrder;
    pItem->done = 0;
    pItem->bSpanIsTab = pOldItem->bSpanIsTab;
    pItem->bSorterRef = pOldItem->bSorterRef;
    pItem->u = pOldItem->u;
  }
  return pNew;
}

/*
** If cursors, triggers, views and subqueries are all omitted from
95883
95884
95885
95886
95887
95888
95889


95890
95891
95892
95893
95894
95895
95896
95897
95898
95899
95900
95901
95902
95903
95904
95905
95906
95907
95908


95909
95910
95911
95912
95913
95914
95915
96563
96564
96565
96566
96567
96568
96569
96570
96571
96572
96573
96574
96575
96576
96577
96578
96579
96580
96581
96582
96583
96584
96585
96586
96587
96588


96589
96590
96591
96592
96593
96594
96595
96596
96597







+
+

















-
-
+
+







      testcase( pExpr->op==TK_AGG_FUNCTION );
      testcase( pExpr->op==TK_AGG_COLUMN );
      if( pWalker->eCode==3 && pExpr->iTable==pWalker->u.iCur ){
        return WRC_Continue;
      }
      /* Fall through */
    case TK_IF_NULL_ROW:
    case TK_REGISTER:
      testcase( pExpr->op==TK_REGISTER );
      testcase( pExpr->op==TK_IF_NULL_ROW );
      pWalker->eCode = 0;
      return WRC_Abort;
    case TK_VARIABLE:
      if( pWalker->eCode==5 ){
        /* Silently convert bound parameters that appear inside of CREATE
        ** statements into a NULL when parsing the CREATE statement text out
        ** of the sqlite_master table */
        pExpr->op = TK_NULL;
      }else if( pWalker->eCode==4 ){
        /* A bound parameter in a CREATE statement that originates from
        ** sqlite3_prepare() causes an error */
        pWalker->eCode = 0;
        return WRC_Abort;
      }
      /* Fall through */
    default:
      testcase( pExpr->op==TK_SELECT ); /* sqlite3SelectWalkFail will disallow */
      testcase( pExpr->op==TK_EXISTS ); /* sqlite3SelectWalkFail will disallow */
      testcase( pExpr->op==TK_SELECT ); /* sqlite3SelectWalkFail() disallows */
      testcase( pExpr->op==TK_EXISTS ); /* sqlite3SelectWalkFail() disallows */
      return WRC_Continue;
  }
}
static int exprIsConst(Expr *p, int initFlag, int iCur){
  Walker w;
  w.eCode = initFlag;
  w.xExprCallback = exprNodeIsConstant;
96465
96466
96467
96468
96469
96470
96471
96472
96473
96474


96475
96476
96477
96478
96479
96480
96481
96482
96483
97147
97148
97149
97150
97151
97152
97153



97154
97155


97156
97157
97158
97159
97160
97161
97162







-
-
-
+
+
-
-







            if( aiMap ) aiMap[i] = j;
          }
  
          assert( i==nExpr || colUsed!=(MASKBIT(nExpr)-1) );
          if( colUsed==(MASKBIT(nExpr)-1) ){
            /* If we reach this point, that means the index pIdx is usable */
            int iAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
#ifndef SQLITE_OMIT_EXPLAIN
            sqlite3VdbeAddOp4(v, OP_Explain, 0, 0, 0,
              sqlite3MPrintf(db, "USING INDEX %s FOR IN-OPERATOR",pIdx->zName),
            ExplainQueryPlan((pParse, 0,
                              "USING INDEX %s FOR IN-OPERATOR",pIdx->zName));
              P4_DYNAMIC);
#endif
            sqlite3VdbeAddOp3(v, OP_OpenRead, iTab, pIdx->tnum, iDb);
            sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
            VdbeComment((v, "%s", pIdx->zName));
            assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );
            eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
  
            if( prRhsHasNull ){
96664
96665
96666
96667
96668
96669
96670
96671
96672
96673
96674
96675
96676
96677
96678
96679
96680
96681
96682
96683
96684
96685
96686
96687
96688
97343
97344
97345
97346
97347
97348
97349











97350
97351
97352
97353
97354
97355
97356







-
-
-
-
-
-
-
-
-
-
-







  ** If all of the above are false, then we can run this code just once
  ** save the results, and reuse the same result on subsequent invocations.
  */
  if( !ExprHasProperty(pExpr, EP_VarSelect) ){
    jmpIfDynamic = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
  }

#ifndef SQLITE_OMIT_EXPLAIN
  if( pParse->explain==2 ){
    char *zMsg = sqlite3MPrintf(pParse->db, "EXECUTE %s%s SUBQUERY %d",
        jmpIfDynamic>=0?"":"CORRELATED ",
        pExpr->op==TK_IN?"LIST":"SCALAR",
        pParse->iNextSelectId
    );
    sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);
  }
#endif

  switch( pExpr->op ){
    case TK_IN: {
      int addr;                   /* Address of OP_OpenEphemeral instruction */
      Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
      KeyInfo *pKeyInfo = 0;      /* Key information */
      int nVal;                   /* Size of vector pLeft */
      
96712
96713
96714
96715
96716
96717
96718



96719
96720
96721
96722
96723
96724
96725
97380
97381
97382
97383
97384
97385
97386
97387
97388
97389
97390
97391
97392
97393
97394
97395
97396







+
+
+







        **
        ** Generate code to write the results of the select into the temporary
        ** table allocated and opened above.
        */
        Select *pSelect = pExpr->x.pSelect;
        ExprList *pEList = pSelect->pEList;

        ExplainQueryPlan((pParse, 1, "%sLIST SUBQUERY",
            jmpIfDynamic>=0?"":"CORRELATED "
        ));
        assert( !isRowid );
        /* If the LHS and RHS of the IN operator do not match, that
        ** error will have been caught long before we reach this point. */
        if( ALWAYS(pEList->nExpr==nVal) ){
          SelectDest dest;
          int i;
          sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
96753
96754
96755
96756
96757
96758
96759
96760
96761
96762
96763
96764
96765
96766
96767
97424
97425
97426
97427
97428
97429
97430

97431
97432
97433
97434
97435
97436
97437







-







        ** a column, use numeric affinity.
        */
        char affinity;            /* Affinity of the LHS of the IN */
        int i;
        ExprList *pList = pExpr->x.pList;
        struct ExprList_item *pItem;
        int r1, r2, r3;

        affinity = sqlite3ExprAffinity(pLeft);
        if( !affinity ){
          affinity = SQLITE_AFF_BLOB;
        }
        if( pKeyInfo ){
          assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
          pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
96834
96835
96836
96837
96838
96839
96840


96841
96842
96843
96844
96845
96846
96847
97504
97505
97506
97507
97508
97509
97510
97511
97512
97513
97514
97515
97516
97517
97518
97519







+
+








      testcase( pExpr->op==TK_EXISTS );
      testcase( pExpr->op==TK_SELECT );
      assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
      assert( ExprHasProperty(pExpr, EP_xIsSelect) );

      pSel = pExpr->x.pSelect;
      ExplainQueryPlan((pParse, 1, "%sSCALAR SUBQUERY",
            jmpIfDynamic>=0?"":"CORRELATED "));
      nReg = pExpr->op==TK_SELECT ? pSel->pEList->nExpr : 1;
      sqlite3SelectDestInit(&dest, 0, pParse->nMem+1);
      pParse->nMem += nReg;
      if( pExpr->op==TK_SELECT ){
        dest.eDest = SRT_Mem;
        dest.iSdst = dest.iSDParm;
        dest.nSdst = nReg;
97596
97597
97598
97599
97600
97601
97602

97603
97604
97605
97606
97607
97608
97609
98268
98269
98270
98271
98272
98273
98274
98275
98276
98277
98278
98279
98280
98281
98282







+








  assert( target>0 && target<=pParse->nMem );
  if( v==0 ){
    assert( pParse->db->mallocFailed );
    return 0;
  }

expr_code_doover:
  if( pExpr==0 ){
    op = TK_NULL;
  }else{
    op = pExpr->op;
  }
  switch( op ){
    case TK_AGG_COLUMN: {
98056
98057
98058
98059
98060
98061
98062
98063


98064
98065
98066
98067
98068
98069
98070
98729
98730
98731
98732
98733
98734
98735

98736
98737
98738
98739
98740
98741
98742
98743
98744







-
+
+







    case TK_BETWEEN: {
      exprCodeBetween(pParse, pExpr, target, 0, 0);
      return target;
    }
    case TK_SPAN:
    case TK_COLLATE: 
    case TK_UPLUS: {
      return sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
      pExpr = pExpr->pLeft;
      goto expr_code_doover;
    }

    case TK_TRIGGER: {
      /* If the opcode is TK_TRIGGER, then the expression is a reference
      ** to a column in the new.* or old.* pseudo-tables available to
      ** trigger programs. In this case Expr.iTable is set to 1 for the
      ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn
98094
98095
98096
98097
98098
98099
98100
98101

98102
98103

98104
98105
98106
98107
98108
98109
98110
98111
98768
98769
98770
98771
98772
98773
98774

98775
98776

98777

98778
98779
98780
98781
98782
98783
98784







-
+

-
+
-








      assert( pExpr->iTable==0 || pExpr->iTable==1 );
      assert( pExpr->iColumn>=-1 && pExpr->iColumn<pTab->nCol );
      assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey );
      assert( p1>=0 && p1<(pTab->nCol*2+2) );

      sqlite3VdbeAddOp2(v, OP_Param, p1, target);
      VdbeComment((v, "%s.%s -> $%d",
      VdbeComment((v, "r[%d]=%s.%s", target,
        (pExpr->iTable ? "new" : "old"),
        (pExpr->iColumn<0 ? "rowid" : pExpr->pTab->aCol[pExpr->iColumn].zName),
        (pExpr->iColumn<0 ? "rowid" : pExpr->pTab->aCol[pExpr->iColumn].zName)
        target
      ));

#ifndef SQLITE_OMIT_FLOATING_POINT
      /* If the column has REAL affinity, it may currently be stored as an
      ** integer. Use OP_RealAffinity to make sure it is really real.
      **
      ** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to
98429
98430
98431
98432
98433
98434
98435






98436
98437
98438
98439
98440
98441
98442
99102
99103
99104
99105
99106
99107
99108
99109
99110
99111
99112
99113
99114
99115
99116
99117
99118
99119
99120
99121







+
+
+
+
+
+







  assert( pList!=0 );
  assert( target>0 );
  assert( pParse->pVdbe!=0 );  /* Never gets this far otherwise */
  n = pList->nExpr;
  if( !ConstFactorOk(pParse) ) flags &= ~SQLITE_ECEL_FACTOR;
  for(pItem=pList->a, i=0; i<n; i++, pItem++){
    Expr *pExpr = pItem->pExpr;
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
    if( pItem->bSorterRef ){
      i--;
      n--;
    }else
#endif
    if( (flags & SQLITE_ECEL_REF)!=0 && (j = pItem->u.x.iOrderByCol)>0 ){
      if( flags & SQLITE_ECEL_OMITREF ){
        i--;
        n--;
      }else{
        sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i);
      }
98957
98958
98959
98960
98961
98962
98963


98964
98965

98966
98967
98968
98969
98970
98971
98972
98973
98974


98975
98976
98977
98978
98979
98980
98981
99636
99637
99638
99639
99640
99641
99642
99643
99644
99645

99646
99647
99648
99649
99650
99651
99652
99653
99654

99655
99656
99657
99658
99659
99660
99661
99662
99663







+
+

-
+








-
+
+







      return 1;
    }
    return 2;
  }
  if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
    if( pA->op==TK_FUNCTION ){
      if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
    }else if( pA->op==TK_COLLATE ){
      if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
    }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
      return pA->op==TK_COLLATE ? 1 : 2;
      return 2;
    }
  }
  if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
  if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
    if( combinedFlags & EP_xIsSelect ) return 2;
    if( sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
    if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
    if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
    if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){
    assert( (combinedFlags & EP_Reduced)==0 );
    if( pA->op!=TK_STRING && pA->op!=TK_TRUEFALSE ){
      if( pA->iColumn!=pB->iColumn ) return 2;
      if( pA->iTable!=pB->iTable 
       && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
    }
  }
  return 0;
}
99313
99314
99315
99316
99317
99318
99319
99320

99321

99322
99323
99324
99325
99326
99327
99328
99995
99996
99997
99998
99999
100000
100001

100002
100003
100004
100005
100006
100007
100008
100009
100010
100011







-
+

+







** for additional information.
*/
static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
  int i;
  NameContext *pNC = pWalker->u.pNC;
  Parse *pParse = pNC->pParse;
  SrcList *pSrcList = pNC->pSrcList;
  AggInfo *pAggInfo = pNC->pAggInfo;
  AggInfo *pAggInfo = pNC->uNC.pAggInfo;

  assert( pNC->ncFlags & NC_UAggInfo );
  switch( pExpr->op ){
    case TK_AGG_COLUMN:
    case TK_COLUMN: {
      testcase( pExpr->op==TK_AGG_COLUMN );
      testcase( pExpr->op==TK_COLUMN );
      /* Check to see if the column is in one of the tables in the FROM
      ** clause of the aggregate query */
102484
102485
102486
102487
102488
102489
102490
102491

102492
102493
102494
102495
102496
102497
102498
103167
103168
103169
103170
103171
103172
103173

103174
103175
103176
103177
103178
103179
103180
103181







-
+







    }
    assert( pVfs );
    flags |= SQLITE_OPEN_MAIN_DB;
    rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
    sqlite3_free( zPath );
    db->nDb++;
  }
  db->skipBtreeMutex = 0;
  db->noSharedCache = 0;
  if( rc==SQLITE_CONSTRAINT ){
    rc = SQLITE_ERROR;
    zErrDyn = sqlite3MPrintf(db, "database is already attached");
  }else if( rc==SQLITE_OK ){
    Pager *pPager;
    pNew->pSchema = sqlite3SchemaGet(db, pNew->pBt);
    if( !pNew->pSchema ){
102556
102557
102558
102559
102560
102561
102562

102563
102564
102565
102566
102567
102568
102569
103239
103240
103241
103242
103243
103244
103245
103246
103247
103248
103249
103250
103251
103252
103253







+







  ** If this fails, or if opening the file failed, then close the file and 
  ** remove the entry from the db->aDb[] array. i.e. put everything back the
  ** way we found it.
  */
  if( rc==SQLITE_OK ){
    sqlite3BtreeEnterAll(db);
    db->init.iDb = 0;
    db->mDbFlags &= ~(DBFLAG_SchemaKnownOk);
    rc = sqlite3Init(db, &zErrDyn);
    sqlite3BtreeLeaveAll(db);
    assert( zErrDyn==0 || rc!=SQLITE_OK );
  }
#ifdef SQLITE_USER_AUTHENTICATION
  if( rc==SQLITE_OK ){
    u8 newAuth = 0;
102828
102829
102830
102831
102832
102833
102834



102835
102836
102837
102838
102839
102840
102841
103512
103513
103514
103515
103516
103517
103518
103519
103520
103521
103522
103523
103524
103525
103526
103527
103528







+
+
+







      pItem->zDatabase = 0;
      pItem->pSchema = pFix->pSchema;
    }
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
    if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;
    if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;
#endif
    if( pItem->fg.isTabFunc && sqlite3FixExprList(pFix, pItem->u1.pFuncArg) ){
      return 1;
    }
  }
  return 0;
}
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
SQLITE_PRIVATE int sqlite3FixSelect(
  DbFixer *pFix,       /* Context of the fixation */
  Select *pSelect      /* The SELECT statement to be fixed to one database */
102927
102928
102929
102930
102931
102932
102933












102934
102935
102936
102937
102938
102939
102940
103614
103615
103616
103617
103618
103619
103620
103621
103622
103623
103624
103625
103626
103627
103628
103629
103630
103631
103632
103633
103634
103635
103636
103637
103638
103639







+
+
+
+
+
+
+
+
+
+
+
+







    }
    if( sqlite3FixExpr(pFix, pStep->pWhere) ){
      return 1;
    }
    if( sqlite3FixExprList(pFix, pStep->pExprList) ){
      return 1;
    }
#ifndef SQLITE_OMIT_UPSERT
    if( pStep->pUpsert ){
      Upsert *pUp = pStep->pUpsert;
      if( sqlite3FixExprList(pFix, pUp->pUpsertTarget)
       || sqlite3FixExpr(pFix, pUp->pUpsertTargetWhere)
       || sqlite3FixExprList(pFix, pUp->pUpsertSet)
       || sqlite3FixExpr(pFix, pUp->pUpsertWhere)
      ){
        return 1;
      }
    }
#endif
    pStep = pStep->pNext;
  }
  return 0;
}
#endif

/************** End of attach.c **********************************************/
103554
103555
103556
103557
103558
103559
103560

103561
103562
103563

103564


103565
103566
103567
103568

103569
103570
103571
103572

103573
103574
103575
103576

103577
103578

103579
103580
103581
103582
103583
103584
103585
104253
104254
104255
104256
104257
104258
104259
104260
104261
104262
104263
104264

104265
104266
104267
104268
104269

104270
104271
104272
104273

104274
104275
104276
104277

104278
104279

104280
104281
104282
104283
104284
104285
104286
104287







+



+
-
+
+



-
+



-
+



-
+

-
+







SQLITE_PRIVATE Table *sqlite3LocateTable(
  Parse *pParse,         /* context in which to report errors */
  u32 flags,             /* LOCATE_VIEW or LOCATE_NOERR */
  const char *zName,     /* Name of the table we are looking for */
  const char *zDbase     /* Name of the database.  Might be NULL */
){
  Table *p;
  sqlite3 *db = pParse->db;

  /* Read the database schema. If an error occurs, leave an error message
  ** and code in pParse and return NULL. */
  if( (db->mDbFlags & DBFLAG_SchemaKnownOk)==0 
  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
   && SQLITE_OK!=sqlite3ReadSchema(pParse)
  ){
    return 0;
  }

  p = sqlite3FindTable(pParse->db, zName, zDbase);
  p = sqlite3FindTable(db, zName, zDbase);
  if( p==0 ){
    const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
#ifndef SQLITE_OMIT_VIRTUALTABLE
    if( sqlite3FindDbName(pParse->db, zDbase)<1 ){
    if( sqlite3FindDbName(db, zDbase)<1 ){
      /* If zName is the not the name of a table in the schema created using
      ** CREATE, then check to see if it is the name of an virtual table that
      ** can be an eponymous virtual table. */
      Module *pMod = (Module*)sqlite3HashFind(&pParse->db->aModule, zName);
      Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
      if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
        pMod = sqlite3PragmaVtabRegister(pParse->db, zName);
        pMod = sqlite3PragmaVtabRegister(db, zName);
      }
      if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
        return pMod->pEpoTab;
      }
    }
#endif
    if( (flags & LOCATE_NOERR)==0 ){
103736
103737
103738
103739
103740
103741
103742

103743
103744
103745
103746
103747
103748
103749
104438
104439
104440
104441
104442
104443
104444
104445
104446
104447
104448
104449
104450
104451
104452







+







  int i;
  assert( iDb<db->nDb );

  if( iDb>=0 ){
    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
    DbSetProperty(db, iDb, DB_ResetWanted);
    DbSetProperty(db, 1, DB_ResetWanted);
    db->mDbFlags &= ~DBFLAG_SchemaKnownOk;
  }

  if( db->nSchemaLock==0 ){
    for(i=0; i<db->nDb; i++){
      if( DbHasProperty(db, i, DB_ResetWanted) ){
        sqlite3SchemaClear(db->aDb[i].pSchema);
      }
103761
103762
103763
103764
103765
103766
103767
103768

103769
103770
103771
103772
103773
103774
103775
104464
104465
104466
104467
104468
104469
104470

104471
104472
104473
104474
104475
104476
104477
104478







-
+







  assert( db->nSchemaLock==0 );
  for(i=0; i<db->nDb; i++){
    Db *pDb = &db->aDb[i];
    if( pDb->pSchema ){
      sqlite3SchemaClear(pDb->pSchema);
    }
  }
  db->mDbFlags &= ~DBFLAG_SchemaChange;
  db->mDbFlags &= ~(DBFLAG_SchemaChange|DBFLAG_SchemaKnownOk);
  sqlite3VtabUnlockList(db);
  sqlite3BtreeLeaveAll(db);
  sqlite3CollapseDatabaseArray(db);
}

/*
** This routine is called when a commit occurs.
104306
104307
104308
104309
104310
104311
104312
104313

104314
104315





104316
104317
104318
104319
104320
104321

104322
104323
104324
104325
104326
104327
104328
105009
105010
105011
105012
105013
105014
105015

105016
105017
105018
105019
105020
105021
105022
105023
105024
105025
105026
105027
105028

105029
105030
105031
105032
105033
105034
105035
105036







-
+


+
+
+
+
+





-
+







  pCol = &p->aCol[p->nCol];
  memset(pCol, 0, sizeof(p->aCol[0]));
  pCol->zName = z;
  sqlite3ColumnPropertiesFromName(p, pCol);
 
  if( pType->n==0 ){
    /* If there is no type specified, columns have the default affinity
    ** 'BLOB'. */
    ** 'BLOB' with a default size of 4 bytes. */
    pCol->affinity = SQLITE_AFF_BLOB;
    pCol->szEst = 1;
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
    if( 4>=sqlite3GlobalConfig.szSorterRef ){
      pCol->colFlags |= COLFLAG_SORTERREF;
    }
#endif
  }else{
    zType = z + sqlite3Strlen30(z) + 1;
    memcpy(zType, pType->z, pType->n);
    zType[pType->n] = 0;
    sqlite3Dequote(zType);
    pCol->affinity = sqlite3AffinityType(zType, &pCol->szEst);
    pCol->affinity = sqlite3AffinityType(zType, pCol);
    pCol->colFlags |= COLFLAG_HASTYPE;
  }
  p->nCol++;
  pParse->constraintName.n = 0;
}

/*
104374
104375
104376
104377
104378
104379
104380
104381

104382
104383
104384
104385
104386
104387
104388
105082
105083
105084
105085
105086
105087
105088

105089
105090
105091
105092
105093
105094
105095
105096







-
+







** 'REAL'        | SQLITE_AFF_REAL
** 'FLOA'        | SQLITE_AFF_REAL
** 'DOUB'        | SQLITE_AFF_REAL
**
** If none of the substrings in the above table are found,
** SQLITE_AFF_NUMERIC is returned.
*/
SQLITE_PRIVATE char sqlite3AffinityType(const char *zIn, u8 *pszEst){
SQLITE_PRIVATE char sqlite3AffinityType(const char *zIn, Column *pCol){
  u32 h = 0;
  char aff = SQLITE_AFF_NUMERIC;
  const char *zChar = 0;

  assert( zIn!=0 );
  while( zIn[0] ){
    h = (h<<8) + sqlite3UpperToLower[(*zIn)&0xff];
104411
104412
104413
104414
104415
104416
104417
104418

104419
104420
104421


104422
104423
104424
104425
104426

104427
104428
104429
104430
104431
104432
104433
104434
104435
104436

104437
104438








104439
104440
104441
104442
104443
104444
104445
105119
105120
105121
105122
105123
105124
105125

105126
105127


105128
105129
105130
105131
105132
105133

105134
105135



105136
105137
105138
105139
105140

105141
105142
105143
105144
105145
105146
105147
105148
105149
105150
105151
105152
105153
105154
105155
105156
105157
105158







-
+

-
-
+
+




-
+

-
-
-





-
+


+
+
+
+
+
+
+
+







#endif
    }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){    /* INT */
      aff = SQLITE_AFF_INTEGER;
      break;
    }
  }

  /* If pszEst is not NULL, store an estimate of the field size.  The
  /* If pCol is not NULL, store an estimate of the field size.  The
  ** estimate is scaled so that the size of an integer is 1.  */
  if( pszEst ){
    *pszEst = 1;   /* default size is approx 4 bytes */
  if( pCol ){
    int v = 0;   /* default size is approx 4 bytes */
    if( aff<SQLITE_AFF_NUMERIC ){
      if( zChar ){
        while( zChar[0] ){
          if( sqlite3Isdigit(zChar[0]) ){
            int v = 0;
            /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */
            sqlite3GetInt32(zChar, &v);
            v = v/4 + 1;
            if( v>255 ) v = 255;
            *pszEst = v; /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */
            break;
          }
          zChar++;
        }
      }else{
        *pszEst = 5;   /* BLOB, TEXT, CLOB -> r=5  (approx 20 bytes)*/
        v = 16;   /* BLOB, TEXT, CLOB -> r=5  (approx 20 bytes)*/
      }
    }
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
    if( v>=sqlite3GlobalConfig.szSorterRef ){
      pCol->colFlags |= COLFLAG_SORTERREF;
    }
#endif
    v = v/4 + 1;
    if( v>255 ) v = 255;
    pCol->szEst = v;
  }
  return aff;
}

/*
** The expression is the default value for the most recently added column
** of the table currently under construction.
106040
106041
106042
106043
106044
106045
106046

106047
106048
106049
106050
106051
106052
106053
106054
106055
106056
106057
106058
106059
106060

106061
106062

106063
106064
106065

106066
106067
106068
106069
106070
106071
106072
106753
106754
106755
106756
106757
106758
106759
106760
106761
106762
106763
106764
106765
106766
106767
106768
106769
106770
106771
106772
106773

106774

106775
106776
106777
106778
106779
106780
106781
106782
106783
106784
106785
106786
106787







+













-
+
-

+



+







                    sqlite3KeyInfoRef(pKey), P4_KEYINFO);

  /* Open the table. Loop through all rows of the table, inserting index
  ** records into the sorter. */
  sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
  addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); VdbeCoverage(v);
  regRecord = sqlite3GetTempReg(pParse);
  sqlite3MultiWrite(pParse);

  sqlite3GenerateIndexKey(pParse,pIndex,iTab,regRecord,0,&iPartIdxLabel,0,0);
  sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
  sqlite3ResolvePartIdxLabel(pParse, iPartIdxLabel);
  sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1); VdbeCoverage(v);
  sqlite3VdbeJumpHere(v, addr1);
  if( memRootPage<0 ) sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb);
  sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, 
                    (char *)pKey, P4_KEYINFO);
  sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0));

  addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0); VdbeCoverage(v);
  if( IsUniqueIndex(pIndex) ){
    int j2 = sqlite3VdbeCurrentAddr(v) + 3;
    int j2 = sqlite3VdbeGoto(v, 1);
    sqlite3VdbeGoto(v, j2);
    addr2 = sqlite3VdbeCurrentAddr(v);
    sqlite3VdbeVerifyAbortable(v, OE_Abort);
    sqlite3VdbeAddOp4Int(v, OP_SorterCompare, iSorter, j2, regRecord,
                         pIndex->nKeyCol); VdbeCoverage(v);
    sqlite3UniqueConstraint(pParse, OE_Abort, pIndex);
    sqlite3VdbeJumpHere(v, j2);
  }else{
    addr2 = sqlite3VdbeCurrentAddr(v);
  }
  sqlite3VdbeAddOp3(v, OP_SorterData, iSorter, regRecord, iIdx);
  sqlite3VdbeAddOp1(v, OP_SeekEnd, iIdx);
  sqlite3VdbeAddOp2(v, OP_IdxInsert, iIdx, regRecord);
  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
106221
106222
106223
106224
106225
106226
106227



106228


106229
106230
106231
106232
106233
106234
106235
106936
106937
106938
106939
106940
106941
106942
106943
106944
106945

106946
106947
106948
106949
106950
106951
106952
106953
106954







+
+
+
-
+
+







  assert( pTab!=0 );
  assert( pParse->nErr==0 );
  if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 
       && db->init.busy==0
#if SQLITE_USER_AUTHENTICATION
       && sqlite3UserAuthTable(pTab->zName)==0
#endif
#ifdef SQLITE_ALLOW_SQLITE_MASTER_INDEX
       && sqlite3StrICmp(&pTab->zName[7],"master")!=0
#endif
       && sqlite3StrNICmp(&pTab->zName[7],"altertab_",9)!=0 ){
       && sqlite3StrNICmp(&pTab->zName[7],"altertab_",9)!=0
 ){
    sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
    goto exit_create_index;
  }
#ifndef SQLITE_OMIT_VIEW
  if( pTab->pSelect ){
    sqlite3ErrorMsg(pParse, "views may not be indexed");
    goto exit_create_index;
107400
107401
107402
107403
107404
107405
107406
107407

107408
107409
107410
107411
107412
107413
107414
107415
107416




107417
107418
107419
107420
107421
107422
107423
108119
108120
108121
108122
108123
108124
108125

108126
108127
108128
108129
108130
108131




108132
108133
108134
108135
108136
108137
108138
108139
108140
108141
108142







-
+





-
-
-
-
+
+
+
+







  char *zErr;
  int j;
  StrAccum errMsg;
  Table *pTab = pIdx->pTable;

  sqlite3StrAccumInit(&errMsg, pParse->db, 0, 0, 200);
  if( pIdx->aColExpr ){
    sqlite3XPrintf(&errMsg, "index '%q'", pIdx->zName);
    sqlite3_str_appendf(&errMsg, "index '%q'", pIdx->zName);
  }else{
    for(j=0; j<pIdx->nKeyCol; j++){
      char *zCol;
      assert( pIdx->aiColumn[j]>=0 );
      zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
      if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2);
      sqlite3StrAccumAppendAll(&errMsg, pTab->zName);
      sqlite3StrAccumAppend(&errMsg, ".", 1);
      sqlite3StrAccumAppendAll(&errMsg, zCol);
      if( j ) sqlite3_str_append(&errMsg, ", ", 2);
      sqlite3_str_appendall(&errMsg, pTab->zName);
      sqlite3_str_append(&errMsg, ".", 1);
      sqlite3_str_appendall(&errMsg, zCol);
    }
  }
  zErr = sqlite3StrAccumFinish(&errMsg);
  sqlite3HaltConstraint(pParse, 
    IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY 
                            : SQLITE_CONSTRAINT_UNIQUE,
    onError, zErr, P4_DYNAMIC, P5_ConstraintUnique);
108095
108096
108097
108098
108099
108100
108101

108102
108103
108104
108105

108106
108107
108108
108109
108110
108111
108112
108814
108815
108816
108817
108818
108819
108820
108821
108822
108823
108824
108825
108826
108827
108828
108829
108830
108831
108832
108833







+




+







  /* If the createFlag parameter is true and the search did not reveal an
  ** exact match for the name, number of arguments and encoding, then add a
  ** new entry to the hash table and return it.
  */
  if( createFlag && bestScore<FUNC_PERFECT_MATCH && 
      (pBest = sqlite3DbMallocZero(db, sizeof(*pBest)+nName+1))!=0 ){
    FuncDef *pOther;
    u8 *z;
    pBest->zName = (const char*)&pBest[1];
    pBest->nArg = (u16)nArg;
    pBest->funcFlags = enc;
    memcpy((char*)&pBest[1], zName, nName+1);
    for(z=(u8*)pBest->zName; *z; z++) *z = sqlite3UpperToLower[*z];
    pOther = (FuncDef*)sqlite3HashInsert(&db->aFunc, pBest->zName, pBest);
    if( pOther==pBest ){
      sqlite3DbFree(db, pBest);
      sqlite3OomFault(db);
      return 0;
    }else{
      pBest->pNext = pOther;
108416
108417
108418
108419
108420
108421
108422
108423

108424
108425
108426
108427
108428
108429
108430
109137
109138
109139
109140
109141
109142
109143

109144
109145
109146
109147
109148
109149
109150
109151







-
+







  int iDataCur = 0;      /* VDBE cursor for the canonical data source */
  int iIdxCur = 0;       /* Cursor number of the first index */
  int nIdx;              /* Number of indices */
  sqlite3 *db;           /* Main database structure */
  AuthContext sContext;  /* Authorization context */
  NameContext sNC;       /* Name context to resolve expressions in */
  int iDb;               /* Database number */
  int memCnt = -1;       /* Memory cell used for change counting */
  int memCnt = 0;        /* Memory cell used for change counting */
  int rcauth;            /* Value returned by authorization callback */
  int eOnePass;          /* ONEPASS_OFF or _SINGLE or _MULTI */
  int aiCurOnePass[2];   /* The write cursors opened by WHERE_ONEPASS */
  u8 *aToOpen = 0;       /* Open cursor iTabCur+j if aToOpen[j] is true */
  Index *pPk;            /* The PRIMARY KEY index on the table */
  int iPk = 0;           /* First of nPk registers holding PRIMARY KEY value */
  i16 nPk = 1;           /* Number of columns in the PRIMARY KEY */
108521
108522
108523
108524
108525
108526
108527
108528

108529
108530
108531
108532
108533
108534
108535
109242
109243
109244
109245
109246
109247
109248

109249
109250
109251
109252
109253
109254
109255
109256







-
+







  /* Begin generating code.
  */
  v = sqlite3GetVdbe(pParse);
  if( v==0 ){
    goto delete_from_cleanup;
  }
  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
  sqlite3BeginWriteOperation(pParse, 1, iDb);
  sqlite3BeginWriteOperation(pParse, bComplex, iDb);

  /* If we are trying to delete from a view, realize that view into
  ** an ephemeral table.
  */
#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
  if( isView ){
    sqlite3MaterializeView(pParse, pTab, 
108549
108550
108551
108552
108553
108554
108555
108556




108557
108558
108559
108560
108561
108562
108563
109270
109271
109272
109273
109274
109275
109276

109277
109278
109279
109280
109281
109282
109283
109284
109285
109286
109287







-
+
+
+
+







  if( sqlite3ResolveExprNames(&sNC, pWhere) ){
    goto delete_from_cleanup;
  }

  /* Initialize the counter of the number of rows deleted, if
  ** we are counting rows.
  */
  if( db->flags & SQLITE_CountRows ){
  if( (db->flags & SQLITE_CountRows)!=0
   && !pParse->nested
   && !pParse->pTriggerTab
  ){
    memCnt = ++pParse->nMem;
    sqlite3VdbeAddOp2(v, OP_Integer, 0, memCnt);
  }

#ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
  /* Special case: A DELETE without a WHERE clause deletes everything.
  ** It is easier just to erase the whole table. Prior to version 3.6.5,
108577
108578
108579
108580
108581
108582
108583
108584

108585
108586
108587
108588
108589
108590
108591
109301
109302
109303
109304
109305
109306
109307

109308
109309
109310
109311
109312
109313
109314
109315







-
+







#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
   && db->xPreUpdateCallback==0
#endif
  ){
    assert( !isView );
    sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);
    if( HasRowid(pTab) ){
      sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt,
      sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt ? memCnt : -1,
                        pTab->zName, P4_STATIC);
    }
    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
      assert( pIdx->pSchema==pTab->pSchema );
      sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);
    }
  }else
108622
108623
108624
108625
108626
108627
108628

108629
108630
108631

108632
108633
108634
108635
108636
108637
108638
109346
109347
109348
109349
109350
109351
109352
109353
109354
109355

109356
109357
109358
109359
109360
109361
109362
109363







+


-
+







    **  ONEPASS_MULTI:  One-pass approach - any number of rows may be deleted.
    */
    pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, wcf, iTabCur+1);
    if( pWInfo==0 ) goto delete_from_cleanup;
    eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);
    assert( IsVirtual(pTab)==0 || eOnePass!=ONEPASS_MULTI );
    assert( IsVirtual(pTab) || bComplex || eOnePass!=ONEPASS_OFF );
    if( eOnePass!=ONEPASS_SINGLE ) sqlite3MultiWrite(pParse);
  
    /* Keep track of the number of rows to be deleted */
    if( db->flags & SQLITE_CountRows ){
    if( memCnt ){
      sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
    }
  
    /* Extract the rowid or primary key for the current row */
    if( pPk ){
      for(i=0; i<nPk; i++){
        assert( pPk->aiColumn[i]>=0 );
108727
108728
108729
108730
108731
108732
108733
108734
108735
108736
108737
108738
108739
108740








108741
108742
108743
108744
108745
108746
108747
109452
109453
109454
109455
109456
109457
109458


109459
109460



109461
109462
109463
109464
109465
109466
109467
109468
109469
109470
109471
109472
109473
109474
109475







-
-


-
-
-
+
+
+
+
+
+
+
+







    }  
  
    /* Delete the row */
#ifndef SQLITE_OMIT_VIRTUALTABLE
    if( IsVirtual(pTab) ){
      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);
      sqlite3VtabMakeWritable(pParse, pTab);
      sqlite3VdbeAddOp4(v, OP_VUpdate, 0, 1, iKey, pVTab, P4_VTAB);
      sqlite3VdbeChangeP5(v, OE_Abort);
      assert( eOnePass==ONEPASS_OFF || eOnePass==ONEPASS_SINGLE );
      sqlite3MayAbort(pParse);
      if( eOnePass==ONEPASS_SINGLE && sqlite3IsToplevel(pParse) ){
        pParse->isMultiWrite = 0;
      }
      if( eOnePass==ONEPASS_SINGLE ){
        sqlite3VdbeAddOp1(v, OP_Close, iTabCur);
        if( sqlite3IsToplevel(pParse) ){
          pParse->isMultiWrite = 0;
        }
      }
      sqlite3VdbeAddOp4(v, OP_VUpdate, 0, 1, iKey, pVTab, P4_VTAB);
      sqlite3VdbeChangeP5(v, OE_Abort);
    }else
#endif
    {
      int count = (pParse->nested==0);    /* True to count changes */
      sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
          iKey, nKey, count, OE_Default, eOnePass, aiCurOnePass[1]);
    }
108767
108768
108769
108770
108771
108772
108773
108774

108775
108776
108777
108778
108779
108780
108781
109495
109496
109497
109498
109499
109500
109501

109502
109503
109504
109505
109506
109507
109508
109509







-
+







    sqlite3AutoincrementEnd(pParse);
  }

  /* Return the number of rows that were deleted. If this routine is 
  ** generating code because of a call to sqlite3NestedParse(), do not
  ** invoke the callback function.
  */
  if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){
  if( memCnt ){
    sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1);
    sqlite3VdbeSetNumCols(v, 1);
    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC);
  }

delete_from_cleanup:
  sqlite3AuthContextPop(&sContext);
109375
109376
109377
109378
109379
109380
109381
109382

109383
109384
109385
109386
109387
109388
109389
110103
110104
110105
110106
110107
110108
110109

110110
110111
110112
110113
110114
110115
110116
110117







-
+








  if( argc>=1 && (zFormat = (const char*)sqlite3_value_text(argv[0]))!=0 ){
    x.nArg = argc-1;
    x.nUsed = 0;
    x.apArg = argv+1;
    sqlite3StrAccumInit(&str, db, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]);
    str.printfFlags = SQLITE_PRINTF_SQLFUNC;
    sqlite3XPrintf(&str, zFormat, &x);
    sqlite3_str_appendf(&str, zFormat, &x);
    n = str.nChar;
    sqlite3_result_text(context, sqlite3StrAccumFinish(&str), n,
                        SQLITE_DYNAMIC);
  }
}

/*
110778
110779
110780
110781
110782
110783
110784
110785

110786
110787
110788
110789

110790
110791
110792
110793
110794
110795
110796

110797
110798

110799
110800
110801
110802
110803
110804
110805
111506
111507
111508
111509
111510
111511
111512

111513
111514
111515
111516

111517
111518
111519
111520
111521
111522
111523

111524
111525

111526
111527
111528
111529
111530
111531
111532
111533







-
+



-
+






-
+

-
+







      if( argc==2 ){
        zSep = (char*)sqlite3_value_text(argv[1]);
        nSep = sqlite3_value_bytes(argv[1]);
      }else{
        zSep = ",";
        nSep = 1;
      }
      if( zSep ) sqlite3StrAccumAppend(pAccum, zSep, nSep);
      if( zSep ) sqlite3_str_append(pAccum, zSep, nSep);
    }
    zVal = (char*)sqlite3_value_text(argv[0]);
    nVal = sqlite3_value_bytes(argv[0]);
    if( zVal ) sqlite3StrAccumAppend(pAccum, zVal, nVal);
    if( zVal ) sqlite3_str_append(pAccum, zVal, nVal);
  }
}
static void groupConcatFinalize(sqlite3_context *context){
  StrAccum *pAccum;
  pAccum = sqlite3_aggregate_context(context, 0);
  if( pAccum ){
    if( pAccum->accError==STRACCUM_TOOBIG ){
    if( pAccum->accError==SQLITE_TOOBIG ){
      sqlite3_result_error_toobig(context);
    }else if( pAccum->accError==STRACCUM_NOMEM ){
    }else if( pAccum->accError==SQLITE_NOMEM ){
      sqlite3_result_error_nomem(context);
    }else{    
      sqlite3_result_text(context, sqlite3StrAccumFinish(pAccum), -1, 
                          sqlite3_free);
    }
  }
}
111368
111369
111370
111371
111372
111373
111374






111375
111376
111377
111378
111379
111380
111381
112096
112097
112098
112099
112100
112101
112102
112103
112104
112105
112106
112107
112108
112109
112110
112111
112112
112113
112114
112115







+
+
+
+
+
+







  int isIgnore          /* If true, pretend pTab contains all NULL values */
){
  int i;                                    /* Iterator variable */
  Vdbe *v = sqlite3GetVdbe(pParse);         /* Vdbe to add code to */
  int iCur = pParse->nTab - 1;              /* Cursor number to use */
  int iOk = sqlite3VdbeMakeLabel(v);        /* jump here if parent key found */

  sqlite3VdbeVerifyAbortable(v,
    (!pFKey->isDeferred
      && !(pParse->db->flags & SQLITE_DeferFKs)
      && !pParse->pToplevel 
      && !pParse->isMultiWrite) ? OE_Abort : OE_Ignore);

  /* If nIncr is less than zero, then check at runtime if there are any
  ** outstanding constraints to resolve. If there are not, there is no need
  ** to check if deleting this row resolves any outstanding violations.
  **
  ** Check if any of the key columns in the child table row are NULL. If 
  ** any are, then the constraint is considered satisfied. No need to 
  ** search for a matching row in the parent table.  */
111775
111776
111777
111778
111779
111780
111781

111782
111783
111784
111785
111786
111787
111788
112509
112510
112511
112512
112513
112514
112515
112516
112517
112518
112519
112520
112521
112522
112523







+







    ** transactions are not able to rollback schema changes.  
    **
    ** If the SQLITE_DeferFKs flag is set, then this is not required, as
    ** the statement transaction will not be rolled back even if FK
    ** constraints are violated.
    */
    if( (db->flags & SQLITE_DeferFKs)==0 ){
      sqlite3VdbeVerifyAbortable(v, OE_Abort);
      sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
      VdbeCoverage(v);
      sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,
          OE_Abort, 0, P4_STATIC, P5_ConstraintFK);
    }

    if( iSkip ){
112687
112688
112689
112690
112691
112692
112693

112694
112695
112696
112697
112698














112699
112700
112701
112702
112703
112704
112705
113422
113423
113424
113425
113426
113427
113428
113429
113430
113431
113432
113433
113434
113435
113436
113437
113438
113439
113440
113441
113442
113443
113444
113445
113446
113447
113448
113449
113450
113451
113452
113453
113454
113455







+





+
+
+
+
+
+
+
+
+
+
+
+
+
+







*/
static int autoIncBegin(
  Parse *pParse,      /* Parsing context */
  int iDb,            /* Index of the database holding pTab */
  Table *pTab         /* The table we are writing to */
){
  int memId = 0;      /* Register holding maximum rowid */
  assert( pParse->db->aDb[iDb].pSchema!=0 );
  if( (pTab->tabFlags & TF_Autoincrement)!=0
   && (pParse->db->mDbFlags & DBFLAG_Vacuum)==0
  ){
    Parse *pToplevel = sqlite3ParseToplevel(pParse);
    AutoincInfo *pInfo;
    Table *pSeqTab = pParse->db->aDb[iDb].pSchema->pSeqTab;

    /* Verify that the sqlite_sequence table exists and is an ordinary
    ** rowid table with exactly two columns.
    ** Ticket d8dc2b3a58cd5dc2918a1d4acb 2018-05-23 */
    if( pSeqTab==0
     || !HasRowid(pSeqTab)
     || IsVirtual(pSeqTab)
     || pSeqTab->nCol!=2
    ){
      pParse->nErr++;
      pParse->rc = SQLITE_CORRUPT_SEQUENCE;
      return 0;
    }

    pInfo = pToplevel->pAinc;
    while( pInfo && pInfo->pTab!=pTab ){ pInfo = pInfo->pNext; }
    if( pInfo==0 ){
      pInfo = sqlite3DbMallocRawNN(pParse->db, sizeof(*pInfo));
      if( pInfo==0 ) return 0;
      pInfo->pNext = pToplevel->pAinc;
112949
112950
112951
112952
112953
112954
112955
112956


112957
112958
112959
112960
112961
112962
112963
113699
113700
113701
113702
113703
113704
113705

113706
113707
113708
113709
113710
113711
113712
113713
113714







-
+
+







**      D: cleanup
*/
SQLITE_PRIVATE void sqlite3Insert(
  Parse *pParse,        /* Parser context */
  SrcList *pTabList,    /* Name of table into which we are inserting */
  Select *pSelect,      /* A SELECT statement to use as the data source */
  IdList *pColumn,      /* Column names corresponding to IDLIST. */
  int onError           /* How to handle constraint errors */
  int onError,          /* How to handle constraint errors */
  Upsert *pUpsert       /* ON CONFLICT clauses for upsert, or NULL */
){
  sqlite3 *db;          /* The main database structure */
  Table *pTab;          /* The table to insert into.  aka TABLE */
  int i, j;             /* Loop counters */
  Vdbe *v;              /* Generate code into this virtual machine */
  Index *pIdx;          /* For looping over indices of the table */
  int nColumn;          /* Number of columns in the data */
113244
113245
113246
113247
113248
113249
113250
113251




113252
113253
113254
113255
113256
113257
113258
113259
113260
113261
113262
113263
113264
113265
113266
113267
113268
113269
113270













113271
113272
113273
113274
113275
113276
113277
113995
113996
113997
113998
113999
114000
114001

114002
114003
114004
114005
114006
114007
114008
114009
114010
114011
114012
114013
114014
114015
114016
114017
114018
114019
114020
114021
114022
114023
114024
114025
114026
114027
114028
114029
114030
114031
114032
114033
114034
114035
114036
114037
114038
114039
114040
114041
114042
114043
114044







-
+
+
+
+



















+
+
+
+
+
+
+
+
+
+
+
+
+







  if( pColumn!=0 && nColumn!=pColumn->nId ){
    sqlite3ErrorMsg(pParse, "%d values for %d columns", nColumn, pColumn->nId);
    goto insert_cleanup;
  }
    
  /* Initialize the count of rows to be inserted
  */
  if( db->flags & SQLITE_CountRows ){
  if( (db->flags & SQLITE_CountRows)!=0
   && !pParse->nested
   && !pParse->pTriggerTab
  ){
    regRowCount = ++pParse->nMem;
    sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount);
  }

  /* If this is not a view, open the table and and all indices */
  if( !isView ){
    int nIdx;
    nIdx = sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, -1, 0,
                                      &iDataCur, &iIdxCur);
    aRegIdx = sqlite3DbMallocRawNN(db, sizeof(int)*(nIdx+1));
    if( aRegIdx==0 ){
      goto insert_cleanup;
    }
    for(i=0, pIdx=pTab->pIndex; i<nIdx; pIdx=pIdx->pNext, i++){
      assert( pIdx );
      aRegIdx[i] = ++pParse->nMem;
      pParse->nMem += pIdx->nColumn;
    }
  }
#ifndef SQLITE_OMIT_UPSERT
  if( pUpsert ){
    pTabList->a[0].iCursor = iDataCur;
    pUpsert->pUpsertSrc = pTabList;
    pUpsert->regData = regData;
    pUpsert->iDataCur = iDataCur;
    pUpsert->iIdxCur = iIdxCur;
    if( pUpsert->pUpsertTarget ){
      sqlite3UpsertAnalyzeTarget(pParse, pTabList, pUpsert);
    }
  }
#endif


  /* This is the top of the main insertion loop */
  if( useTempTable ){
    /* This block codes the top of loop only.  The complete loop is the
    ** following pseudocode (template 4):
    **
    **         rewind temp table, if empty goto D
113466
113467
113468
113469
113470
113471
113472
113473

113474
113475
113476
113477
113478
113479
113480
114233
114234
114235
114236
114237
114238
114239

114240
114241
114242
114243
114244
114245
114246
114247







-
+







      sqlite3MayAbort(pParse);
    }else
#endif
    {
      int isReplace;    /* Set to true if constraints may cause a replace */
      int bUseSeek;     /* True to use OPFLAG_SEEKRESULT */
      sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
          regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0
          regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0, pUpsert
      );
      sqlite3FkCheck(pParse, pTab, 0, regIns, 0, 0);

      /* Set the OPFLAG_USESEEKRESULT flag if either (a) there are no REPLACE
      ** constraints or (b) there are no triggers and this table is not a
      ** parent table in a foreign key constraint. It is safe to set the
      ** flag in the second case as if any REPLACE constraint is hit, an
113489
113490
113491
113492
113493
113494
113495
113496

113497
113498
113499
113500
113501
113502
113503
114256
114257
114258
114259
114260
114261
114262

114263
114264
114265
114266
114267
114268
114269
114270







-
+







          regIns, aRegIdx, 0, appendFlag, bUseSeek
      );
    }
  }

  /* Update the count of rows that are inserted
  */
  if( (db->flags & SQLITE_CountRows)!=0 ){
  if( regRowCount ){
    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);
  }

  if( pTrigger ){
    /* Code AFTER triggers */
    sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_AFTER, 
        pTab, regData-2-pTab->nCol, onError, endOfLoop);
113526
113527
113528
113529
113530
113531
113532
113533

113534
113535
113536
113537
113538
113539
113540
113541

113542
113543
113544
113545
113546
113547
113548
114293
114294
114295
114296
114297
114298
114299

114300
114301
114302
114303
114304
114305
114306
114307
114308
114309
114310
114311
114312
114313
114314
114315
114316







-
+








+







  }

  /*
  ** Return the number of rows inserted. If this routine is 
  ** generating code because of a call to sqlite3NestedParse(), do not
  ** invoke the callback function.
  */
  if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){
  if( regRowCount ){
    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);
    sqlite3VdbeSetNumCols(v, 1);
    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC);
  }

insert_cleanup:
  sqlite3SrcListDelete(db, pTabList);
  sqlite3ExprListDelete(db, pList);
  sqlite3UpsertDelete(db, pUpsert);
  sqlite3SelectDelete(db, pSelect);
  sqlite3IdListDelete(db, pColumn);
  sqlite3DbFree(db, aRegIdx);
}

/* Make sure "isView" and other macros defined above are undefined. Otherwise
** they may interfere with compilation of other functions in this file
113605
113606
113607
113608
113609
113610
113611






































113612
113613
113614
113615
113616
113617
113618
114373
114374
114375
114376
114377
114378
114379
114380
114381
114382
114383
114384
114385
114386
114387
114388
114389
114390
114391
114392
114393
114394
114395
114396
114397
114398
114399
114400
114401
114402
114403
114404
114405
114406
114407
114408
114409
114410
114411
114412
114413
114414
114415
114416
114417
114418
114419
114420
114421
114422
114423
114424







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  }
  testcase( w.eCode==0 );
  testcase( w.eCode==CKCNSTRNT_COLUMN );
  testcase( w.eCode==CKCNSTRNT_ROWID );
  testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) );
  return !w.eCode;
}

/*
** An instance of the ConstraintAddr object remembers the byte-code addresses
** for sections of the constraint checks that deal with uniqueness constraints
** on the rowid and on the upsert constraint.
**
** This information is passed into checkReorderConstraintChecks() to insert
** some OP_Goto operations so that the rowid and upsert constraints occur
** in the correct order relative to other constraints.
*/
typedef struct ConstraintAddr ConstraintAddr;
struct ConstraintAddr {
  int ipkTop;          /* Subroutine for rowid constraint check */
  int upsertTop;       /* Label for upsert constraint check subroutine */
  int upsertTop2;      /* Copy of upsertTop not cleared by the call */
  int upsertBtm;       /* upsert constraint returns to this label */
  int ipkBtm;          /* Return opcode rowid constraint check */
};

/*
** Generate any OP_Goto operations needed to cause constraints to be
** run that haven't already been run.
*/
static void reorderConstraintChecks(Vdbe *v, ConstraintAddr *p){
  if( p->upsertTop ){
    testcase( sqlite3VdbeLabelHasBeenResolved(v, p->upsertTop) );
    sqlite3VdbeGoto(v, p->upsertTop);
    VdbeComment((v, "call upsert subroutine"));
    sqlite3VdbeResolveLabel(v, p->upsertBtm);
    p->upsertTop = 0;
  }
  if( p->ipkTop ){
    sqlite3VdbeGoto(v, p->ipkTop);
    VdbeComment((v, "call rowid unique-check subroutine"));
    sqlite3VdbeJumpHere(v, p->ipkBtm);
    p->ipkTop = 0;
  }
}

/*
** Generate code to do constraint checks prior to an INSERT or an UPDATE
** on table pTab.
**
** The regNewData parameter is the first register in a range that contains
** the data to be inserted or the data after the update.  There will be
113701
113702
113703
113704
113705
113706
113707
113708


113709
113710
113711
113712
113713
113714
113715
113716
113717
113718
113719
113720
113721
113722


113723
113724

113725
113726
113727
113728
113729
113730
113731

113732
113733
113734
113735
113736
113737
113738
114507
114508
114509
114510
114511
114512
114513

114514
114515
114516
114517
114518
114519
114520
114521
114522
114523
114524
114525
114526
114527


114528
114529
114530
114531
114532
114533
114534
114535
114536
114537
114538
114539
114540
114541
114542
114543
114544
114545
114546
114547







-
+
+












-
-
+
+


+







+







  int iIdxCur,         /* First index cursor */
  int regNewData,      /* First register in a range holding values to insert */
  int regOldData,      /* Previous content.  0 for INSERTs */
  u8 pkChng,           /* Non-zero if the rowid or PRIMARY KEY changed */
  u8 overrideError,    /* Override onError to this if not OE_Default */
  int ignoreDest,      /* Jump to this label on an OE_Ignore resolution */
  int *pbMayReplace,   /* OUT: Set to true if constraint may cause a replace */
  int *aiChng          /* column i is unchanged if aiChng[i]<0 */
  int *aiChng,         /* column i is unchanged if aiChng[i]<0 */
  Upsert *pUpsert      /* ON CONFLICT clauses, if any.  NULL otherwise */
){
  Vdbe *v;             /* VDBE under constrution */
  Index *pIdx;         /* Pointer to one of the indices */
  Index *pPk = 0;      /* The PRIMARY KEY index */
  sqlite3 *db;         /* Database connection */
  int i;               /* loop counter */
  int ix;              /* Index loop counter */
  int nCol;            /* Number of columns */
  int onError;         /* Conflict resolution strategy */
  int addr1;           /* Address of jump instruction */
  int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */
  int nPkField;        /* Number of fields in PRIMARY KEY. 1 for ROWID tables */
  int ipkTop = 0;      /* Top of the rowid change constraint check */
  int ipkBottom = 0;   /* Bottom of the rowid change constraint check */
  ConstraintAddr sAddr;/* Address information for constraint reordering */
  Index *pUpIdx = 0;   /* Index to which to apply the upsert */
  u8 isUpdate;         /* True if this is an UPDATE operation */
  u8 bAffinityDone = 0;  /* True if the OP_Affinity operation has been run */
  int upsertBypass = 0;  /* Address of Goto to bypass upsert subroutine */

  isUpdate = regOldData!=0;
  db = pParse->db;
  v = sqlite3GetVdbe(pParse);
  assert( v!=0 );
  assert( pTab->pSelect==0 );  /* This table is not a VIEW */
  nCol = pTab->nCol;
  memset(&sAddr, 0, sizeof(sAddr));
  
  /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for
  ** normal rowid tables.  nPkField is the number of key fields in the 
  ** pPk index or 1 for a rowid table.  In other words, nPkField is the
  ** number of fields in the true primary key of the table. */
  if( HasRowid(pTab) ){
    pPk = 0;
113807
113808
113809
113810
113811
113812
113813

113814
113815
113816
113817
113818
113819
113820
113821
113822
113823
113824
113825
113826
113827
113828
113829








































113830
113831
113832
113833
113834
113835
113836
113837
113838
113839
113840
113841
113842
113843


























113844
113845
113846
113847
113848
113849
113850
113851
113852
113853
113854
113855
113856
113857
113858
113859
113860
113861
113862
113863
113864
113865
113866
113867
113868
113869


113870
113871
113872
113873
113874
113875
113876
113877
113878
113879
113880
113881



113882
113883
113884
113885
113886
113887
113888
114616
114617
114618
114619
114620
114621
114622
114623
114624
114625
114626
114627
114628
114629
114630
114631
114632
114633
114634
114635
114636
114637
114638
114639
114640
114641
114642
114643
114644
114645
114646
114647
114648
114649
114650
114651
114652
114653
114654
114655
114656
114657
114658
114659
114660
114661
114662
114663
114664
114665
114666
114667
114668
114669
114670
114671
114672
114673
114674
114675
114676
114677
114678
114679
114680
114681
114682
114683
114684
114685
114686
114687
114688
114689
114690
114691
114692
114693
114694
114695
114696
114697
114698
114699
114700
114701
114702
114703
114704
114705
114706
114707
114708
114709
114710
114711
114712
114713
114714
114715
114716
114717
114718
114719
114720
114721
114722
114723
114724
114725
114726
114727
114728
114729














114730
114731
114732
114733
114734
114735
114736

114737
114738
114739
114740
114741
114742
114743
114744
114745
114746
114747
114748
114749
114750
114751
114752
114753
114754







+
















+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+














+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+










-
-
-
-
-
-
-
-
-
-
-
-
-
-


+
+



-








+
+
+







    pParse->iSelfTab = -(regNewData+1);
    onError = overrideError!=OE_Default ? overrideError : OE_Abort;
    for(i=0; i<pCheck->nExpr; i++){
      int allOk;
      Expr *pExpr = pCheck->a[i].pExpr;
      if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue;
      allOk = sqlite3VdbeMakeLabel(v);
      sqlite3VdbeVerifyAbortable(v, onError);
      sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);
      if( onError==OE_Ignore ){
        sqlite3VdbeGoto(v, ignoreDest);
      }else{
        char *zName = pCheck->a[i].zName;
        if( zName==0 ) zName = pTab->zName;
        if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
        sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_CHECK,
                              onError, zName, P4_TRANSIENT,
                              P5_ConstraintCheck);
      }
      sqlite3VdbeResolveLabel(v, allOk);
    }
    pParse->iSelfTab = 0;
  }
#endif /* !defined(SQLITE_OMIT_CHECK) */

  /* UNIQUE and PRIMARY KEY constraints should be handled in the following
  ** order:
  **
  **   (1)  OE_Abort, OE_Fail, OE_Rollback, OE_Ignore
  **   (2)  OE_Update
  **   (3)  OE_Replace
  **
  ** OE_Fail and OE_Ignore must happen before any changes are made.
  ** OE_Update guarantees that only a single row will change, so it
  ** must happen before OE_Replace.  Technically, OE_Abort and OE_Rollback
  ** could happen in any order, but they are grouped up front for
  ** convenience.
  **
  ** Constraint checking code is generated in this order:
  **   (A)  The rowid constraint
  **   (B)  Unique index constraints that do not have OE_Replace as their
  **        default conflict resolution strategy
  **   (C)  Unique index that do use OE_Replace by default.
  **
  ** The ordering of (2) and (3) is accomplished by making sure the linked
  ** list of indexes attached to a table puts all OE_Replace indexes last
  ** in the list.  See sqlite3CreateIndex() for where that happens.
  */

  if( pUpsert ){
    if( pUpsert->pUpsertTarget==0 ){
      /* An ON CONFLICT DO NOTHING clause, without a constraint-target.
      ** Make all unique constraint resolution be OE_Ignore */
      assert( pUpsert->pUpsertSet==0 );
      overrideError = OE_Ignore;
      pUpsert = 0;
    }else if( (pUpIdx = pUpsert->pUpsertIdx)!=0 ){
      /* If the constraint-target is on some column other than
      ** then ROWID, then we might need to move the UPSERT around
      ** so that it occurs in the correct order. */
      sAddr.upsertTop = sAddr.upsertTop2 = sqlite3VdbeMakeLabel(v);
      sAddr.upsertBtm = sqlite3VdbeMakeLabel(v);
    }
  }

  /* If rowid is changing, make sure the new rowid does not previously
  ** exist in the table.
  */
  if( pkChng && pPk==0 ){
    int addrRowidOk = sqlite3VdbeMakeLabel(v);

    /* Figure out what action to take in case of a rowid collision */
    onError = pTab->keyConf;
    if( overrideError!=OE_Default ){
      onError = overrideError;
    }else if( onError==OE_Default ){
      onError = OE_Abort;
    }

    /* figure out whether or not upsert applies in this case */
    if( pUpsert && pUpsert->pUpsertIdx==0 ){
      if( pUpsert->pUpsertSet==0 ){
        onError = OE_Ignore;  /* DO NOTHING is the same as INSERT OR IGNORE */
      }else{
        onError = OE_Update;  /* DO UPDATE */
      }
    }

    /* If the response to a rowid conflict is REPLACE but the response
    ** to some other UNIQUE constraint is FAIL or IGNORE, then we need
    ** to defer the running of the rowid conflict checking until after
    ** the UNIQUE constraints have run.
    */
    assert( OE_Update>OE_Replace );
    assert( OE_Ignore<OE_Replace );
    assert( OE_Fail<OE_Replace );
    assert( OE_Abort<OE_Replace );
    assert( OE_Rollback<OE_Replace );
    if( onError>=OE_Replace
     && (pUpsert || onError!=overrideError)
     && pTab->pIndex
    ){
      sAddr.ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1;
    }

    if( isUpdate ){
      /* pkChng!=0 does not mean that the rowid has changed, only that
      ** it might have changed.  Skip the conflict logic below if the rowid
      ** is unchanged. */
      sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRowidOk, regOldData);
      sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
      VdbeCoverage(v);
    }

    /* If the response to a rowid conflict is REPLACE but the response
    ** to some other UNIQUE constraint is FAIL or IGNORE, then we need
    ** to defer the running of the rowid conflict checking until after
    ** the UNIQUE constraints have run.
    */
    if( onError==OE_Replace && overrideError!=OE_Replace ){
      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
        if( pIdx->onError==OE_Ignore || pIdx->onError==OE_Fail ){
          ipkTop = sqlite3VdbeAddOp0(v, OP_Goto);
          break;
        }
      }
    }

    /* Check to see if the new rowid already exists in the table.  Skip
    ** the following conflict logic if it does not. */
    VdbeNoopComment((v, "uniqueness check for ROWID"));
    sqlite3VdbeVerifyAbortable(v, onError);
    sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRowidOk, regNewData);
    VdbeCoverage(v);

    /* Generate code that deals with a rowid collision */
    switch( onError ){
      default: {
        onError = OE_Abort;
        /* Fall thru into the next case */
      }
      case OE_Rollback:
      case OE_Abort:
      case OE_Fail: {
        testcase( onError==OE_Rollback );
        testcase( onError==OE_Abort );
        testcase( onError==OE_Fail );
        sqlite3RowidConstraint(pParse, onError, pTab);
        break;
      }
      case OE_Replace: {
        /* If there are DELETE triggers on this table and the
        ** recursive-triggers flag is set, call GenerateRowDelete() to
        ** remove the conflicting row from the table. This will fire
113911
113912
113913
113914
113915
113916
113917
113918
113919
113920
113921
113922
113923
113924







113925
113926
113927
113928
113929
113930
113931
113932
113933
113934






113935
113936

113937
113938
113939
113940
113941
113942
113943
113944



113945
113946
113947
113948
113949
113950
113951
113952
113953
113954
113955
113956
113957
113958
113959
113960
113961









113962
113963
113964
113965
113966
113967

113968
113969
113970
113971
113972
113973
113974
114777
114778
114779
114780
114781
114782
114783







114784
114785
114786
114787
114788
114789
114790

114791
114792
114793
114794
114795
114796
114797
114798
114799
114800
114801
114802
114803
114804
114805
114806

114807
114808
114809
114810
114811
114812



114813
114814
114815
114816
114817
114818
114819
114820
114821
114822
114823
114824
114825
114826
114827
114828
114829
114830
114831
114832
114833
114834
114835
114836
114837
114838
114839
114840
114841
114842
114843
114844
114845
114846

114847
114848
114849
114850
114851
114852
114853
114854







-
-
-
-
-
-
-
+
+
+
+
+
+
+
-









+
+
+
+
+
+

-
+





-
-
-
+
+
+

















+
+
+
+
+
+
+
+
+





-
+







        }
        if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
          sqlite3MultiWrite(pParse);
          sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
                                   regNewData, 1, 0, OE_Replace, 1, -1);
        }else{
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
          if( HasRowid(pTab) ){
            /* This OP_Delete opcode fires the pre-update-hook only. It does
            ** not modify the b-tree. It is more efficient to let the coming
            ** OP_Insert replace the existing entry than it is to delete the
            ** existing entry and then insert a new one. */
            sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, OPFLAG_ISNOOP);
            sqlite3VdbeAppendP4(v, pTab, P4_TABLE);
          assert( HasRowid(pTab) );
          /* This OP_Delete opcode fires the pre-update-hook only. It does
          ** not modify the b-tree. It is more efficient to let the coming
          ** OP_Insert replace the existing entry than it is to delete the
          ** existing entry and then insert a new one. */
          sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, OPFLAG_ISNOOP);
          sqlite3VdbeAppendP4(v, pTab, P4_TABLE);
          }
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
          if( pTab->pIndex ){
            sqlite3MultiWrite(pParse);
            sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,-1);
          }
        }
        seenReplace = 1;
        break;
      }
#ifndef SQLITE_OMIT_UPSERT
      case OE_Update: {
        sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, 0, iDataCur);
        /* Fall through */
      }
#endif
      case OE_Ignore: {
        /*assert( seenReplace==0 );*/
        testcase( onError==OE_Ignore );
        sqlite3VdbeGoto(v, ignoreDest);
        break;
      }
    }
    sqlite3VdbeResolveLabel(v, addrRowidOk);
    if( ipkTop ){
      ipkBottom = sqlite3VdbeAddOp0(v, OP_Goto);
      sqlite3VdbeJumpHere(v, ipkTop);
    if( sAddr.ipkTop ){
      sAddr.ipkBtm = sqlite3VdbeAddOp0(v, OP_Goto);
      sqlite3VdbeJumpHere(v, sAddr.ipkTop-1);
    }
  }

  /* Test all UNIQUE constraints by creating entries for each UNIQUE
  ** index and making sure that duplicate entries do not already exist.
  ** Compute the revised record entries for indices as we go.
  **
  ** This loop also handles the case of the PRIMARY KEY index for a
  ** WITHOUT ROWID table.
  */
  for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){
    int regIdx;          /* Range of registers hold conent for pIdx */
    int regR;            /* Range of registers holding conflicting PK */
    int iThisCur;        /* Cursor for this UNIQUE index */
    int addrUniqueOk;    /* Jump here if the UNIQUE constraint is satisfied */

    if( aRegIdx[ix]==0 ) continue;  /* Skip indices that do not change */
    if( pUpIdx==pIdx ){
      addrUniqueOk = sAddr.upsertBtm;
      upsertBypass = sqlite3VdbeGoto(v, 0);
      VdbeComment((v, "Skip upsert subroutine"));
      sqlite3VdbeResolveLabel(v, sAddr.upsertTop2);
    }else{
      addrUniqueOk = sqlite3VdbeMakeLabel(v);
    }
    VdbeNoopComment((v, "uniqueness check for %s", pIdx->zName));
    if( bAffinityDone==0 ){
      sqlite3TableAffinity(v, pTab, regNewData+1);
      bAffinityDone = 1;
    }
    iThisCur = iIdxCur+ix;
    addrUniqueOk = sqlite3VdbeMakeLabel(v);


    /* Skip partial indices for which the WHERE clause is not true */
    if( pIdx->pPartIdxWhere ){
      sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[ix]);
      pParse->iSelfTab = -(regNewData+1);
      sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, addrUniqueOk,
                            SQLITE_JUMPIFNULL);
114019
114020
114021
114022
114023
114024
114025


















114026
114027
114028
114029
114030
114031
114032
114899
114900
114901
114902
114903
114904
114905
114906
114907
114908
114909
114910
114911
114912
114913
114914
114915
114916
114917
114918
114919
114920
114921
114922
114923
114924
114925
114926
114927
114928
114929
114930







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







      continue;  /* pIdx is not a UNIQUE index */
    }
    if( overrideError!=OE_Default ){
      onError = overrideError;
    }else if( onError==OE_Default ){
      onError = OE_Abort;
    }

    /* Figure out if the upsert clause applies to this index */
    if( pUpIdx==pIdx ){
      if( pUpsert->pUpsertSet==0 ){
        onError = OE_Ignore;  /* DO NOTHING is the same as INSERT OR IGNORE */
      }else{
        onError = OE_Update;  /* DO UPDATE */
      }
    }

    /* Invoke subroutines to handle IPK replace and upsert prior to running
    ** the first REPLACE constraint check. */
    if( onError==OE_Replace ){
      testcase( sAddr.ipkTop );
      testcase( sAddr.upsertTop
             && sqlite3VdbeLabelHasBeenResolved(v,sAddr.upsertTop) );
      reorderConstraintChecks(v, &sAddr);
    }

    /* Collision detection may be omitted if all of the following are true:
    **   (1) The conflict resolution algorithm is REPLACE
    **   (2) The table is a WITHOUT ROWID table
    **   (3) There are no secondary indexes on the table
    **   (4) No delete triggers need to be fired if there is a conflict
    **   (5) No FK constraint counters need to be updated if a conflict occurs.
114041
114042
114043
114044
114045
114046
114047

114048
114049
114050
114051
114052
114053
114054
114939
114940
114941
114942
114943
114944
114945
114946
114947
114948
114949
114950
114951
114952
114953







+







    ){
      sqlite3VdbeResolveLabel(v, addrUniqueOk);
      continue;
    }

    /* Check to see if the new index entry will be unique */
    sqlite3ExprCachePush(pParse);
    sqlite3VdbeVerifyAbortable(v, onError);
    sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,
                         regIdx, pIdx->nKeyCol); VdbeCoverage(v);

    /* Generate code to handle collisions */
    regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField);
    if( isUpdate || onError==OE_Replace ){
      if( HasRowid(pTab) ){
114102
114103
114104
114105
114106
114107
114108
114109

114110
114111
114112
114113



114114
114115
114116






114117

114118
114119
114120
114121
114122
114123
114124
114125
114126



114127
114128
114129
114130
114131
114132
114133
114134



114135


114136
114137
114138

114139
114140
114141
114142




114143
114144
114145
114146
114147
114148
114149
115001
115002
115003
115004
115005
115006
115007

115008
115009
115010
115011
115012
115013
115014
115015
115016
115017
115018
115019
115020
115021
115022
115023
115024
115025
115026
115027
115028
115029
115030
115031
115032

115033
115034
115035
115036
115037
115038
115039
115040
115041
115042
115043
115044
115045
115046
115047
115048

115049
115050
115051
115052

115053



115054
115055
115056
115057
115058
115059
115060
115061
115062
115063
115064
115065







-
+




+
+
+



+
+
+
+
+
+

+






-


+
+
+








+
+
+
-
+
+


-
+
-
-
-

+
+
+
+







          }
        }
      }
    }

    /* Generate code that executes if the new index entry is not unique */
    assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail
        || onError==OE_Ignore || onError==OE_Replace );
        || onError==OE_Ignore || onError==OE_Replace || onError==OE_Update );
    switch( onError ){
      case OE_Rollback:
      case OE_Abort:
      case OE_Fail: {
        testcase( onError==OE_Rollback );
        testcase( onError==OE_Abort );
        testcase( onError==OE_Fail );
        sqlite3UniqueConstraint(pParse, onError, pIdx);
        break;
      }
#ifndef SQLITE_OMIT_UPSERT
      case OE_Update: {
        sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, pIdx, iIdxCur+ix);
        /* Fall through */
      }
#endif
      case OE_Ignore: {
        testcase( onError==OE_Ignore );
        sqlite3VdbeGoto(v, ignoreDest);
        break;
      }
      default: {
        Trigger *pTrigger = 0;
        assert( onError==OE_Replace );
        sqlite3MultiWrite(pParse);
        if( db->flags&SQLITE_RecTriggers ){
          pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
        }
        if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
          sqlite3MultiWrite(pParse);
        }
        sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
            regR, nPkField, 0, OE_Replace,
            (pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);
        seenReplace = 1;
        break;
      }
    }
    if( pUpIdx==pIdx ){
      sqlite3VdbeJumpHere(v, upsertBypass);
    }else{
    sqlite3VdbeResolveLabel(v, addrUniqueOk);
      sqlite3VdbeResolveLabel(v, addrUniqueOk);
    }
    sqlite3ExprCachePop(pParse);
    if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField);
  }

  if( ipkTop ){
    sqlite3VdbeGoto(v, ipkTop+1);
    sqlite3VdbeJumpHere(v, ipkBottom);
  }
  testcase( sAddr.ipkTop!=0 );
  testcase( sAddr.upsertTop
         && sqlite3VdbeLabelHasBeenResolved(v,sAddr.upsertTop) );
  reorderConstraintChecks(v, &sAddr);
  
  *pbMayReplace = seenReplace;
  VdbeModuleComment((v, "END: GenCnstCks(%d)", seenReplace));
}

#ifdef SQLITE_ENABLE_NULL_TRIM
/*
114635
114636
114637
114638
114639
114640
114641

114642
114643
114644
114645
114646
114647
114648
115551
115552
115553
115554
115555
115556
115557
115558
115559
115560
115561
115562
115563
115564
115565







+







  }
  if( HasRowid(pSrc) ){
    u8 insFlags;
    sqlite3OpenTable(pParse, iSrc, iDbSrc, pSrc, OP_OpenRead);
    emptySrcTest = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v);
    if( pDest->iPKey>=0 ){
      addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);
      sqlite3VdbeVerifyAbortable(v, onError);
      addr2 = sqlite3VdbeAddOp3(v, OP_NotExists, iDest, 0, regRowid);
      VdbeCoverage(v);
      sqlite3RowidConstraint(pParse, onError, pDest);
      sqlite3VdbeJumpHere(v, addr2);
      autoIncStep(pParse, regAutoinc, regRowid);
    }else if( pDest->pIndex==0 ){
      addr1 = sqlite3VdbeAddOp2(v, OP_NewRowid, iDest, regRowid);
115192
115193
115194
115195
115196
115197
115198















115199
115200
115201
115202
115203
115204
115205
116109
116110
116111
116112
116113
116114
116115
116116
116117
116118
116119
116120
116121
116122
116123
116124
116125
116126
116127
116128
116129
116130
116131
116132
116133
116134
116135
116136
116137







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







                      sqlite3_stmt**,const void**);
  int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*));
  void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*));
  void *(*value_pointer)(sqlite3_value*,const char*);
  int (*vtab_nochange)(sqlite3_context*);
  int (*value_nochange)(sqlite3_value*);
  const char *(*vtab_collation)(sqlite3_index_info*,int);
  /* Version 3.24.0 and later */
  int (*keyword_count)(void);
  int (*keyword_name)(int,const char**,int*);
  int (*keyword_check)(const char*,int);
  sqlite3_str *(*str_new)(sqlite3*);
  char *(*str_finish)(sqlite3_str*);
  void (*str_appendf)(sqlite3_str*, const char *zFormat, ...);
  void (*str_vappendf)(sqlite3_str*, const char *zFormat, va_list);
  void (*str_append)(sqlite3_str*, const char *zIn, int N);
  void (*str_appendall)(sqlite3_str*, const char *zIn);
  void (*str_appendchar)(sqlite3_str*, int N, char C);
  void (*str_reset)(sqlite3_str*);
  int (*str_errcode)(sqlite3_str*);
  int (*str_length)(sqlite3_str*);
  char *(*str_value)(sqlite3_str*);
};

/*
** This is the function signature used for all extension entry points.  It
** is also defined in the file "loadext.c".
*/
typedef int (*sqlite3_loadext_entry)(
115462
115463
115464
115465
115466
115467
115468















115469
115470
115471
115472
115473
115474
115475
116394
116395
116396
116397
116398
116399
116400
116401
116402
116403
116404
116405
116406
116407
116408
116409
116410
116411
116412
116413
116414
116415
116416
116417
116418
116419
116420
116421
116422







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







#define sqlite3_bind_pointer           sqlite3_api->bind_pointer
#define sqlite3_result_pointer         sqlite3_api->result_pointer
#define sqlite3_value_pointer          sqlite3_api->value_pointer
/* Version 3.22.0 and later */
#define sqlite3_vtab_nochange          sqlite3_api->vtab_nochange
#define sqlite3_value_nochange         sqlite3_api->value_nochange
#define sqlite3_vtab_collation         sqlite3_api->vtab_collation
/* Version 3.24.0 and later */
#define sqlite3_keyword_count          sqlite3_api->keyword_count
#define sqlite3_keyword_name           sqlite3_api->keyword_name
#define sqlite3_keyword_check          sqlite3_api->keyword_check
#define sqlite3_str_new                sqlite3_api->str_new
#define sqlite3_str_finish             sqlite3_api->str_finish
#define sqlite3_str_appendf            sqlite3_api->str_appendf
#define sqlite3_str_vappendf           sqlite3_api->str_vappendf
#define sqlite3_str_append             sqlite3_api->str_append
#define sqlite3_str_appendall          sqlite3_api->str_appendall
#define sqlite3_str_appendchar         sqlite3_api->str_appendchar
#define sqlite3_str_reset              sqlite3_api->str_reset
#define sqlite3_str_errcode            sqlite3_api->str_errcode
#define sqlite3_str_length             sqlite3_api->str_length
#define sqlite3_str_value              sqlite3_api->str_value
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */

#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
  /* This case when the file really is being compiled as a loadable 
  ** extension */
# define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api=0;
# define SQLITE_EXTENSION_INIT2(v)  sqlite3_api=v;
115900
115901
115902
115903
115904
115905
115906
115907
















115908
115909
115910
115911
115912
115913
115914
116847
116848
116849
116850
116851
116852
116853

116854
116855
116856
116857
116858
116859
116860
116861
116862
116863
116864
116865
116866
116867
116868
116869
116870
116871
116872
116873
116874
116875
116876







-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  sqlite3_prepare16_v3,
  sqlite3_bind_pointer,
  sqlite3_result_pointer,
  sqlite3_value_pointer,
  /* Version 3.22.0 and later */
  sqlite3_vtab_nochange,
  sqlite3_value_nochange,
  sqlite3_vtab_collation
  sqlite3_vtab_collation,
  /* Version 3.24.0 and later */
  sqlite3_keyword_count,
  sqlite3_keyword_name,
  sqlite3_keyword_check,
  sqlite3_str_new,
  sqlite3_str_finish,
  sqlite3_str_appendf,
  sqlite3_str_vappendf,
  sqlite3_str_append,
  sqlite3_str_appendall,
  sqlite3_str_appendchar,
  sqlite3_str_reset,
  sqlite3_str_errcode,
  sqlite3_str_length,
  sqlite3_str_value
};

/*
** Attempt to load an SQLite extension library contained in the file
** zFile.  The entry point is zProc.  zProc may be 0 in which case a
** default entry point name (sqlite3_extension_init) is used.  Use
** of the default name is recommended.
115966
115967
115968
115969
115970
115971
115972
115973
115974
115975
115976

115977
115978
115979
115980
115981
115982
115983
116928
116929
116930
116931
116932
116933
116934

116935


116936
116937
116938
116939
116940
116941
116942
116943







-

-
-
+








  zEntry = zProc ? zProc : "sqlite3_extension_init";

  handle = sqlite3OsDlOpen(pVfs, zFile);
#if SQLITE_OS_UNIX || SQLITE_OS_WIN
  for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){
    char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEndings[ii]);
    int bExists = 0;
    if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;
    sqlite3OsAccess(pVfs, zAltFile, SQLITE_ACCESS_EXISTS, &bExists);
    if( bExists )  handle = sqlite3OsDlOpen(pVfs, zAltFile);
    handle = sqlite3OsDlOpen(pVfs, zAltFile);
    sqlite3_free(zAltFile);
  }
#endif
  if( handle==0 ){
    if( pzErrMsg ){
      *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
      if( zErrmsg ){
119141
119142
119143
119144
119145
119146
119147
119148

119149
119150

119151
119152
119153
119154

119155
119156
119157
119158
119159
119160

119161
119162
119163
119164

119165
119166
119167

119168
119169
119170
119171
119172
119173
119174
120101
120102
120103
120104
120105
120106
120107

120108
120109

120110
120111
120112
120113

120114
120115
120116
120117
120118
120119

120120
120121
120122
120123

120124
120125
120126

120127
120128
120129
120130
120131
120132
120133
120134







-
+

-
+



-
+





-
+



-
+


-
+







  char cSep = '(';
  StrAccum acc;
  char zBuf[200];

  UNUSED_PARAMETER(argc);
  UNUSED_PARAMETER(argv);
  sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
  sqlite3StrAccumAppendAll(&acc, "CREATE TABLE x");
  sqlite3_str_appendall(&acc, "CREATE TABLE x");
  for(i=0, j=pPragma->iPragCName; i<pPragma->nPragCName; i++, j++){
    sqlite3XPrintf(&acc, "%c\"%s\"", cSep, pragCName[j]);
    sqlite3_str_appendf(&acc, "%c\"%s\"", cSep, pragCName[j]);
    cSep = ',';
  }
  if( i==0 ){
    sqlite3XPrintf(&acc, "(\"%s\"", pPragma->zName);
    sqlite3_str_appendf(&acc, "(\"%s\"", pPragma->zName);
    cSep = ',';
    i++;
  }
  j = 0;
  if( pPragma->mPragFlg & PragFlg_Result1 ){
    sqlite3StrAccumAppendAll(&acc, ",arg HIDDEN");
    sqlite3_str_appendall(&acc, ",arg HIDDEN");
    j++;
  }
  if( pPragma->mPragFlg & (PragFlg_SchemaOpt|PragFlg_SchemaReq) ){
    sqlite3StrAccumAppendAll(&acc, ",schema HIDDEN");
    sqlite3_str_appendall(&acc, ",schema HIDDEN");
    j++;
  }
  sqlite3StrAccumAppend(&acc, ")", 1);
  sqlite3_str_append(&acc, ")", 1);
  sqlite3StrAccumFinish(&acc);
  assert( strlen(zBuf) < sizeof(zBuf)-1 );
  rc = sqlite3_declare_vtab(db, zBuf);
  if( rc==SQLITE_OK ){
    pTab = (PragmaVtab*)sqlite3_malloc(sizeof(PragmaVtab));
    if( pTab==0 ){
      rc = SQLITE_NOMEM;
119312
119313
119314
119315
119316
119317
119318
119319

119320
119321

119322
119323

119324
119325

119326
119327
119328
119329
119330
119331
119332
120272
120273
120274
120275
120276
120277
120278

120279
120280

120281
120282

120283
120284

120285
120286
120287
120288
120289
120290
120291
120292







-
+

-
+

-
+

-
+







      pCsr->azArg[j] = sqlite3_mprintf("%s", zText);
      if( pCsr->azArg[j]==0 ){
        return SQLITE_NOMEM;
      }
    }
  }
  sqlite3StrAccumInit(&acc, 0, 0, 0, pTab->db->aLimit[SQLITE_LIMIT_SQL_LENGTH]);
  sqlite3StrAccumAppendAll(&acc, "PRAGMA ");
  sqlite3_str_appendall(&acc, "PRAGMA ");
  if( pCsr->azArg[1] ){
    sqlite3XPrintf(&acc, "%Q.", pCsr->azArg[1]);
    sqlite3_str_appendf(&acc, "%Q.", pCsr->azArg[1]);
  }
  sqlite3StrAccumAppendAll(&acc, pTab->pName->zName);
  sqlite3_str_appendall(&acc, pTab->pName->zName);
  if( pCsr->azArg[0] ){
    sqlite3XPrintf(&acc, "=%Q", pCsr->azArg[0]);
    sqlite3_str_appendf(&acc, "=%Q", pCsr->azArg[0]);
  }
  zSql = sqlite3StrAccumFinish(&acc);
  if( zSql==0 ) return SQLITE_NOMEM;
  rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pPragma, 0);
  sqlite3_free(zSql);
  if( rc!=SQLITE_OK ){
    pTab->base.zErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pTab->db));
119561
119562
119563
119564
119565
119566
119567

119568
119569
119570
119571
119572
119573
119574
120521
120522
120523
120524
120525
120526
120527
120528
120529
120530
120531
120532
120533
120534
120535







+







  Db *pDb;
  char const *azArg[4];
  int meta[5];
  InitData initData;
  const char *zMasterName;
  int openedTransaction = 0;

  assert( (db->mDbFlags & DBFLAG_SchemaKnownOk)==0 );
  assert( iDb>=0 && iDb<db->nDb );
  assert( db->aDb[iDb].pSchema );
  assert( sqlite3_mutex_held(db->mutex) );
  assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );

  db->init.busy = 1;

119630
119631
119632
119633
119634
119635
119636



119637
119638
119639
119640
119641
119642
119643
120591
120592
120593
120594
120595
120596
120597
120598
120599
120600
120601
120602
120603
120604
120605
120606
120607







+
+
+







  **    meta[9]   unused
  **
  ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to
  ** the possible values of meta[4].
  */
  for(i=0; i<ArraySize(meta); i++){
    sqlite3BtreeGetMeta(pDb->pBt, i+1, (u32 *)&meta[i]);
  }
  if( (db->flags & SQLITE_ResetDatabase)!=0 ){
    memset(meta, 0, sizeof(meta));
  }
  pDb->pSchema->schema_cookie = meta[BTREE_SCHEMA_VERSION-1];

  /* If opening a non-empty database, check the text encoding. For the
  ** main database, set sqlite3.enc to the encoding of the main database.
  ** For an attached db, it is an error if the encoding is not the same
  ** as sqlite3.enc.
119790
119791
119792
119793
119794
119795
119796

119797
119798
119799
119800
119801
119802
119803
120754
120755
120756
120757
120758
120759
120760
120761
120762
120763
120764
120765
120766
120767
120768







+







  /* Do the main schema first */
  if( !DbHasProperty(db, 0, DB_SchemaLoaded) ){
    rc = sqlite3InitOne(db, 0, pzErrMsg);
    if( rc ) return rc;
  }
  /* All other schemas after the main schema. The "temp" schema must be last */
  for(i=db->nDb-1; i>0; i--){
    assert( i==1 || sqlite3BtreeHoldsMutex(db->aDb[i].pBt) );
    if( !DbHasProperty(db, i, DB_SchemaLoaded) ){
      rc = sqlite3InitOne(db, i, pzErrMsg);
      if( rc ) return rc;
    }
  }
  if( commit_internal ){
    sqlite3CommitInternalChanges(db);
119811
119812
119813
119814
119815
119816
119817
119818
119819
119820
119821






119822
119823
119824
119825
119826
119827
119828
120776
120777
120778
120779
120780
120781
120782




120783
120784
120785
120786
120787
120788
120789
120790
120791
120792
120793
120794
120795







-
-
-
-
+
+
+
+
+
+







*/
SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse){
  int rc = SQLITE_OK;
  sqlite3 *db = pParse->db;
  assert( sqlite3_mutex_held(db->mutex) );
  if( !db->init.busy ){
    rc = sqlite3Init(db, &pParse->zErrMsg);
  }
  if( rc!=SQLITE_OK ){
    pParse->rc = rc;
    pParse->nErr++;
    if( rc!=SQLITE_OK ){
      pParse->rc = rc;
      pParse->nErr++;
    }else if( db->noSharedCache ){
      db->mDbFlags |= DBFLAG_SchemaKnownOk;
    }
  }
  return rc;
}


/*
** Check schema cookies in all databases.  If any cookie is out
120025
120026
120027
120028
120029
120030
120031
120032

120033
120034
120035
120036
120037
120038
120039
120992
120993
120994
120995
120996
120997
120998

120999
121000
121001
121002
121003
121004
121005
121006







-
+







  }
  rc = sParse.rc;

#ifndef SQLITE_OMIT_EXPLAIN
  if( rc==SQLITE_OK && sParse.pVdbe && sParse.explain ){
    static const char * const azColName[] = {
       "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment",
       "selectid", "order", "from", "detail"
       "id", "parent", "notused", "detail"
    };
    int iFirst, mx;
    if( sParse.explain==2 ){
      sqlite3VdbeSetNumCols(sParse.pVdbe, 4);
      iFirst = 8;
      mx = 12;
    }else{
120339
120340
120341
120342
120343
120344
120345
120346

120347
120348
120349
120350
120351
120352
120353
121306
121307
121308
121309
121310
121311
121312

121313
121314
121315
121316
121317
121318
121319
121320







-
+







/*
** Trace output macros
*/
#if SELECTTRACE_ENABLED
/***/ int sqlite3SelectTrace = 0;
# define SELECTTRACE(K,P,S,X)  \
  if(sqlite3SelectTrace&(K))   \
    sqlite3DebugPrintf("%s/%p: ",(S)->zSelName,(S)),\
    sqlite3DebugPrintf("%s/%d/%p: ",(S)->zSelName,(P)->addrExplain,(S)),\
    sqlite3DebugPrintf X
#else
# define SELECTTRACE(K,P,S,X)
#endif


/*
120362
120363
120364
120365
120366
120367
120368














120369
120370
120371
120372
120373
120374
120375
120376
120377
120378
120379
120380









120381
120382
120383
120384
120385
120386
120387
121329
121330
121331
121332
121333
121334
121335
121336
121337
121338
121339
121340
121341
121342
121343
121344
121345
121346
121347
121348
121349
121350
121351
121352
121353
121354
121355
121356
121357
121358
121359
121360
121361
121362
121363
121364
121365
121366
121367
121368
121369
121370
121371
121372
121373
121374
121375
121376
121377







+
+
+
+
+
+
+
+
+
+
+
+
+
+












+
+
+
+
+
+
+
+
+







  int tabTnct;    /* Ephemeral table used for DISTINCT processing */
  int addrTnct;   /* Address of OP_OpenEphemeral opcode for tabTnct */
};

/*
** An instance of the following object is used to record information about
** the ORDER BY (or GROUP BY) clause of query is being coded.
**
** The aDefer[] array is used by the sorter-references optimization. For
** example, assuming there is no index that can be used for the ORDER BY,
** for the query:
**
**     SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10;
**
** it may be more efficient to add just the "a" values to the sorter, and
** retrieve the associated "bigblob" values directly from table t1 as the
** 10 smallest "a" values are extracted from the sorter.
**
** When the sorter-reference optimization is used, there is one entry in the
** aDefer[] array for each database table that may be read as values are
** extracted from the sorter.
*/
typedef struct SortCtx SortCtx;
struct SortCtx {
  ExprList *pOrderBy;   /* The ORDER BY (or GROUP BY clause) */
  int nOBSat;           /* Number of ORDER BY terms satisfied by indices */
  int iECursor;         /* Cursor number for the sorter */
  int regReturn;        /* Register holding block-output return address */
  int labelBkOut;       /* Start label for the block-output subroutine */
  int addrSortIndex;    /* Address of the OP_SorterOpen or OP_OpenEphemeral */
  int labelDone;        /* Jump here when done, ex: LIMIT reached */
  u8 sortFlags;         /* Zero or more SORTFLAG_* bits */
  u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
  u8 nDefer;            /* Number of valid entries in aDefer[] */
  struct DeferredCsr {
    Table *pTab;        /* Table definition */
    int iCsr;           /* Cursor number for table */
    int nKey;           /* Number of PK columns for table pTab (>=1) */
  } aDefer[4];
#endif
  struct RowLoadInfo *pDeferredRowLoad;  /* Deferred row loading info or NULL */
};
#define SORTFLAG_UseSorter  0x01   /* Use SorterOpen instead of OpenEphemeral */

/*
** Delete all the content of a Select structure.  Deallocate the structure
** itself only if bFree is true.
*/
120831
120832
120833
120834
120835
120836
120837
























































120838
120839
120840
120841
120842
120843
120844
120845
120846
120847
120848
120849

120850
120851
120852
120853
120854
120855
120856
120857

120858
120859
120860

120861
120862














120863

120864
120865
120866

120867
120868
120869
120870
120871
120872
120873
120874
120875
120876
120877
120878
120879
120880
120881
120882
120883
120884
120885
120886
120887
120888
120889
120890

120891
120892
120893
120894
120895
120896
120897
121821
121822
121823
121824
121825
121826
121827
121828
121829
121830
121831
121832
121833
121834
121835
121836
121837
121838
121839
121840
121841
121842
121843
121844
121845
121846
121847
121848
121849
121850
121851
121852
121853
121854
121855
121856
121857
121858
121859
121860
121861
121862
121863
121864
121865
121866
121867
121868
121869
121870
121871
121872
121873
121874
121875
121876
121877
121878
121879
121880
121881
121882
121883
121884
121885
121886
121887
121888
121889
121890
121891
121892
121893
121894

121895
121896
121897
121898
121899
121900
121901
121902

121903
121904
121905
121906
121907
121908
121909
121910
121911
121912
121913
121914
121915
121916
121917
121918
121919
121920
121921
121922
121923
121924
121925
121926
121927

121928
121929
121930
121931
121932
121933
121934
121935
121936
121937
121938
121939
121940
121941
121942
121943

121944
121945
121946
121947
121948
121949
121950
121951
121952
121953
121954
121955
121956
121957
121958
121959







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+











-
+







-
+



+


+
+
+
+
+
+
+
+
+
+
+
+
+
+

+


-
+















-








+







/* Forward reference */
static KeyInfo *keyInfoFromExprList(
  Parse *pParse,       /* Parsing context */
  ExprList *pList,     /* Form the KeyInfo object from this ExprList */
  int iStart,          /* Begin with this column of pList */
  int nExtra           /* Add this many extra columns to the end */
);

/*
** An instance of this object holds information (beyond pParse and pSelect)
** needed to load the next result row that is to be added to the sorter.
*/
typedef struct RowLoadInfo RowLoadInfo;
struct RowLoadInfo {
  int regResult;               /* Store results in array of registers here */
  u8 ecelFlags;                /* Flag argument to ExprCodeExprList() */
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
  ExprList *pExtra;            /* Extra columns needed by sorter refs */
  int regExtraResult;          /* Where to load the extra columns */
#endif
};

/*
** This routine does the work of loading query data into an array of
** registers so that it can be added to the sorter.
*/
static void innerLoopLoadRow(
  Parse *pParse,             /* Statement under construction */
  Select *pSelect,           /* The query being coded */
  RowLoadInfo *pInfo         /* Info needed to complete the row load */
){
  sqlite3ExprCodeExprList(pParse, pSelect->pEList, pInfo->regResult,
                          0, pInfo->ecelFlags);
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
  if( pInfo->pExtra ){
    sqlite3ExprCodeExprList(pParse, pInfo->pExtra, pInfo->regExtraResult, 0, 0);
    sqlite3ExprListDelete(pParse->db, pInfo->pExtra);
  }
#endif
}

/*
** Code the OP_MakeRecord instruction that generates the entry to be
** added into the sorter.
**
** Return the register in which the result is stored.
*/
static int makeSorterRecord(
  Parse *pParse,
  SortCtx *pSort,
  Select *pSelect,
  int regBase,
  int nBase
){
  int nOBSat = pSort->nOBSat;
  Vdbe *v = pParse->pVdbe;
  int regOut = ++pParse->nMem;
  if( pSort->pDeferredRowLoad ){
    innerLoopLoadRow(pParse, pSelect, pSort->pDeferredRowLoad);
  }
  sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase+nOBSat, nBase-nOBSat, regOut);
  return regOut;
}

/*
** Generate code that will push the record in registers regData
** through regData+nData-1 onto the sorter.
*/
static void pushOntoSorter(
  Parse *pParse,         /* Parser context */
  SortCtx *pSort,        /* Information about the ORDER BY clause */
  Select *pSelect,       /* The whole SELECT statement */
  int regData,           /* First register holding data to be sorted */
  int regOrigData,       /* First register holding data before packing */
  int nData,             /* Number of elements in the data array */
  int nData,             /* Number of elements in the regData data array */
  int nPrefixReg         /* No. of reg prior to regData available for use */
){
  Vdbe *v = pParse->pVdbe;                         /* Stmt under construction */
  int bSeq = ((pSort->sortFlags & SORTFLAG_UseSorter)==0);
  int nExpr = pSort->pOrderBy->nExpr;              /* No. of ORDER BY terms */
  int nBase = nExpr + bSeq + nData;                /* Fields in sorter record */
  int regBase;                                     /* Regs for sorter record */
  int regRecord = ++pParse->nMem;                  /* Assembled sorter record */
  int regRecord = 0;                               /* Assembled sorter record */
  int nOBSat = pSort->nOBSat;                      /* ORDER BY terms to skip */
  int op;                            /* Opcode to add sorter record to sorter */
  int iLimit;                        /* LIMIT counter */
  int iSkip = 0;                     /* End of the sorter insert loop */

  assert( bSeq==0 || bSeq==1 );

  /* Three cases:
  **   (1) The data to be sorted has already been packed into a Record
  **       by a prior OP_MakeRecord.  In this case nData==1 and regData
  **       will be completely unrelated to regOrigData.
  **   (2) All output columns are included in the sort record.  In that
  **       case regData==regOrigData.
  **   (3) Some output columns are omitted from the sort record due to
  **       the SQLITE_ENABLE_SORTER_REFERENCE optimization, or due to the
  **       SQLITE_ECEL_OMITREF optimization, or due to the 
  **       SortCtx.pDeferredRowLoad optimiation.  In any of these cases
  **       regOrigData is 0 to prevent this routine from trying to copy
  **       values that might not yet exist.
  */
  assert( nData==1 || regData==regOrigData || regOrigData==0 );

  if( nPrefixReg ){
    assert( nPrefixReg==nExpr+bSeq );
    regBase = regData - nExpr - bSeq;
    regBase = regData - nPrefixReg;
  }else{
    regBase = pParse->nMem + 1;
    pParse->nMem += nBase;
  }
  assert( pSelect->iOffset==0 || pSelect->iLimit!=0 );
  iLimit = pSelect->iOffset ? pSelect->iOffset+1 : pSelect->iLimit;
  pSort->labelDone = sqlite3VdbeMakeLabel(v);
  sqlite3ExprCodeExprList(pParse, pSort->pOrderBy, regBase, regOrigData,
                          SQLITE_ECEL_DUP | (regOrigData? SQLITE_ECEL_REF : 0));
  if( bSeq ){
    sqlite3VdbeAddOp2(v, OP_Sequence, pSort->iECursor, regBase+nExpr);
  }
  if( nPrefixReg==0 && nData>0 ){
    sqlite3ExprCodeMove(pParse, regData, regBase+nExpr+bSeq, nData);
  }
  sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase+nOBSat, nBase-nOBSat, regRecord);
  if( nOBSat>0 ){
    int regPrevKey;   /* The first nOBSat columns of the previous row */
    int addrFirst;    /* Address of the OP_IfNot opcode */
    int addrJmp;      /* Address of the OP_Jump opcode */
    VdbeOp *pOp;      /* Opcode that opens the sorter */
    int nKey;         /* Number of sorting key columns, including OP_Sequence */
    KeyInfo *pKI;     /* Original KeyInfo on the sorter table */

    regRecord = makeSorterRecord(pParse, pSort, pSelect, regBase, nBase);
    regPrevKey = pParse->nMem+1;
    pParse->nMem += pSort->nOBSat;
    nKey = nExpr - pSort->nOBSat + bSeq;
    if( bSeq ){
      addrFirst = sqlite3VdbeAddOp1(v, OP_IfNot, regBase+nExpr); 
    }else{
      addrFirst = sqlite3VdbeAddOp1(v, OP_SequenceTest, pSort->iECursor);
120917
120918
120919
120920
120921
120922
120923




























120924
120925
120926
120927
120928
120929
120930
120931

120932
120933
120934
120935
120936
120937
120938
120939
120940

120941
120942
120943
120944
120945
120946
120947
120948
120949
120950
120951
120952
120953
120954

120955
120956
120957

120958
120959
120960
120961
120962
120963
120964
121979
121980
121981
121982
121983
121984
121985
121986
121987
121988
121989
121990
121991
121992
121993
121994
121995
121996
121997
121998
121999
122000
122001
122002
122003
122004
122005
122006
122007
122008
122009
122010
122011
122012
122013
122014
122015
122016
122017
122018
122019
122020

122021









122022














122023



122024
122025
122026
122027
122028
122029
122030
122031







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







-
+
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
+







      sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, pSort->labelDone);
      VdbeCoverage(v);
    }
    sqlite3VdbeJumpHere(v, addrFirst);
    sqlite3ExprCodeMove(pParse, regBase, regPrevKey, pSort->nOBSat);
    sqlite3VdbeJumpHere(v, addrJmp);
  }
  if( iLimit ){
    /* At this point the values for the new sorter entry are stored
    ** in an array of registers. They need to be composed into a record
    ** and inserted into the sorter if either (a) there are currently
    ** less than LIMIT+OFFSET items or (b) the new record is smaller than 
    ** the largest record currently in the sorter. If (b) is true and there
    ** are already LIMIT+OFFSET items in the sorter, delete the largest
    ** entry before inserting the new one. This way there are never more 
    ** than LIMIT+OFFSET items in the sorter.
    **
    ** If the new record does not need to be inserted into the sorter,
    ** jump to the next iteration of the loop. Or, if the
    ** pSort->bOrderedInnerLoop flag is set to indicate that the inner
    ** loop delivers items in sorted order, jump to the next iteration
    ** of the outer loop.
    */
    int iCsr = pSort->iECursor;
    sqlite3VdbeAddOp2(v, OP_IfNotZero, iLimit, sqlite3VdbeCurrentAddr(v)+4);
    VdbeCoverage(v);
    sqlite3VdbeAddOp2(v, OP_Last, iCsr, 0);
    iSkip = sqlite3VdbeAddOp4Int(v, OP_IdxLE,
                                 iCsr, 0, regBase+nOBSat, nExpr-nOBSat);
    VdbeCoverage(v);
    sqlite3VdbeAddOp1(v, OP_Delete, iCsr);
  }
  if( regRecord==0 ){
    regRecord = makeSorterRecord(pParse, pSort, pSelect, regBase, nBase);
  }
  if( pSort->sortFlags & SORTFLAG_UseSorter ){
    op = OP_SorterInsert;
  }else{
    op = OP_IdxInsert;
  }
  sqlite3VdbeAddOp4Int(v, op, pSort->iECursor, regRecord,
                       regBase+nOBSat, nBase-nOBSat);
  if( iLimit ){
  if( iSkip ){
    int addr;
    int r1 = 0;
    /* Fill the sorter until it contains LIMIT+OFFSET entries.  (The iLimit
    ** register is initialized with value of LIMIT+OFFSET.)  After the sorter
    ** fills up, delete the least entry in the sorter after each insert.
    ** Thus we never hold more than the LIMIT+OFFSET rows in memory at once */
    addr = sqlite3VdbeAddOp1(v, OP_IfNotZero, iLimit); VdbeCoverage(v);
    sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor);
    if( pSort->bOrderedInnerLoop ){
    assert( pSort->bOrderedInnerLoop==0 || pSort->bOrderedInnerLoop==1 );
      r1 = ++pParse->nMem;
      sqlite3VdbeAddOp3(v, OP_Column, pSort->iECursor, nExpr, r1);
      VdbeComment((v, "seq"));
    }
    sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor);
    if( pSort->bOrderedInnerLoop ){
      /* If the inner loop is driven by an index such that values from
      ** the same iteration of the inner loop are in sorted order, then
      ** immediately jump to the next iteration of an inner loop if the
      ** entry from the current iteration does not fit into the top
      ** LIMIT+OFFSET entries of the sorter. */
      int iBrk = sqlite3VdbeCurrentAddr(v) + 2;
      sqlite3VdbeAddOp3(v, OP_Eq, regBase+nExpr, iBrk, r1);
      sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
    sqlite3VdbeChangeP2(v, iSkip,
      VdbeCoverage(v);
    }
    sqlite3VdbeJumpHere(v, addr);
         sqlite3VdbeCurrentAddr(v) + pSort->bOrderedInnerLoop);
  }
}

/*
** Add code to implement the OFFSET
*/
static void codeOffset(
120996
120997
120998
120999
121000
121001
121002

















































































121003
121004
121005
121006
121007
121008
121009
122063
122064
122065
122066
122067
122068
122069
122070
122071
122072
122073
122074
122075
122076
122077
122078
122079
122080
122081
122082
122083
122084
122085
122086
122087
122088
122089
122090
122091
122092
122093
122094
122095
122096
122097
122098
122099
122100
122101
122102
122103
122104
122105
122106
122107
122108
122109
122110
122111
122112
122113
122114
122115
122116
122117
122118
122119
122120
122121
122122
122123
122124
122125
122126
122127
122128
122129
122130
122131
122132
122133
122134
122135
122136
122137
122138
122139
122140
122141
122142
122143
122144
122145
122146
122147
122148
122149
122150
122151
122152
122153
122154
122155
122156
122157







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N); VdbeCoverage(v);
  sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1);
  sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r1, iMem, N);
  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
  sqlite3ReleaseTempReg(pParse, r1);
}

#ifdef SQLITE_ENABLE_SORTER_REFERENCES
/*
** This function is called as part of inner-loop generation for a SELECT
** statement with an ORDER BY that is not optimized by an index. It 
** determines the expressions, if any, that the sorter-reference 
** optimization should be used for. The sorter-reference optimization
** is used for SELECT queries like:
**
**   SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10
**
** If the optimization is used for expression "bigblob", then instead of
** storing values read from that column in the sorter records, the PK of
** the row from table t1 is stored instead. Then, as records are extracted from
** the sorter to return to the user, the required value of bigblob is
** retrieved directly from table t1. If the values are very large, this 
** can be more efficient than storing them directly in the sorter records.
**
** The ExprList_item.bSorterRef flag is set for each expression in pEList 
** for which the sorter-reference optimization should be enabled. 
** Additionally, the pSort->aDefer[] array is populated with entries
** for all cursors required to evaluate all selected expressions. Finally.
** output variable (*ppExtra) is set to an expression list containing
** expressions for all extra PK values that should be stored in the
** sorter records.
*/
static void selectExprDefer(
  Parse *pParse,                  /* Leave any error here */
  SortCtx *pSort,                 /* Sorter context */
  ExprList *pEList,               /* Expressions destined for sorter */
  ExprList **ppExtra              /* Expressions to append to sorter record */
){
  int i;
  int nDefer = 0;
  ExprList *pExtra = 0;
  for(i=0; i<pEList->nExpr; i++){
    struct ExprList_item *pItem = &pEList->a[i];
    if( pItem->u.x.iOrderByCol==0 ){
      Expr *pExpr = pItem->pExpr;
      Table *pTab = pExpr->pTab;
      if( pExpr->op==TK_COLUMN && pTab && !IsVirtual(pTab)
       && (pTab->aCol[pExpr->iColumn].colFlags & COLFLAG_SORTERREF)
      ){
        int j;
        for(j=0; j<nDefer; j++){
          if( pSort->aDefer[j].iCsr==pExpr->iTable ) break;
        }
        if( j==nDefer ){
          if( nDefer==ArraySize(pSort->aDefer) ){
            continue;
          }else{
            int nKey = 1;
            int k;
            Index *pPk = 0;
            if( !HasRowid(pTab) ){
              pPk = sqlite3PrimaryKeyIndex(pTab);
              nKey = pPk->nKeyCol;
            }
            for(k=0; k<nKey; k++){
              Expr *pNew = sqlite3PExpr(pParse, TK_COLUMN, 0, 0);
              if( pNew ){
                pNew->iTable = pExpr->iTable;
                pNew->pTab = pExpr->pTab;
                pNew->iColumn = pPk ? pPk->aiColumn[k] : -1;
                pExtra = sqlite3ExprListAppend(pParse, pExtra, pNew);
              }
            }
            pSort->aDefer[nDefer].pTab = pExpr->pTab;
            pSort->aDefer[nDefer].iCsr = pExpr->iTable;
            pSort->aDefer[nDefer].nKey = nKey;
            nDefer++;
          }
        }
        pItem->bSorterRef = 1;
      }
    }
  }
  pSort->nDefer = (u8)nDefer;
  *ppExtra = pExtra;
}
#endif

/*
** This routine generates the code for the inside of the inner loop
** of a SELECT.
**
** If srcTab is negative, then the p->pEList expressions
** are evaluated in order to get the data for this row.  If srcTab is
** zero or more, then data is pulled from srcTab and p->pEList is used only 
121022
121023
121024
121025
121026
121027
121028

121029
121030
121031
121032
121033
121034
121035
122170
122171
122172
122173
122174
122175
122176
122177
122178
122179
122180
122181
122182
122183
122184







+







  Vdbe *v = pParse->pVdbe;
  int i;
  int hasDistinct;            /* True if the DISTINCT keyword is present */
  int eDest = pDest->eDest;   /* How to dispose of results */
  int iParm = pDest->iSDParm; /* First argument to disposal method */
  int nResultCol;             /* Number of result columns */
  int nPrefixReg = 0;         /* Number of extra registers before regResult */
  RowLoadInfo sRowLoadInfo;   /* Info for deferred row loading */

  /* Usually, regResult is the first cell in an array of memory cells
  ** containing the current result row. In this case regOrig is set to the
  ** same value. However, if the results are being sent to the sorter, the
  ** values for any expressions that are also part of the sort-key are omitted
  ** from this array. In this case regOrig is set to zero.  */
  int regResult;              /* Start of memory holding current results */
121068
121069
121070
121071
121072
121073
121074



121075
121076
121077
121078


121079
121080
121081
121082
121083
121084
121085
121086
121087
121088
121089
121090
121091

121092
121093
121094
121095
121096
121097

























121098









121099
121100
121101
121102
121103


















121104
121105
121106
121107
121108
121109
121110
122217
122218
122219
122220
122221
122222
122223
122224
122225
122226
122227
122228
122229

122230
122231
122232
122233
122234
122235
122236
122237
122238
122239
122240
122241
122242
122243
122244
122245
122246
122247
122248
122249
122250
122251
122252
122253
122254
122255
122256
122257
122258
122259
122260
122261
122262
122263
122264
122265
122266
122267
122268
122269
122270
122271
122272
122273
122274
122275
122276

122277
122278
122279
122280
122281
122282
122283
122284
122285
122286
122287
122288


122289
122290
122291
122292
122293
122294
122295
122296
122297
122298
122299
122300
122301
122302
122303
122304
122305
122306
122307
122308
122309
122310
122311
122312
122313







+
+
+



-
+
+













+






+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+



-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  regOrig = regResult = pDest->iSdst;
  if( srcTab>=0 ){
    for(i=0; i<nResultCol; i++){
      sqlite3VdbeAddOp3(v, OP_Column, srcTab, i, regResult+i);
      VdbeComment((v, "%s", p->pEList->a[i].zName));
    }
  }else if( eDest!=SRT_Exists ){
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
    ExprList *pExtra = 0;
#endif
    /* If the destination is an EXISTS(...) expression, the actual
    ** values returned by the SELECT are not required.
    */
    u8 ecelFlags;
    u8 ecelFlags;    /* "ecel" is an abbreviation of "ExprCodeExprList" */
    ExprList *pEList;
    if( eDest==SRT_Mem || eDest==SRT_Output || eDest==SRT_Coroutine ){
      ecelFlags = SQLITE_ECEL_DUP;
    }else{
      ecelFlags = 0;
    }
    if( pSort && hasDistinct==0 && eDest!=SRT_EphemTab && eDest!=SRT_Table ){
      /* For each expression in p->pEList that is a copy of an expression in
      ** the ORDER BY clause (pSort->pOrderBy), set the associated 
      ** iOrderByCol value to one more than the index of the ORDER BY 
      ** expression within the sort-key that pushOntoSorter() will generate.
      ** This allows the p->pEList field to be omitted from the sorted record,
      ** saving space and CPU cycles.  */
      ecelFlags |= (SQLITE_ECEL_OMITREF|SQLITE_ECEL_REF);

      for(i=pSort->nOBSat; i<pSort->pOrderBy->nExpr; i++){
        int j;
        if( (j = pSort->pOrderBy->a[i].u.x.iOrderByCol)>0 ){
          p->pEList->a[j-1].u.x.iOrderByCol = i+1-pSort->nOBSat;
        }
      }
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
      selectExprDefer(pParse, pSort, p->pEList, &pExtra);
      if( pExtra && pParse->db->mallocFailed==0 ){
        /* If there are any extra PK columns to add to the sorter records,
        ** allocate extra memory cells and adjust the OpenEphemeral 
        ** instruction to account for the larger records. This is only
        ** required if there are one or more WITHOUT ROWID tables with
        ** composite primary keys in the SortCtx.aDefer[] array.  */
        VdbeOp *pOp = sqlite3VdbeGetOp(v, pSort->addrSortIndex);
        pOp->p2 += (pExtra->nExpr - pSort->nDefer);
        pOp->p4.pKeyInfo->nAllField += (pExtra->nExpr - pSort->nDefer);
        pParse->nMem += pExtra->nExpr;
      }
#endif

      /* Adjust nResultCol to account for columns that are omitted
      ** from the sorter by the optimizations in this branch */
      pEList = p->pEList;
      for(i=0; i<pEList->nExpr; i++){
        if( pEList->a[i].u.x.iOrderByCol>0
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
         || pEList->a[i].bSorterRef
#endif
        ){
          nResultCol--;
      regOrig = 0;
          regOrig = 0;
        }
      }

      testcase( regOrig );
      testcase( eDest==SRT_Set );
      testcase( eDest==SRT_Mem );
      testcase( eDest==SRT_Coroutine );
      testcase( eDest==SRT_Output );
      assert( eDest==SRT_Set || eDest==SRT_Mem 
           || eDest==SRT_Coroutine || eDest==SRT_Output );
    }
    nResultCol = sqlite3ExprCodeExprList(pParse,p->pEList,regResult,
                                         0,ecelFlags);
    sRowLoadInfo.regResult = regResult;
    sRowLoadInfo.ecelFlags = ecelFlags;
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
    sRowLoadInfo.pExtra = pExtra;
    sRowLoadInfo.regExtraResult = regResult + nResultCol;
    if( pExtra ) nResultCol += pExtra->nExpr;
#endif
    if( p->iLimit
     && (ecelFlags & SQLITE_ECEL_OMITREF)!=0 
     && nPrefixReg>0
    ){
      assert( pSort!=0 );
      assert( hasDistinct==0 );
      pSort->pDeferredRowLoad = &sRowLoadInfo;
      regOrig = 0;
    }else{
      innerLoopLoadRow(pParse, p, &sRowLoadInfo);
    }
  }

  /* If the DISTINCT keyword was present on the SELECT statement
  ** and this row has been seen before, then do not make this row
  ** part of the result.
  */
  if( hasDistinct ){
121212
121213
121214
121215
121216
121217
121218

121219

121220
121221
121222
121223
121224
121225
121226
122415
122416
122417
122418
122419
122420
122421
122422

122423
122424
122425
122426
122427
122428
122429
122430







+
-
+







        sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, addr, r1, 0);
        VdbeCoverage(v);
        sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm+1, r1,regResult,nResultCol);
        assert( pSort==0 );
      }
#endif
      if( pSort ){
        assert( regResult==regOrig );
        pushOntoSorter(pParse, pSort, p, r1+nPrefixReg,regResult,1,nPrefixReg);
        pushOntoSorter(pParse, pSort, p, r1+nPrefixReg, regOrig, 1, nPrefixReg);
      }else{
        int r2 = sqlite3GetTempReg(pParse);
        sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, r2);
        sqlite3VdbeAddOp3(v, OP_Insert, iParm, r1, r2);
        sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
        sqlite3ReleaseTempReg(pParse, r2);
      }
121479
121480
121481
121482
121483
121484
121485
121486
121487
121488

121489
121490
121491
121492
121493
121494
121495
121496
121497
121498
121499
121500
121501
121502
121503
121504
121505
121506
121507
121508
121509
121510
121511
121512
121513
121514
121515
121516
121517
121518
121519
121520
121521
121522
121523
121524
121525
121526
121527
121528
121529
121530
121531
121532
121533
121534
121535
121536
121537
121538
121539
121540
121541
121542
121543
121544
121545
121546
121547
121548
121549
121550
121551
121552
121553
121554
121555
121556
121557
121558
121559
121560
121561

121562
121563
121564
121565
121566
121567
121568
121569
121570

121571
121572
121573
121574

121575
121576
121577
121578
121579
121580
121581
121582











121583
121584
121585
121586
121587
121588
121589
121590
121591
121592
121593
121594
121595
121596
121597
121598
121599
121600


121601
121602
121603
121604
121605
121606
121607
121608
121609
121610
121611
121612
121613




121614
121615































121616
121617
121618
121619
121620
121621
121622
121623
121624
















121625
121626
121627
121628
121629
121630
121631
122683
122684
122685
122686
122687
122688
122689



122690


122691
122692
122693
122694
122695
122696
122697
122698
122699
122700
122701
122702
122703
122704
122705
122706
122707




































122708
122709
122710
122711
122712
122713
122714
122715
122716
122717
122718
122719
122720
122721
122722
122723
122724

122725
122726
122727
122728
122729
122730
122731
122732
122733

122734
122735

122736
122737
122738
122739
122740
122741
122742
122743
122744
122745
122746
122747
122748
122749
122750
122751
122752
122753
122754
122755
122756
122757
122758
122759
122760
122761

122762
122763
122764

122765
122766
122767
122768
122769
122770
122771
122772

122773
122774
122775
122776
122777
122778
122779
122780
122781
122782
122783
122784
122785
122786

122787
122788
122789
122790
122791
122792
122793
122794
122795
122796
122797
122798
122799
122800
122801
122802
122803
122804
122805
122806
122807
122808
122809
122810
122811
122812
122813
122814
122815
122816
122817
122818
122819
122820
122821
122822
122823









122824
122825
122826
122827
122828
122829
122830
122831
122832
122833
122834
122835
122836
122837
122838
122839
122840
122841
122842
122843
122844
122845
122846







-
-
-
+
-
-

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

















-
+








-
+

-


+








+
+
+
+
+
+
+
+
+
+
+




-



-








-
+
+












-
+
+
+
+


+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







**
**   "USE TEMP B-TREE FOR xxx"
**
** where xxx is one of "DISTINCT", "ORDER BY" or "GROUP BY". Exactly which
** is determined by the zUsage argument.
*/
static void explainTempTable(Parse *pParse, const char *zUsage){
  if( pParse->explain==2 ){
    Vdbe *v = pParse->pVdbe;
    char *zMsg = sqlite3MPrintf(pParse->db, "USE TEMP B-TREE FOR %s", zUsage);
  ExplainQueryPlan((pParse, 0, "USE TEMP B-TREE FOR %s", zUsage));
    sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);
  }
}

/*
** Assign expression b to lvalue a. A second, no-op, version of this macro
** is provided when SQLITE_OMIT_EXPLAIN is defined. This allows the code
** in sqlite3Select() to assign values to structure member variables that
** only exist if SQLITE_OMIT_EXPLAIN is not defined without polluting the
** code with #ifndef directives.
*/
# define explainSetInteger(a, b) a = b

#else
/* No-op versions of the explainXXX() functions and macros. */
# define explainTempTable(y,z)
# define explainSetInteger(y,z)
#endif

#if !defined(SQLITE_OMIT_EXPLAIN) && !defined(SQLITE_OMIT_COMPOUND_SELECT)
/*
** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function
** is a no-op. Otherwise, it adds a single row of output to the EQP result,
** where the caption is of one of the two forms:
**
**   "COMPOSITE SUBQUERIES iSub1 and iSub2 (op)"
**   "COMPOSITE SUBQUERIES iSub1 and iSub2 USING TEMP B-TREE (op)"
**
** where iSub1 and iSub2 are the integers passed as the corresponding
** function parameters, and op is the text representation of the parameter
** of the same name. The parameter "op" must be one of TK_UNION, TK_EXCEPT,
** TK_INTERSECT or TK_ALL. The first form is used if argument bUseTmp is 
** false, or the second form if it is true.
*/
static void explainComposite(
  Parse *pParse,                  /* Parse context */
  int op,                         /* One of TK_UNION, TK_EXCEPT etc. */
  int iSub1,                      /* Subquery id 1 */
  int iSub2,                      /* Subquery id 2 */
  int bUseTmp                     /* True if a temp table was used */
){
  assert( op==TK_UNION || op==TK_EXCEPT || op==TK_INTERSECT || op==TK_ALL );
  if( pParse->explain==2 ){
    Vdbe *v = pParse->pVdbe;
    char *zMsg = sqlite3MPrintf(
        pParse->db, "COMPOUND SUBQUERIES %d AND %d %s(%s)", iSub1, iSub2,
        bUseTmp?"USING TEMP B-TREE ":"", selectOpName(op)
    );
    sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);
  }
}
#else
/* No-op versions of the explainXXX() functions and macros. */
# define explainComposite(v,w,x,y,z)
#endif

/*
** If the inner loop was generated using a non-null pOrderBy argument,
** then the results were placed in a sorter.  After the loop is terminated
** we need to run the sorter and output the results.  The following
** routine generates the code needed to do that.
*/
static void generateSortTail(
  Parse *pParse,    /* Parsing context */
  Select *p,        /* The SELECT statement */
  SortCtx *pSort,   /* Information on the ORDER BY clause */
  int nColumn,      /* Number of columns of data */
  SelectDest *pDest /* Write the sorted results here */
){
  Vdbe *v = pParse->pVdbe;                     /* The prepared statement */
  int addrBreak = pSort->labelDone;            /* Jump here to exit loop */
  int addrContinue = sqlite3VdbeMakeLabel(v);  /* Jump here for next cycle */
  int addr;
  int addr;                       /* Top of output loop. Jump for Next. */
  int addrOnce = 0;
  int iTab;
  ExprList *pOrderBy = pSort->pOrderBy;
  int eDest = pDest->eDest;
  int iParm = pDest->iSDParm;
  int regRow;
  int regRowid;
  int iCol;
  int nKey;
  int nKey;                       /* Number of key columns in sorter record */
  int iSortTab;                   /* Sorter cursor to read from */
  int nSortData;                  /* Trailing values to read from sorter */
  int i;
  int bSeq;                       /* True if sorter record includes seq. no. */
  int nRefKey = 0;
  struct ExprList_item *aOutEx = p->pEList->a;

  assert( addrBreak<0 );
  if( pSort->labelBkOut ){
    sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
    sqlite3VdbeGoto(v, addrBreak);
    sqlite3VdbeResolveLabel(v, pSort->labelBkOut);
  }

#ifdef SQLITE_ENABLE_SORTER_REFERENCES
  /* Open any cursors needed for sorter-reference expressions */
  for(i=0; i<pSort->nDefer; i++){
    Table *pTab = pSort->aDefer[i].pTab;
    int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
    sqlite3OpenTable(pParse, pSort->aDefer[i].iCsr, iDb, pTab, OP_OpenRead);
    nRefKey = MAX(nRefKey, pSort->aDefer[i].nKey);
  }
#endif

  iTab = pSort->iECursor;
  if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){
    regRowid = 0;
    regRow = pDest->iSdst;
    nSortData = nColumn;
  }else{
    regRowid = sqlite3GetTempReg(pParse);
    regRow = sqlite3GetTempRange(pParse, nColumn);
    nSortData = nColumn;
  }
  nKey = pOrderBy->nExpr - pSort->nOBSat;
  if( pSort->sortFlags & SORTFLAG_UseSorter ){
    int regSortOut = ++pParse->nMem;
    iSortTab = pParse->nTab++;
    if( pSort->labelBkOut ){
      addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
    }
    sqlite3VdbeAddOp3(v, OP_OpenPseudo, iSortTab, regSortOut, nKey+1+nSortData);
    sqlite3VdbeAddOp3(v, OP_OpenPseudo, iSortTab, regSortOut, 
        nKey+1+nColumn+nRefKey);
    if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);
    addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak);
    VdbeCoverage(v);
    codeOffset(v, p->iOffset, addrContinue);
    sqlite3VdbeAddOp3(v, OP_SorterData, iTab, regSortOut, iSortTab);
    bSeq = 0;
  }else{
    addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, addrBreak); VdbeCoverage(v);
    codeOffset(v, p->iOffset, addrContinue);
    iSortTab = iTab;
    bSeq = 1;
  }
  for(i=0, iCol=nKey+bSeq-1; i<nSortData; i++){
  for(i=0, iCol=nKey+bSeq-1; i<nColumn; i++){
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
    if( aOutEx[i].bSorterRef ) continue;
#endif
    if( aOutEx[i].u.x.iOrderByCol==0 ) iCol++;
  }
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
  if( pSort->nDefer ){
    int iKey = iCol+1;
    int regKey = sqlite3GetTempRange(pParse, nRefKey);

    for(i=0; i<pSort->nDefer; i++){
      int iCsr = pSort->aDefer[i].iCsr;
      Table *pTab = pSort->aDefer[i].pTab;
      int nKey = pSort->aDefer[i].nKey;

      sqlite3VdbeAddOp1(v, OP_NullRow, iCsr);
      if( HasRowid(pTab) ){
        sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iKey++, regKey);
        sqlite3VdbeAddOp3(v, OP_SeekRowid, iCsr, 
            sqlite3VdbeCurrentAddr(v)+1, regKey);
      }else{
        int k;
        int iJmp;
        assert( sqlite3PrimaryKeyIndex(pTab)->nKeyCol==nKey );
        for(k=0; k<nKey; k++){
          sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iKey++, regKey+k);
        }
        iJmp = sqlite3VdbeCurrentAddr(v);
        sqlite3VdbeAddOp4Int(v, OP_SeekGE, iCsr, iJmp+2, regKey, nKey);
        sqlite3VdbeAddOp4Int(v, OP_IdxLE, iCsr, iJmp+3, regKey, nKey);
        sqlite3VdbeAddOp1(v, OP_NullRow, iCsr);
      }
    }
    sqlite3ReleaseTempRange(pParse, regKey, nRefKey);
  }
#endif
  for(i=nSortData-1; i>=0; i--){
    int iRead;
    if( aOutEx[i].u.x.iOrderByCol ){
      iRead = aOutEx[i].u.x.iOrderByCol-1;
    }else{
      iRead = iCol--;
    }
    sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iRead, regRow+i);
    VdbeComment((v, "%s", aOutEx[i].zName ? aOutEx[i].zName : aOutEx[i].zSpan));
  for(i=nColumn-1; i>=0; i--){
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
    if( aOutEx[i].bSorterRef ){
      sqlite3ExprCode(pParse, aOutEx[i].pExpr, regRow+i);
    }else
#endif
    {
      int iRead;
      if( aOutEx[i].u.x.iOrderByCol ){
        iRead = aOutEx[i].u.x.iOrderByCol-1;
      }else{
        iRead = iCol--;
      }
      sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iRead, regRow+i);
      VdbeComment((v, "%s", aOutEx[i].zName?aOutEx[i].zName : aOutEx[i].zSpan));
    }
  }
  switch( eDest ){
    case SRT_Table:
    case SRT_EphemTab: {
      sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid);
      sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid);
      sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
121935
121936
121937
121938
121939
121940
121941
121942

121943
121944
121945
121946
121947
121948
121949
123150
123151
123152
123153
123154
123155
123156

123157
123158
123159
123160
123161
123162
123163
123164







-
+







#ifndef SQLITE_OMIT_EXPLAIN
  /* If this is an EXPLAIN, skip this step */
  if( pParse->explain ){
    return;
  }
#endif

  if( pParse->colNamesSet || db->mallocFailed ) return;
  if( pParse->colNamesSet ) return;
  /* Column names are determined by the left-most term of a compound select */
  while( pSelect->pPrior ) pSelect = pSelect->pPrior;
  SELECTTRACE(1,pParse,pSelect,("generating column names\n"));
  pTabList = pSelect->pSrc;
  pEList = pSelect->pEList;
  assert( v!=0 );
  assert( pTabList!=0 );
122462
122463
122464
122465
122466
122467
122468

122469
122470
122471
122472
122473
122474
122475
123677
123678
123679
123680
123681
123682
123683
123684
123685
123686
123687
123688
123689
123690
123691







+







  }

  /* Detach the ORDER BY clause from the compound SELECT */
  p->pOrderBy = 0;

  /* Store the results of the setup-query in Queue. */
  pSetup->pNext = 0;
  ExplainQueryPlan((pParse, 1, "SETUP"));
  rc = sqlite3Select(pParse, pSetup, &destQueue);
  pSetup->pNext = p;
  if( rc ) goto end_of_recursive_query;

  /* Find the next row in the Queue and output that row */
  addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, iQueue, addrBreak); VdbeCoverage(v);

122496
122497
122498
122499
122500
122501
122502

122503
122504
122505
122506
122507
122508
122509
123712
123713
123714
123715
123716
123717
123718
123719
123720
123721
123722
123723
123724
123725
123726







+







  /* Execute the recursive SELECT taking the single row in Current as
  ** the value for the recursive-table. Store the results in the Queue.
  */
  if( p->selFlags & SF_Aggregate ){
    sqlite3ErrorMsg(pParse, "recursive aggregate queries not supported");
  }else{
    p->pPrior = 0;
    ExplainQueryPlan((pParse, 1, "RECURSIVE STEP"));
    sqlite3Select(pParse, p, &destQueue);
    assert( p->pPrior==0 );
    p->pPrior = pSetup;
  }

  /* Keep running the loop until the Queue is empty */
  sqlite3VdbeGoto(v, addrTop);
122541
122542
122543
122544
122545
122546
122547
122548
122549
122550
122551

122552
122553
122554
122555
122556
122557
122558
122559
122560

122561


122562
122563
122564
122565

122566
122567

122568
122569
122570
122571
122572
122573
122574
123758
123759
123760
123761
123762
123763
123764


123765
123766
123767
123768
123769
123770
123771
123772
123773
123774
123775

123776
123777
123778
123779
123780



123781


123782
123783
123784
123785
123786
123787
123788
123789







-
-


+








-
+

+
+

-
-
-
+
-
-
+







** Since the limit is exactly 1, we only need to evalutes the left-most VALUES.
*/
static int multiSelectValues(
  Parse *pParse,        /* Parsing context */
  Select *p,            /* The right-most of SELECTs to be coded */
  SelectDest *pDest     /* What to do with query results */
){
  Select *pPrior;
  Select *pRightmost = p;
  int nRow = 1;
  int rc = 0;
  int bShowAll = p->pLimit==0;
  assert( p->selFlags & SF_MultiValue );
  do{
    assert( p->selFlags & SF_Values );
    assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) );
    assert( p->pNext==0 || p->pEList->nExpr==p->pNext->pEList->nExpr );
    if( p->pPrior==0 ) break;
    assert( p->pPrior->pNext==p );
    p = p->pPrior;
    nRow++;
    nRow += bShowAll;
  }while(1);
  ExplainQueryPlan((pParse, 0, "SCAN %d CONSTANT ROW%s", nRow,
                    nRow==1 ? "" : "S"));
  while( p ){
    pPrior = p->pPrior;
    p->pPrior = 0;
    rc = sqlite3Select(pParse, p, pDest);
    selectInnerLoop(pParse, p, -1, 0, 0, pDest, 1, 1);
    p->pPrior = pPrior;
    if( rc || pRightmost->pLimit ) break;
    if( !bShowAll ) break;
    p->nSelectRow = nRow;
    p = p->pNext;
  }
  return rc;
}

/*
122609
122610
122611
122612
122613
122614
122615
122616
122617
122618
122619
122620
122621
122622
122623
122624
122625
122626
123824
123825
123826
123827
123828
123829
123830




123831
123832
123833
123834
123835
123836
123837







-
-
-
-







){
  int rc = SQLITE_OK;   /* Success code from a subroutine */
  Select *pPrior;       /* Another SELECT immediately to our left */
  Vdbe *v;              /* Generate code to this VDBE */
  SelectDest dest;      /* Alternative data destination */
  Select *pDelete = 0;  /* Chain of simple selects to delete */
  sqlite3 *db;          /* Database connection */
#ifndef SQLITE_OMIT_EXPLAIN
  int iSub1 = 0;        /* EQP id of left-hand query */
  int iSub2 = 0;        /* EQP id of right-hand query */
#endif

  /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs.  Only
  ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.
  */
  assert( p && p->pPrior );  /* Calling function guarantees this much */
  assert( (p->selFlags & SF_Recursive)==0 || p->op==TK_ALL || p->op==TK_UNION );
  db = pParse->db;
122663
122664
122665
122666
122667
122668
122669
122670

122671







122672
122673
122674
122675
122676
122677
122678
122679
122680
122681










122682
122683
122684
122685
122686
122687
122688
122689
122690
122691
122692
122693
122694
122695
122696
122697
122698
122699
122700
122701
122702
122703
122704
122705
122706
122707
122708
122709
122710
122711
122712
122713
122714
122715
122716
122717
122718
122719
122720
122721
122722
122723
122724
122725
122726
122727
122728
122729
122730
122731
122732
122733
122734
122735
122736
122737
122738
122739
122740
122741
122742
122743
122744
122745
122746
122747
122748
122749
122750




































































122751
122752
122753
122754
122755
122756
122757
122758
122759
122760
122761
122762
122763
122764
122765
122766
122767
122768
122769
122770
122771
122772
122773
122774
122775
122776
122777
122778
122779
122780
122781
122782
122783
122784
122785
122786
122787
122788
122789
122790
122791
122792
122793
122794
122795
122796
122797
122798
122799
122800
122801
122802
122803
122804
122805
122806
122807
122808
122809
122810
122811
122812
122813
122814
122815
122816
122817
122818
122819
122820
122821
122822
122823
122824
122825
122826
122827
122828
122829
122830
122831

















































































122832
122833
122834
122835
122836
122837
122838
122839
122840
122841
122842
122843
122844
122845
122846
122847
122848
122849
122850
122851
122852
122853
122854
122855
122856
122857
122858
122859
122860
122861
122862
122863
122864
122865
122866
122867
122868
122869
122870
122871
122872
122873
122874
122875
122876
122877
122878
122879
122880

























































122881
122882
122883
122884
122885
122886
122887
123874
123875
123876
123877
123878
123879
123880

123881
123882
123883
123884
123885
123886
123887
123888
123889










123890
123891
123892
123893
123894
123895
123896
123897
123898
123899





































































123900
123901
123902
123903
123904
123905
123906
123907
123908
123909
123910
123911
123912
123913
123914
123915
123916
123917
123918
123919
123920
123921
123922
123923
123924
123925
123926
123927
123928
123929
123930
123931
123932
123933
123934
123935
123936
123937
123938
123939
123940
123941
123942
123943
123944
123945
123946
123947
123948
123949
123950
123951
123952
123953
123954
123955
123956
123957
123958
123959
123960
123961
123962
123963
123964
123965
123966
123967

















































































123968
123969
123970
123971
123972
123973
123974
123975
123976
123977
123978
123979
123980
123981
123982
123983
123984
123985
123986
123987
123988
123989
123990
123991
123992
123993
123994
123995
123996
123997
123998
123999
124000
124001
124002
124003
124004
124005
124006
124007
124008
124009
124010
124011
124012
124013
124014
124015
124016
124017
124018
124019
124020
124021
124022
124023
124024
124025
124026
124027
124028
124029
124030
124031
124032
124033
124034
124035
124036
124037
124038
124039
124040
124041
124042
124043
124044
124045
124046
124047
124048

















































124049
124050
124051
124052
124053
124054
124055
124056
124057
124058
124059
124060
124061
124062
124063
124064
124065
124066
124067
124068
124069
124070
124071
124072
124073
124074
124075
124076
124077
124078
124079
124080
124081
124082
124083
124084
124085
124086
124087
124088
124089
124090
124091
124092
124093
124094
124095
124096
124097
124098
124099
124100
124101
124102
124103
124104
124105
124106
124107
124108
124109
124110
124111
124112







-
+

+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  }else
#endif

  /* Compound SELECTs that have an ORDER BY clause are handled separately.
  */
  if( p->pOrderBy ){
    return multiSelectOrderBy(pParse, p, pDest);
  }else
  }else{

#ifndef SQLITE_OMIT_EXPLAIN
    if( pPrior->pPrior==0 ){
      ExplainQueryPlan((pParse, 1, "COMPOUND QUERY"));
      ExplainQueryPlan((pParse, 1, "LEFT-MOST SUBQUERY"));
    }
#endif

  /* Generate code for the left and right SELECT statements.
  */
  switch( p->op ){
    case TK_ALL: {
      int addr = 0;
      int nLimit;
      assert( !pPrior->pLimit );
      pPrior->iLimit = p->iLimit;
      pPrior->iOffset = p->iOffset;
      pPrior->pLimit = p->pLimit;
    /* Generate code for the left and right SELECT statements.
    */
    switch( p->op ){
      case TK_ALL: {
        int addr = 0;
        int nLimit;
        assert( !pPrior->pLimit );
        pPrior->iLimit = p->iLimit;
        pPrior->iOffset = p->iOffset;
        pPrior->pLimit = p->pLimit;
      explainSetInteger(iSub1, pParse->iNextSelectId);
      rc = sqlite3Select(pParse, pPrior, &dest);
      p->pLimit = 0;
      if( rc ){
        goto multi_select_end;
      }
      p->pPrior = 0;
      p->iLimit = pPrior->iLimit;
      p->iOffset = pPrior->iOffset;
      if( p->iLimit ){
        addr = sqlite3VdbeAddOp1(v, OP_IfNot, p->iLimit); VdbeCoverage(v);
        VdbeComment((v, "Jump ahead if LIMIT reached"));
        if( p->iOffset ){
          sqlite3VdbeAddOp3(v, OP_OffsetLimit,
                            p->iLimit, p->iOffset+1, p->iOffset);
        }
      }
      explainSetInteger(iSub2, pParse->iNextSelectId);
      rc = sqlite3Select(pParse, p, &dest);
      testcase( rc!=SQLITE_OK );
      pDelete = p->pPrior;
      p->pPrior = pPrior;
      p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
      if( pPrior->pLimit
       && sqlite3ExprIsInteger(pPrior->pLimit->pLeft, &nLimit)
       && nLimit>0 && p->nSelectRow > sqlite3LogEst((u64)nLimit) 
      ){
        p->nSelectRow = sqlite3LogEst((u64)nLimit);
      }
      if( addr ){
        sqlite3VdbeJumpHere(v, addr);
      }
      break;
    }
    case TK_EXCEPT:
    case TK_UNION: {
      int unionTab;    /* Cursor number of the temporary table holding result */
      u8 op = 0;       /* One of the SRT_ operations to apply to self */
      int priorOp;     /* The SRT_ operation to apply to prior selects */
      Expr *pLimit;    /* Saved values of p->nLimit  */
      int addr;
      SelectDest uniondest;

      testcase( p->op==TK_EXCEPT );
      testcase( p->op==TK_UNION );
      priorOp = SRT_Union;
      if( dest.eDest==priorOp ){
        /* We can reuse a temporary table generated by a SELECT to our
        ** right.
        */
        assert( p->pLimit==0 );      /* Not allowed on leftward elements */
        unionTab = dest.iSDParm;
      }else{
        /* We will need to create our own temporary table to hold the
        ** intermediate results.
        */
        unionTab = pParse->nTab++;
        assert( p->pOrderBy==0 );
        addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, unionTab, 0);
        assert( p->addrOpenEphm[0] == -1 );
        p->addrOpenEphm[0] = addr;
        findRightmost(p)->selFlags |= SF_UsesEphemeral;
        assert( p->pEList );
      }

      /* Code the SELECT statements to our left
      */
      assert( !pPrior->pOrderBy );
      sqlite3SelectDestInit(&uniondest, priorOp, unionTab);
        rc = sqlite3Select(pParse, pPrior, &dest);
        p->pLimit = 0;
        if( rc ){
          goto multi_select_end;
        }
        p->pPrior = 0;
        p->iLimit = pPrior->iLimit;
        p->iOffset = pPrior->iOffset;
        if( p->iLimit ){
          addr = sqlite3VdbeAddOp1(v, OP_IfNot, p->iLimit); VdbeCoverage(v);
          VdbeComment((v, "Jump ahead if LIMIT reached"));
          if( p->iOffset ){
            sqlite3VdbeAddOp3(v, OP_OffsetLimit,
                              p->iLimit, p->iOffset+1, p->iOffset);
          }
        }
        ExplainQueryPlan((pParse, 1, "UNION ALL"));
        rc = sqlite3Select(pParse, p, &dest);
        testcase( rc!=SQLITE_OK );
        pDelete = p->pPrior;
        p->pPrior = pPrior;
        p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
        if( pPrior->pLimit
         && sqlite3ExprIsInteger(pPrior->pLimit->pLeft, &nLimit)
         && nLimit>0 && p->nSelectRow > sqlite3LogEst((u64)nLimit) 
        ){
          p->nSelectRow = sqlite3LogEst((u64)nLimit);
        }
        if( addr ){
          sqlite3VdbeJumpHere(v, addr);
        }
        break;
      }
      case TK_EXCEPT:
      case TK_UNION: {
        int unionTab;    /* Cursor number of the temp table holding result */
        u8 op = 0;       /* One of the SRT_ operations to apply to self */
        int priorOp;     /* The SRT_ operation to apply to prior selects */
        Expr *pLimit;    /* Saved values of p->nLimit  */
        int addr;
        SelectDest uniondest;
  
        testcase( p->op==TK_EXCEPT );
        testcase( p->op==TK_UNION );
        priorOp = SRT_Union;
        if( dest.eDest==priorOp ){
          /* We can reuse a temporary table generated by a SELECT to our
          ** right.
          */
          assert( p->pLimit==0 );      /* Not allowed on leftward elements */
          unionTab = dest.iSDParm;
        }else{
          /* We will need to create our own temporary table to hold the
          ** intermediate results.
          */
          unionTab = pParse->nTab++;
          assert( p->pOrderBy==0 );
          addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, unionTab, 0);
          assert( p->addrOpenEphm[0] == -1 );
          p->addrOpenEphm[0] = addr;
          findRightmost(p)->selFlags |= SF_UsesEphemeral;
          assert( p->pEList );
        }
  
        /* Code the SELECT statements to our left
        */
        assert( !pPrior->pOrderBy );
        sqlite3SelectDestInit(&uniondest, priorOp, unionTab);
      explainSetInteger(iSub1, pParse->iNextSelectId);
      rc = sqlite3Select(pParse, pPrior, &uniondest);
      if( rc ){
        goto multi_select_end;
      }

      /* Code the current SELECT statement
      */
      if( p->op==TK_EXCEPT ){
        op = SRT_Except;
      }else{
        assert( p->op==TK_UNION );
        op = SRT_Union;
      }
      p->pPrior = 0;
      pLimit = p->pLimit;
      p->pLimit = 0;
      uniondest.eDest = op;
      explainSetInteger(iSub2, pParse->iNextSelectId);
      rc = sqlite3Select(pParse, p, &uniondest);
      testcase( rc!=SQLITE_OK );
      /* Query flattening in sqlite3Select() might refill p->pOrderBy.
      ** Be sure to delete p->pOrderBy, therefore, to avoid a memory leak. */
      sqlite3ExprListDelete(db, p->pOrderBy);
      pDelete = p->pPrior;
      p->pPrior = pPrior;
      p->pOrderBy = 0;
      if( p->op==TK_UNION ){
        p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
      }
      sqlite3ExprDelete(db, p->pLimit);
      p->pLimit = pLimit;
      p->iLimit = 0;
      p->iOffset = 0;

      /* Convert the data in the temporary table into whatever form
      ** it is that we currently need.
      */
      assert( unionTab==dest.iSDParm || dest.eDest!=priorOp );
      if( dest.eDest!=priorOp ){
        int iCont, iBreak, iStart;
        assert( p->pEList );
        iBreak = sqlite3VdbeMakeLabel(v);
        iCont = sqlite3VdbeMakeLabel(v);
        computeLimitRegisters(pParse, p, iBreak);
        sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v);
        iStart = sqlite3VdbeCurrentAddr(v);
        selectInnerLoop(pParse, p, unionTab,
                        0, 0, &dest, iCont, iBreak);
        sqlite3VdbeResolveLabel(v, iCont);
        sqlite3VdbeAddOp2(v, OP_Next, unionTab, iStart); VdbeCoverage(v);
        sqlite3VdbeResolveLabel(v, iBreak);
        sqlite3VdbeAddOp2(v, OP_Close, unionTab, 0);
      }
      break;
    }
    default: assert( p->op==TK_INTERSECT ); {
      int tab1, tab2;
      int iCont, iBreak, iStart;
      Expr *pLimit;
      int addr;
      SelectDest intersectdest;
      int r1;

      /* INTERSECT is different from the others since it requires
      ** two temporary tables.  Hence it has its own case.  Begin
      ** by allocating the tables we will need.
      */
      tab1 = pParse->nTab++;
      tab2 = pParse->nTab++;
      assert( p->pOrderBy==0 );

      addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab1, 0);
      assert( p->addrOpenEphm[0] == -1 );
      p->addrOpenEphm[0] = addr;
      findRightmost(p)->selFlags |= SF_UsesEphemeral;
      assert( p->pEList );

      /* Code the SELECTs to our left into temporary table "tab1".
      */
      sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1);
        rc = sqlite3Select(pParse, pPrior, &uniondest);
        if( rc ){
          goto multi_select_end;
        }
  
        /* Code the current SELECT statement
        */
        if( p->op==TK_EXCEPT ){
          op = SRT_Except;
        }else{
          assert( p->op==TK_UNION );
          op = SRT_Union;
        }
        p->pPrior = 0;
        pLimit = p->pLimit;
        p->pLimit = 0;
        uniondest.eDest = op;
        ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
                          selectOpName(p->op)));
        rc = sqlite3Select(pParse, p, &uniondest);
        testcase( rc!=SQLITE_OK );
        /* Query flattening in sqlite3Select() might refill p->pOrderBy.
        ** Be sure to delete p->pOrderBy, therefore, to avoid a memory leak. */
        sqlite3ExprListDelete(db, p->pOrderBy);
        pDelete = p->pPrior;
        p->pPrior = pPrior;
        p->pOrderBy = 0;
        if( p->op==TK_UNION ){
          p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
        }
        sqlite3ExprDelete(db, p->pLimit);
        p->pLimit = pLimit;
        p->iLimit = 0;
        p->iOffset = 0;
  
        /* Convert the data in the temporary table into whatever form
        ** it is that we currently need.
        */
        assert( unionTab==dest.iSDParm || dest.eDest!=priorOp );
        if( dest.eDest!=priorOp ){
          int iCont, iBreak, iStart;
          assert( p->pEList );
          iBreak = sqlite3VdbeMakeLabel(v);
          iCont = sqlite3VdbeMakeLabel(v);
          computeLimitRegisters(pParse, p, iBreak);
          sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v);
          iStart = sqlite3VdbeCurrentAddr(v);
          selectInnerLoop(pParse, p, unionTab,
                          0, 0, &dest, iCont, iBreak);
          sqlite3VdbeResolveLabel(v, iCont);
          sqlite3VdbeAddOp2(v, OP_Next, unionTab, iStart); VdbeCoverage(v);
          sqlite3VdbeResolveLabel(v, iBreak);
          sqlite3VdbeAddOp2(v, OP_Close, unionTab, 0);
        }
        break;
      }
      default: assert( p->op==TK_INTERSECT ); {
        int tab1, tab2;
        int iCont, iBreak, iStart;
        Expr *pLimit;
        int addr;
        SelectDest intersectdest;
        int r1;
  
        /* INTERSECT is different from the others since it requires
        ** two temporary tables.  Hence it has its own case.  Begin
        ** by allocating the tables we will need.
        */
        tab1 = pParse->nTab++;
        tab2 = pParse->nTab++;
        assert( p->pOrderBy==0 );
  
        addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab1, 0);
        assert( p->addrOpenEphm[0] == -1 );
        p->addrOpenEphm[0] = addr;
        findRightmost(p)->selFlags |= SF_UsesEphemeral;
        assert( p->pEList );
  
        /* Code the SELECTs to our left into temporary table "tab1".
        */
        sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1);
      explainSetInteger(iSub1, pParse->iNextSelectId);
      rc = sqlite3Select(pParse, pPrior, &intersectdest);
      if( rc ){
        goto multi_select_end;
      }

      /* Code the current SELECT into temporary table "tab2"
      */
      addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);
      assert( p->addrOpenEphm[1] == -1 );
      p->addrOpenEphm[1] = addr;
      p->pPrior = 0;
      pLimit = p->pLimit;
      p->pLimit = 0;
      intersectdest.iSDParm = tab2;
      explainSetInteger(iSub2, pParse->iNextSelectId);
      rc = sqlite3Select(pParse, p, &intersectdest);
      testcase( rc!=SQLITE_OK );
      pDelete = p->pPrior;
      p->pPrior = pPrior;
      if( p->nSelectRow>pPrior->nSelectRow ) p->nSelectRow = pPrior->nSelectRow;
      sqlite3ExprDelete(db, p->pLimit);
      p->pLimit = pLimit;

      /* Generate code to take the intersection of the two temporary
      ** tables.
      */
      assert( p->pEList );
      iBreak = sqlite3VdbeMakeLabel(v);
      iCont = sqlite3VdbeMakeLabel(v);
      computeLimitRegisters(pParse, p, iBreak);
      sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); VdbeCoverage(v);
      r1 = sqlite3GetTempReg(pParse);
      iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);
      sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0); VdbeCoverage(v);
      sqlite3ReleaseTempReg(pParse, r1);
      selectInnerLoop(pParse, p, tab1,
                      0, 0, &dest, iCont, iBreak);
      sqlite3VdbeResolveLabel(v, iCont);
      sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart); VdbeCoverage(v);
      sqlite3VdbeResolveLabel(v, iBreak);
      sqlite3VdbeAddOp2(v, OP_Close, tab2, 0);
      sqlite3VdbeAddOp2(v, OP_Close, tab1, 0);
      break;
    }
  }

  explainComposite(pParse, p->op, iSub1, iSub2, p->op!=TK_ALL);

        rc = sqlite3Select(pParse, pPrior, &intersectdest);
        if( rc ){
          goto multi_select_end;
        }
  
        /* Code the current SELECT into temporary table "tab2"
        */
        addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);
        assert( p->addrOpenEphm[1] == -1 );
        p->addrOpenEphm[1] = addr;
        p->pPrior = 0;
        pLimit = p->pLimit;
        p->pLimit = 0;
        intersectdest.iSDParm = tab2;
        ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
                          selectOpName(p->op)));
        rc = sqlite3Select(pParse, p, &intersectdest);
        testcase( rc!=SQLITE_OK );
        pDelete = p->pPrior;
        p->pPrior = pPrior;
        if( p->nSelectRow>pPrior->nSelectRow ){
          p->nSelectRow = pPrior->nSelectRow;
        }
        sqlite3ExprDelete(db, p->pLimit);
        p->pLimit = pLimit;
  
        /* Generate code to take the intersection of the two temporary
        ** tables.
        */
        assert( p->pEList );
        iBreak = sqlite3VdbeMakeLabel(v);
        iCont = sqlite3VdbeMakeLabel(v);
        computeLimitRegisters(pParse, p, iBreak);
        sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); VdbeCoverage(v);
        r1 = sqlite3GetTempReg(pParse);
        iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);
        sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0);
        VdbeCoverage(v);
        sqlite3ReleaseTempReg(pParse, r1);
        selectInnerLoop(pParse, p, tab1,
                        0, 0, &dest, iCont, iBreak);
        sqlite3VdbeResolveLabel(v, iCont);
        sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart); VdbeCoverage(v);
        sqlite3VdbeResolveLabel(v, iBreak);
        sqlite3VdbeAddOp2(v, OP_Close, tab2, 0);
        sqlite3VdbeAddOp2(v, OP_Close, tab1, 0);
        break;
      }
    }
  
  #ifndef SQLITE_OMIT_EXPLAIN
    if( p->pNext==0 ){
      ExplainQueryPlanPop(pParse);
    }
  #endif
  }
  
  /* Compute collating sequences used by 
  ** temporary tables needed to implement the compound select.
  ** Attach the KeyInfo structure to all temporary tables.
  **
  ** This section is run by the right-most SELECT statement only.
  ** SELECT statements to the left always skip this part.  The right-most
  ** SELECT might also skip this part if it has no ORDER BY clause and
123211
123212
123213
123214
123215
123216
123217
123218
123219
123220
123221
123222
123223
123224
123225
123226
123227
123228
124436
124437
124438
124439
124440
124441
124442




124443
124444
124445
124446
124447
124448
124449







-
-
-
-







  int op;               /* One of TK_ALL, TK_UNION, TK_EXCEPT, TK_INTERSECT */
  KeyInfo *pKeyDup = 0; /* Comparison information for duplicate removal */
  KeyInfo *pKeyMerge;   /* Comparison information for merging rows */
  sqlite3 *db;          /* Database connection */
  ExprList *pOrderBy;   /* The ORDER BY clause */
  int nOrderBy;         /* Number of terms in the ORDER BY clause */
  int *aPermute;        /* Mapping from ORDER BY terms to result set columns */
#ifndef SQLITE_OMIT_EXPLAIN
  int iSub1;            /* EQP id of left-hand query */
  int iSub2;            /* EQP id of right-hand query */
#endif

  assert( p->pOrderBy!=0 );
  assert( pKeyDup==0 ); /* "Managed" code needs this.  Ticket #3382. */
  db = pParse->db;
  v = pParse->pVdbe;
  assert( v!=0 );       /* Already thrown the error if VDBE alloc failed */
  labelEnd = sqlite3VdbeMakeLabel(v);
123334
123335
123336
123337
123338
123339
123340


123341
123342
123343
123344
123345
123346
123347
123348

123349
123350
123351
123352
123353
123354
123355
123356
123357
123358
123359
123360
123361
123362
123363

123364
123365
123366
123367
123368
123369
123370
124555
124556
124557
124558
124559
124560
124561
124562
124563
124564
124565
124566
124567
124568
124569
124570

124571
124572
124573
124574
124575
124576
124577
124578
124579
124580
124581
124582
124583
124584
124585

124586
124587
124588
124589
124590
124591
124592
124593







+
+







-
+














-
+







  regAddrA = ++pParse->nMem;
  regAddrB = ++pParse->nMem;
  regOutA = ++pParse->nMem;
  regOutB = ++pParse->nMem;
  sqlite3SelectDestInit(&destA, SRT_Coroutine, regAddrA);
  sqlite3SelectDestInit(&destB, SRT_Coroutine, regAddrB);

  ExplainQueryPlan((pParse, 1, "MERGE (%s)", selectOpName(p->op)));

  /* Generate a coroutine to evaluate the SELECT statement to the
  ** left of the compound operator - the "A" select.
  */
  addrSelectA = sqlite3VdbeCurrentAddr(v) + 1;
  addr1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrA, 0, addrSelectA);
  VdbeComment((v, "left SELECT"));
  pPrior->iLimit = regLimitA;
  explainSetInteger(iSub1, pParse->iNextSelectId);
  ExplainQueryPlan((pParse, 1, "LEFT"));
  sqlite3Select(pParse, pPrior, &destA);
  sqlite3VdbeEndCoroutine(v, regAddrA);
  sqlite3VdbeJumpHere(v, addr1);

  /* Generate a coroutine to evaluate the SELECT statement on 
  ** the right - the "B" select
  */
  addrSelectB = sqlite3VdbeCurrentAddr(v) + 1;
  addr1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrB, 0, addrSelectB);
  VdbeComment((v, "right SELECT"));
  savedLimit = p->iLimit;
  savedOffset = p->iOffset;
  p->iLimit = regLimitB;
  p->iOffset = 0;  
  explainSetInteger(iSub2, pParse->iNextSelectId);
  ExplainQueryPlan((pParse, 1, "RIGHT"));
  sqlite3Select(pParse, p, &destB);
  p->iLimit = savedLimit;
  p->iOffset = savedOffset;
  sqlite3VdbeEndCoroutine(v, regAddrB);

  /* Generate a subroutine that outputs the current row of the A
  ** select as the next output row of the compound select.
123468
123469
123470
123471
123472
123473
123474
123475

123476
123477
123478
123479
123480
123481
123482
124691
124692
124693
124694
124695
124696
124697

124698
124699
124700
124701
124702
124703
124704
124705







-
+







    sqlite3SelectDelete(db, p->pPrior);
  }
  p->pPrior = pPrior;
  pPrior->pNext = p;

  /*** TBD:  Insert subroutine calls to close cursors on incomplete
  **** subqueries ****/
  explainComposite(pParse, p->op, iSub1, iSub2, 0);
  ExplainQueryPlanPop(pParse);
  return pParse->nErr!=0;
}
#endif

#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)

/* An instance of the SubstContext object describes an substitution edit
123955
123956
123957
123958
123959
123960
123961
123962

123963
123964

123965
123966
123967
123968
123969
123970
123971
125178
125179
125180
125181
125182
125183
125184

125185


125186
125187
125188
125189
125190
125191
125192
125193







-
+
-
-
+







    if( pNew==0 ){
      p->pPrior = pPrior;
    }else{
      pNew->pPrior = pPrior;
      if( pPrior ) pPrior->pNext = pNew;
      pNew->pNext = p;
      p->pPrior = pNew;
      SELECTTRACE(2,pParse,p,
      SELECTTRACE(2,pParse,p,("compound-subquery flattener"
         ("compound-subquery flattener creates %s.%p as peer\n",
         pNew->zSelName, pNew));
                              " creates %s.%p as peer\n",pNew->zSelName, pNew));
    }
    if( db->mallocFailed ) return 1;
  }

  /* Begin flattening the iFrom-th entry of the FROM clause 
  ** in the outer query.
  */
125257
125258
125259
125260
125261
125262
125263
125264

125265
125266
125267
125268
125269
125270
125271
125272
125273
125274
125275
125276
125277
125278
126479
126480
126481
126482
126483
126484
126485

126486
126487
126488
126489
126490



126491
126492
126493
126494
126495
126496
126497







-
+




-
-
-







static void explainSimpleCount(
  Parse *pParse,                  /* Parse context */
  Table *pTab,                    /* Table being queried */
  Index *pIdx                     /* Index used to optimize scan, or NULL */
){
  if( pParse->explain==2 ){
    int bCover = (pIdx!=0 && (HasRowid(pTab) || !IsPrimaryKeyIndex(pIdx)));
    char *zEqp = sqlite3MPrintf(pParse->db, "SCAN TABLE %s%s%s",
    sqlite3VdbeExplain(pParse, 0, "SCAN TABLE %s%s%s",
        pTab->zName,
        bCover ? " USING COVERING INDEX " : "",
        bCover ? pIdx->zName : ""
    );
    sqlite3VdbeAddOp4(
        pParse->pVdbe, OP_Explain, pParse->iSelectId, 0, 0, zEqp, P4_DYNAMIC
    );
  }
}
#else
# define explainSimpleCount(a,b,c)
#endif

/*
125477
125478
125479
125480
125481
125482
125483
125484
125485
125486
125487
125488
125489

125490
125491
125492
125493
125494
125495
125496

125497
125498
125499
125500
125501
125502
125503
126696
126697
126698
126699
126700
126701
126702





126703
126704
126705
126706
126707
126708
126709
126710

126711
126712
126713
126714
126715
126716
126717
126718







-
-
-
-
-

+






-
+







  SortCtx sSort;         /* Info on how to code the ORDER BY clause */
  AggInfo sAggInfo;      /* Information used by aggregate queries */
  int iEnd;              /* Address of the end of the query */
  sqlite3 *db;           /* The database connection */
  ExprList *pMinMaxOrderBy = 0;  /* Added ORDER BY for min/max queries */
  u8 minMaxFlag;                 /* Flag for min/max queries */

#ifndef SQLITE_OMIT_EXPLAIN
  int iRestoreSelectId = pParse->iSelectId;
  pParse->iSelectId = pParse->iNextSelectId++;
#endif

  db = pParse->db;
  v = sqlite3GetVdbe(pParse);
  if( p==0 || db->mallocFailed || pParse->nErr ){
    return 1;
  }
  if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1;
  memset(&sAggInfo, 0, sizeof(sAggInfo));
#if SELECTTRACE_ENABLED
  SELECTTRACE(1,pParse,p, ("begin processing:\n"));
  SELECTTRACE(1,pParse,p, ("begin processing:\n", pParse->addrExplain));
  if( sqlite3SelectTrace & 0x100 ){
    sqlite3TreeViewSelect(0, p, 0);
  }
#endif

  assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistFifo );
  assert( p->pOrderBy==0 || pDest->eDest!=SRT_Fifo );
125520
125521
125522
125523
125524
125525
125526
125527
125528


125529
125530
125531
125532
125533
125534
125535
125536
125537
125538
125539
125540
125541
125542
125543
126735
126736
126737
126738
126739
126740
126741


126742
126743
126744
126745
126746
126747




126748
126749
126750
126751
126752
126753
126754







-
-
+
+




-
-
-
-







  pTabList = p->pSrc;
  if( pParse->nErr || db->mallocFailed ){
    goto select_end;
  }
  assert( p->pEList!=0 );
  isAgg = (p->selFlags & SF_Aggregate)!=0;
#if SELECTTRACE_ENABLED
  if( sqlite3SelectTrace & 0x100 ){
    SELECTTRACE(0x100,pParse,p, ("after name resolution:\n"));
  if( sqlite3SelectTrace & 0x104 ){
    SELECTTRACE(0x104,pParse,p, ("after name resolution:\n"));
    sqlite3TreeViewSelect(0, p, 0);
  }
#endif

  /* Get a pointer the VDBE under construction, allocating a new VDBE if one
  ** does not already exist */
  v = sqlite3GetVdbe(pParse);
  if( v==0 ) goto select_end;
  if( pDest->eDest==SRT_Output ){
    generateColumnNames(pParse, p);
  }

  /* Try to various optimizations (flattening subqueries, and strength
  ** reduction of join operators) in the FROM clause up into the main query
  */
125622
125623
125624
125625
125626
125627
125628
125629
125630
125631




125632

125633
125634
125635
125636
125637
125638
125639
126833
126834
126835
126836
126837
126838
126839

126840

126841
126842
126843
126844
126845
126846
126847
126848
126849
126850
126851
126852
126853







-

-
+
+
+
+

+








#ifndef SQLITE_OMIT_COMPOUND_SELECT
  /* Handle compound SELECT statements using the separate multiSelect()
  ** procedure.
  */
  if( p->pPrior ){
    rc = multiSelect(pParse, p, pDest);
    explainSetInteger(pParse->iSelectId, iRestoreSelectId);
#if SELECTTRACE_ENABLED
    SELECTTRACE(1,pParse,p,("end compound-select processing\n"));
    SELECTTRACE(0x1,pParse,p,("end compound-select processing\n"));
    if( (sqlite3SelectTrace & 0x2000)!=0 && ExplainQueryPlanParent(pParse)==0 ){
      sqlite3TreeViewSelect(0, p, 0);
    }
#endif
    if( p->pNext==0 ) ExplainQueryPlanPop(pParse);
    return rc;
  }
#endif

  /* For each term in the FROM clause, do two things:
  ** (1) Authorized unreferenced tables
  ** (2) Generate code for all sub-queries
125737
125738
125739
125740
125741
125742
125743
125744

125745
125746
125747
125748
125749
125750
125751
126951
126952
126953
126954
126955
126956
126957

126958
126959
126960
126961
126962
126963
126964
126965







-
+







      int addrTop = sqlite3VdbeCurrentAddr(v)+1;
     
      pItem->regReturn = ++pParse->nMem;
      sqlite3VdbeAddOp3(v, OP_InitCoroutine, pItem->regReturn, 0, addrTop);
      VdbeComment((v, "%s", pItem->pTab->zName));
      pItem->addrFillSub = addrTop;
      sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn);
      explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);
      ExplainQueryPlan((pParse, 1, "CO-ROUTINE 0x%p", pSub));
      sqlite3Select(pParse, pSub, &dest);
      pItem->pTab->nRowLogEst = pSub->nSelectRow;
      pItem->fg.viaCoroutine = 1;
      pItem->regResult = dest.iSdst;
      sqlite3VdbeEndCoroutine(v, pItem->regReturn);
      sqlite3VdbeJumpHere(v, addrTop-1);
      sqlite3ClearTempRegCache(pParse);
125772
125773
125774
125775
125776
125777
125778
125779
125780
125781
125782
125783
125784

125785
125786
125787
125788
125789
125790
125791
126986
126987
126988
126989
126990
126991
126992

126993
126994
126995
126996

126997
126998
126999
127000
127001
127002
127003
127004







-




-
+







        VdbeComment((v, "materialize \"%s\"", pItem->pTab->zName));
      }else{
        VdbeNoopComment((v, "materialize \"%s\"", pItem->pTab->zName));
      }
      pPrior = isSelfJoinView(pTabList, pItem);
      if( pPrior ){
        sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);
        explainSetInteger(pItem->iSelectId, pPrior->iSelectId);
        assert( pPrior->pSelect!=0 );
        pSub->nSelectRow = pPrior->pSelect->nSelectRow;
      }else{
        sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
        explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);
        ExplainQueryPlan((pParse, 1, "MATERIALIZE 0x%p", pSub));
        sqlite3Select(pParse, pSub, &dest);
      }
      pItem->pTab->nRowLogEst = pSub->nSelectRow;
      if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr);
      retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn);
      VdbeComment((v, "end %s", pItem->pTab->zName));
      sqlite3VdbeChangeP1(v, topAddr, retAddr);
126004
126005
126006
126007
126008
126009
126010
126011


126012
126013
126014
126015
126016
126017
126018
127217
127218
127219
127220
127221
127222
127223

127224
127225
127226
127227
127228
127229
127230
127231
127232







-
+
+







    /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in
    ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the
    ** SELECT statement.
    */
    memset(&sNC, 0, sizeof(sNC));
    sNC.pParse = pParse;
    sNC.pSrcList = pTabList;
    sNC.pAggInfo = &sAggInfo;
    sNC.uNC.pAggInfo = &sAggInfo;
    VVA_ONLY( sNC.ncFlags = NC_UAggInfo; )
    sAggInfo.mnReg = pParse->nMem+1;
    sAggInfo.nSortingColumn = pGroupBy ? pGroupBy->nExpr : 0;
    sAggInfo.pGroupBy = pGroupBy;
    sqlite3ExprAnalyzeAggList(&sNC, pEList);
    sqlite3ExprAnalyzeAggList(&sNC, sSort.pOrderBy);
    if( pHaving ){
      if( pGroupBy ){
126393
126394
126395
126396
126397
126398
126399

126400
126401
126402
126403
126404
126405
126406
126407
126408
126409
126410
126411
126412
126413
126414
126415
126416
126417
126418
126419
126420




126421

126422
126423
126424
126425
126426
126427
126428
127607
127608
127609
127610
127611
127612
127613
127614
127615
127616
127617
127618
127619
127620
127621
127622
127623
127624
127625
127626
127627
127628
127629

127630
127631
127632
127633

127634
127635
127636
127637
127638
127639
127640
127641
127642
127643
127644
127645
127646







+















-




-
+
+
+
+

+








  /* If there is an ORDER BY clause, then we need to sort the results
  ** and send them to the callback one by one.
  */
  if( sSort.pOrderBy ){
    explainTempTable(pParse,
                     sSort.nOBSat>0 ? "RIGHT PART OF ORDER BY":"ORDER BY");
    assert( p->pEList==pEList );
    generateSortTail(pParse, p, &sSort, pEList->nExpr, pDest);
  }

  /* Jump here to skip this query
  */
  sqlite3VdbeResolveLabel(v, iEnd);

  /* The SELECT has been coded. If there is an error in the Parse structure,
  ** set the return code to 1. Otherwise 0. */
  rc = (pParse->nErr>0);

  /* Control jumps to here if an error is encountered above, or upon
  ** successful coding of the SELECT.
  */
select_end:
  explainSetInteger(pParse->iSelectId, iRestoreSelectId);
  sqlite3ExprListDelete(db, pMinMaxOrderBy);
  sqlite3DbFree(db, sAggInfo.aCol);
  sqlite3DbFree(db, sAggInfo.aFunc);
#if SELECTTRACE_ENABLED
  SELECTTRACE(1,pParse,p,("end processing\n"));
  SELECTTRACE(0x1,pParse,p,("end processing\n"));
  if( (sqlite3SelectTrace & 0x2000)!=0 && ExplainQueryPlanParent(pParse)==0 ){
    sqlite3TreeViewSelect(0, p, 0);
  }
#endif
  ExplainQueryPlanPop(pParse);
  return rc;
}

/************** End of select.c **********************************************/
/************** Begin file table.c *******************************************/
/*
** 2001 September 15
126648
126649
126650
126651
126652
126653
126654

126655
126656
126657
126658
126659
126660
126661
127866
127867
127868
127869
127870
127871
127872
127873
127874
127875
127876
127877
127878
127879
127880







+







    TriggerStep * pTmp = pTriggerStep;
    pTriggerStep = pTriggerStep->pNext;

    sqlite3ExprDelete(db, pTmp->pWhere);
    sqlite3ExprListDelete(db, pTmp->pExprList);
    sqlite3SelectDelete(db, pTmp->pSelect);
    sqlite3IdListDelete(db, pTmp->pIdList);
    sqlite3UpsertDelete(db, pTmp->pUpsert);
    sqlite3DbFree(db, pTmp->zSpan);

    sqlite3DbFree(db, pTmp);
  }
}

/*
127039
127040
127041
127042
127043
127044
127045

127046
127047
127048
127049
127050
127051
127052
127053
127054
127055
127056

127057
127058

127059


127060
127061
127062
127063
127064
127065
127066
128258
128259
128260
128261
128262
128263
128264
128265
128266
128267
128268
128269
128270
128271
128272
128273
128274
128275
128276
128277
128278
128279
128280
128281
128282
128283
128284
128285
128286
128287
128288
128289
128290







+











+


+

+
+







*/
SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(
  sqlite3 *db,        /* The database connection */
  Token *pTableName,  /* Name of the table into which we insert */
  IdList *pColumn,    /* List of columns in pTableName to insert into */
  Select *pSelect,    /* A SELECT statement that supplies values */
  u8 orconf,          /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */
  Upsert *pUpsert,    /* ON CONFLICT clauses for upsert */
  const char *zStart, /* Start of SQL text */
  const char *zEnd    /* End of SQL text */
){
  TriggerStep *pTriggerStep;

  assert(pSelect != 0 || db->mallocFailed);

  pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName, zStart, zEnd);
  if( pTriggerStep ){
    pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
    pTriggerStep->pIdList = pColumn;
    pTriggerStep->pUpsert = pUpsert;
    pTriggerStep->orconf = orconf;
  }else{
    testcase( pColumn );
    sqlite3IdListDelete(db, pColumn);
    testcase( pUpsert );
    sqlite3UpsertDelete(db, pUpsert);
  }
  sqlite3SelectDelete(db, pSelect);

  return pTriggerStep;
}

/*
127369
127370
127371
127372
127373
127374
127375
127376

127377
127378
127379
127380
127381
127382
127383
127384
127385


127386
127387
127388
127389
127390
127391
127392
128593
128594
128595
128596
128597
128598
128599

128600
128601
128602
128603
128604
128605
128606
128607
128608

128609
128610
128611
128612
128613
128614
128615
128616
128617







-
+








-
+
+








    switch( pStep->op ){
      case TK_UPDATE: {
        sqlite3Update(pParse, 
          targetSrcList(pParse, pStep),
          sqlite3ExprListDup(db, pStep->pExprList, 0), 
          sqlite3ExprDup(db, pStep->pWhere, 0), 
          pParse->eOrconf, 0, 0
          pParse->eOrconf, 0, 0, 0
        );
        break;
      }
      case TK_INSERT: {
        sqlite3Insert(pParse, 
          targetSrcList(pParse, pStep),
          sqlite3SelectDup(db, pStep->pSelect, 0), 
          sqlite3IdListDup(db, pStep->pIdList), 
          pParse->eOrconf
          pParse->eOrconf,
          sqlite3UpsertDup(db, pStep->pUpsert)
        );
        break;
      }
      case TK_DELETE: {
        sqlite3DeleteFrom(pParse, 
          targetSrcList(pParse, pStep),
          sqlite3ExprDup(db, pStep->pWhere, 0), 0, 0
127856
127857
127858
127859
127860
127861
127862
127863


127864
127865
127866
127867
127868
127869
127870
129081
129082
129083
129084
129085
129086
129087

129088
129089
129090
129091
129092
129093
129094
129095
129096







-
+
+







SQLITE_PRIVATE void sqlite3Update(
  Parse *pParse,         /* The parser context */
  SrcList *pTabList,     /* The table in which we should change things */
  ExprList *pChanges,    /* Things to be changed */
  Expr *pWhere,          /* The WHERE clause.  May be null */
  int onError,           /* How to handle constraint errors */
  ExprList *pOrderBy,    /* ORDER BY clause. May be null */
  Expr *pLimit           /* LIMIT clause. May be null */
  Expr *pLimit,          /* LIMIT clause. May be null */
  Upsert *pUpsert        /* ON CONFLICT clause, or null */
){
  int i, j;              /* Loop counters */
  Table *pTab;           /* The table to be updated */
  int addrTop = 0;       /* VDBE instruction address of the start of the loop */
  WhereInfo *pWInfo;     /* Information about the WHERE clause */
  Vdbe *v;               /* The virtual database engine */
  Index *pIdx;           /* For looping over indices */
127963
127964
127965
127966
127967
127968
127969
127970

127971
127972

127973
127974

127975
127976
127977
127978
127979







127980
127981
127982
127983
127984
127985
127986
127987
127988
127989
127990
127991
127992
127993
127994
127995


127996
127997
127998
127999
128000
128001
128002
129189
129190
129191
129192
129193
129194
129195

129196
129197
129198
129199
129200

129201
129202

129203
129204
129205
129206
129207
129208
129209
129210
129211
129212
129213
129214
129215
129216
129217
129218
129219
129220
129221
129222
129223
129224
129225
129226
129227
129228
129229
129230
129231
129232
129233
129234
129235
129236
129237







-
+


+

-
+

-



+
+
+
+
+
+
+
















+
+







  }

  /* Allocate a cursors for the main database table and for all indices.
  ** The index cursors might not be used, but if they are used they
  ** need to occur right after the database cursor.  So go ahead and
  ** allocate enough space, just in case.
  */
  pTabList->a[0].iCursor = iBaseCur = iDataCur = pParse->nTab++;
  iBaseCur = iDataCur = pParse->nTab++;
  iIdxCur = iDataCur+1;
  pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);
  testcase( pPk!=0 && pPk!=pTab->pIndex );
  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){
    if( IsPrimaryKeyIndex(pIdx) && pPk!=0 ){
    if( pPk==pIdx ){
      iDataCur = pParse->nTab;
      pTabList->a[0].iCursor = iDataCur;
    }
    pParse->nTab++;
  }
  if( pUpsert ){
    /* On an UPSERT, reuse the same cursors already opened by INSERT */
    iDataCur = pUpsert->iDataCur;
    iIdxCur = pUpsert->iIdxCur;
    pParse->nTab = iBaseCur;
  }
  pTabList->a[0].iCursor = iDataCur;

  /* Allocate space for aXRef[], aRegIdx[], and aToOpen[].  
  ** Initialize aXRef[] and aToOpen[] to their default values.
  */
  aXRef = sqlite3DbMallocRawNN(db, sizeof(int) * (pTab->nCol+nIdx) + nIdx+2 );
  if( aXRef==0 ) goto update_cleanup;
  aRegIdx = aXRef+pTab->nCol;
  aToOpen = (u8*)(aRegIdx+nIdx);
  memset(aToOpen, 1, nIdx+1);
  aToOpen[nIdx+1] = 0;
  for(i=0; i<pTab->nCol; i++) aXRef[i] = -1;

  /* Initialize the name-context */
  memset(&sNC, 0, sizeof(sNC));
  sNC.pParse = pParse;
  sNC.pSrcList = pTabList;
  sNC.uNC.pUpsert = pUpsert;
  sNC.ncFlags = NC_UUpsert;

  /* Resolve the column names in all the expressions of the
  ** of the UPDATE statement.  Also find the column index
  ** for each column to be updated in the pChanges array.  For each
  ** column to be updated, make sure we have authorization to change
  ** that column.
  */
128092
128093
128094
128095
128096
128097
128098
128099

128100
128101
128102
128103
128104
128105
128106
129327
129328
129329
129330
129331
129332
129333

129334
129335
129336
129337
129338
129339
129340
129341







-
+







    memset(aToOpen, 1, nIdx+1);
  }

  /* Begin generating code. */
  v = sqlite3GetVdbe(pParse);
  if( v==0 ) goto update_cleanup;
  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
  sqlite3BeginWriteOperation(pParse, 1, iDb);
  sqlite3BeginWriteOperation(pParse, pTrigger || hasFK, iDb);

  /* Allocate required registers. */
  if( !IsVirtual(pTab) ){
    regRowSet = ++pParse->nMem;
    regOldRowid = regNewRowid = ++pParse->nMem;
    if( chngPk || pTrigger || hasFK ){
      regOld = pParse->nMem + 1;
128143
128144
128145
128146
128147
128148
128149




128150
128151






128152
128153
128154
128155
128156
128157
128158
128159
128160
128161
128162
128163

128164

128165
128166
128167
128168
128169
128170
128171
128172
128173
128174
128175
128176
128177
128178
128179
128180
128181
128182
128183
128184
128185
128186
128187
128188
128189
128190
128191
128192
128193
128194
128195
128196
128197
128198
128199
128200
128201
128202
128203





















































128204
128205
128206
128207
128208
128209
128210
128211
128212
128213
128214
128215
128216
128217
128218
128219
128220
128221
128222
128223

128224
128225
128226
128227
128228
128229
128230
128231
128232

128233
128234
128235
128236




128237
128238
128239
128240
128241
128242
128243
128244
128245
128246
128247
128248
128249
128250
128251
128252
128253
128254
128255
128256
128257
128258
128259
128260
128261
128262

























128263
128264
128265
128266
128267
128268
128269
128270
128271
128272
128273
128274
128275
128276
128277
128278
128279
128280
128281
128282
128283
128284
128285






















128286
128287
128288
128289
128290
128291
128292
129378
129379
129380
129381
129382
129383
129384
129385
129386
129387
129388


129389
129390
129391
129392
129393
129394
129395
129396
129397
129398
129399
129400
129401
129402
129403
129404
129405
129406
129407

129408







































129409
129410
129411
129412
129413
129414
129415
129416
129417
129418
129419
129420
129421
129422
129423
129424
129425
129426
129427
129428
129429
129430
129431
129432
129433
129434
129435
129436
129437
129438
129439
129440
129441
129442
129443
129444
129445
129446
129447
129448
129449
129450
129451
129452
129453
129454
129455
129456
129457
129458
129459
129460
129461
129462
129463
129464
129465
129466
129467
129468
129469
129470
129471
129472
129473
129474
129475
129476
129477
129478
129479
129480

129481
129482
129483
129484
129485
129486
129487
129488
129489
129490
129491




129492
129493
129494
129495


























129496
129497
129498
129499
129500
129501
129502
129503
129504
129505
129506
129507
129508
129509
129510
129511
129512
129513
129514
129515
129516
129517
129518
129519
129520























129521
129522
129523
129524
129525
129526
129527
129528
129529
129530
129531
129532
129533
129534
129535
129536
129537
129538
129539
129540
129541
129542
129543
129544
129545
129546
129547
129548
129549







+
+
+
+
-
-
+
+
+
+
+
+












+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+



















-
+









+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  if( IsVirtual(pTab) ){
    updateVirtualTable(pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef,
                       pWhere, onError);
    goto update_cleanup;
  }
#endif

  /* Jump to labelBreak to abandon further processing of this UPDATE */
  labelContinue = labelBreak = sqlite3VdbeMakeLabel(v);

  /* Not an UPSERT.  Normal processing.  Begin by
  /* Initialize the count of updated rows */
  if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab ){
  ** initialize the count of updated rows */
  if( (db->flags&SQLITE_CountRows)!=0
   && !pParse->pTriggerTab
   && !pParse->nested
   && pUpsert==0
  ){
    regRowCount = ++pParse->nMem;
    sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount);
  }

  if( HasRowid(pTab) ){
    sqlite3VdbeAddOp3(v, OP_Null, 0, regRowSet, regOldRowid);
  }else{
    assert( pPk!=0 );
    nPk = pPk->nKeyCol;
    iPk = pParse->nMem+1;
    pParse->nMem += nPk;
    regKey = ++pParse->nMem;
    if( pUpsert==0 ){
    iEph = pParse->nTab++;
      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
  ** there are any triggers or foreign keys to process, or rows may
  ** be deleted as a result of REPLACE conflict handling. Any of these
  ** things might disturb a cursor being used to scan through the table
  ** or index, causing a single-pass approach to malfunction.  */
  flags = WHERE_ONEPASS_DESIRED|WHERE_SEEK_UNIQ_TABLE;
  if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){
    flags |= WHERE_ONEPASS_MULTIROW;
  }
  pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, flags, iIdxCur);
  if( pWInfo==0 ) goto update_cleanup;

  /* A one-pass strategy that might update more than one row may not
  ** be used if any column of the index used for the scan is being
  ** updated. Otherwise, if there is an index on "b", statements like
  ** the following could create an infinite loop:
  **
  **   UPDATE t1 SET b=b+1 WHERE b>?
  **
  ** Fall back to ONEPASS_OFF if where.c has selected a ONEPASS_MULTI
  ** strategy that uses an index for which one or more columns are being
  ** updated.  */
  eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);
  if( eOnePass==ONEPASS_MULTI ){
    int iCur = aiCurOnePass[1];
    if( iCur>=0 && iCur!=iDataCur && aToOpen[iCur-iBaseCur] ){
      eOnePass = ONEPASS_OFF;
    }
    assert( iCur!=iDataCur || !HasRowid(pTab) );
  }
  
        sqlite3VdbeAddOp3(v, OP_Null, 0, iPk, iPk+nPk-1);
      addrOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEph, nPk);
      sqlite3VdbeSetP4KeyInfo(pParse, pPk);
    }
  }
  
  if( pUpsert ){
    /* If this is an UPSERT, then all cursors have already been opened by
    ** the outer INSERT and the data cursor should be pointing at the row
    ** that is to be updated.  So bypass the code that searches for the
    ** row(s) to be updated.
    */
    pWInfo = 0;
    eOnePass = ONEPASS_SINGLE;
    sqlite3ExprIfFalse(pParse, pWhere, labelBreak, SQLITE_JUMPIFNULL);
  }else{
    /* Begin the database scan. 
    **
    ** Do not consider a single-pass strategy for a multi-row update if
    ** there are any triggers or foreign keys to process, or rows may
    ** be deleted as a result of REPLACE conflict handling. Any of these
    ** things might disturb a cursor being used to scan through the table
    ** or index, causing a single-pass approach to malfunction.  */
    flags = WHERE_ONEPASS_DESIRED|WHERE_SEEK_UNIQ_TABLE;
    if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){
      flags |= WHERE_ONEPASS_MULTIROW;
    }
    pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, flags, iIdxCur);
    if( pWInfo==0 ) goto update_cleanup;
  
    /* A one-pass strategy that might update more than one row may not
    ** be used if any column of the index used for the scan is being
    ** updated. Otherwise, if there is an index on "b", statements like
    ** the following could create an infinite loop:
    **
    **   UPDATE t1 SET b=b+1 WHERE b>?
    **
    ** Fall back to ONEPASS_OFF if where.c has selected a ONEPASS_MULTI
    ** strategy that uses an index for which one or more columns are being
    ** updated.  */
    eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);
    if( eOnePass!=ONEPASS_SINGLE ){
      sqlite3MultiWrite(pParse);
      if( eOnePass==ONEPASS_MULTI ){
        int iCur = aiCurOnePass[1];
        if( iCur>=0 && iCur!=iDataCur && aToOpen[iCur-iBaseCur] ){
          eOnePass = ONEPASS_OFF;
        }
        assert( iCur!=iDataCur || !HasRowid(pTab) );
      }
    }
  }

  if( HasRowid(pTab) ){
    /* Read the rowid of the current row of the WHERE scan. In ONEPASS_OFF
    ** mode, write the rowid into the FIFO. In either of the one-pass modes,
    ** leave it in register regOldRowid.  */
    sqlite3VdbeAddOp2(v, OP_Rowid, iDataCur, regOldRowid);
    if( eOnePass==ONEPASS_OFF ){
      sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid);
    }
  }else{
    /* Read the PK of the current row into an array of registers. In
    ** ONEPASS_OFF mode, serialize the array into a record and store it in
    ** the ephemeral table. Or, in ONEPASS_SINGLE or MULTI mode, change
    ** the OP_OpenEphemeral instruction to a Noop (the ephemeral table 
    ** is not required) and leave the PK fields in the array of registers.  */
    for(i=0; i<nPk; i++){
      assert( pPk->aiColumn[i]>=0 );
      sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur,pPk->aiColumn[i],iPk+i);
    }
    if( eOnePass ){
      sqlite3VdbeChangeToNoop(v, addrOpen);
      if( addrOpen ) sqlite3VdbeChangeToNoop(v, addrOpen);
      nKey = nPk;
      regKey = iPk;
    }else{
      sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, regKey,
                        sqlite3IndexAffinityStr(db, pPk), nPk);
      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iEph, regKey, iPk, nPk);
    }
  }

  if( pUpsert==0 ){
  if( eOnePass!=ONEPASS_MULTI ){
    sqlite3WhereEnd(pWInfo);
  }

    if( eOnePass!=ONEPASS_MULTI ){
      sqlite3WhereEnd(pWInfo);
    }
  
  labelBreak = sqlite3VdbeMakeLabel(v);
  if( !isView ){
    int addrOnce = 0;

    /* Open every index that needs updating. */
    if( eOnePass!=ONEPASS_OFF ){
      if( aiCurOnePass[0]>=0 ) aToOpen[aiCurOnePass[0]-iBaseCur] = 0;
      if( aiCurOnePass[1]>=0 ) aToOpen[aiCurOnePass[1]-iBaseCur] = 0;
    }

    if( eOnePass==ONEPASS_MULTI && (nIdx-(aiCurOnePass[1]>=0))>0 ){
      addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
    }
    sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, iBaseCur, aToOpen,
                               0, 0);
    if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);
  }

  /* Top of the update loop */
  if( eOnePass!=ONEPASS_OFF ){
    if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){
      assert( pPk );
      sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey, nKey);
      VdbeCoverageNeverTaken(v);
    }
    if( eOnePass==ONEPASS_SINGLE ){
    if( !isView ){
      int addrOnce = 0;
  
      /* Open every index that needs updating. */
      if( eOnePass!=ONEPASS_OFF ){
        if( aiCurOnePass[0]>=0 ) aToOpen[aiCurOnePass[0]-iBaseCur] = 0;
        if( aiCurOnePass[1]>=0 ) aToOpen[aiCurOnePass[1]-iBaseCur] = 0;
      }
  
      if( eOnePass==ONEPASS_MULTI && (nIdx-(aiCurOnePass[1]>=0))>0 ){
        addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
      }
      sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, iBaseCur,
                                 aToOpen, 0, 0);
      if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);
    }
  
    /* Top of the update loop */
    if( eOnePass!=ONEPASS_OFF ){
      if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){
        assert( pPk );
        sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey,nKey);
        VdbeCoverageNeverTaken(v);
      }
      if( eOnePass!=ONEPASS_SINGLE ){
      labelContinue = labelBreak;
    }else{
      labelContinue = sqlite3VdbeMakeLabel(v);
    }
    sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);
    VdbeCoverageIf(v, pPk==0);
    VdbeCoverageIf(v, pPk!=0);
  }else if( pPk ){
    labelContinue = sqlite3VdbeMakeLabel(v);
    sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v);
    addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey);
    sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0);
    VdbeCoverage(v);
  }else{
    labelContinue = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet, labelBreak,
                             regOldRowid);
    VdbeCoverage(v);
    sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid);
    VdbeCoverage(v);
  }

  /* If the record number will change, set register regNewRowid to
  ** contain the new value. If the record number is not being modified,
        labelContinue = sqlite3VdbeMakeLabel(v);
      }
      sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);
      VdbeCoverageIf(v, pPk==0);
      VdbeCoverageIf(v, pPk!=0);
    }else if( pPk ){
      labelContinue = sqlite3VdbeMakeLabel(v);
      sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v);
      addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey);
      sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0);
      VdbeCoverage(v);
    }else{
      labelContinue = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet,labelBreak,
                               regOldRowid);
      VdbeCoverage(v);
      sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid);
      VdbeCoverage(v);
    }
  }

  /* If the rowid value will change, set register regNewRowid to
  ** contain the new value. If the rowid is not being modified,
  ** then regNewRowid is the same register as regOldRowid, which is
  ** already populated.  */
  assert( chngKey || pTrigger || hasFK || regOldRowid==regNewRowid );
  if( chngRowid ){
    sqlite3ExprCode(pParse, pRowidExpr, regNewRowid);
    sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid); VdbeCoverage(v);
  }
128342
128343
128344
128345
128346
128347
128348






128349
128350
128351
128352
128353
128354
128355
129599
129600
129601
129602
129603
129604
129605
129606
129607
129608
129609
129610
129611
129612
129613
129614
129615
129616
129617
129618







+
+
+
+
+
+







        ** into a register. This is done if there are no BEFORE triggers, or
        ** if there are one or more BEFORE triggers that use this value via
        ** a new.* reference in a trigger program.
        */
        testcase( i==31 );
        testcase( i==32 );
        sqlite3ExprCodeGetColumnToReg(pParse, pTab, i, iDataCur, regNew+i);
        if( tmask & TRIGGER_BEFORE ){
          /* This value will be recomputed in After-BEFORE-trigger-reload-loop
          ** below, so make sure that it is not cached and reused.
          ** Ticket d85fffd6ffe856092ed8daefa811b1e399706b28. */
          sqlite3ExprCacheRemove(pParse, regNew+i, 1);
        }
      }else{
        sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);
      }
    }
  }

  /* Fire any BEFORE UPDATE triggers. This happens before constraints are
128370
128371
128372
128373
128374
128375
128376

128377

128378
128379
128380





128381
128382
128383
128384
128385
128386
128387
128388
128389
128390
128391
128392
128393
128394
128395
128396

128397
128398
128399
128400
128401
128402
128403
129633
129634
129635
129636
129637
129638
129639
129640

129641
129642


129643
129644
129645
129646
129647
129648
129649
129650
129651
129652
129653
129654
129655
129656
129657
129658
129659
129660
129661
129662

129663
129664
129665
129666
129667
129668
129669
129670







+
-
+

-
-
+
+
+
+
+















-
+







      sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue,regKey,nKey);
      VdbeCoverage(v);
    }else{
      sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid);
      VdbeCoverage(v);
    }

    /* After-BEFORE-trigger-reload-loop:
    /* If it did not delete it, the row-trigger may still have modified 
    ** If it did not delete it, the BEFORE trigger may still have modified 
    ** some of the columns of the row being updated. Load the values for 
    ** all columns not modified by the update statement into their 
    ** registers in case this has happened.
    ** all columns not modified by the update statement into their registers
    ** in case this has happened. Only unmodified columns are reloaded.
    ** The values computed for modified columns use the values before the
    ** BEFORE trigger runs.  See test case trigger1-18.0 (added 2018-04-26)
    ** for an example.
    */
    for(i=0; i<pTab->nCol; i++){
      if( aXRef[i]<0 && i!=pTab->iPKey ){
        sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i);
      }
    }
  }

  if( !isView ){
    int addr1 = 0;        /* Address of jump instruction */

    /* Do constraint checks. */
    assert( regOldRowid>0 );
    sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
        regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace,
        aXRef);
        aXRef, 0);

    /* Do FK constraint checks. */
    if( hasFK ){
      sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey);
    }

    /* Delete the index entries associated with the current record.  */
128459
128460
128461
128462
128463
128464
128465
128466

128467
128468
128469
128470
128471
128472
128473
129726
129727
129728
129729
129730
129731
129732

129733
129734
129735
129736
129737
129738
129739
129740







-
+







    if( hasFK ){
      sqlite3FkActions(pParse, pTab, pChanges, regOldRowid, aXRef, chngKey);
    }
  }

  /* Increment the row counter 
  */
  if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab){
  if( regRowCount ){
    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);
  }

  sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, 
      TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue);

  /* Repeat the above with the next record to be updated, until
128486
128487
128488
128489
128490
128491
128492
128493

128494
128495
128496
128497
128498

128499
128500

128501
128502

128503
128504
128505
128506
128507
128508
128509
129753
129754
129755
129756
129757
129758
129759

129760
129761
129762
129763
129764

129765


129766
129767

129768
129769
129770
129771
129772
129773
129774
129775







-
+




-
+
-
-
+

-
+







  }
  sqlite3VdbeResolveLabel(v, labelBreak);

  /* Update the sqlite_sequence table by storing the content of the
  ** maximum rowid counter values recorded while inserting into
  ** autoincrement tables.
  */
  if( pParse->nested==0 && pParse->pTriggerTab==0 ){
  if( pParse->nested==0 && pParse->pTriggerTab==0 && pUpsert==0 ){
    sqlite3AutoincrementEnd(pParse);
  }

  /*
  ** Return the number of rows that were changed. If this routine is 
  ** Return the number of rows that were changed, if we are tracking
  ** generating code because of a call to sqlite3NestedParse(), do not
  ** invoke the callback function.
  ** that information.
  */
  if( (db->flags&SQLITE_CountRows) && !pParse->pTriggerTab && !pParse->nested ){
  if( regRowCount ){
    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);
    sqlite3VdbeSetNumCols(v, 1);
    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC);
  }

update_cleanup:
  sqlite3AuthContextPop(&sContext);
128567
128568
128569
128570
128571
128572
128573
128574

128575
128576
128577
128578
128579
128580
128581
129833
129834
129835
129836
129837
129838
129839

129840
129841
129842
129843
129844
129845
129846
129847







-
+







  WhereInfo *pWInfo;
  int nArg = 2 + pTab->nCol;      /* Number of arguments to VUpdate */
  int regArg;                     /* First register in VUpdate arg array */
  int regRec;                     /* Register in which to assemble record */
  int regRowid;                   /* Register for ephem table rowid */
  int iCsr = pSrc->a[0].iCursor;  /* Cursor used for virtual table scan */
  int aDummy[2];                  /* Unused arg for sqlite3WhereOkOnePass() */
  int bOnePass;                   /* True to use onepass strategy */
  int eOnePass;                   /* True to use onepass strategy */
  int addr;                       /* Address of OP_OpenEphemeral */

  /* Allocate nArg registers in which to gather the arguments for VUpdate. Then
  ** create and open the ephemeral table in which the records created from
  ** these arguments will be temporarily stored. */
  assert( v );
  ephemTab = pParse->nTab++;
128612
128613
128614
128615
128616
128617
128618
128619

128620



128621

128622
128623

128624
128625
128626

128627
128628
128629
128630
128631

128632
128633
128634
128635
128636
128637
128638
128639
128640
128641
128642
128643

128644
128645
128646
128647
128648
128649
128650
128651
128652
128653
128654
128655
128656
128657
128658
128659
128660
128661
128662
128663

128664
128665
128666
128667
128668
128669
128670
128671
128672
128673





























































































































































































































































128674
128675
128676
128677
128678
128679
128680
129878
129879
129880
129881
129882
129883
129884

129885
129886
129887
129888
129889

129890
129891

129892

129893

129894


129895
129896
129897
129898
129899
129900
129901
129902
129903
129904
129905
129906
129907
129908
129909

129910
129911
129912
129913
129914
129915
129916
129917
129918
129919
129920
129921
129922
129923
129924
129925
129926
129927
129928
129929

129930
129931
129932
129933
129934
129935
129936
129937
129938
129939
129940
129941
129942
129943
129944
129945
129946
129947
129948
129949
129950
129951
129952
129953
129954
129955
129956
129957
129958
129959
129960
129961
129962
129963
129964
129965
129966
129967
129968
129969
129970
129971
129972
129973
129974
129975
129976
129977
129978
129979
129980
129981
129982
129983
129984
129985
129986
129987
129988
129989
129990
129991
129992
129993
129994
129995
129996
129997
129998
129999
130000
130001
130002
130003
130004
130005
130006
130007
130008
130009
130010
130011
130012
130013
130014
130015
130016
130017
130018
130019
130020
130021
130022
130023
130024
130025
130026
130027
130028
130029
130030
130031
130032
130033
130034
130035
130036
130037
130038
130039
130040
130041
130042
130043
130044
130045
130046
130047
130048
130049
130050
130051
130052
130053
130054
130055
130056
130057
130058
130059
130060
130061
130062
130063
130064
130065
130066
130067
130068
130069
130070
130071
130072
130073
130074
130075
130076
130077
130078
130079
130080
130081
130082
130083
130084
130085
130086
130087
130088
130089
130090
130091
130092
130093
130094
130095
130096
130097
130098
130099
130100
130101
130102
130103
130104
130105
130106
130107
130108
130109
130110
130111
130112
130113
130114
130115
130116
130117
130118
130119
130120
130121
130122
130123
130124
130125
130126
130127
130128
130129
130130
130131
130132
130133
130134
130135
130136
130137
130138
130139
130140
130141
130142
130143
130144
130145
130146
130147
130148
130149
130150
130151
130152
130153
130154
130155
130156
130157
130158
130159
130160
130161
130162
130163
130164
130165
130166
130167
130168
130169
130170
130171
130172
130173
130174
130175
130176
130177
130178
130179
130180
130181
130182
130183
130184
130185
130186
130187
130188
130189
130190
130191
130192
130193
130194
130195
130196
130197
130198
130199
130200







-
+

+
+
+
-
+

-
+
-

-
+
-
-



+











-
+



















-
+










+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







    assert( pPk!=0 );
    assert( pPk->nKeyCol==1 );
    iPk = pPk->aiColumn[0];
    sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, iPk, regArg);
    sqlite3VdbeAddOp2(v, OP_SCopy, regArg+2+iPk, regArg+1);
  }

  bOnePass = sqlite3WhereOkOnePass(pWInfo, aDummy);
  eOnePass = sqlite3WhereOkOnePass(pWInfo, aDummy);

  /* There is no ONEPASS_MULTI on virtual tables */
  assert( eOnePass==ONEPASS_OFF || eOnePass==ONEPASS_SINGLE );

  if( bOnePass ){
  if( eOnePass ){
    /* If using the onepass strategy, no-op out the OP_OpenEphemeral coded
    ** above. Also, if this is a top-level parse (not a trigger), clear the
    ** above. */
    ** multi-write flag so that the VM does not open a statement journal */
    sqlite3VdbeChangeToNoop(v, addr);
    if( sqlite3IsToplevel(pParse) ){
    sqlite3VdbeAddOp1(v, OP_Close, iCsr);
      pParse->isMultiWrite = 0;
    }
  }else{
    /* Create a record from the argument register contents and insert it into
    ** the ephemeral table. */
    sqlite3MultiWrite(pParse);
    sqlite3VdbeAddOp3(v, OP_MakeRecord, regArg, nArg, regRec);
#ifdef SQLITE_DEBUG
    /* Signal an assert() within OP_MakeRecord that it is allowed to
    ** accept no-change records with serial_type 10 */
    sqlite3VdbeChangeP5(v, OPFLAG_NOCHNG_MAGIC);
#endif
    sqlite3VdbeAddOp2(v, OP_NewRowid, ephemTab, regRowid);
    sqlite3VdbeAddOp3(v, OP_Insert, ephemTab, regRec, regRowid);
  }


  if( bOnePass==0 ){
  if( eOnePass==ONEPASS_OFF ){
    /* End the virtual table scan */
    sqlite3WhereEnd(pWInfo);

    /* Begin scannning through the ephemeral table. */
    addr = sqlite3VdbeAddOp1(v, OP_Rewind, ephemTab); VdbeCoverage(v);

    /* Extract arguments from the current row of the ephemeral table and 
    ** invoke the VUpdate method.  */
    for(i=0; i<nArg; i++){
      sqlite3VdbeAddOp3(v, OP_Column, ephemTab, i, regArg+i);
    }
  }
  sqlite3VtabMakeWritable(pParse, pTab);
  sqlite3VdbeAddOp4(v, OP_VUpdate, 0, nArg, regArg, pVTab, P4_VTAB);
  sqlite3VdbeChangeP5(v, onError==OE_Default ? OE_Abort : onError);
  sqlite3MayAbort(pParse);

  /* End of the ephemeral table scan. Or, if using the onepass strategy,
  ** jump to here if the scan visited zero rows. */
  if( bOnePass==0 ){
  if( eOnePass==ONEPASS_OFF ){
    sqlite3VdbeAddOp2(v, OP_Next, ephemTab, addr+1); VdbeCoverage(v);
    sqlite3VdbeJumpHere(v, addr);
    sqlite3VdbeAddOp2(v, OP_Close, ephemTab, 0);
  }else{
    sqlite3WhereEnd(pWInfo);
  }
}
#endif /* SQLITE_OMIT_VIRTUALTABLE */

/************** End of update.c **********************************************/
/************** Begin file upsert.c ******************************************/
/*
** 2018-04-12
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    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 contains code to implement various aspects of UPSERT
** processing and handling of the Upsert object.
*/
/* #include "sqliteInt.h" */

#ifndef SQLITE_OMIT_UPSERT
/*
** Free a list of Upsert objects
*/
SQLITE_PRIVATE void sqlite3UpsertDelete(sqlite3 *db, Upsert *p){
  if( p ){
    sqlite3ExprListDelete(db, p->pUpsertTarget);
    sqlite3ExprDelete(db, p->pUpsertTargetWhere);
    sqlite3ExprListDelete(db, p->pUpsertSet);
    sqlite3ExprDelete(db, p->pUpsertWhere);
    sqlite3DbFree(db, p);
  }
}

/*
** Duplicate an Upsert object.
*/
SQLITE_PRIVATE Upsert *sqlite3UpsertDup(sqlite3 *db, Upsert *p){
  if( p==0 ) return 0;
  return sqlite3UpsertNew(db,
           sqlite3ExprListDup(db, p->pUpsertTarget, 0),
           sqlite3ExprDup(db, p->pUpsertTargetWhere, 0),
           sqlite3ExprListDup(db, p->pUpsertSet, 0),
           sqlite3ExprDup(db, p->pUpsertWhere, 0)
         );
}

/*
** Create a new Upsert object.
*/
SQLITE_PRIVATE Upsert *sqlite3UpsertNew(
  sqlite3 *db,           /* Determines which memory allocator to use */
  ExprList *pTarget,     /* Target argument to ON CONFLICT, or NULL */
  Expr *pTargetWhere,    /* Optional WHERE clause on the target */
  ExprList *pSet,        /* UPDATE columns, or NULL for a DO NOTHING */
  Expr *pWhere           /* WHERE clause for the ON CONFLICT UPDATE */
){
  Upsert *pNew;
  pNew = sqlite3DbMallocRaw(db, sizeof(Upsert));
  if( pNew==0 ){
    sqlite3ExprListDelete(db, pTarget);
    sqlite3ExprDelete(db, pTargetWhere);
    sqlite3ExprListDelete(db, pSet);
    sqlite3ExprDelete(db, pWhere);
    return 0;
  }else{
    pNew->pUpsertTarget = pTarget;
    pNew->pUpsertTargetWhere = pTargetWhere;
    pNew->pUpsertSet = pSet;
    pNew->pUpsertWhere = pWhere;
    pNew->pUpsertIdx = 0;
  }
  return pNew;
}

/*
** Analyze the ON CONFLICT clause described by pUpsert.  Resolve all
** symbols in the conflict-target.
**
** Return SQLITE_OK if everything works, or an error code is something
** is wrong.
*/
SQLITE_PRIVATE int sqlite3UpsertAnalyzeTarget(
  Parse *pParse,     /* The parsing context */
  SrcList *pTabList, /* Table into which we are inserting */
  Upsert *pUpsert    /* The ON CONFLICT clauses */
){
  Table *pTab;            /* That table into which we are inserting */
  int rc;                 /* Result code */
  int iCursor;            /* Cursor used by pTab */
  Index *pIdx;            /* One of the indexes of pTab */
  ExprList *pTarget;      /* The conflict-target clause */
  Expr *pTerm;            /* One term of the conflict-target clause */
  NameContext sNC;        /* Context for resolving symbolic names */
  Expr sCol[2];           /* Index column converted into an Expr */

  assert( pTabList->nSrc==1 );
  assert( pTabList->a[0].pTab!=0 );
  assert( pUpsert!=0 );
  assert( pUpsert->pUpsertTarget!=0 );

  /* Resolve all symbolic names in the conflict-target clause, which
  ** includes both the list of columns and the optional partial-index
  ** WHERE clause.
  */
  memset(&sNC, 0, sizeof(sNC));
  sNC.pParse = pParse;
  sNC.pSrcList = pTabList;
  rc = sqlite3ResolveExprListNames(&sNC, pUpsert->pUpsertTarget);
  if( rc ) return rc;
  rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertTargetWhere);
  if( rc ) return rc;

  /* Check to see if the conflict target matches the rowid. */  
  pTab = pTabList->a[0].pTab;
  pTarget = pUpsert->pUpsertTarget;
  iCursor = pTabList->a[0].iCursor;
  if( HasRowid(pTab) 
   && pTarget->nExpr==1
   && (pTerm = pTarget->a[0].pExpr)->op==TK_COLUMN
   && pTerm->iColumn==XN_ROWID
  ){
    /* The conflict-target is the rowid of the primary table */
    assert( pUpsert->pUpsertIdx==0 );
    return SQLITE_OK;
  }

  /* Initialize sCol[0..1] to be an expression parse tree for a
  ** single column of an index.  The sCol[0] node will be the TK_COLLATE
  ** operator and sCol[1] will be the TK_COLUMN operator.  Code below
  ** will populate the specific collation and column number values
  ** prior to comparing against the conflict-target expression.
  */
  memset(sCol, 0, sizeof(sCol));
  sCol[0].op = TK_COLLATE;
  sCol[0].pLeft = &sCol[1];
  sCol[1].op = TK_COLUMN;
  sCol[1].iTable = pTabList->a[0].iCursor;

  /* Check for matches against other indexes */
  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
    int ii, jj, nn;
    if( !IsUniqueIndex(pIdx) ) continue;
    if( pTarget->nExpr!=pIdx->nKeyCol ) continue;
    if( pIdx->pPartIdxWhere ){
      if( pUpsert->pUpsertTargetWhere==0 ) continue;
      if( sqlite3ExprCompare(pParse, pUpsert->pUpsertTargetWhere,
                             pIdx->pPartIdxWhere, iCursor)!=0 ){
        continue;
      }
    }
    nn = pIdx->nKeyCol;
    for(ii=0; ii<nn; ii++){
      Expr *pExpr;
      sCol[0].u.zToken = (char*)pIdx->azColl[ii];
      if( pIdx->aiColumn[ii]==XN_EXPR ){
        assert( pIdx->aColExpr!=0 );
        assert( pIdx->aColExpr->nExpr>ii );
        pExpr = pIdx->aColExpr->a[ii].pExpr;
        if( pExpr->op!=TK_COLLATE ){
          sCol[0].pLeft = pExpr;
          pExpr = &sCol[0];
        }
      }else{
        sCol[0].pLeft = &sCol[1];
        sCol[1].iColumn = pIdx->aiColumn[ii];
        pExpr = &sCol[0];
      }
      for(jj=0; jj<nn; jj++){
        if( sqlite3ExprCompare(pParse, pTarget->a[jj].pExpr, pExpr,iCursor)<2 ){
          break;  /* Column ii of the index matches column jj of target */
        }
      }
      if( jj>=nn ){
        /* The target contains no match for column jj of the index */
        break;
      }
    }
    if( ii<nn ){
      /* Column ii of the index did not match any term of the conflict target.
      ** Continue the search with the next index. */
      continue;
    }
    pUpsert->pUpsertIdx = pIdx;
    return SQLITE_OK;
  }
  sqlite3ErrorMsg(pParse, "ON CONFLICT clause does not match any "
                          "PRIMARY KEY or UNIQUE constraint");
  return SQLITE_ERROR;
}

/*
** Generate bytecode that does an UPDATE as part of an upsert.
**
** If pIdx is NULL, then the UNIQUE constraint that failed was the IPK.
** In this case parameter iCur is a cursor open on the table b-tree that
** currently points to the conflicting table row. Otherwise, if pIdx
** is not NULL, then pIdx is the constraint that failed and iCur is a
** cursor points to the conflicting row.
*/
SQLITE_PRIVATE void sqlite3UpsertDoUpdate(
  Parse *pParse,        /* The parsing and code-generating context */
  Upsert *pUpsert,      /* The ON CONFLICT clause for the upsert */
  Table *pTab,          /* The table being updated */
  Index *pIdx,          /* The UNIQUE constraint that failed */
  int iCur              /* Cursor for pIdx (or pTab if pIdx==NULL) */
){
  Vdbe *v = pParse->pVdbe;
  sqlite3 *db = pParse->db;
  SrcList *pSrc;            /* FROM clause for the UPDATE */
  int iDataCur = pUpsert->iDataCur;

  assert( v!=0 );
  VdbeNoopComment((v, "Begin DO UPDATE of UPSERT"));
  if( pIdx && iCur!=iDataCur ){
    if( HasRowid(pTab) ){
      int regRowid = sqlite3GetTempReg(pParse);
      sqlite3VdbeAddOp2(v, OP_IdxRowid, iCur, regRowid);
      sqlite3VdbeAddOp3(v, OP_SeekRowid, iDataCur, 0, regRowid);
      VdbeCoverage(v);
      sqlite3ReleaseTempReg(pParse, regRowid);
    }else{
      Index *pPk = sqlite3PrimaryKeyIndex(pTab);
      int nPk = pPk->nKeyCol;
      int iPk = pParse->nMem+1;
      int i;
      pParse->nMem += nPk;
      for(i=0; i<nPk; i++){
        int k;
        assert( pPk->aiColumn[i]>=0 );
        k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
        sqlite3VdbeAddOp3(v, OP_Column, iCur, k, iPk+i);
        VdbeComment((v, "%s.%s", pIdx->zName,
                    pTab->aCol[pPk->aiColumn[i]].zName));
      }
      sqlite3VdbeVerifyAbortable(v, OE_Abort);
      i = sqlite3VdbeAddOp4Int(v, OP_Found, iDataCur, 0, iPk, nPk);
      VdbeCoverage(v);
      sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CORRUPT, OE_Abort, 0, 
            "corrupt database", P4_STATIC);
      sqlite3VdbeJumpHere(v, i);
    }
  }
  /* pUpsert does not own pUpsertSrc - the outer INSERT statement does.  So
  ** we have to make a copy before passing it down into sqlite3Update() */
  pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0);
  sqlite3Update(pParse, pSrc, pUpsert->pUpsertSet,
      pUpsert->pUpsertWhere, OE_Abort, 0, 0, pUpsert);
  pUpsert->pUpsertSet = 0;    /* Will have been deleted by sqlite3Update() */
  pUpsert->pUpsertWhere = 0;  /* Will have been deleted by sqlite3Update() */
  VdbeNoopComment((v, "End DO UPDATE of UPSERT"));
}

#endif /* SQLITE_OMIT_UPSERT */

/************** End of upsert.c **********************************************/
/************** Begin file vacuum.c ******************************************/
/*
** 2003 April 6
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
128709
128710
128711
128712
128713
128714
128715
128716
128717








128718
128719
128720
128721
128722
128723
128724
130229
130230
130231
130232
130233
130234
130235


130236
130237
130238
130239
130240
130241
130242
130243
130244
130245
130246
130247
130248
130249
130250







-
-
+
+
+
+
+
+
+
+








  /* printf("SQL: [%s]\n", zSql); fflush(stdout); */
  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
  if( rc!=SQLITE_OK ) return rc;
  while( SQLITE_ROW==(rc = sqlite3_step(pStmt)) ){
    const char *zSubSql = (const char*)sqlite3_column_text(pStmt,0);
    assert( sqlite3_strnicmp(zSql,"SELECT",6)==0 );
    assert( sqlite3_strnicmp(zSubSql,"SELECT",6)!=0 || CORRUPT_DB );
    if( zSubSql && zSubSql[0]!='S' ){
    /* The secondary SQL must be one of CREATE TABLE, CREATE INDEX,
    ** or INSERT.  Historically there have been attacks that first
    ** corrupt the sqlite_master.sql field with other kinds of statements
    ** then run VACUUM to get those statements to execute at inappropriate
    ** times. */
    if( zSubSql
     && (strncmp(zSubSql,"CRE",3)==0 || strncmp(zSubSql,"INS",3)==0)
    ){
      rc = execSql(db, pzErrMsg, zSubSql);
      if( rc!=SQLITE_OK ) break;
    }
  }
  assert( rc!=SQLITE_ROW );
  if( rc==SQLITE_DONE ) rc = SQLITE_OK;
  if( rc ){
128923
128924
128925
128926
128927
128928
128929
128930

128931
128932
128933
128934
128935
128936
128937
130449
130450
130451
130452
130453
130454
130455

130456
130457
130458
130459
130460
130461
130462
130463







-
+







      " WHERE type='table'AND name<>'sqlite_sequence'"
      " AND coalesce(rootpage,1)>0",
      zDbMain
  );
  if( rc!=SQLITE_OK ) goto end_of_vacuum;
  rc = execSqlF(db, pzErrMsg,
      "SELECT sql FROM \"%w\".sqlite_master"
      " WHERE type='index' AND length(sql)>10",
      " WHERE type='index'",
      zDbMain
  );
  if( rc!=SQLITE_OK ) goto end_of_vacuum;
  db->init.iDb = 0;

  /* Loop through the tables in the main database. For each, do
  ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy
130093
130094
130095
130096
130097
130098
130099
130100
130101
130102
130103
130104
130105
130106
130107
130108
130109
130110
130111
130112
130113
130114
130115
130116
130117





130118



130119

130120
130121
130122


130123
130124
130125
130126


130127
130128
130129
130130
130131
130132
130133
131619
131620
131621
131622
131623
131624
131625



131626
131627
131628
131629
131630
131631
131632
131633
131634
131635
131636
131637
131638
131639

131640
131641
131642
131643
131644
131645
131646
131647
131648

131649



131650
131651
131652


131653
131654
131655
131656
131657
131658
131659
131660
131661
131662







-
-
-














-
+
+
+
+
+

+
+
+
-
+
-
-
-
+
+

-
-

+
+







  Table *pTab;
  sqlite3_vtab *pVtab;
  sqlite3_module *pMod;
  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**) = 0;
  void *pArg = 0;
  FuncDef *pNew;
  int rc = 0;
  char *zLowerName;
  unsigned char *z;


  /* Check to see the left operand is a column in a virtual table */
  if( NEVER(pExpr==0) ) return pDef;
  if( pExpr->op!=TK_COLUMN ) return pDef;
  pTab = pExpr->pTab;
  if( pTab==0 ) return pDef;
  if( !IsVirtual(pTab) ) return pDef;
  pVtab = sqlite3GetVTable(db, pTab)->pVtab;
  assert( pVtab!=0 );
  assert( pVtab->pModule!=0 );
  pMod = (sqlite3_module *)pVtab->pModule;
  if( pMod->xFindFunction==0 ) return pDef;
 
  /* Call the xFindFunction method on the virtual table implementation
  ** to see if the implementation wants to overload this function 
  ** to see if the implementation wants to overload this function.
  **
  ** Though undocumented, we have historically always invoked xFindFunction
  ** with an all lower-case function name.  Continue in this tradition to
  ** avoid any chance of an incompatibility.
  */
#ifdef SQLITE_DEBUG
  {
    int i;
  zLowerName = sqlite3DbStrDup(db, pDef->zName);
    for(i=0; pDef->zName[i]; i++){
  if( zLowerName ){
    for(z=(unsigned char*)zLowerName; *z; z++){
      *z = sqlite3UpperToLower[*z];
      unsigned char x = (unsigned char)pDef->zName[i];
      assert( x==sqlite3UpperToLower[x] );
    }
    rc = pMod->xFindFunction(pVtab, nArg, zLowerName, &xSFunc, &pArg);
    sqlite3DbFree(db, zLowerName);
  }
#endif
  rc = pMod->xFindFunction(pVtab, nArg, pDef->zName, &xSFunc, &pArg);
  if( rc==0 ){
    return pDef;
  }

  /* Create a new ephemeral function definition for the overloaded
  ** function */
  pNew = sqlite3DbMallocZero(db, sizeof(*pNew)
130779
130780
130781
130782
130783
130784
130785
130786
130787
130788
130789
130790
130791

130792
130793
130794
130795
130796
130797
130798
132308
132309
132310
132311
132312
132313
132314


132315
132316
132317

132318
132319
132320
132321
132322
132323
132324
132325







-
-



-
+








/* wherecode.c: */
#ifndef SQLITE_OMIT_EXPLAIN
SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
  Parse *pParse,                  /* Parse context */
  SrcList *pTabList,              /* Table list this loop refers to */
  WhereLevel *pLevel,             /* Scan to write OP_Explain opcode for */
  int iLevel,                     /* Value for "level" column of output */
  int iFrom,                      /* Value for "from" column of output */
  u16 wctrlFlags                  /* Flags passed to sqlite3WhereBegin() */
);
#else
# define sqlite3WhereExplainOneScan(u,v,w,x,y,z) 0
# define sqlite3WhereExplainOneScan(u,v,w,x) 0
#endif /* SQLITE_OMIT_EXPLAIN */
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
SQLITE_PRIVATE void sqlite3WhereAddScanStatus(
  Vdbe *v,                        /* Vdbe to add scanstatus entry to */
  SrcList *pSrclist,              /* FROM clause pLvl reads data from */
  WhereLevel *pLvl,               /* Level to add scanstatus() entry for */
  int addrExplain                 /* Address of OP_Explain (or 0) */
130904
130905
130906
130907
130908
130909
130910
130911

130912
130913

130914
130915
130916


130917
130918

130919
130920

130921
130922

130923
130924
130925


130926
130927

130928
130929
130930
130931
130932
130933
130934
132431
132432
132433
132434
132435
132436
132437

132438
132439

132440
132441


132442
132443
132444

132445
132446

132447
132448

132449
132450


132451
132452
132453

132454
132455
132456
132457
132458
132459
132460
132461







-
+

-
+

-
-
+
+

-
+

-
+

-
+

-
-
+
+

-
+







  int iTerm,                  /* Zero-based index of first term. */
  int bAnd,                   /* Non-zero to append " AND " */
  const char *zOp             /* Name of the operator */
){
  int i;

  assert( nTerm>=1 );
  if( bAnd ) sqlite3StrAccumAppend(pStr, " AND ", 5);
  if( bAnd ) sqlite3_str_append(pStr, " AND ", 5);

  if( nTerm>1 ) sqlite3StrAccumAppend(pStr, "(", 1);
  if( nTerm>1 ) sqlite3_str_append(pStr, "(", 1);
  for(i=0; i<nTerm; i++){
    if( i ) sqlite3StrAccumAppend(pStr, ",", 1);
    sqlite3StrAccumAppendAll(pStr, explainIndexColumnName(pIdx, iTerm+i));
    if( i ) sqlite3_str_append(pStr, ",", 1);
    sqlite3_str_appendall(pStr, explainIndexColumnName(pIdx, iTerm+i));
  }
  if( nTerm>1 ) sqlite3StrAccumAppend(pStr, ")", 1);
  if( nTerm>1 ) sqlite3_str_append(pStr, ")", 1);

  sqlite3StrAccumAppend(pStr, zOp, 1);
  sqlite3_str_append(pStr, zOp, 1);

  if( nTerm>1 ) sqlite3StrAccumAppend(pStr, "(", 1);
  if( nTerm>1 ) sqlite3_str_append(pStr, "(", 1);
  for(i=0; i<nTerm; i++){
    if( i ) sqlite3StrAccumAppend(pStr, ",", 1);
    sqlite3StrAccumAppend(pStr, "?", 1);
    if( i ) sqlite3_str_append(pStr, ",", 1);
    sqlite3_str_append(pStr, "?", 1);
  }
  if( nTerm>1 ) sqlite3StrAccumAppend(pStr, ")", 1);
  if( nTerm>1 ) sqlite3_str_append(pStr, ")", 1);
}

/*
** Argument pLevel describes a strategy for scanning table pTab. This 
** function appends text to pStr that describes the subset of table
** rows scanned by the strategy in the form of an SQL expression.
**
130944
130945
130946
130947
130948
130949
130950
130951

130952
130953
130954
130955


130956
130957
130958
130959
130960
130961
130962
130963
130964
130965
130966

130967
130968
130969
130970
130971
130972
130973
130974
130975
130976
130977
130978
130979
130980
130981
130982
130983
130984
130985
130986
130987
130988
130989
130990
130991
130992
130993
130994
130995
130996
130997
130998
130999
131000
131001
131002
131003
131004
131005
131006
131007
131008
131009
131010
131011

131012
131013

131014
131015

131016
131017
131018
131019

131020
131021
131022
131023
131024
131025
131026
132471
132472
132473
132474
132475
132476
132477

132478
132479
132480


132481
132482
132483
132484
132485
132486
132487
132488
132489
132490
132491
132492

132493
132494
132495
132496
132497
132498
132499
132500
132501
132502
132503
132504
132505
132506
132507
132508


132509
132510
132511
132512
132513
132514
132515
132516
132517
132518

132519
132520
132521
132522
132523
132524
132525
132526
132527
132528
132529
132530
132531
132532
132533
132534

132535
132536

132537
132538

132539
132540
132541
132542

132543
132544
132545
132546
132547
132548
132549
132550







-
+


-
-
+
+










-
+















-
-










-
















-
+

-
+

-
+



-
+







static void explainIndexRange(StrAccum *pStr, WhereLoop *pLoop){
  Index *pIndex = pLoop->u.btree.pIndex;
  u16 nEq = pLoop->u.btree.nEq;
  u16 nSkip = pLoop->nSkip;
  int i, j;

  if( nEq==0 && (pLoop->wsFlags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))==0 ) return;
  sqlite3StrAccumAppend(pStr, " (", 2);
  sqlite3_str_append(pStr, " (", 2);
  for(i=0; i<nEq; i++){
    const char *z = explainIndexColumnName(pIndex, i);
    if( i ) sqlite3StrAccumAppend(pStr, " AND ", 5);
    sqlite3XPrintf(pStr, i>=nSkip ? "%s=?" : "ANY(%s)", z);
    if( i ) sqlite3_str_append(pStr, " AND ", 5);
    sqlite3_str_appendf(pStr, i>=nSkip ? "%s=?" : "ANY(%s)", z);
  }

  j = i;
  if( pLoop->wsFlags&WHERE_BTM_LIMIT ){
    explainAppendTerm(pStr, pIndex, pLoop->u.btree.nBtm, j, i, ">");
    i = 1;
  }
  if( pLoop->wsFlags&WHERE_TOP_LIMIT ){
    explainAppendTerm(pStr, pIndex, pLoop->u.btree.nTop, j, i, "<");
  }
  sqlite3StrAccumAppend(pStr, ")", 1);
  sqlite3_str_append(pStr, ")", 1);
}

/*
** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN
** command, or if either SQLITE_DEBUG or SQLITE_ENABLE_STMT_SCANSTATUS was
** defined at compile-time. If it is not a no-op, a single OP_Explain opcode 
** is added to the output to describe the table scan strategy in pLevel.
**
** If an OP_Explain opcode is added to the VM, its address is returned.
** Otherwise, if no OP_Explain is coded, zero is returned.
*/
SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
  Parse *pParse,                  /* Parse context */
  SrcList *pTabList,              /* Table list this loop refers to */
  WhereLevel *pLevel,             /* Scan to write OP_Explain opcode for */
  int iLevel,                     /* Value for "level" column of output */
  int iFrom,                      /* Value for "from" column of output */
  u16 wctrlFlags                  /* Flags passed to sqlite3WhereBegin() */
){
  int ret = 0;
#if !defined(SQLITE_DEBUG) && !defined(SQLITE_ENABLE_STMT_SCANSTATUS)
  if( sqlite3ParseToplevel(pParse)->explain==2 )
#endif
  {
    struct SrcList_item *pItem = &pTabList->a[pLevel->iFrom];
    Vdbe *v = pParse->pVdbe;      /* VM being constructed */
    sqlite3 *db = pParse->db;     /* Database handle */
    int iId = pParse->iSelectId;  /* Select id (left-most output column) */
    int isSearch;                 /* True for a SEARCH. False for SCAN. */
    WhereLoop *pLoop;             /* The controlling WhereLoop object */
    u32 flags;                    /* Flags that describe this loop */
    char *zMsg;                   /* Text to add to EQP output */
    StrAccum str;                 /* EQP output string */
    char zBuf[100];               /* Initial space for EQP output string */

    pLoop = pLevel->pWLoop;
    flags = pLoop->wsFlags;
    if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_OR_SUBCLAUSE) ) return 0;

    isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
            || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
            || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));

    sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
    sqlite3StrAccumAppendAll(&str, isSearch ? "SEARCH" : "SCAN");
    sqlite3_str_appendall(&str, isSearch ? "SEARCH" : "SCAN");
    if( pItem->pSelect ){
      sqlite3XPrintf(&str, " SUBQUERY %d", pItem->iSelectId);
      sqlite3_str_appendf(&str, " SUBQUERY 0x%p", pItem->pSelect);
    }else{
      sqlite3XPrintf(&str, " TABLE %s", pItem->zName);
      sqlite3_str_appendf(&str, " TABLE %s", pItem->zName);
    }

    if( pItem->zAlias ){
      sqlite3XPrintf(&str, " AS %s", pItem->zAlias);
      sqlite3_str_appendf(&str, " AS %s", pItem->zAlias);
    }
    if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0 ){
      const char *zFmt = 0;
      Index *pIdx;

      assert( pLoop->u.btree.pIndex!=0 );
      pIdx = pLoop->u.btree.pIndex;
131035
131036
131037
131038
131039
131040
131041
131042
131043


131044
131045
131046
131047
131048
131049
131050
131051
131052
131053
131054
131055
131056
131057

131058

131059
131060
131061
131062

131063
131064
131065
131066
131067

131068

131069
131070

131071
131072
131073
131074


131075
131076
131077
131078
131079
131080
131081
132559
132560
132561
132562
132563
132564
132565


132566
132567
132568
132569
132570
132571
132572
132573
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

132600
132601
132602
132603
132604
132605
132606
132607
132608







-
-
+
+














+
-
+



-
+





+
-
+

-
+



-
+
+







        zFmt = "AUTOMATIC COVERING INDEX";
      }else if( flags & WHERE_IDX_ONLY ){
        zFmt = "COVERING INDEX %s";
      }else{
        zFmt = "INDEX %s";
      }
      if( zFmt ){
        sqlite3StrAccumAppend(&str, " USING ", 7);
        sqlite3XPrintf(&str, zFmt, pIdx->zName);
        sqlite3_str_append(&str, " USING ", 7);
        sqlite3_str_appendf(&str, zFmt, pIdx->zName);
        explainIndexRange(&str, pLoop);
      }
    }else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){
      const char *zRangeOp;
      if( flags&(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) ){
        zRangeOp = "=";
      }else if( (flags&WHERE_BOTH_LIMIT)==WHERE_BOTH_LIMIT ){
        zRangeOp = ">? AND rowid<";
      }else if( flags&WHERE_BTM_LIMIT ){
        zRangeOp = ">";
      }else{
        assert( flags&WHERE_TOP_LIMIT);
        zRangeOp = "<";
      }
      sqlite3_str_appendf(&str, 
      sqlite3XPrintf(&str, " USING INTEGER PRIMARY KEY (rowid%s?)",zRangeOp);
          " USING INTEGER PRIMARY KEY (rowid%s?)",zRangeOp);
    }
#ifndef SQLITE_OMIT_VIRTUALTABLE
    else if( (flags & WHERE_VIRTUALTABLE)!=0 ){
      sqlite3XPrintf(&str, " VIRTUAL TABLE INDEX %d:%s",
      sqlite3_str_appendf(&str, " VIRTUAL TABLE INDEX %d:%s",
                  pLoop->u.vtab.idxNum, pLoop->u.vtab.idxStr);
    }
#endif
#ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS
    if( pLoop->nOut>=10 ){
      sqlite3_str_appendf(&str, " (~%llu rows)",
      sqlite3XPrintf(&str, " (~%llu rows)", sqlite3LogEstToInt(pLoop->nOut));
             sqlite3LogEstToInt(pLoop->nOut));
    }else{
      sqlite3StrAccumAppend(&str, " (~1 row)", 9);
      sqlite3_str_append(&str, " (~1 row)", 9);
    }
#endif
    zMsg = sqlite3StrAccumFinish(&str);
    ret = sqlite3VdbeAddOp4(v, OP_Explain, iId, iLevel, iFrom, zMsg,P4_DYNAMIC);
    ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v),
                            pParse->addrExplain, 0, zMsg,P4_DYNAMIC);
  }
  return ret;
}
#endif /* SQLITE_OMIT_EXPLAIN */

#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
/*
132068
132069
132070
132071
132072
132073
132074



132075
132076
132077
132078
132079
132080
132081
133595
133596
133597
133598
133599
133600
133601
133602
133603
133604
133605
133606
133607
133608
133609
133610
133611







+
+
+







  addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(v);
  addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(v);

  /* If this is the right table of a LEFT OUTER JOIN, allocate and
  ** initialize a memory cell that records if this table matches any
  ** row of the left table of the join.
  */
  assert( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)
       || pLevel->iFrom>0 || (pTabItem[0].fg.jointype & JT_LEFT)==0
  );
  if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
    pLevel->iLeftJoin = ++pParse->nMem;
    sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
    VdbeComment((v, "init LEFT JOIN no-match flag"));
  }

  /* Compute a safe address to jump to if we discover that the table for
132601
132602
132603
132604
132605
132606
132607






132608

132609
132610


132611
132612
132613
132614
132615
132616
132617
134131
134132
134133
134134
134135
134136
134137
134138
134139
134140
134141
134142
134143
134144
134145


134146
134147
134148
134149
134150
134151
134152
134153
134154







+
+
+
+
+
+

+
-
-
+
+







      sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont,
                           iRowidReg, pPk->nKeyCol); VdbeCoverage(v);
    }

    /* If pIdx is an index on one or more expressions, then look through
    ** all the expressions in pWInfo and try to transform matching expressions
    ** into reference to index columns.
    **
    ** Do not do this for the RHS of a LEFT JOIN. This is because the 
    ** expression may be evaluated after OP_NullRow has been executed on
    ** the cursor. In this case it is important to do the full evaluation,
    ** as the result of the expression may not be NULL, even if all table
    ** column values are.  https://www.sqlite.org/src/info/7fa8049685b50b5a
    */
    if( pLevel->iLeftJoin==0 ){
    whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);

      whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);
    }

    /* Record the instruction used to terminate the loop. */
    if( pLoop->wsFlags & WHERE_ONEROW ){
      pLevel->op = OP_Noop;
    }else if( bRev ){
      pLevel->op = OP_Prev;
    }else{
132759
132760
132761
132762
132763
132764
132765
132766
132767
132768
132769
132770
132771
132772
132773
132774
132775
132776
132777
132778
132779
132780
132781
132782
132783
132784

132785
132786
132787
132788
132789
132790

132791



132792
132793
132794
132795
132796
132797
132798
132799
132800
132801
132802
132803

132804
132805
132806
132807
132808
132809
132810
134296
134297
134298
134299
134300
134301
134302

134303
134304
134305
134306
134307
134308
134309
134310
134311
134312
134313
134314
134315
134316
134317
134318
134319
134320
134321
134322
134323
134324
134325
134326
134327
134328

134329
134330
134331
134332
134333
134334
134335
134336
134337
134338
134339
134340
134341
134342

134343
134344
134345
134346
134347
134348
134349
134350







-


















+






+
-
+
+
+











-
+







    ** See ticket http://www.sqlite.org/src/info/f2369304e4
    */
    if( pWC->nTerm>1 ){
      int iTerm;
      for(iTerm=0; iTerm<pWC->nTerm; iTerm++){
        Expr *pExpr = pWC->a[iTerm].pExpr;
        if( &pWC->a[iTerm] == pTerm ) continue;
        if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
        testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL );
        testcase( pWC->a[iTerm].wtFlags & TERM_CODED );
        if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED))!=0 ) continue;
        if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
        testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );
        pExpr = sqlite3ExprDup(db, pExpr, 0);
        pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
      }
      if( pAndExpr ){
        pAndExpr = sqlite3PExpr(pParse, TK_AND|TKFLG_DONTFOLD, 0, pAndExpr);
      }
    }

    /* Run a separate WHERE clause for each term of the OR clause.  After
    ** eliminating duplicates from other WHERE clauses, the action for each
    ** sub-WHERE clause is to to invoke the main loop body as a subroutine.
    */
    wctrlFlags =  WHERE_OR_SUBCLAUSE | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE);
    ExplainQueryPlan((pParse, 1, "MULTI-INDEX OR"));
    for(ii=0; ii<pOrWc->nTerm; ii++){
      WhereTerm *pOrTerm = &pOrWc->a[ii];
      if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
        WhereInfo *pSubWInfo;           /* Info for single OR-term scan */
        Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
        int jmp1 = 0;                   /* Address of jump operation */
        assert( (pTabItem[0].fg.jointype & JT_LEFT)==0 
        if( pAndExpr && !ExprHasProperty(pOrExpr, EP_FromJoin) ){
             || ExprHasProperty(pOrExpr, EP_FromJoin) 
        );
        if( pAndExpr ){
          pAndExpr->pLeft = pOrExpr;
          pOrExpr = pAndExpr;
        }
        /* Loop through table entries that match term pOrTerm. */
        WHERETRACE(0xffff, ("Subplan for OR-clause:\n"));
        pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
                                      wctrlFlags, iCovCur);
        assert( pSubWInfo || pParse->nErr || db->mallocFailed );
        if( pSubWInfo ){
          WhereLoop *pSubLoop;
          int addrExplain = sqlite3WhereExplainOneScan(
              pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
              pParse, pOrTab, &pSubWInfo->a[0], 0
          );
          sqlite3WhereAddScanStatus(v, pOrTab, &pSubWInfo->a[0], addrExplain);

          /* This is the sub-WHERE clause body.  First skip over
          ** duplicate rows from prior sub-WHERE clauses, and record the
          ** rowid (or PRIMARY KEY) for the current row so that the same
          ** row will be skipped in subsequent sub-WHERE clauses.
132895
132896
132897
132898
132899
132900
132901

132902
132903
132904
132905
132906
132907
132908
134435
134436
134437
134438
134439
134440
134441
134442
134443
134444
134445
134446
134447
134448
134449







+







          }

          /* Finish the loop through table entries that match term pOrTerm. */
          sqlite3WhereEnd(pSubWInfo);
        }
      }
    }
    ExplainQueryPlanPop(pParse);
    pLevel->u.pCovidx = pCov;
    if( pCov ) pLevel->iIdxCur = iCovCur;
    if( pAndExpr ){
      pAndExpr->pLeft = 0;
      sqlite3ExprDelete(db, pAndExpr);
    }
    sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
132967
132968
132969
132970
132971
132972
132973
132974

132975
132976
132977
132978
132979
132980
132981
134508
134509
134510
134511
134512
134513
134514

134515
134516
134517
134518
134519
134520
134521
134522







-
+







        testcase( pWInfo->untestedTerms==0
            && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 );
        pWInfo->untestedTerms = 1;
        continue;
      }
      pE = pTerm->pExpr;
      assert( pE!=0 );
      if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
      if( (pTabItem->fg.jointype&JT_LEFT) && !ExprHasProperty(pE,EP_FromJoin) ){
        continue;
      }
      
      if( iLoop==1 && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){
        iNext = 2;
        continue;
      }
133894
133895
133896
133897
133898
133899
133900
133901
133902
133903
133904
133905
133906
133907
133908
135435
135436
135437
135438
135439
135440
135441

135442
135443
135444
135445
135446
135447
135448







-







        testcase( idxNew==0 );
        exprAnalyze(pSrc, pWC, idxNew);
        pTerm = &pWC->a[idxTerm];
        markTermAsChild(pWC, idxNew, idxTerm);
      }else{
        sqlite3ExprListDelete(db, pList);
      }
      pTerm->eOperator = WO_NOOP;  /* case 1 trumps case 3 */
    }
  }
}
#endif /* !SQLITE_OMIT_OR_OPTIMIZATION && !SQLITE_OMIT_SUBQUERY */

/*
** We already know that pExpr is a binary operator where both operands are
137031
137032
137033
137034
137035
137036
137037
137038

137039
137040
137041
137042
137043
137044
137045
137046
137047
137048
137049
137050
137051
137052
137053
138571
138572
138573
138574
138575
138576
138577

138578
138579
138580
138581
138582

138583


138584
138585
138586
138587
138588
138589
138590







-
+




-

-
-







    }
    if( pTerm->prereqRight & pNew->maskSelf ) continue;

    /* Do not allow the upper bound of a LIKE optimization range constraint
    ** to mix with a lower range bound from some other source */
    if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;

    /* Do not allow IS constraints from the WHERE clause to be used by the
    /* Do not allow constraints from the WHERE clause to be used by the
    ** right table of a LEFT JOIN.  Only constraints in the ON clause are
    ** allowed */
    if( (pSrc->fg.jointype & JT_LEFT)!=0
     && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
     && (eOp & (WO_IS|WO_ISNULL))!=0
    ){
      testcase( eOp & WO_IS );
      testcase( eOp & WO_ISNULL );
      continue;
    }

    if( IsUniqueIndex(pProbe) && saved_nEq==pProbe->nKeyCol-1 ){
      pBuilder->bldFlags |= SQLITE_BLDF_UNIQUE;
    }else{
      pBuilder->bldFlags |= SQLITE_BLDF_INDEXED;
137476
137477
137478
137479
137480
137481
137482
137483

137484
137485
137486
137487
137488

137489
137490



137491
137492
137493
137494
137495
137496
137497
139013
139014
139015
139016
139017
139018
139019

139020
139021
139022
139023
139024

139025
139026

139027
139028
139029
139030
139031
139032
139033
139034
139035
139036







-
+




-
+

-
+
+
+







        pNew->nSkip = 0;
        pNew->u.btree.pIndex = 0;
        pNew->nLTerm = 1;
        pNew->aLTerm[0] = pTerm;
        /* TUNING: One-time cost for computing the automatic index is
        ** estimated to be X*N*log2(N) where N is the number of rows in
        ** the table being indexed and where X is 7 (LogEst=28) for normal
        ** tables or 1.375 (LogEst=4) for views and subqueries.  The value
        ** tables or 0.5 (LogEst=-10) for views and subqueries.  The value
        ** of X is smaller for views and subqueries so that the query planner
        ** will be more aggressive about generating automatic indexes for
        ** those objects, since there is no opportunity to add schema
        ** indexes on subqueries and views. */
        pNew->rSetup = rLogSize + rSize + 4;
        pNew->rSetup = rLogSize + rSize;
        if( pTab->pSelect==0 && (pTab->tabFlags & TF_Ephemeral)==0 ){
          pNew->rSetup += 24;
          pNew->rSetup += 28;
        }else{
          pNew->rSetup -= 10;
        }
        ApplyCostMultiplier(pNew->rSetup, pTab->costMult);
        if( pNew->rSetup<0 ) pNew->rSetup = 0;
        /* TUNING: Each index lookup yields 20 rows in the table.  This
        ** is more than the usual guess of 10 rows, since we have no way
        ** of knowing how selective the index will ultimately be.  It would
        ** not be unreasonable to make this value much larger. */
138619
138620
138621
138622
138623
138624
138625
138626

138627
138628



138629
138630
138631

138632
138633
138634
138635
138636
138637
138638
140158
140159
140160
140161
140162
140163
140164

140165
140166

140167
140168
140169
140170
140171
140172
140173
140174
140175
140176
140177
140178
140179
140180







-
+

-
+
+
+



+







        LogEst rUnsorted;                 /* Unsorted cost of (pFrom+pWLoop) */
        i8 isOrdered = pFrom->isOrdered;  /* isOrdered for (pFrom+pWLoop) */
        Bitmask maskNew;                  /* Mask of src visited by (..) */
        Bitmask revMask = 0;              /* Mask of rev-order loops for (..) */

        if( (pWLoop->prereq & ~pFrom->maskLoop)!=0 ) continue;
        if( (pWLoop->maskSelf & pFrom->maskLoop)!=0 ) continue;
        if( (pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 && pFrom->nRow<10 ){
        if( (pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 && pFrom->nRow<3 ){
          /* Do not use an automatic index if the this loop is expected
          ** to run less than 2 times. */
          ** to run less than 1.25 times.  It is tempting to also exclude
          ** automatic index usage on an outer loop, but sometimes an automatic
          ** index is useful in the outer loop of a correlated subquery. */
          assert( 10==sqlite3LogEst(2) );
          continue;
        }

        /* At this point, pWLoop is a candidate to be the next loop. 
        ** Compute its cost */
        rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup,pWLoop->rRun + pFrom->nRow);
        rUnsorted = sqlite3LogEstAdd(rUnsorted, pFrom->rUnsorted);
        nOut = pFrom->nRow + pWLoop->nOut;
        maskNew = pFrom->maskLoop | pWLoop->maskSelf;
        if( isOrdered<0 ){
139206
139207
139208
139209
139210
139211
139212

139213
139214
139215
139216
139217
139218
139219
140748
140749
140750
140751
140752
140753
140754
140755
140756
140757
140758
140759
140760
140761
140762







+







  /* Special case: No FROM clause
  */
  if( nTabList==0 ){
    if( pOrderBy ) pWInfo->nOBSat = pOrderBy->nExpr;
    if( wctrlFlags & WHERE_WANT_DISTINCT ){
      pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
    }
    ExplainQueryPlan((pParse, 0, "SCAN CONSTANT ROW"));
  }else{
    /* Assign a bit from the bitmask to every term in the FROM clause.
    **
    ** The N-th term of the FROM clause is assigned a bitmask of 1<<N.
    **
    ** The rule of the previous sentence ensures thta if X is the bitmask for
    ** a table T, then X-1 is the bitmask for all other tables to the left of T.
139601
139602
139603
139604
139605
139606
139607
139608

139609
139610
139611
139612
139613
139614
139615
141144
141145
141146
141147
141148
141149
141150

141151
141152
141153
141154
141155
141156
141157
141158







-
+







    if( (pLevel->pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 ){
      constructAutomaticIndex(pParse, &pWInfo->sWC,
                &pTabList->a[pLevel->iFrom], notReady, pLevel);
      if( db->mallocFailed ) goto whereBeginError;
    }
#endif
    addrExplain = sqlite3WhereExplainOneScan(
        pParse, pTabList, pLevel, ii, pLevel->iFrom, wctrlFlags
        pParse, pTabList, pLevel, wctrlFlags
    );
    pLevel->addrBody = sqlite3VdbeCurrentAddr(v);
    notReady = sqlite3WhereCodeOneLoopStart(pWInfo, ii, notReady);
    pWInfo->iContinue = pLevel->addrCont;
    if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_OR_SUBCLAUSE)==0 ){
      sqlite3WhereAddScanStatus(v, pTabList, pLevel, addrExplain);
    }
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
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







+


+



















-
+

-
+




-
+
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+




-
-
-
-
+
+
+
+
+
+
+
+
+
+

-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+







**                       This is typically a union of many types, one of
**                       which is sqlite3ParserTOKENTYPE.  The entry in the union
**                       for terminal symbols is called "yy0".
**    YYSTACKDEPTH       is the maximum depth of the parser's stack.  If
**                       zero the stack is dynamically sized using realloc()
**    sqlite3ParserARG_SDECL     A static variable declaration for the %extra_argument
**    sqlite3ParserARG_PDECL     A parameter declaration for the %extra_argument
**    sqlite3ParserARG_PARAM     Code to pass %extra_argument as a subroutine parameter
**    sqlite3ParserARG_STORE     Code to store %extra_argument into yypParser
**    sqlite3ParserARG_FETCH     Code to extract %extra_argument from yypParser
**    sqlite3ParserCTX_*         As sqlite3ParserARG_ except for %extra_context
**    YYERRORSYMBOL      is the code number of the error symbol.  If not
**                       defined, then do no error processing.
**    YYNSTATE           the combined number of states.
**    YYNRULE            the number of rules in the grammar
**    YYNTOKEN           Number of terminal symbols
**    YY_MAX_SHIFT       Maximum value for shift actions
**    YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
**    YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
**    YY_ERROR_ACTION    The yy_action[] code for syntax error
**    YY_ACCEPT_ACTION   The yy_action[] code for accept
**    YY_NO_ACTION       The yy_action[] code for no-op
**    YY_MIN_REDUCE      Minimum value for reduce actions
**    YY_MAX_REDUCE      Maximum value for reduce actions
*/
#ifndef INTERFACE
# define INTERFACE 1
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned char
#define YYNOCODE 253
#define YYNOCODE 255
#define YYACTIONTYPE unsigned short int
#define YYWILDCARD 83
#define YYWILDCARD 84
#define sqlite3ParserTOKENTYPE Token
typedef union {
  int yyinit;
  sqlite3ParserTOKENTYPE yy0;
  int yy4;
  const char* yy36;
  struct TrigEvent yy90;
  TriggerStep* yy203;
  struct {int value; int mask;} yy215;
  TriggerStep* yy47;
  With* yy91;
  struct {int value; int mask;} yy107;
  SrcList* yy259;
  Expr* yy314;
  ExprList* yy322;
  const char* yy336;
  IdList* yy384;
  Select* yy387;
  With* yy451;
  Expr* yy182;
  Upsert* yy198;
  ExprList* yy232;
  struct TrigEvent yy300;
  Select* yy399;
  SrcList* yy427;
  int yy502;
  IdList* yy510;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#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 sqlite3ParserARG_SDECL
#define sqlite3ParserARG_PDECL
#define sqlite3ParserARG_PARAM
#define sqlite3ParserARG_FETCH
#define sqlite3ParserARG_STORE
#define sqlite3ParserCTX_SDECL Parse *pParse;
#define sqlite3ParserCTX_PDECL ,Parse *pParse
#define sqlite3ParserCTX_PARAM ,pParse
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
#define sqlite3ParserCTX_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
#define YYNSTATE             490
#define YYNRULE              341
#define YYNTOKEN             145
#define YY_MAX_SHIFT         489
#define YY_MIN_SHIFTREDUCE   705
#define YY_MAX_SHIFTREDUCE   1045
#define YY_ERROR_ACTION      1046
#define YY_ACCEPT_ACTION     1047
#define YY_NO_ACTION         1048
#define YY_MIN_REDUCE        1049
#define YY_MAX_REDUCE        1389
/************* 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
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
140594
140595
140596
140597
140598
140599
140600
140601
140602
140603
140604
140605
140606
140607
140608
140609
140610
140611
140612
140613
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
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
141811
141812
141813
141814
141815
141816
141817
141818
141819
141820




















141821
141822
141823
141824
141825
141826
141827
141828
141829
141830
141831
141832
141833
141834
141835
141836
141837
141838
141839
141840
141841




















141842
141843
141844
141845
141846
141847
141848
141849
141850
141851
141852
141853
141854
141855
141856
141857
141858
141859
141860
141861
141862




















141863
141864
141865
141866
141867
141868
141869
141870
141871
141872
141873
141874
141875
141876
141877
141878
141879
141880
141881
141882
141883
141884
141885














141886
141887
141888
141889
141890
141891
141892
141893
141894
141895
141896
141897
141898
141899













141900
141901
141902
141903
141904
141905
141906
141907



141908




























141909
141910
141911
141912
141913
141914
141915
141916
141917
141918
141919
141920
141921
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
142189
142190
142191
142192
142193
142194
142195
142196
142197
142198
142199
142200
142201
142202
142203
142204
142205
142206
142207
142208
142209
142210
142211
142212
142213
142214
142215
142216
142217
142218
142219







-
+

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
+

-
+

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
-
+
+
+

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







**  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)
#define YY_ACTTAB_COUNT (1657)
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,
 /*     0 */   349,   99,   96,  185,   99,   96,  185,  233, 1047,    1,
 /*    10 */     1,  489,    2, 1051,  484,  477,  477,  477,  260,  351,
 /*    20 */   121, 1310, 1120, 1120, 1178, 1115, 1094, 1128,  380,  380,
 /*    30 */   380,  835,  454,  410, 1115,   59,   59, 1357,  425,  836,
 /*    40 */   710,  711,  712,  106,  107,   97, 1023, 1023,  900,  903,
 /*    50 */   892,  892,  104,  104,  105,  105,  105,  105,  346,  238,
 /*    60 */   238,   99,   96,  185,  238,  238,  889,  889,  901,  904,
 /*    70 */   460,  481,  351,   99,   96,  185,  481,  347, 1177,   82,
 /*    80 */   388,  214,  182,   23,  194,  103,  103,  103,  103,  102,
 /*    90 */   102,  101,  101,  101,  100,  381,  106,  107,   97, 1023,
 /*   100 */  1023,  900,  903,  892,  892,  104,  104,  105,  105,  105,
 /*   110 */   105,   10,  385,  484,   24,  484, 1333,  489,    2, 1051,
 /*   120 */   335, 1043,  108,  893,  260,  351,  121,   99,   96,  185,
 /*   130 */   100,  381,  386, 1128,   59,   59,   59,   59,  103,  103,
 /*   140 */   103,  103,  102,  102,  101,  101,  101,  100,  381,  106,
 /*   150 */   107,   97, 1023, 1023,  900,  903,  892,  892,  104,  104,
 /*   160 */   105,  105,  105,  105,  360,  238,  238,  170,  170,  467,
 /*   170 */   455,  467,  464,   67,  381,  329,  169,  481,  351,  343,
 /*   180 */   338,  400, 1044,   68,  101,  101,  101,  100,  381,  393,
 /*   190 */   194,  103,  103,  103,  103,  102,  102,  101,  101,  101,
 /*   200 */   100,  381,  106,  107,   97, 1023, 1023,  900,  903,  892,
 /*   210 */   892,  104,  104,  105,  105,  105,  105,  483,  385,  103,
 /*   220 */   103,  103,  103,  102,  102,  101,  101,  101,  100,  381,
 /*   230 */   268,  351,  946,  946,  422,  296,  102,  102,  101,  101,
 /*   240 */   101,  100,  381,  861,  103,  103,  103,  103,  102,  102,
 /*   250 */   101,  101,  101,  100,  381,  106,  107,   97, 1023, 1023,
 /*   260 */   900,  903,  892,  892,  104,  104,  105,  105,  105,  105,
 /*   270 */   484,  983, 1383,  206, 1353, 1383,  438,  435,  434,  281,
 /*   280 */   396,  269, 1089,  941,  351, 1002,  433,  861,  743,  401,
 /*   290 */   282,   57,   57,  482,  145,  791,  791,  103,  103,  103,
 /*   300 */   103,  102,  102,  101,  101,  101,  100,  381,  106,  107,
 /*   310 */    97, 1023, 1023,  900,  903,  892,  892,  104,  104,  105,
 /*   320 */   105,  105,  105,  281, 1002, 1003, 1004,  206,  879,  319,
 /*   330 */   438,  435,  434,  981,  259,  474,  360,  351, 1118, 1118,
 /*   340 */   433,  736,  379,  378,  872, 1002, 1356,  322,  871,  766,
 /*   350 */   103,  103,  103,  103,  102,  102,  101,  101,  101,  100,
 /*   360 */   381,  106,  107,   97, 1023, 1023,  900,  903,  892,  892,
 /*   370 */   104,  104,  105,  105,  105,  105,  484,  801,  484,  871,
 /*   380 */   871,  873,  401,  282, 1002, 1003, 1004, 1030,  360, 1030,
 /*   390 */   351,  983, 1384,  213,  880, 1384,  145,   59,   59,   59,
 /*   400 */    59, 1002,  244,  103,  103,  103,  103,  102,  102,  101,
 /*   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,
 /*   410 */   101,  101,  100,  381,  106,  107,   97, 1023, 1023,  900,
 /*   420 */   903,  892,  892,  104,  104,  105,  105,  105,  105,  274,
 /*   430 */   484,  110,  467,  479,  467,  444,  259,  474,  232,  232,
 /*   440 */  1002, 1003, 1004,  351,  210,  335,  982,  866, 1385,  336,
 /*   450 */   481,   59,   59,  981,  245,  307,  103,  103,  103,  103,
 /*   460 */   102,  102,  101,  101,  101,  100,  381,  106,  107,   97,
 /*   470 */  1023, 1023,  900,  903,  892,  892,  104,  104,  105,  105,
 /*   480 */   105,  105,  453,  459,  484,  408,  377,  259,  474,  271,
 /*   490 */   183,  273,  209,  208,  207,  356,  351,  307,  178,  177,
 /*   500 */   127, 1006, 1098,   14,   14,   43,   43, 1044,  425,  103,
 /*   510 */   103,  103,  103,  102,  102,  101,  101,  101,  100,  381,
 /*   520 */   106,  107,   97, 1023, 1023,  900,  903,  892,  892,  104,
 /*   530 */   104,  105,  105,  105,  105,  294, 1132,  408,  160,  484,
 /*   540 */   408, 1006,  129,  962, 1209,  239,  239,  481,  307,  425,
 /*   550 */  1309, 1097,  351,  235,  243,  272,  820,  481,  963,  425,
 /*   560 */    11,   11,  103,  103,  103,  103,  102,  102,  101,  101,
 /*   570 */   101,  100,  381,  964,  362, 1002,  106,  107,   97, 1023,
 /*   580 */  1023,  900,  903,  892,  892,  104,  104,  105,  105,  105,
 /*   590 */   105, 1275,  161,  126,  777,  289, 1209,  292, 1072,  357,
 /*   600 */  1209, 1127,  476,  357,  778,  425,  247,  425,  351,  248,
 /*   610 */   414,  364,  414,  171, 1002, 1003, 1004,   84,  103,  103,
 /*   620 */   103,  103,  102,  102,  101,  101,  101,  100,  381, 1002,
 /*   630 */   184,  484,  106,  107,   97, 1023, 1023,  900,  903,  892,
 /*   640 */   892,  104,  104,  105,  105,  105,  105, 1123, 1209,  287,
 /*   650 */   484, 1209,   11,   11,  179,  820,  259,  474,  307,  237,
 /*   660 */   182,  351,  321,  365,  414,  308,  367,  366, 1002, 1003,
 /*   670 */  1004,   44,   44,   87,  103,  103,  103,  103,  102,  102,
 /*   680 */   101,  101,  101,  100,  381,  106,  107,   97, 1023, 1023,
 /*   690 */   900,  903,  892,  892,  104,  104,  105,  105,  105,  105,
 /*   700 */   246,  368,  280,  128,   10,  358,  146,  796,  835,  258,
 /*   710 */  1020,   88,  795,   86,  351,  421,  836,  943,  376,  348,
 /*   720 */   191,  943, 1318,  267,  308,  279,  456,  103,  103,  103,
 /*   730 */   103,  102,  102,  101,  101,  101,  100,  381,  106,   95,
 /*   740 */    97, 1023, 1023,  900,  903,  892,  892,  104,  104,  105,
 /*   750 */   105,  105,  105,  420,  249,  238,  238,  238,  238,   79,
 /*   760 */   375,  125,  305,   29,  262,  978,  351,  481,  337,  481,
 /*   770 */   756,  755,  304,  278,  415,   15,   81,  940, 1126,  940,
 /*   780 */   103,  103,  103,  103,  102,  102,  101,  101,  101,  100,
 /*   790 */   381,  107,   97, 1023, 1023,  900,  903,  892,  892,  104,
 /*   800 */   104,  105,  105,  105,  105,  457,  263,  484,  174,  484,
 /*   810 */   238,  238,  863,  407,  402,  216,  216,  351,  409,  193,
 /*   820 */   283,  216,  481,   81,  763,  764,  266,    5,   13,   13,
 /*   830 */    34,   34,  103,  103,  103,  103,  102,  102,  101,  101,
 /*   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,
 /*   840 */   101,  100,  381,   97, 1023, 1023,  900,  903,  892,  892,
 /*   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,
 /*   850 */   104,  104,  105,  105,  105,  105,   93,  475, 1002,    4,
 /*   860 */   403, 1002,  340,  431, 1002,  297,  212, 1277,   81,  746,
 /*   870 */  1163,  152,  926,  478,  166,  212,  757,  829,  930,  939,
 /*   880 */   216,  939,  858,  103,  103,  103,  103,  102,  102,  101,
 /*   890 */   101,  101,  100,  381,  238,  238,  382, 1002, 1003, 1004,
 /*   900 */  1002, 1003, 1004, 1002, 1003, 1004,  481,  439,  472,  746,
 /*   910 */   105,  105,  105,  105,   98,  758, 1162,  145,  930,  412,
 /*   920 */   879,  406,  793,   81,  395,   89,   90,   91,  105,  105,
 /*   930 */   105,  105, 1323,   92,  484,  382,  486,  485,  240,  275,
 /*   940 */   871,  103,  103,  103,  103,  102,  102,  101,  101,  101,
 /*   950 */   100,  381, 1096,  371,  355,   45,   45,  259,  474,  103,
 /*   960 */   103,  103,  103,  102,  102,  101,  101,  101,  100,  381,
 /*   970 */  1150,  871,  871,  873,  874,   21, 1332,  991,  384,  730,
 /*   980 */   722,  242,  123, 1298,  124,  875,  333,  333,  332,  227,
 /*   990 */   330,  991,  384,  719,  256,  242,  484,  391,  413, 1297,
 /*  1000 */   333,  333,  332,  227,  330,  748,  187,  719,  265,  470,
 /*  1010 */  1279, 1002,  484,  417,  391,  390,  264,   11,   11,  284,
 /*  1020 */   187,  732,  265,   93,  475,  875,    4, 1279, 1281,  419,
 /*   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,
 /*  1030 */   264,  369,  416,   11,   11, 1159,  288,  484,  399, 1346,
 /*  1040 */   478,  379,  378,  291,  484,  293,  189,  250,  295, 1027,
 /*  1050 */  1002, 1003, 1004,  190, 1029, 1111,  140,  188,   11,   11,
 /*  1060 */   189,  732, 1028,  382,  923,   46,   46,  190, 1095,  230,
 /*  1070 */   140,  188,  462,   93,  475,  472,    4,  300,  309,  391,
 /*  1080 */   373,    6, 1069,  217,  739,  310, 1030,  879, 1030, 1171,
 /*  1090 */   478,  352, 1279,   90,   91,  800,  259,  474, 1208,  484,
 /*  1100 */    92, 1268,  382,  486,  485,  352, 1002,  871,  879,  426,
 /*  1110 */   259,  474,  172,  382,  238,  238, 1146,  170, 1021,  389,
 /*  1120 */    47,   47, 1157,  739,  872,  472,  481,  469,  871,  350,
 /*  1130 */  1214,   83,  475,  389,    4, 1078, 1071,  879,  871,  871,
 /*  1140 */   873,  874,   21,   90,   91, 1002, 1003, 1004,  478,  251,
 /*  1150 */    92,  251,  382,  486,  485,  443,  370,  871, 1021,  871,
 /*  1160 */   871,  873,  224,  241,  306,  441,  301,  440,  211, 1060,
 /*  1170 */   820,  382,  822,  447,  299, 1059,  484, 1061, 1143,  962,
 /*  1180 */   430,  796,  484,  472, 1340,  312,  795,  465,  871,  871,
 /*  1190 */   873,  874,   21,  314,  963,  879,  316,   59,   59, 1002,
 /*  1200 */     9,   90,   91,   48,   48,  238,  238,  210,   92,  964,
 /*  1210 */   382,  486,  485,  176,  334,  871,  242,  481, 1193,  238,
 /*  1220 */   238,  333,  333,  332,  227,  330,  394,  270,  719,  277,
 /*  1230 */   471,  481,  467,  466,  484,  145,  217, 1201, 1002, 1003,
 /*  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,
 /*  1240 */  1004,  187,    3,  265,  184,  445,  871,  871,  873,  874,
 /*  1250 */    21,  264, 1337,  450, 1051,   39,   39,  392,  356,  260,
 /*  1260 */   342,  121,  468,  411,  436,  821,  180, 1094, 1128,  820,
 /*  1270 */   303, 1021, 1272, 1271,  299,  259,  474,  238,  238, 1002,
 /*  1280 */   473,  189,  484,  318,  327,  238,  238,  484,  190,  481,
 /*  1290 */   446,  140,  188, 1343,  238,  238, 1038,  481,  148,  175,
 /*  1300 */   238,  238,  484,   49,   49,  219,  481,  484,   35,   35,
 /*  1310 */  1317, 1021,  481,  484, 1035,  484, 1315,  484, 1002, 1003,
 /*  1320 */  1004,  484,   66,   36,   36,  194,  352,  484,   38,   38,
 /*  1330 */   484,  259,  474,   69,   50,   50,   51,   51,   52,   52,
 /*  1340 */   359,  484,   12,   12,  484, 1198,  484,  158,   53,   53,
 /*  1350 */   405,  112,  112,  385,  389,  484,   26,  484,  143,  484,
 /*  1360 */   150,  484,   54,   54,  397,   40,   40,   55,   55,  484,
 /*  1370 */    79,  484,  153, 1190,  484,  154,   56,   56,   41,   41,
 /*  1380 */    58,   58,  133,  133,  484,  398,  484,  429,  484,  155,
 /*  1390 */   134,  134,  135,  135,  484,   63,   63,  484,  341,  484,
 /*  1400 */   339,  484,  196,  484,  156,   42,   42,  113,  113,   60,
 /*  1410 */    60,  484,  404,  484,   27,  114,  114, 1204,  115,  115,
 /*  1420 */   111,  111,  132,  132,  131,  131, 1266,  418,  484,  162,
 /*  1430 */   484,  200,  119,  119,  118,  118,  484,   74,  424,  484,
 /*  1440 */  1286,  484,  231,  484,  202,  484,  167,  286,  427,  116,
 /*  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,
 /*  1450 */   116,  117,  117,  290,  203,  442, 1062,   62,   62,  204,
 /*  1460 */    64,   64,   61,   61,   33,   33,   37,   37,  344,  372,
 /*  1470 */  1114, 1105,  748, 1113,  374, 1112,  254,  458, 1086,  255,
 /*  1480 */   345, 1085,  302, 1084, 1355,   78, 1154,  311, 1104,  449,
 /*  1490 */   452, 1155, 1153,  218,    7,  313,  315,  320, 1152,   85,
 /*  1500 */  1252,  317,  109,   80,  463,  225,  461, 1068,   25,  487,
 /*  1510 */   997,  323,  257,  226,  229,  228, 1136,  324,  325,  326,
 /*  1520 */   488,  136, 1057, 1052, 1302, 1303, 1301,  706, 1300,  137,
 /*  1530 */   122,  138,  383,  173, 1082,  261,  186,  252, 1081,   65,
 /*  1540 */   387,  120,  938,  936,  855,  353,  149, 1079,  139,  151,
 /*  1550 */   192,  780,  195,  276,  952,  157,  141,  361,   70,  363,
 /*  1560 */   859,  159,   71,   72,  142,   73,  955,  354,  147,  197,
 /*  1570 */   198,  951,  130,   16,  199,  285,  216, 1032,  201,  423,
 /*  1580 */   164,  944,  163,   28,  721,  428,  304,  165,  205,  759,
 /*  1590 */    75,  432,  298,   17,   18,  437,   76,  253,  878,  144,
 /*  1600 */   877,  906,   77,  986,   30,  448,  987,   31,  451,  181,
 /*  1610 */   234,  236,  168,  828,  823,   89,  910,  921,   81,  907,
 /*  1620 */   215,  905,  909,  961,  960,   19,  221,   20,  220,   22,
 /*  1630 */    32,  331,  876,  731,   94,  790,  794,    8,  992,  222,
 /*  1640 */   480,  328, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
 /*  1650 */   223, 1048, 1048, 1048, 1048, 1348, 1347,
};
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,
 /*     0 */   174,  226,  227,  228,  226,  227,  228,  172,  145,  146,
 /*    10 */   147,  148,  149,  150,  153,  169,  170,  171,  155,   19,
 /*    20 */   157,  246,  192,  193,  177,  181,  182,  164,  169,  170,
 /*    30 */   171,   31,  164,  153,  190,  174,  175,  187,  153,   39,
 /*    40 */     7,    8,    9,   43,   44,   45,   46,   47,   48,   49,
 /*    50 */    50,   51,   52,   53,   54,   55,   56,   57,  174,  196,
 /*    60 */   197,  226,  227,  228,  196,  197,   46,   47,   48,   49,
 /*    70 */   209,  208,   19,  226,  227,  228,  208,  174,  177,   26,
 /*    80 */   195,  213,  214,   22,  221,   85,   86,   87,   88,   89,
 /*    90 */    90,   91,   92,   93,   94,   95,   43,   44,   45,   46,
 /*   100 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   110 */    57,  172,  249,  153,   53,  153,  147,  148,  149,  150,
 /*   120 */    22,   23,   69,  103,  155,   19,  157,  226,  227,  228,
 /*   130 */    94,   95,  247,  164,  174,  175,  174,  175,   85,   86,
 /*   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,
 /*   140 */    87,   88,   89,   90,   91,   92,   93,   94,   95,   43,
 /*   150 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
 /*   160 */    54,   55,   56,   57,  153,  196,  197,  153,  153,  209,
 /*   170 */   210,  209,  210,   67,   95,  161,  237,  208,   19,  165,
 /*   180 */   165,  242,   84,   24,   91,   92,   93,   94,   95,  223,
 /*   190 */   221,   85,   86,   87,   88,   89,   90,   91,   92,   93,
 /*   200 */    94,   95,   43,   44,   45,   46,   47,   48,   49,   50,
 /*   210 */    51,   52,   53,   54,   55,   56,   57,  153,  249,   85,
 /*   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,
 /*   220 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   95,
 /*   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,
 /*   230 */   219,   19,  109,  110,  111,   23,   89,   90,   91,   92,
 /*   240 */    93,   94,   95,   73,   85,   86,   87,   88,   89,   90,
 /*   250 */    91,   92,   93,   94,   95,   43,   44,   45,   46,   47,
 /*   260 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   270 */   153,   22,   23,  101,  173,   26,  104,  105,  106,  109,
 /*   280 */   110,  111,  181,   11,   19,   59,  114,   73,   23,  110,
 /*   290 */   111,  174,  175,  116,   80,  118,  119,   85,   86,   87,
 /*   300 */    88,   89,   90,   91,   92,   93,   94,   95,   43,   44,
 /*   310 */    45,   46,   47,   48,   49,   50,   51,   52,   53,   54,
 /*   320 */    55,   56,   57,  109,   98,   99,  100,  101,   83,  153,
 /*   330 */   104,  105,  106,   84,  120,  121,  153,   19,  192,  193,
 /*   340 */   114,   23,   89,   90,   99,   59,   23,  230,  103,   26,
 /*   350 */    85,   86,   87,   88,   89,   90,   91,   92,   93,   94,
 /*   360 */    95,   43,   44,   45,   46,   47,   48,   49,   50,   51,
 /*   370 */    52,   53,   54,   55,   56,   57,  153,   91,  153,  134,
 /*   380 */   135,  136,  110,  111,   98,   99,  100,  134,  153,  136,
 /*   390 */    19,   22,   23,   26,   23,   26,   80,  174,  175,  174,
 /*   400 */   175,   59,  219,   85,   86,   87,   88,   89,   90,   91,
 /*   410 */    92,   93,   94,   95,   43,   44,   45,   46,   47,   48,
 /*   420 */    49,   50,   51,   52,   53,   54,   55,   56,   57,   16,
 /*   430 */   153,   22,  209,  210,  209,  210,  120,  121,  196,  197,
 /*   440 */    98,   99,  100,   19,   46,   22,   23,   23,  252,  253,
 /*   450 */   208,  174,  175,   84,  219,  153,   85,   86,   87,   88,
 /*   460 */    89,   90,   91,   92,   93,   94,   95,   43,   44,   45,
 /*   470 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
 /*   480 */    56,   57,  153,  153,  153,  153,  209,  120,  121,   76,
 /*   490 */   153,   78,  109,  110,  111,   97,   19,  153,   89,   90,
 /*   500 */   198,   59,  183,  174,  175,  174,  175,   84,  153,   85,
 /*   510 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   95,
 /*   520 */    43,   44,   45,   46,   47,   48,   49,   50,   51,   52,
 /*   530 */    53,   54,   55,   56,   57,   16,  197,  153,   22,  153,
 /*   540 */   153,   99,  198,   12,  153,  196,  197,  208,  153,  153,
 /*   550 */   195,  183,   19,   23,  222,  142,   26,  208,   27,  153,
 /*   560 */   174,  175,   85,   86,   87,   88,   89,   90,   91,   92,
 /*   570 */    93,   94,   95,   42,  188,   59,   43,   44,   45,   46,
 /*   580 */    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,
 /*   590 */    57,  195,   22,  198,   63,   76,  153,   78,  167,  168,
 /*   600 */   153,  195,  167,  168,   73,  153,  222,  153,   19,  222,
 /*   610 */   153,  220,  153,   24,   98,   99,  100,  140,   85,   86,
 /*   620 */    87,   88,   89,   90,   91,   92,   93,   94,   95,   59,
 /*   630 */   100,  153,   43,   44,   45,   46,   47,   48,   49,   50,
 /*   640 */    51,   52,   53,   54,   55,   56,   57,  195,  153,  195,
 /*   650 */   153,  153,  174,  175,   26,  125,  120,  121,  153,  213,
 /*   660 */   214,   19,  153,  220,  153,  153,  188,  220,   98,   99,
 /*   670 */   100,  174,  175,  140,   85,   86,   87,   88,   89,   90,
 /*   680 */    91,   92,   93,   94,   95,   43,   44,   45,   46,   47,
 /*   690 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   700 */   243,  189,  243,  198,  172,  250,  251,  117,   31,  201,
 /*   710 */    26,  139,  122,  141,   19,  220,   39,   29,  220,  211,
 /*   720 */    24,   33,  153,  164,  153,  164,   19,   85,   86,   87,
 /*   730 */    88,   89,   90,   91,   92,   93,   94,   95,   43,   44,
 /*   740 */    45,   46,   47,   48,   49,   50,   51,   52,   53,   54,
 /*   750 */    55,   56,   57,   65,  243,  196,  197,  196,  197,  131,
 /*   760 */   189,   22,  103,   24,  153,   23,   19,  208,   26,  208,
 /*   770 */   102,  103,  113,   23,  242,   22,   26,  134,  164,  136,
 /*   780 */    85,   86,   87,   88,   89,   90,   91,   92,   93,   94,
 /*   790 */    95,   44,   45,   46,   47,   48,   49,   50,   51,   52,
 /*   800 */    53,   54,   55,   56,   57,   98,  153,  153,  124,  153,
 /*   810 */   196,  197,   23,   23,   61,   26,   26,   19,   23,  123,
 /*   820 */    23,   26,  208,   26,    7,    8,  153,   22,  174,  175,
 /*   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,
 /*   830 */   174,  175,   85,   86,   87,   88,   89,   90,   91,   92,
 /*   840 */    93,   94,   95,   45,   46,   47,   48,   49,   50,   51,
 /*   850 */    52,   53,   54,   55,   56,   57,   19,   20,   59,   22,
 /*   860 */   111,   59,  164,   23,   59,   23,   26,  153,   26,   59,
 /*   870 */   153,   72,   23,   36,   72,   26,   35,   23,   59,  134,
 /*   880 */    26,  136,  133,   85,   86,   87,   88,   89,   90,   91,
 /*   890 */    92,   93,   94,   95,  196,  197,   59,   98,   99,  100,
 /*   900 */    98,   99,  100,   98,   99,  100,  208,   66,   71,   99,
 /*   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,
 /*   910 */    54,   55,   56,   57,   58,   74,  153,   80,   99,   19,
 /*   920 */    83,  223,   23,   26,  153,   26,   89,   90,   54,   55,
 /*   930 */    56,   57,  153,   96,  153,   98,   99,  100,   22,  153,
 /*   940 */   103,   85,   86,   87,   88,   89,   90,   91,   92,   93,
 /*   950 */    94,   95,  183,  112,  158,  174,  175,  120,  121,   85,
 /*   960 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   95,
 /*   970 */   215,  134,  135,  136,  137,  138,    0,    1,    2,   23,
 /*   980 */    21,    5,   26,  153,   22,   59,   10,   11,   12,   13,
 /*   990 */    14,    1,    2,   17,  212,    5,  153,  153,   98,  153,
 /*  1000 */    10,   11,   12,   13,   14,  108,   30,   17,   32,  193,
 /*  1010 */   153,   59,  153,  153,  170,  171,   40,  174,  175,  153,
 /*  1020 */    30,   59,   32,   19,   20,   99,   22,  170,  171,  233,
 /*  1030 */    40,  188,  236,  174,  175,  153,  153,  153,   79,  123,
 /*  1040 */    36,   89,   90,  153,  153,  153,   70,  188,  153,   97,
 /*  1050 */    98,   99,  100,   77,  102,  153,   80,   81,  174,  175,
 /*  1060 */    70,   99,  110,   59,  105,  174,  175,   77,  153,  238,
 /*  1070 */    80,   81,  188,   19,   20,   71,   22,  153,  153,  235,
 /*  1080 */    19,   22,  164,   24,   59,  153,  134,   83,  136,  153,
 /*  1090 */    36,  115,  235,   89,   90,   91,  120,  121,  153,  153,
 /*  1100 */    96,  142,   98,   99,  100,  115,   59,  103,   83,  239,
 /*  1110 */   120,  121,  199,   59,  196,  197,  153,  153,   59,  143,
 /*  1120 */   174,  175,  153,   98,   99,   71,  208,  153,  103,  165,
 /*  1130 */   153,   19,   20,  143,   22,  153,  153,   83,  134,  135,
 /*  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,
 /*  1140 */   136,  137,  138,   89,   90,   98,   99,  100,   36,  185,
 /*  1150 */    96,  187,   98,   99,  100,   91,   95,  103,   99,  134,
 /*  1160 */   135,  136,  101,  102,  103,  104,  105,  106,  107,  153,
 /*  1170 */    26,   59,  125,  164,  113,  153,  153,  153,  212,   12,
 /*  1180 */    19,  117,  153,   71,  153,  212,  122,  164,  134,  135,
 /*  1190 */   136,  137,  138,  212,   27,   83,  212,  174,  175,   59,
 /*  1200 */   200,   89,   90,  174,  175,  196,  197,   46,   96,   42,
 /*  1210 */    98,   99,  100,  172,  151,  103,    5,  208,  203,  196,
 /*  1220 */   197,   10,   11,   12,   13,   14,  216,  216,   17,  244,
 /*  1230 */    63,  208,  209,  210,  153,   80,   24,  203,   98,   99,
 /*  1240 */   100,   30,   22,   32,  100,  164,  134,  135,  136,  137,
 /*  1250 */   138,   40,  148,  164,  150,  174,  175,  102,   97,  155,
 /*  1260 */   203,  157,  164,  244,  178,  125,  186,  182,  164,  125,
 /*  1270 */   177,   59,  177,  177,  113,  120,  121,  196,  197,   59,
 /*  1280 */   232,   70,  153,  216,  202,  196,  197,  153,   77,  208,
 /*  1290 */   209,   80,   81,  156,  196,  197,   60,  208,  248,  200,
 /*  1300 */   196,  197,  153,  174,  175,  123,  208,  153,  174,  175,
 /*  1310 */   160,   99,  208,  153,   38,  153,  160,  153,   98,   99,
 /*  1320 */   100,  153,  245,  174,  175,  221,  115,  153,  174,  175,
 /*  1330 */   153,  120,  121,  245,  174,  175,  174,  175,  174,  175,
 /*  1340 */   160,  153,  174,  175,  153,  225,  153,   22,  174,  175,
 /*  1350 */    97,  174,  175,  249,  143,  153,  224,  153,   43,  153,
 /*  1360 */   191,  153,  174,  175,   18,  174,  175,  174,  175,  153,
 /*  1370 */   131,  153,  194,  203,  153,  194,  174,  175,  174,  175,
 /*  1380 */   174,  175,  174,  175,  153,  160,  153,   18,  153,  194,
 /*  1390 */   174,  175,  174,  175,  153,  174,  175,  153,  225,  153,
 /*  1400 */   203,  153,  159,  153,  194,  174,  175,  174,  175,  174,
 /*  1410 */   175,  153,  203,  153,  224,  174,  175,  191,  174,  175,
 /*  1420 */   174,  175,  174,  175,  174,  175,  203,  160,  153,  191,
 /*  1430 */   153,  159,  174,  175,  174,  175,  153,  139,   62,  153,
 /*  1440 */   241,  153,  160,  153,  159,  153,   22,  240,  179,  174,
 /*  1450 */   175,  174,  175,  160,  159,   97,  160,  174,  175,  159,
 /*  1460 */   174,  175,  174,  175,  174,  175,  174,  175,  179,   64,
 /*  1470 */   176,  184,  108,  176,   95,  176,  234,  126,  176,  234,
 /*  1480 */   179,  178,  176,  176,  176,   97,  218,  217,  184,  179,
 /*  1490 */   179,  218,  218,  160,   22,  217,  217,  160,  218,  139,
 /*  1500 */   229,  217,  130,  129,  127,   25,  128,  163,   26,  162,
 /*  1510 */    13,  206,  231,  154,    6,  154,  207,  205,  204,  203,
 /*  1520 */   152,  166,  152,  152,  172,  172,  172,    4,  172,  166,
 /*  1530 */   180,  166,    3,   22,  172,  144,   15,  180,  172,  172,
 /*  1540 */    82,   16,   23,   23,  121,  254,  132,  172,  112,  124,
 /*  1550 */    24,   20,  126,   16,    1,  124,  112,   61,   53,   37,
 /*  1560 */   133,  132,   53,   53,  112,   53,   98,  254,  251,   34,
 /*  1570 */   123,    1,    5,   22,   97,  142,   26,   75,  123,   41,
 /*  1580 */    97,   68,   68,   24,   20,   19,  113,   22,  107,   28,
 /*  1590 */    22,   67,   23,   22,   22,   67,   22,   67,   23,   37,
 /*  1600 */    23,   23,   26,   23,   22,   24,   23,   22,   24,  123,
 /*  1610 */    23,   23,   22,   98,  125,   26,   11,   23,   26,   23,
 /*  1620 */    34,   23,   23,   23,   23,   34,   22,   34,   26,   22,
 /*  1630 */    22,   15,   23,   23,   22,  117,   23,   22,    1,  123,
 /*  1640 */    26,   23,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1650 */   123,  255,  255,  255,  255,  123,  123,  255,  255,  255,
 /*  1660 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1670 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1680 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1690 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1700 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1710 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1720 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1730 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1740 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1750 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1760 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1770 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1780 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1790 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
 /*  1800 */   255,  255,
};
#define YY_SHIFT_COUNT    (471)
#define YY_SHIFT_COUNT    (489)
#define YY_SHIFT_MIN      (0)
#define YY_SHIFT_MAX      (1559)
#define YY_SHIFT_MAX      (1637)
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,
 /*     0 */   990,  976, 1211,  837,  837,  316, 1054, 1054, 1054, 1054,
 /*    10 */   214,    0,    0,  106,  642, 1054, 1054, 1054, 1054, 1054,
 /*    20 */  1054, 1054, 1054,  952,  952,  226, 1155,  316,  316,  316,
 /*    30 */   316,  316,  316,   53,  159,  212,  265,  318,  371,  424,
 /*    40 */   477,  533,  589,  642,  642,  642,  642,  642,  642,  642,
 /*    50 */   642,  642,  642,  642,  642,  642,  642,  642,  642,  642,
 /*    60 */   695,  642,  747,  798,  798, 1004, 1054, 1054, 1054, 1054,
 /*    70 */  1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
 /*    80 */  1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
 /*    90 */  1054, 1054, 1054, 1054, 1054, 1054, 1054, 1112, 1054, 1054,
 /*   100 */  1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
 /*   110 */  1054,  856,  874,  874,  874,  874,  874,  134,  147,   93,
 /*   120 */   342,  959, 1161,  253,  253,  342,  367,  367,  367,  367,
 /*   130 */   179,   36,   79, 1657, 1657, 1657, 1061, 1061, 1061,  516,
 /*   140 */   799,  516,  516,  531,  531,  802,  249,  369,  342,  342,
 /*   150 */   342,  342,  342,  342,  342,  342,  342,  342,  342,  342,
 /*   160 */   342,  342,  342,  342,  342,  342,  342,  342,  342,  272,
 /*   170 */   442,  442,  536, 1657, 1657, 1657, 1025,  245,  245,  570,
 /*   180 */   172,  286,  805, 1047, 1140, 1220,  342,  342,  342,  342,
 /*   190 */   342,  342,  342,  342,  170,  342,  342,  342,  342,  342,
 /*   200 */   342,  342,  342,  342,  342,  342,  342,  841,  841,  841,
 /*   210 */   342,  342,  342,  342,  530,  342,  342,  342, 1059,  342,
 /*   220 */   342, 1167,  342,  342,  342,  342,  342,  342,  342,  342,
 /*   230 */   123,  688,  177, 1212, 1212, 1212, 1212, 1144,  177,  177,
 /*   240 */  1064,  409,   33,  628,  707,  707,  900,  628,  628,  900,
 /*   250 */   897,  323,  398,  677,  677,  677,  707,  572,  684,  590,
 /*   260 */   739, 1236, 1182, 1182, 1276, 1276, 1182, 1253, 1325, 1315,
 /*   270 */  1239, 1346, 1346, 1346, 1346, 1182, 1369, 1239, 1239, 1253,
 /*   280 */  1325, 1315, 1315, 1239, 1182, 1369, 1298, 1376, 1182, 1369,
 /*   290 */  1424, 1182, 1369, 1182, 1369, 1424, 1358, 1358, 1358, 1405,
 /*   300 */  1424, 1358, 1364, 1358, 1405, 1358, 1358, 1424, 1379, 1379,
 /*   310 */  1424, 1351, 1388, 1351, 1388, 1351, 1388, 1351, 1388, 1182,
 /*   320 */  1472, 1182, 1360, 1372, 1377, 1374, 1378, 1239, 1480, 1482,
 /*   330 */  1497, 1497, 1508, 1508, 1508, 1657, 1657, 1657, 1657, 1657,
 /*   340 */  1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657,
 /*   350 */  1657,   20,  413,   98,  423,  519,  383,  962,  742,   61,
 /*   360 */   696,  749,  750,  753,  789,  790,  795,  797,  840,  842,
 /*   370 */   810,  668,  817,  659,  819,  849,  854,  899,  643,  745,
 /*   380 */   956,  926,  916, 1523, 1529, 1511, 1391, 1521, 1458, 1525,
 /*   390 */  1519, 1520, 1423, 1414, 1436, 1526, 1425, 1531, 1426, 1537,
 /*   400 */  1553, 1431, 1427, 1444, 1496, 1522, 1429, 1505, 1509, 1510,
 /*   410 */  1512, 1452, 1468, 1535, 1447, 1570, 1567, 1551, 1477, 1433,
 /*   420 */  1513, 1550, 1514, 1502, 1538, 1455, 1483, 1559, 1564, 1566,
 /*   430 */  1473, 1481, 1565, 1524, 1568, 1571, 1569, 1572, 1528, 1561,
 /*   440 */  1574, 1530, 1562, 1575, 1577, 1578, 1576, 1580, 1582, 1581,
 /*   450 */  1583, 1585, 1584, 1486, 1587, 1588, 1515, 1586, 1590, 1489,
 /*   460 */  1589, 1591, 1592, 1593, 1594, 1596, 1598, 1589, 1599, 1600,
 /*   470 */  1602, 1601, 1604, 1605, 1607, 1608, 1609, 1610, 1612, 1613,
 /*   480 */  1615, 1614, 1518, 1516, 1527, 1532, 1533, 1618, 1616, 1637,
};
#define YY_REDUCE_COUNT (341)
#define YY_REDUCE_MIN   (-211)
#define YY_REDUCE_MAX   (1301)
#define YY_REDUCE_COUNT (350)
#define YY_REDUCE_MIN   (-225)
#define YY_REDUCE_MAX   (1375)
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,
 /*     0 */  -137,  -31, 1104, 1023, 1081, -132,  -40,  -38,  223,  225,
 /*    10 */   698, -153,  -99, -225, -165,  386,  478,  843,  859, -139,
 /*    20 */   884,  117,  277,  844,  857,  964,  559,  561,  614,  918,
 /*    30 */  1009, 1089, 1098, -222, -222, -222, -222, -222, -222, -222,
 /*    40 */  -222, -222, -222, -222, -222, -222, -222, -222, -222, -222,
 /*    50 */  -222, -222, -222, -222, -222, -222, -222, -222, -222, -222,
 /*    60 */  -222, -222, -222, -222, -222,  329,  331,  497,  654,  656,
 /*    70 */   781,  891,  946, 1029, 1129, 1134, 1149, 1154, 1160, 1162,
 /*    80 */  1164, 1168, 1174, 1177, 1188, 1191, 1193, 1202, 1204, 1206,
 /*    90 */  1208, 1216, 1218, 1221, 1231, 1233, 1235, 1241, 1244, 1246,
 /*   100 */  1248, 1250, 1258, 1260, 1275, 1277, 1283, 1286, 1288, 1290,
 /*   110 */  1292, -222, -222, -222, -222, -222, -222, -222, -222, -222,
 /*   120 */  -115,  796, -156, -154, -141,   14,  242,  349,  242,  349,
 /*   130 */   -61, -222, -222, -222, -222, -222,  101,  101,  101,  332,
 /*   140 */   302,  384,  387, -170,  146,  344,  196,  196,   15,   11,
 /*   150 */   183,  235,  395,  355,  396,  406,  452,  457,  391,  459,
 /*   160 */   443,  447,  511,  495,  454,  512,  505,  571,  498,  532,
 /*   170 */   431,  435,  339,  455,  446,  508, -174, -116,  -97, -120,
 /*   180 */  -150,   64,  176,  330,  337,  509,  569,  611,  653,  673,
 /*   190 */   714,  717,  763,  771,  -34,  779,  786,  830,  846,  860,
 /*   200 */   866,  882,  883,  890,  892,  895,  902,  319,  368,  769,
 /*   210 */   915,  924,  925,  932,  755,  936,  945,  963,  782,  969,
 /*   220 */   974,  816,  977,   64,  982,  983, 1016, 1022, 1024, 1031,
 /*   230 */   870,  831,  913,  966,  973,  981,  984,  755,  913,  913,
 /*   240 */  1000, 1041, 1063, 1015, 1010, 1011,  985, 1034, 1057, 1019,
 /*   250 */  1086, 1080, 1085, 1093, 1095, 1096, 1067, 1048, 1082, 1099,
 /*   260 */  1137, 1050, 1150, 1156, 1077, 1088, 1180, 1120, 1132, 1169,
 /*   270 */  1170, 1178, 1181, 1195, 1210, 1225, 1243, 1197, 1209, 1173,
 /*   280 */  1190, 1226, 1238, 1223, 1267, 1272, 1199, 1207, 1282, 1285,
 /*   290 */  1269, 1293, 1295, 1296, 1300, 1289, 1294, 1297, 1299, 1287,
 /*   300 */  1301, 1302, 1303, 1306, 1304, 1307, 1308, 1310, 1242, 1245,
 /*   310 */  1311, 1268, 1270, 1273, 1278, 1274, 1279, 1280, 1284, 1333,
 /*   320 */  1271, 1337, 1281, 1309, 1305, 1312, 1314, 1316, 1344, 1347,
 /*   330 */  1359, 1361, 1368, 1370, 1371, 1291, 1313, 1317, 1355, 1352,
 /*   340 */  1353, 1354, 1356, 1363, 1350, 1357, 1362, 1366, 1367, 1375,
 /*   350 */  1365,
};
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,
 /*     0 */  1389, 1389, 1389, 1261, 1046, 1151, 1261, 1261, 1261, 1261,
 /*    10 */  1046, 1181, 1181, 1312, 1077, 1046, 1046, 1046, 1046, 1046,
 /*    20 */  1046, 1260, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*    30 */  1046, 1046, 1046, 1187, 1046, 1046, 1046, 1046, 1262, 1263,
 /*    40 */  1046, 1046, 1046, 1311, 1313, 1197, 1196, 1195, 1194, 1294,
 /*    50 */  1168, 1192, 1185, 1189, 1256, 1257, 1255, 1259, 1262, 1263,
 /*    60 */  1046, 1188, 1226, 1240, 1225, 1046, 1046, 1046, 1046, 1046,
 /*    70 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*    80 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*    90 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*   100 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*   110 */  1046, 1234, 1239, 1246, 1238, 1235, 1228, 1227, 1229, 1230,
 /*   120 */  1046, 1067, 1116, 1046, 1046, 1046, 1329, 1328, 1046, 1046,
 /*   130 */  1077, 1231, 1232, 1243, 1242, 1241, 1319, 1345, 1344, 1046,
 /*   140 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*   150 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*   160 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1077,
 /*   170 */  1073, 1073, 1046, 1324, 1151, 1142, 1046, 1046, 1046, 1046,
 /*   180 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1316, 1314, 1046,
 /*   190 */  1276, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*   200 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*   210 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1147, 1046,
 /*   220 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1339,
 /*   230 */  1046, 1289, 1130, 1147, 1147, 1147, 1147, 1149, 1131, 1129,
 /*   240 */  1141, 1077, 1053, 1191, 1170, 1170, 1378, 1191, 1191, 1378,
 /*   250 */  1091, 1359, 1088, 1181, 1181, 1181, 1170, 1258, 1148, 1141,
 /*   260 */  1046, 1381, 1156, 1156, 1380, 1380, 1156, 1200, 1206, 1119,
 /*   270 */  1191, 1125, 1125, 1125, 1125, 1156, 1064, 1191, 1191, 1200,
 /*   280 */  1206, 1119, 1119, 1191, 1156, 1064, 1293, 1375, 1156, 1064,
 /*   290 */  1269, 1156, 1064, 1156, 1064, 1269, 1117, 1117, 1117, 1106,
 /*   300 */  1269, 1117, 1091, 1117, 1106, 1117, 1117, 1269, 1273, 1273,
 /*   310 */  1269, 1174, 1169, 1174, 1169, 1174, 1169, 1174, 1169, 1156,
 /*   320 */  1264, 1156, 1046, 1186, 1175, 1184, 1182, 1191, 1070, 1109,
 /*   330 */  1342, 1342, 1338, 1338, 1338, 1386, 1386, 1324, 1354, 1077,
 /*   340 */  1077, 1077, 1077, 1354, 1093, 1093, 1077, 1077, 1077, 1077,
 /*   350 */  1354, 1046, 1046, 1046, 1046, 1046, 1046, 1349, 1046, 1278,
 /*   360 */  1160, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*   370 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*   380 */  1046, 1046, 1211, 1046, 1049, 1321, 1046, 1046, 1320, 1046,
 /*   390 */  1046, 1046, 1046, 1046, 1046, 1161, 1046, 1046, 1046, 1046,
 /*   400 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*   410 */  1046, 1046, 1046, 1046, 1377, 1046, 1046, 1046, 1046, 1046,
 /*   420 */  1046, 1292, 1291, 1046, 1046, 1158, 1046, 1046, 1046, 1046,
 /*   430 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*   440 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*   450 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*   460 */  1183, 1046, 1176, 1046, 1046, 1046, 1046, 1368, 1046, 1046,
 /*   470 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
 /*   480 */  1046, 1363, 1133, 1213, 1046, 1212, 1216, 1046, 1058, 1046,
};
/********** 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.
140712
140713
140714
140715
140716
140717
140718

140719
140720
140721
140722
140723
140724
140725
142286
142287
142288
142289
142290
142291
142292
142293
142294
142295
142296
142297
142298
142299
142300







+







    0,  /*         GT => nothing */
    0,  /*         LE => nothing */
    0,  /*         LT => nothing */
    0,  /*         GE => nothing */
    0,  /*     ESCAPE => nothing */
    0,  /*         ID => nothing */
   59,  /*   COLUMNKW => ID */
   59,  /*         DO => ID */
   59,  /*        FOR => ID */
   59,  /*     IGNORE => ID */
   59,  /*  INITIALLY => ID */
   59,  /*    INSTEAD => ID */
   59,  /*         NO => ID */
   59,  /*        KEY => ID */
   59,  /*         OF => ID */
140773
140774
140775
140776
140777
140778
140779

140780
140781
140782
140783
140784
140785
140786
142348
142349
142350
142351
142352
142353
142354
142355
142356
142357
142358
142359
142360
142361
142362







+







#ifdef YYTRACKMAXSTACKDEPTH
  int yyhwm;                    /* High-water mark of the stack */
#endif
#ifndef YYNOERRORRECOVERY
  int yyerrcnt;                 /* Shifts left before out of the error */
#endif
  sqlite3ParserARG_SDECL                /* A place to hold %extra_argument */
  sqlite3ParserCTX_SDECL                /* A place to hold %extra_context */
#if YYSTACKDEPTH<=0
  int yystksz;                  /* Current side of the stack */
  yyStackEntry *yystack;        /* The parser's stack */
  yyStackEntry yystk0;          /* First stack entry */
#else
  yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */
  yyStackEntry *yystackEnd;            /* Last entry in the stack */
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
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
141034
141035
141036
141037
141038
141039
141040
141041
141042
141043
141044
141045
141046
141047
141048
141049
141050
141051
141052
141053
141054
141055
141056
141057
141058
141059
141060
141061
141062
141063
141064
141065
141066
141067
141068
141069
141070
141071
141072
141073
141074
141075
141076
141077
141078










































































































141079
141080
141081
141082
141083
141084
141085
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
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
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







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  /*   54 */ "GT",
  /*   55 */ "LE",
  /*   56 */ "LT",
  /*   57 */ "GE",
  /*   58 */ "ESCAPE",
  /*   59 */ "ID",
  /*   60 */ "COLUMNKW",
  /*   61 */ "FOR",
  /*   62 */ "IGNORE",
  /*   63 */ "INITIALLY",
  /*   64 */ "INSTEAD",
  /*   65 */ "NO",
  /*   66 */ "KEY",
  /*   67 */ "OF",
  /*   68 */ "OFFSET",
  /*   69 */ "PRAGMA",
  /*   70 */ "RAISE",
  /*   71 */ "RECURSIVE",
  /*   72 */ "REPLACE",
  /*   73 */ "RESTRICT",
  /*   74 */ "ROW",
  /*   75 */ "TRIGGER",
  /*   76 */ "VACUUM",
  /*   77 */ "VIEW",
  /*   78 */ "VIRTUAL",
  /*   79 */ "WITH",
  /*   80 */ "REINDEX",
  /*   81 */ "RENAME",
  /*   82 */ "CTIME_KW",
  /*   83 */ "ANY",
  /*   84 */ "BITAND",
  /*   85 */ "BITOR",
  /*   86 */ "LSHIFT",
  /*   87 */ "RSHIFT",
  /*   88 */ "PLUS",
  /*   89 */ "MINUS",
  /*   90 */ "STAR",
  /*   91 */ "SLASH",
  /*   92 */ "REM",
  /*   93 */ "CONCAT",
  /*   94 */ "COLLATE",
  /*   95 */ "BITNOT",
  /*   96 */ "INDEXED",
  /*   97 */ "STRING",
  /*   98 */ "JOIN_KW",
  /*   99 */ "CONSTRAINT",
  /*  100 */ "DEFAULT",
  /*  101 */ "NULL",
  /*  102 */ "PRIMARY",
  /*  103 */ "UNIQUE",
  /*  104 */ "CHECK",
  /*  105 */ "REFERENCES",
  /*  106 */ "AUTOINCR",
  /*  107 */ "ON",
  /*  108 */ "INSERT",
  /*  109 */ "DELETE",
  /*  110 */ "UPDATE",
  /*  111 */ "SET",
  /*  112 */ "DEFERRABLE",
  /*  113 */ "FOREIGN",
  /*  114 */ "DROP",
  /*  115 */ "UNION",
  /*  116 */ "ALL",
  /*  117 */ "EXCEPT",
  /*  118 */ "INTERSECT",
  /*  119 */ "SELECT",
  /*  120 */ "VALUES",
  /*  121 */ "DISTINCT",
  /*  122 */ "DOT",
  /*  123 */ "FROM",
  /*  124 */ "JOIN",
  /*  125 */ "USING",
  /*  126 */ "ORDER",
  /*  127 */ "GROUP",
  /*  128 */ "HAVING",
  /*  129 */ "LIMIT",
  /*  130 */ "WHERE",
  /*  131 */ "INTO",
  /*  132 */ "FLOAT",
  /*  133 */ "BLOB",
  /*  134 */ "INTEGER",
  /*  135 */ "VARIABLE",
  /*  136 */ "CASE",
  /*  137 */ "WHEN",
  /*  138 */ "THEN",
  /*  139 */ "ELSE",
  /*  140 */ "INDEX",
  /*  141 */ "ALTER",
  /*  142 */ "ADD",
  /*  143 */ "error",
  /*  144 */ "input",
  /*  145 */ "cmdlist",
  /*  146 */ "ecmd",
  /*  147 */ "explain",
  /*   61 */ "DO",
  /*   62 */ "FOR",
  /*   63 */ "IGNORE",
  /*   64 */ "INITIALLY",
  /*   65 */ "INSTEAD",
  /*   66 */ "NO",
  /*   67 */ "KEY",
  /*   68 */ "OF",
  /*   69 */ "OFFSET",
  /*   70 */ "PRAGMA",
  /*   71 */ "RAISE",
  /*   72 */ "RECURSIVE",
  /*   73 */ "REPLACE",
  /*   74 */ "RESTRICT",
  /*   75 */ "ROW",
  /*   76 */ "TRIGGER",
  /*   77 */ "VACUUM",
  /*   78 */ "VIEW",
  /*   79 */ "VIRTUAL",
  /*   80 */ "WITH",
  /*   81 */ "REINDEX",
  /*   82 */ "RENAME",
  /*   83 */ "CTIME_KW",
  /*   84 */ "ANY",
  /*   85 */ "BITAND",
  /*   86 */ "BITOR",
  /*   87 */ "LSHIFT",
  /*   88 */ "RSHIFT",
  /*   89 */ "PLUS",
  /*   90 */ "MINUS",
  /*   91 */ "STAR",
  /*   92 */ "SLASH",
  /*   93 */ "REM",
  /*   94 */ "CONCAT",
  /*   95 */ "COLLATE",
  /*   96 */ "BITNOT",
  /*   97 */ "ON",
  /*   98 */ "INDEXED",
  /*   99 */ "STRING",
  /*  100 */ "JOIN_KW",
  /*  101 */ "CONSTRAINT",
  /*  102 */ "DEFAULT",
  /*  103 */ "NULL",
  /*  104 */ "PRIMARY",
  /*  105 */ "UNIQUE",
  /*  106 */ "CHECK",
  /*  107 */ "REFERENCES",
  /*  108 */ "AUTOINCR",
  /*  109 */ "INSERT",
  /*  110 */ "DELETE",
  /*  111 */ "UPDATE",
  /*  112 */ "SET",
  /*  113 */ "DEFERRABLE",
  /*  114 */ "FOREIGN",
  /*  115 */ "DROP",
  /*  116 */ "UNION",
  /*  117 */ "ALL",
  /*  118 */ "EXCEPT",
  /*  119 */ "INTERSECT",
  /*  120 */ "SELECT",
  /*  121 */ "VALUES",
  /*  122 */ "DISTINCT",
  /*  123 */ "DOT",
  /*  124 */ "FROM",
  /*  125 */ "JOIN",
  /*  126 */ "USING",
  /*  127 */ "ORDER",
  /*  128 */ "GROUP",
  /*  129 */ "HAVING",
  /*  130 */ "LIMIT",
  /*  131 */ "WHERE",
  /*  132 */ "INTO",
  /*  133 */ "NOTHING",
  /*  134 */ "FLOAT",
  /*  135 */ "BLOB",
  /*  136 */ "INTEGER",
  /*  137 */ "VARIABLE",
  /*  138 */ "CASE",
  /*  139 */ "WHEN",
  /*  140 */ "THEN",
  /*  141 */ "ELSE",
  /*  142 */ "INDEX",
  /*  143 */ "ALTER",
  /*  144 */ "ADD",
  /*  145 */ "input",
  /*  146 */ "cmdlist",
  /*  147 */ "ecmd",
  /*  148 */ "cmdx",
  /*  149 */ "cmd",
  /*  150 */ "transtype",
  /*  151 */ "trans_opt",
  /*  152 */ "nm",
  /*  153 */ "savepoint_opt",
  /*  154 */ "create_table",
  /*  155 */ "create_table_args",
  /*  156 */ "createkw",
  /*  157 */ "temp",
  /*  158 */ "ifnotexists",
  /*  159 */ "dbnm",
  /*  160 */ "columnlist",
  /*  161 */ "conslist_opt",
  /*  162 */ "table_options",
  /*  163 */ "select",
  /*  164 */ "columnname",
  /*  165 */ "carglist",
  /*  166 */ "typetoken",
  /*  167 */ "typename",
  /*  168 */ "signed",
  /*  169 */ "plus_num",
  /*  170 */ "minus_num",
  /*  171 */ "scanpt",
  /*  172 */ "ccons",
  /*  173 */ "term",
  /*  174 */ "expr",
  /*  175 */ "onconf",
  /*  176 */ "sortorder",
  /*  177 */ "autoinc",
  /*  178 */ "eidlist_opt",
  /*  179 */ "refargs",
  /*  180 */ "defer_subclause",
  /*  181 */ "refarg",
  /*  182 */ "refact",
  /*  183 */ "init_deferred_pred_opt",
  /*  184 */ "conslist",
  /*  185 */ "tconscomma",
  /*  186 */ "tcons",
  /*  187 */ "sortlist",
  /*  188 */ "eidlist",
  /*  189 */ "defer_subclause_opt",
  /*  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",
  /*  205 */ "orderby_opt",
  /*  206 */ "limit_opt",
  /*  207 */ "values",
  /*  208 */ "nexprlist",
  /*  209 */ "exprlist",
  /*  210 */ "sclp",
  /*  211 */ "as",
  /*  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",
  /*  149 */ "explain",
  /*  150 */ "cmd",
  /*  151 */ "transtype",
  /*  152 */ "trans_opt",
  /*  153 */ "nm",
  /*  154 */ "savepoint_opt",
  /*  155 */ "create_table",
  /*  156 */ "create_table_args",
  /*  157 */ "createkw",
  /*  158 */ "temp",
  /*  159 */ "ifnotexists",
  /*  160 */ "dbnm",
  /*  161 */ "columnlist",
  /*  162 */ "conslist_opt",
  /*  163 */ "table_options",
  /*  164 */ "select",
  /*  165 */ "columnname",
  /*  166 */ "carglist",
  /*  167 */ "typetoken",
  /*  168 */ "typename",
  /*  169 */ "signed",
  /*  170 */ "plus_num",
  /*  171 */ "minus_num",
  /*  172 */ "scanpt",
  /*  173 */ "ccons",
  /*  174 */ "term",
  /*  175 */ "expr",
  /*  176 */ "onconf",
  /*  177 */ "sortorder",
  /*  178 */ "autoinc",
  /*  179 */ "eidlist_opt",
  /*  180 */ "refargs",
  /*  181 */ "defer_subclause",
  /*  182 */ "refarg",
  /*  183 */ "refact",
  /*  184 */ "init_deferred_pred_opt",
  /*  185 */ "conslist",
  /*  186 */ "tconscomma",
  /*  187 */ "tcons",
  /*  188 */ "sortlist",
  /*  189 */ "eidlist",
  /*  190 */ "defer_subclause_opt",
  /*  191 */ "orconf",
  /*  192 */ "resolvetype",
  /*  193 */ "raisetype",
  /*  194 */ "ifexists",
  /*  195 */ "fullname",
  /*  196 */ "selectnowith",
  /*  197 */ "oneselect",
  /*  198 */ "wqlist",
  /*  199 */ "multiselect_op",
  /*  200 */ "distinct",
  /*  201 */ "selcollist",
  /*  202 */ "from",
  /*  203 */ "where_opt",
  /*  204 */ "groupby_opt",
  /*  205 */ "having_opt",
  /*  206 */ "orderby_opt",
  /*  207 */ "limit_opt",
  /*  208 */ "values",
  /*  209 */ "nexprlist",
  /*  210 */ "exprlist",
  /*  211 */ "sclp",
  /*  212 */ "as",
  /*  213 */ "seltablist",
  /*  214 */ "stl_prefix",
  /*  215 */ "joinop",
  /*  216 */ "indexed_opt",
  /*  217 */ "on_opt",
  /*  218 */ "using_opt",
  /*  219 */ "xfullname",
  /*  220 */ "idlist",
  /*  221 */ "with",
  /*  222 */ "setlist",
  /*  223 */ "insert_cmd",
  /*  224 */ "idlist_opt",
  /*  225 */ "upsert",
  /*  226 */ "likeop",
  /*  227 */ "between_op",
  /*  228 */ "in_op",
  /*  229 */ "paren_exprlist",
  /*  230 */ "case_operand",
  /*  231 */ "case_exprlist",
  /*  232 */ "case_else",
  /*  233 */ "uniqueflag",
  /*  234 */ "collate",
  /*  235 */ "nmnum",
  /*  236 */ "trigger_decl",
  /*  237 */ "trigger_cmd_list",
  /*  238 */ "trigger_time",
  /*  239 */ "trigger_event",
  /*  240 */ "foreach_clause",
  /*  241 */ "when_clause",
  /*  242 */ "trigger_cmd",
  /*  243 */ "trnm",
  /*  244 */ "tridxby",
  /*  245 */ "database_kw_opt",
  /*  246 */ "key_opt",
  /*  247 */ "add_column_fullname",
  /*  248 */ "kwcolumn_opt",
  /*  249 */ "create_vtab",
  /*  250 */ "vtabarglist",
  /*  251 */ "vtabarg",
  /*  252 */ "vtabargtoken",
  /*  253 */ "lp",
  /*  254 */ "anylist",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */

#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
*/
static const char *const yyRuleName[] = {
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
141374
141375
141376
141377
141378
141379
141380
141381
141382
141383
141384
141385
141386
141387
141388
141389
141390
141391
141392
141393
141394
141395
141396
141397
141398
141399
141400
141401
141402
141403
141404
141405
141406
141407
141408
141409
141410
141411
141412
141413
141414
141415
141416
141417
141418




















































141419
141420
141421
141422
141423
141424
141425
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







+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







 /* 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 */ "xfullname ::= nm",
 /* 112 */ "xfullname ::= nm DOT nm",
 /* 113 */ "xfullname ::= nm DOT nm AS nm",
 /* 114 */ "xfullname ::= nm AS 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",
 /* 115 */ "joinop ::= COMMA|JOIN",
 /* 116 */ "joinop ::= JOIN_KW JOIN",
 /* 117 */ "joinop ::= JOIN_KW nm JOIN",
 /* 118 */ "joinop ::= JOIN_KW nm nm JOIN",
 /* 119 */ "on_opt ::= ON expr",
 /* 120 */ "on_opt ::=",
 /* 121 */ "indexed_opt ::=",
 /* 122 */ "indexed_opt ::= INDEXED BY nm",
 /* 123 */ "indexed_opt ::= NOT INDEXED",
 /* 124 */ "using_opt ::= USING LP idlist RP",
 /* 125 */ "using_opt ::=",
 /* 126 */ "orderby_opt ::=",
 /* 127 */ "orderby_opt ::= ORDER BY sortlist",
 /* 128 */ "sortlist ::= sortlist COMMA expr sortorder",
 /* 129 */ "sortlist ::= expr sortorder",
 /* 130 */ "sortorder ::= ASC",
 /* 131 */ "sortorder ::= DESC",
 /* 132 */ "sortorder ::=",
 /* 133 */ "groupby_opt ::=",
 /* 134 */ "groupby_opt ::= GROUP BY nexprlist",
 /* 135 */ "having_opt ::=",
 /* 136 */ "having_opt ::= HAVING expr",
 /* 137 */ "limit_opt ::=",
 /* 138 */ "limit_opt ::= LIMIT expr",
 /* 139 */ "limit_opt ::= LIMIT expr OFFSET expr",
 /* 140 */ "limit_opt ::= LIMIT expr COMMA expr",
 /* 141 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
 /* 142 */ "where_opt ::=",
 /* 143 */ "where_opt ::= WHERE expr",
 /* 144 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
 /* 145 */ "setlist ::= setlist COMMA nm EQ expr",
 /* 146 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
 /* 147 */ "setlist ::= nm EQ expr",
 /* 148 */ "setlist ::= LP idlist RP EQ expr",
 /* 149 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
 /* 150 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
 /* 151 */ "upsert ::=",
 /* 152 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
 /* 153 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
 /* 154 */ "upsert ::= ON CONFLICT DO NOTHING",
 /* 155 */ "insert_cmd ::= INSERT orconf",
 /* 156 */ "insert_cmd ::= REPLACE",
 /* 157 */ "idlist_opt ::=",
 /* 158 */ "idlist_opt ::= LP idlist RP",
 /* 159 */ "idlist ::= idlist COMMA nm",
 /* 160 */ "idlist ::= nm",
 /* 161 */ "expr ::= LP expr RP",
 /* 162 */ "expr ::= ID|INDEXED",
 /* 163 */ "expr ::= JOIN_KW",
 /* 164 */ "expr ::= nm DOT nm",
 /* 165 */ "expr ::= nm DOT nm DOT nm",
 /* 166 */ "term ::= NULL|FLOAT|BLOB",
 /* 167 */ "term ::= STRING",
 /* 168 */ "term ::= INTEGER",
 /* 169 */ "expr ::= VARIABLE",
 /* 170 */ "expr ::= expr COLLATE ID|STRING",
 /* 171 */ "expr ::= CAST LP expr AS typetoken RP",
 /* 172 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
 /* 173 */ "expr ::= ID|INDEXED LP STAR RP",
 /* 174 */ "term ::= CTIME_KW",
 /* 175 */ "expr ::= LP nexprlist COMMA expr RP",
 /* 176 */ "expr ::= expr AND expr",
 /* 177 */ "expr ::= expr OR expr",
 /* 178 */ "expr ::= expr LT|GT|GE|LE expr",
 /* 179 */ "expr ::= expr EQ|NE expr",
 /* 180 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
 /* 181 */ "expr ::= expr PLUS|MINUS expr",
 /* 182 */ "expr ::= expr STAR|SLASH|REM expr",
 /* 183 */ "expr ::= expr CONCAT expr",
 /* 184 */ "likeop ::= NOT LIKE_KW|MATCH",
 /* 185 */ "expr ::= expr likeop expr",
 /* 186 */ "expr ::= expr likeop expr ESCAPE expr",
 /* 187 */ "expr ::= expr ISNULL|NOTNULL",
 /* 188 */ "expr ::= expr NOT NULL",
 /* 189 */ "expr ::= expr IS expr",
 /* 190 */ "expr ::= expr IS NOT expr",
 /* 191 */ "expr ::= NOT expr",
 /* 192 */ "expr ::= BITNOT expr",
 /* 193 */ "expr ::= MINUS expr",
 /* 194 */ "expr ::= PLUS expr",
 /* 195 */ "between_op ::= BETWEEN",
 /* 196 */ "between_op ::= NOT BETWEEN",
 /* 197 */ "expr ::= expr between_op expr AND expr",
 /* 198 */ "in_op ::= IN",
 /* 199 */ "in_op ::= NOT IN",
 /* 200 */ "expr ::= expr in_op LP exprlist RP",
 /* 201 */ "expr ::= LP select RP",
 /* 202 */ "expr ::= expr in_op LP select RP",
 /* 203 */ "expr ::= expr in_op nm dbnm paren_exprlist",
 /* 204 */ "expr ::= EXISTS LP select RP",
 /* 205 */ "expr ::= CASE case_operand case_exprlist case_else END",
 /* 206 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
 /* 207 */ "case_exprlist ::= WHEN expr THEN expr",
 /* 208 */ "case_else ::= ELSE expr",
 /* 209 */ "case_else ::=",
 /* 210 */ "case_operand ::= expr",
 /* 211 */ "case_operand ::=",
 /* 212 */ "exprlist ::=",
 /* 213 */ "nexprlist ::= nexprlist COMMA expr",
 /* 214 */ "nexprlist ::= expr",
 /* 215 */ "paren_exprlist ::=",
 /* 216 */ "paren_exprlist ::= LP exprlist RP",
 /* 217 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
 /* 218 */ "uniqueflag ::= UNIQUE",
 /* 219 */ "uniqueflag ::=",
 /* 220 */ "eidlist_opt ::=",
 /* 221 */ "eidlist_opt ::= LP eidlist RP",
 /* 222 */ "eidlist ::= eidlist COMMA nm collate sortorder",
 /* 223 */ "eidlist ::= nm collate sortorder",
 /* 224 */ "collate ::=",
 /* 225 */ "collate ::= COLLATE ID|STRING",
 /* 226 */ "cmd ::= DROP INDEX ifexists fullname",
 /* 227 */ "cmd ::= VACUUM",
 /* 228 */ "cmd ::= VACUUM nm",
 /* 229 */ "cmd ::= PRAGMA nm dbnm",
 /* 230 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
 /* 231 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
 /* 232 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
 /* 233 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
 /* 234 */ "plus_num ::= PLUS INTEGER|FLOAT",
 /* 235 */ "minus_num ::= MINUS INTEGER|FLOAT",
 /* 236 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
 /* 237 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
 /* 238 */ "trigger_time ::= BEFORE|AFTER",
 /* 239 */ "trigger_time ::= INSTEAD OF",
 /* 240 */ "trigger_time ::=",
 /* 241 */ "trigger_event ::= DELETE|INSERT",
 /* 242 */ "trigger_event ::= UPDATE",
 /* 243 */ "trigger_event ::= UPDATE OF idlist",
 /* 244 */ "when_clause ::=",
 /* 245 */ "when_clause ::= WHEN expr",
 /* 246 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
 /* 247 */ "trigger_cmd_list ::= trigger_cmd SEMI",
 /* 248 */ "trnm ::= nm DOT nm",
 /* 249 */ "tridxby ::= INDEXED BY nm",
 /* 250 */ "tridxby ::= NOT INDEXED",
 /* 251 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
 /* 252 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
 /* 253 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
 /* 254 */ "trigger_cmd ::= scanpt select scanpt",
 /* 255 */ "expr ::= RAISE LP IGNORE RP",
 /* 256 */ "expr ::= RAISE LP raisetype COMMA nm RP",
 /* 257 */ "raisetype ::= ROLLBACK",
 /* 258 */ "raisetype ::= ABORT",
 /* 259 */ "raisetype ::= FAIL",
 /* 260 */ "cmd ::= DROP TRIGGER ifexists fullname",
 /* 261 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
 /* 262 */ "cmd ::= DETACH database_kw_opt expr",
 /* 263 */ "key_opt ::=",
 /* 264 */ "key_opt ::= KEY expr",
 /* 265 */ "cmd ::= REINDEX",
 /* 266 */ "cmd ::= REINDEX nm dbnm",
 /* 267 */ "cmd ::= ANALYZE",
 /* 268 */ "cmd ::= ANALYZE nm dbnm",
 /* 269 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
 /* 270 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
 /* 271 */ "add_column_fullname ::= fullname",
 /* 272 */ "cmd ::= create_vtab",
 /* 273 */ "cmd ::= create_vtab LP vtabarglist RP",
 /* 274 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
 /* 275 */ "vtabarg ::=",
 /* 276 */ "vtabargtoken ::= ANY",
 /* 277 */ "vtabargtoken ::= lp anylist RP",
 /* 278 */ "lp ::= LP",
 /* 279 */ "with ::= WITH wqlist",
 /* 280 */ "with ::= WITH RECURSIVE wqlist",
 /* 281 */ "wqlist ::= nm eidlist_opt AS LP select RP",
 /* 282 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
 /* 283 */ "input ::= cmdlist",
 /* 284 */ "cmdlist ::= cmdlist ecmd",
 /* 285 */ "cmdlist ::= ecmd",
 /* 286 */ "ecmd ::= SEMI",
 /* 287 */ "ecmd ::= cmdx SEMI",
 /* 288 */ "ecmd ::= explain cmdx",
 /* 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 ::=",
 /* 289 */ "trans_opt ::=",
 /* 290 */ "trans_opt ::= TRANSACTION",
 /* 291 */ "trans_opt ::= TRANSACTION nm",
 /* 292 */ "savepoint_opt ::= SAVEPOINT",
 /* 293 */ "savepoint_opt ::=",
 /* 294 */ "cmd ::= create_table create_table_args",
 /* 295 */ "columnlist ::= columnlist COMMA columnname carglist",
 /* 296 */ "columnlist ::= columnname carglist",
 /* 297 */ "nm ::= ID|INDEXED",
 /* 298 */ "nm ::= STRING",
 /* 299 */ "nm ::= JOIN_KW",
 /* 300 */ "typetoken ::= typename",
 /* 301 */ "typename ::= ID|STRING",
 /* 302 */ "signed ::= plus_num",
 /* 303 */ "signed ::= minus_num",
 /* 304 */ "carglist ::= carglist ccons",
 /* 305 */ "carglist ::=",
 /* 306 */ "ccons ::= NULL onconf",
 /* 307 */ "conslist_opt ::= COMMA conslist",
 /* 308 */ "conslist ::= conslist tconscomma tcons",
 /* 309 */ "conslist ::= tcons",
 /* 310 */ "tconscomma ::=",
 /* 311 */ "defer_subclause_opt ::= defer_subclause",
 /* 312 */ "resolvetype ::= raisetype",
 /* 313 */ "selectnowith ::= oneselect",
 /* 314 */ "oneselect ::= values",
 /* 315 */ "sclp ::= selcollist COMMA",
 /* 316 */ "as ::= ID|STRING",
 /* 317 */ "expr ::= term",
 /* 318 */ "likeop ::= LIKE_KW|MATCH",
 /* 319 */ "exprlist ::= nexprlist",
 /* 320 */ "nmnum ::= plus_num",
 /* 321 */ "nmnum ::= nm",
 /* 322 */ "nmnum ::= ON",
 /* 323 */ "nmnum ::= DELETE",
 /* 324 */ "nmnum ::= DEFAULT",
 /* 325 */ "plus_num ::= INTEGER|FLOAT",
 /* 326 */ "foreach_clause ::=",
 /* 327 */ "foreach_clause ::= FOR EACH ROW",
 /* 328 */ "trnm ::= nm",
 /* 329 */ "tridxby ::=",
 /* 330 */ "database_kw_opt ::= DATABASE",
 /* 331 */ "database_kw_opt ::=",
 /* 332 */ "kwcolumn_opt ::=",
 /* 333 */ "kwcolumn_opt ::= COLUMNKW",
 /* 334 */ "vtabarglist ::= vtabarg",
 /* 335 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
 /* 336 */ "vtabarg ::= vtabarg vtabargtoken",
 /* 337 */ "anylist ::=",
 /* 338 */ "anylist ::= anylist LP anylist RP",
 /* 339 */ "anylist ::= anylist ANY",
 /* 340 */ "with ::=",
};
#endif /* NDEBUG */


#if YYSTACKDEPTH<=0
/*
** Try to increase the size of the parser stack.  Return the number
141460
141461
141462
141463
141464
141465
141466
141467
141468



141469
141470

141471
141472
141473
141474
141475
141476
141477
141478






141479
141480
141481
141482

141483
141484
141485
141486



141487
141488

141489
141490
141491
141492
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

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
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
143095
143096
143097
143098
143099
143100
143101
143102
143103
143104
143105
143106
143107
143108
143109
143110
143111
143112
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







-
-
+
+
+

-
+


-
-
-
-
-
-
+
+
+
+
+
+



-
+

-
-
-
+
+
+

-
+
















-
-
-
-
-
+
+
+
+
+
+
+
+
















-
+
+












-
-
-
-
+
+
+
+

-
+


-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+

-
+


-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+

-
+


-
-
-
-
+
+
+
+
+

-
+


-
+

-
+


-
-
-
+
+
+

-
+


-
-
+
+

-
+


-
+

-
+







*/
#ifndef YYMALLOCARGTYPE
# define YYMALLOCARGTYPE size_t
#endif

/* Initialize a new parser that has already been allocated.
*/
SQLITE_PRIVATE void sqlite3ParserInit(void *yypParser){
  yyParser *pParser = (yyParser*)yypParser;
SQLITE_PRIVATE void sqlite3ParserInit(void *yypRawParser sqlite3ParserCTX_PDECL){
  yyParser *yypParser = (yyParser*)yypRawParser;
  sqlite3ParserCTX_STORE
#ifdef YYTRACKMAXSTACKDEPTH
  pParser->yyhwm = 0;
  yypParser->yyhwm = 0;
#endif
#if YYSTACKDEPTH<=0
  pParser->yytos = NULL;
  pParser->yystack = NULL;
  pParser->yystksz = 0;
  if( yyGrowStack(pParser) ){
    pParser->yystack = &pParser->yystk0;
    pParser->yystksz = 1;
  yypParser->yytos = NULL;
  yypParser->yystack = NULL;
  yypParser->yystksz = 0;
  if( yyGrowStack(yypParser) ){
    yypParser->yystack = &yypParser->yystk0;
    yypParser->yystksz = 1;
  }
#endif
#ifndef YYNOERRORRECOVERY
  pParser->yyerrcnt = -1;
  yypParser->yyerrcnt = -1;
#endif
  pParser->yytos = pParser->yystack;
  pParser->yystack[0].stateno = 0;
  pParser->yystack[0].major = 0;
  yypParser->yytos = yypParser->yystack;
  yypParser->yystack[0].stateno = 0;
  yypParser->yystack[0].major = 0;
#if YYSTACKDEPTH>0
  pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1];
  yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1];
#endif
}

#ifndef sqlite3Parser_ENGINEALWAYSONSTACK
/* 
** This function allocates a new parser.
** The only argument is a pointer to a function which works like
** malloc.
**
** Inputs:
** A pointer to the function used to allocate memory.
**
** Outputs:
** A pointer to a parser.  This pointer is used in subsequent calls
** to sqlite3Parser and sqlite3ParserFree.
*/
SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
  yyParser *pParser;
  pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
  if( pParser ) sqlite3ParserInit(pParser);
  return pParser;
SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) sqlite3ParserCTX_PDECL){
  yyParser *yypParser;
  yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
  if( yypParser ){
    sqlite3ParserCTX_STORE
    sqlite3ParserInit(yypParser sqlite3ParserCTX_PARAM);
  }
  return (void*)yypParser;
}
#endif /* sqlite3Parser_ENGINEALWAYSONSTACK */


/* The following function deletes the "minor type" or semantic value
** associated with a symbol.  The symbol can be either a terminal
** or nonterminal. "yymajor" is the symbol code, and "yypminor" is
** a pointer to the value to be deleted.  The code used to do the 
** deletions is derived from the %destructor and/or %token_destructor
** directives of the input grammar.
*/
static void yy_destructor(
  yyParser *yypParser,    /* The parser */
  YYCODETYPE yymajor,     /* Type code for object to destroy */
  YYMINORTYPE *yypminor   /* The object to be destroyed */
){
  sqlite3ParserARG_FETCH;
  sqlite3ParserARG_FETCH
  sqlite3ParserCTX_FETCH
  switch( yymajor ){
    /* Here is inserted the actions which take place when a
    ** terminal or non-terminal is destroyed.  This can happen
    ** when the symbol is popped from the stack during a
    ** reduce or during error processing or when a parser is 
    ** being destroyed before it is finished parsing.
    **
    ** Note: during a reduce, the only symbols destroyed are those
    ** which appear on the RHS of the rule, but which are *not* used
    ** inside the C code.
    */
/********* Begin destructor definitions ***************************************/
    case 163: /* select */
    case 195: /* selectnowith */
    case 196: /* oneselect */
    case 207: /* values */
    case 164: /* select */
    case 196: /* selectnowith */
    case 197: /* oneselect */
    case 208: /* values */
{
sqlite3SelectDelete(pParse->db, (yypminor->yy387));
sqlite3SelectDelete(pParse->db, (yypminor->yy399));
}
      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 */
    case 174: /* term */
    case 175: /* expr */
    case 203: /* where_opt */
    case 205: /* having_opt */
    case 217: /* on_opt */
    case 230: /* case_operand */
    case 232: /* case_else */
    case 241: /* when_clause */
    case 246: /* key_opt */
{
sqlite3ExprDelete(pParse->db, (yypminor->yy314));
sqlite3ExprDelete(pParse->db, (yypminor->yy182));
}
      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 */
    case 179: /* eidlist_opt */
    case 188: /* sortlist */
    case 189: /* eidlist */
    case 201: /* selcollist */
    case 204: /* groupby_opt */
    case 206: /* orderby_opt */
    case 209: /* nexprlist */
    case 210: /* exprlist */
    case 211: /* sclp */
    case 222: /* setlist */
    case 229: /* paren_exprlist */
    case 231: /* case_exprlist */
{
sqlite3ExprListDelete(pParse->db, (yypminor->yy322));
sqlite3ExprListDelete(pParse->db, (yypminor->yy232));
}
      break;
    case 194: /* fullname */
    case 201: /* from */
    case 212: /* seltablist */
    case 213: /* stl_prefix */
    case 195: /* fullname */
    case 202: /* from */
    case 213: /* seltablist */
    case 214: /* stl_prefix */
    case 219: /* xfullname */
{
sqlite3SrcListDelete(pParse->db, (yypminor->yy259));
sqlite3SrcListDelete(pParse->db, (yypminor->yy427));
}
      break;
    case 197: /* wqlist */
    case 198: /* wqlist */
{
sqlite3WithDelete(pParse->db, (yypminor->yy451));
sqlite3WithDelete(pParse->db, (yypminor->yy91));
}
      break;
    case 217: /* using_opt */
    case 218: /* idlist */
    case 222: /* idlist_opt */
    case 218: /* using_opt */
    case 220: /* idlist */
    case 224: /* idlist_opt */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy384));
sqlite3IdListDelete(pParse->db, (yypminor->yy510));
}
      break;
    case 234: /* trigger_cmd_list */
    case 239: /* trigger_cmd */
    case 237: /* trigger_cmd_list */
    case 242: /* trigger_cmd */
{
sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy203));
sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy47));
}
      break;
    case 236: /* trigger_event */
    case 239: /* trigger_event */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy90).b);
sqlite3IdListDelete(pParse->db, (yypminor->yy300).b);
}
      break;
/********* End destructor definitions *****************************************/
    default:  break;   /* If no destructor action specified: do nothing */
  }
}

141709
141710
141711
141712
141713
141714
141715
141716

141717
141718


141719
141720
141721
141722

141723
141724
141725
141726
141727
141728
141729
143302
143303
143304
143305
143306
143307
143308

143309


143310
143311
143312
143313


143314
143315
143316
143317
143318
143319
143320
143321







-
+
-
-
+
+


-
-
+







}
#endif

/*
** Find the appropriate action for a parser given the terminal
** look-ahead token iLookAhead.
*/
static unsigned int yy_find_shift_action(
static YYACTIONTYPE yy_find_shift_action(
  yyParser *pParser,        /* The parser */
  YYCODETYPE iLookAhead     /* The look-ahead token */
  YYCODETYPE iLookAhead,    /* The look-ahead token */
  YYACTIONTYPE stateno      /* Current state number */
){
  int i;
  int stateno = pParser->yytos->stateno;
 

  if( stateno>YY_MAX_SHIFT ) return stateno;
  assert( stateno <= YY_SHIFT_COUNT );
#if defined(YYCOVERAGE)
  yycoverage[stateno][iLookAhead] = 1;
#endif
  do{
    i = yy_shift_ofst[stateno];
141779
141780
141781
141782
141783
141784
141785
141786

141787
141788
141789
141790
141791
141792
141793
143371
143372
143373
143374
143375
143376
143377

143378
143379
143380
143381
143382
143383
143384
143385







-
+







}

/*
** Find the appropriate action for a parser given the non-terminal
** look-ahead token iLookAhead.
*/
static int yy_find_reduce_action(
  int stateno,              /* Current state number */
  YYACTIONTYPE stateno,     /* Current state number */
  YYCODETYPE iLookAhead     /* The look-ahead token */
){
  int i;
#ifdef YYERRORSYMBOL
  if( stateno>YY_REDUCE_COUNT ){
    return yy_default[stateno];
  }
141808
141809
141810
141811
141812
141813
141814
141815


141816
141817
141818
141819
141820
141821
141822
141823
141824
141825
141826
141827
141828


141829
141830
141831
141832
141833
141834
141835
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







-
+
+












-
+
+







  return yy_action[i];
}

/*
** The following routine is called if the stack overflows.
*/
static void yyStackOverflow(yyParser *yypParser){
   sqlite3ParserARG_FETCH;
   sqlite3ParserARG_FETCH
   sqlite3ParserCTX_FETCH
#ifndef NDEBUG
   if( yyTraceFILE ){
     fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
   }
#endif
   while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
   /* Here code is inserted which will execute if the parser
   ** stack every overflows */
/******** Begin %stack_overflow code ******************************************/

  sqlite3ErrorMsg(pParse, "parser stack overflow");
/******** End %stack_overflow code ********************************************/
   sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */
   sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument var */
   sqlite3ParserCTX_STORE
}

/*
** Print tracing information for a SHIFT action
*/
#ifndef NDEBUG
static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){
141850
141851
141852
141853
141854
141855
141856
141857
141858


141859
141860
141861
141862
141863
141864
141865
143444
143445
143446
143447
143448
143449
143450


143451
143452
143453
143454
143455
143456
143457
143458
143459







-
-
+
+







#endif

/*
** Perform a shift action.
*/
static void yy_shift(
  yyParser *yypParser,          /* The parser to be shifted */
  int yyNewState,               /* The new state to shift in */
  int yyMajor,                  /* The major token to shift in */
  YYACTIONTYPE yyNewState,      /* The new state to shift in */
  YYCODETYPE yyMajor,           /* The major token to shift in */
  sqlite3ParserTOKENTYPE yyMinor        /* The minor token to shift in */
){
  yyStackEntry *yytos;
  yypParser->yytos++;
#ifdef YYTRACKMAXSTACKDEPTH
  if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
    yypParser->yyhwm++;
141881
141882
141883
141884
141885
141886
141887
141888
141889


141890
141891
141892
141893
141894
141895
141896
141897
141898
141899
141900
141901
141902


141903
141904
141905
141906
141907
141908
141909
141910
141911
141912
141913
141914
141915
141916
141917
141918
141919
141920
141921
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
142189
142190
142191
142192
142193
142194
142195
142196
142197
142198
142199
142200
142201
142202
142203
142204
142205
142206
142207
142208
142209
142210
142211
142212
142213
142214
142215
142216
142217
142218
142219
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
143475
143476
143477
143478
143479
143480
143481


143482
143483
143484
143485
143486
143487
143488
143489
143490
143491
143492
143493
143494


143495
143496
143497





















































































































































































































































































143498
143499
143500
143501
143502
143503
143504
143505
143506
143507
143508
143509
143510
143511
143512
143513
143514
143515
143516
143517
143518
143519
143520
143521
143522
143523
143524
143525
143526
143527
143528
143529
143530
143531
143532
143533
143534
143535
143536
143537
143538
143539
143540
143541
143542
143543
143544
143545
143546
143547
143548
143549
143550
143551
143552
143553
143554
143555
143556
143557
143558
143559
143560
143561
143562
143563
143564
143565
143566
143567
143568
143569
143570
143571
143572
143573
143574
143575
143576
143577
143578
143579
143580
143581
143582
143583
143584
143585
143586
143587
143588
143589
143590
143591
143592
143593
143594
143595
143596
143597
143598
143599
143600
143601
143602
143603
143604
143605
143606
143607
143608
143609
143610
143611
143612
143613
143614
143615
143616
143617
143618
143619
143620
143621
143622
143623
143624
143625
143626
143627
143628
143629
143630
143631
143632
143633
143634
143635
143636
143637
143638
143639
143640
143641
143642
143643
143644
143645
143646
143647
143648
143649
143650
143651
143652
143653
143654
143655
143656
143657
143658
143659
143660
143661
143662
143663
143664
143665
143666
143667
143668
143669
143670
143671
143672
143673
143674
143675
143676
143677
143678
143679
143680
143681
143682
143683
143684
143685
143686
143687
143688
143689
143690
143691
143692
143693
143694
143695
143696
143697
143698
143699
143700
143701
143702
143703
143704
143705
143706
143707
143708
143709
143710
143711
143712
143713
143714
143715
143716
143717
143718
143719
143720
143721
143722
143723
143724
143725
143726
143727
143728
143729
143730
143731
143732
143733
143734
143735
143736
143737
143738
143739
143740
143741
143742
143743
143744
143745
143746
143747
143748
143749
143750
143751
143752
143753
143754
143755
143756
143757
143758
143759
143760
143761
143762
143763
143764
143765
143766
143767
143768
143769
143770
143771
143772
143773
143774
143775
143776
143777
143778
143779
143780
143781
143782
143783





143784
143785
143786
143787
143788
143789
143790
143791
143792
143793
















































143794
143795
143796
143797
143798
143799
143800
143801
143802
143803
143804
143805
143806
143807
143808
143809
143810
143811
143812
143813
143814
143815
143816
143817
143818
143819
143820
143821
143822
143823
143824
143825
143826
143827
143828
143829
143830
143831
143832
143833
143834
143835
143836
143837
143838
143839
143840
143841
143842
143843
143844
143845
143846
143847
143848
143849

143850
143851
143852
143853
143854
143855
143856
143857
143858
143859
143860

143861
143862
143863
143864
143865
143866
143867
143868







-
-
+
+











-
-
+
+

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+














-
+




+





-
+







    }
  }
#endif
  if( yyNewState > YY_MAX_SHIFT ){
    yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
  }
  yytos = yypParser->yytos;
  yytos->stateno = (YYACTIONTYPE)yyNewState;
  yytos->major = (YYCODETYPE)yyMajor;
  yytos->stateno = yyNewState;
  yytos->major = yyMajor;
  yytos->minor.yy0 = yyMinor;
  yyTraceShift(yypParser, yyNewState, "Shift");
}

/* The following table contains information about every rule that
** is used during the reduce.
*/
static const struct {
  YYCODETYPE lhs;       /* Symbol on the left-hand side of the rule */
  signed char nrhs;     /* Negative of the number of RHS symbols in the rule */
} yyRuleInfo[] = {
  {  147,   -1 }, /* (0) explain ::= EXPLAIN */
  {  147,   -3 }, /* (1) explain ::= EXPLAIN QUERY PLAN */
  {  149,   -1 }, /* (0) explain ::= EXPLAIN */
  {  149,   -3 }, /* (1) explain ::= EXPLAIN QUERY PLAN */
  {  148,   -1 }, /* (2) cmdx ::= cmd */
  {  149,   -3 }, /* (3) cmd ::= BEGIN transtype trans_opt */
  {  150,    0 }, /* (4) transtype ::= */
  {  150,   -1 }, /* (5) transtype ::= DEFERRED */
  {  150,   -1 }, /* (6) transtype ::= IMMEDIATE */
  {  150,   -1 }, /* (7) transtype ::= EXCLUSIVE */
  {  149,   -2 }, /* (8) cmd ::= COMMIT|END trans_opt */
  {  149,   -2 }, /* (9) cmd ::= ROLLBACK trans_opt */
  {  149,   -2 }, /* (10) cmd ::= SAVEPOINT nm */
  {  149,   -3 }, /* (11) cmd ::= RELEASE savepoint_opt nm */
  {  149,   -5 }, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
  {  154,   -6 }, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
  {  156,   -1 }, /* (14) createkw ::= CREATE */
  {  158,    0 }, /* (15) ifnotexists ::= */
  {  158,   -3 }, /* (16) ifnotexists ::= IF NOT EXISTS */
  {  157,   -1 }, /* (17) temp ::= TEMP */
  {  157,    0 }, /* (18) temp ::= */
  {  155,   -5 }, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
  {  155,   -2 }, /* (20) create_table_args ::= AS select */
  {  162,    0 }, /* (21) table_options ::= */
  {  162,   -2 }, /* (22) table_options ::= WITHOUT nm */
  {  164,   -2 }, /* (23) columnname ::= nm typetoken */
  {  166,    0 }, /* (24) typetoken ::= */
  {  166,   -4 }, /* (25) typetoken ::= typename LP signed RP */
  {  166,   -6 }, /* (26) typetoken ::= typename LP signed COMMA signed RP */
  {  167,   -2 }, /* (27) typename ::= typename ID|STRING */
  {  171,    0 }, /* (28) scanpt ::= */
  {  172,   -2 }, /* (29) ccons ::= CONSTRAINT nm */
  {  172,   -4 }, /* (30) ccons ::= DEFAULT scanpt term scanpt */
  {  172,   -4 }, /* (31) ccons ::= DEFAULT LP expr RP */
  {  172,   -4 }, /* (32) ccons ::= DEFAULT PLUS term scanpt */
  {  172,   -4 }, /* (33) ccons ::= DEFAULT MINUS term scanpt */
  {  172,   -3 }, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
  {  172,   -3 }, /* (35) ccons ::= NOT NULL onconf */
  {  172,   -5 }, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
  {  172,   -2 }, /* (37) ccons ::= UNIQUE onconf */
  {  172,   -4 }, /* (38) ccons ::= CHECK LP expr RP */
  {  172,   -4 }, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
  {  172,   -1 }, /* (40) ccons ::= defer_subclause */
  {  172,   -2 }, /* (41) ccons ::= COLLATE ID|STRING */
  {  177,    0 }, /* (42) autoinc ::= */
  {  177,   -1 }, /* (43) autoinc ::= AUTOINCR */
  {  179,    0 }, /* (44) refargs ::= */
  {  179,   -2 }, /* (45) refargs ::= refargs refarg */
  {  181,   -2 }, /* (46) refarg ::= MATCH nm */
  {  181,   -3 }, /* (47) refarg ::= ON INSERT refact */
  {  181,   -3 }, /* (48) refarg ::= ON DELETE refact */
  {  181,   -3 }, /* (49) refarg ::= ON UPDATE refact */
  {  182,   -2 }, /* (50) refact ::= SET NULL */
  {  182,   -2 }, /* (51) refact ::= SET DEFAULT */
  {  182,   -1 }, /* (52) refact ::= CASCADE */
  {  182,   -1 }, /* (53) refact ::= RESTRICT */
  {  182,   -2 }, /* (54) refact ::= NO ACTION */
  {  180,   -3 }, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
  {  180,   -2 }, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
  {  183,    0 }, /* (57) init_deferred_pred_opt ::= */
  {  183,   -2 }, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
  {  183,   -2 }, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
  {  161,    0 }, /* (60) conslist_opt ::= */
  {  185,   -1 }, /* (61) tconscomma ::= COMMA */
  {  186,   -2 }, /* (62) tcons ::= CONSTRAINT nm */
  {  186,   -7 }, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
  {  186,   -5 }, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
  {  186,   -5 }, /* (65) tcons ::= CHECK LP expr RP onconf */
  {  186,  -10 }, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
  {  189,    0 }, /* (67) defer_subclause_opt ::= */
  {  175,    0 }, /* (68) onconf ::= */
  {  175,   -3 }, /* (69) onconf ::= ON CONFLICT resolvetype */
  {  190,    0 }, /* (70) orconf ::= */
  {  190,   -2 }, /* (71) orconf ::= OR resolvetype */
  {  191,   -1 }, /* (72) resolvetype ::= IGNORE */
  {  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 */
  {  150,   -3 }, /* (3) cmd ::= BEGIN transtype trans_opt */
  {  151,    0 }, /* (4) transtype ::= */
  {  151,   -1 }, /* (5) transtype ::= DEFERRED */
  {  151,   -1 }, /* (6) transtype ::= IMMEDIATE */
  {  151,   -1 }, /* (7) transtype ::= EXCLUSIVE */
  {  150,   -2 }, /* (8) cmd ::= COMMIT|END trans_opt */
  {  150,   -2 }, /* (9) cmd ::= ROLLBACK trans_opt */
  {  150,   -2 }, /* (10) cmd ::= SAVEPOINT nm */
  {  150,   -3 }, /* (11) cmd ::= RELEASE savepoint_opt nm */
  {  150,   -5 }, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
  {  155,   -6 }, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
  {  157,   -1 }, /* (14) createkw ::= CREATE */
  {  159,    0 }, /* (15) ifnotexists ::= */
  {  159,   -3 }, /* (16) ifnotexists ::= IF NOT EXISTS */
  {  158,   -1 }, /* (17) temp ::= TEMP */
  {  158,    0 }, /* (18) temp ::= */
  {  156,   -5 }, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
  {  156,   -2 }, /* (20) create_table_args ::= AS select */
  {  163,    0 }, /* (21) table_options ::= */
  {  163,   -2 }, /* (22) table_options ::= WITHOUT nm */
  {  165,   -2 }, /* (23) columnname ::= nm typetoken */
  {  167,    0 }, /* (24) typetoken ::= */
  {  167,   -4 }, /* (25) typetoken ::= typename LP signed RP */
  {  167,   -6 }, /* (26) typetoken ::= typename LP signed COMMA signed RP */
  {  168,   -2 }, /* (27) typename ::= typename ID|STRING */
  {  172,    0 }, /* (28) scanpt ::= */
  {  173,   -2 }, /* (29) ccons ::= CONSTRAINT nm */
  {  173,   -4 }, /* (30) ccons ::= DEFAULT scanpt term scanpt */
  {  173,   -4 }, /* (31) ccons ::= DEFAULT LP expr RP */
  {  173,   -4 }, /* (32) ccons ::= DEFAULT PLUS term scanpt */
  {  173,   -4 }, /* (33) ccons ::= DEFAULT MINUS term scanpt */
  {  173,   -3 }, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
  {  173,   -3 }, /* (35) ccons ::= NOT NULL onconf */
  {  173,   -5 }, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
  {  173,   -2 }, /* (37) ccons ::= UNIQUE onconf */
  {  173,   -4 }, /* (38) ccons ::= CHECK LP expr RP */
  {  173,   -4 }, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
  {  173,   -1 }, /* (40) ccons ::= defer_subclause */
  {  173,   -2 }, /* (41) ccons ::= COLLATE ID|STRING */
  {  178,    0 }, /* (42) autoinc ::= */
  {  178,   -1 }, /* (43) autoinc ::= AUTOINCR */
  {  180,    0 }, /* (44) refargs ::= */
  {  180,   -2 }, /* (45) refargs ::= refargs refarg */
  {  182,   -2 }, /* (46) refarg ::= MATCH nm */
  {  182,   -3 }, /* (47) refarg ::= ON INSERT refact */
  {  182,   -3 }, /* (48) refarg ::= ON DELETE refact */
  {  182,   -3 }, /* (49) refarg ::= ON UPDATE refact */
  {  183,   -2 }, /* (50) refact ::= SET NULL */
  {  183,   -2 }, /* (51) refact ::= SET DEFAULT */
  {  183,   -1 }, /* (52) refact ::= CASCADE */
  {  183,   -1 }, /* (53) refact ::= RESTRICT */
  {  183,   -2 }, /* (54) refact ::= NO ACTION */
  {  181,   -3 }, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
  {  181,   -2 }, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
  {  184,    0 }, /* (57) init_deferred_pred_opt ::= */
  {  184,   -2 }, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
  {  184,   -2 }, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
  {  162,    0 }, /* (60) conslist_opt ::= */
  {  186,   -1 }, /* (61) tconscomma ::= COMMA */
  {  187,   -2 }, /* (62) tcons ::= CONSTRAINT nm */
  {  187,   -7 }, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
  {  187,   -5 }, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
  {  187,   -5 }, /* (65) tcons ::= CHECK LP expr RP onconf */
  {  187,  -10 }, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
  {  190,    0 }, /* (67) defer_subclause_opt ::= */
  {  176,    0 }, /* (68) onconf ::= */
  {  176,   -3 }, /* (69) onconf ::= ON CONFLICT resolvetype */
  {  191,    0 }, /* (70) orconf ::= */
  {  191,   -2 }, /* (71) orconf ::= OR resolvetype */
  {  192,   -1 }, /* (72) resolvetype ::= IGNORE */
  {  192,   -1 }, /* (73) resolvetype ::= REPLACE */
  {  150,   -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */
  {  194,   -2 }, /* (75) ifexists ::= IF EXISTS */
  {  194,    0 }, /* (76) ifexists ::= */
  {  150,   -9 }, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
  {  150,   -4 }, /* (78) cmd ::= DROP VIEW ifexists fullname */
  {  150,   -1 }, /* (79) cmd ::= select */
  {  164,   -3 }, /* (80) select ::= WITH wqlist selectnowith */
  {  164,   -4 }, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
  {  164,   -1 }, /* (82) select ::= selectnowith */
  {  196,   -3 }, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
  {  199,   -1 }, /* (84) multiselect_op ::= UNION */
  {  199,   -2 }, /* (85) multiselect_op ::= UNION ALL */
  {  199,   -1 }, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
  {  197,   -9 }, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
  {  208,   -4 }, /* (88) values ::= VALUES LP nexprlist RP */
  {  208,   -5 }, /* (89) values ::= values COMMA LP exprlist RP */
  {  200,   -1 }, /* (90) distinct ::= DISTINCT */
  {  200,   -1 }, /* (91) distinct ::= ALL */
  {  200,    0 }, /* (92) distinct ::= */
  {  211,    0 }, /* (93) sclp ::= */
  {  201,   -5 }, /* (94) selcollist ::= sclp scanpt expr scanpt as */
  {  201,   -3 }, /* (95) selcollist ::= sclp scanpt STAR */
  {  201,   -5 }, /* (96) selcollist ::= sclp scanpt nm DOT STAR */
  {  212,   -2 }, /* (97) as ::= AS nm */
  {  212,    0 }, /* (98) as ::= */
  {  202,    0 }, /* (99) from ::= */
  {  202,   -2 }, /* (100) from ::= FROM seltablist */
  {  214,   -2 }, /* (101) stl_prefix ::= seltablist joinop */
  {  214,    0 }, /* (102) stl_prefix ::= */
  {  213,   -7 }, /* (103) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
  {  213,   -9 }, /* (104) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
  {  213,   -7 }, /* (105) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
  {  213,   -7 }, /* (106) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
  {  160,    0 }, /* (107) dbnm ::= */
  {  160,   -2 }, /* (108) dbnm ::= DOT nm */
  {  195,   -1 }, /* (109) fullname ::= nm */
  {  195,   -3 }, /* (110) fullname ::= nm DOT nm */
  {  219,   -1 }, /* (111) xfullname ::= nm */
  {  219,   -3 }, /* (112) xfullname ::= nm DOT nm */
  {  219,   -5 }, /* (113) xfullname ::= nm DOT nm AS nm */
  {  219,   -3 }, /* (114) xfullname ::= nm AS nm */
  {  215,   -1 }, /* (115) joinop ::= COMMA|JOIN */
  {  215,   -2 }, /* (116) joinop ::= JOIN_KW JOIN */
  {  215,   -3 }, /* (117) joinop ::= JOIN_KW nm JOIN */
  {  215,   -4 }, /* (118) joinop ::= JOIN_KW nm nm JOIN */
  {  217,   -2 }, /* (119) on_opt ::= ON expr */
  {  217,    0 }, /* (120) on_opt ::= */
  {  216,    0 }, /* (121) indexed_opt ::= */
  {  216,   -3 }, /* (122) indexed_opt ::= INDEXED BY nm */
  {  216,   -2 }, /* (123) indexed_opt ::= NOT INDEXED */
  {  218,   -4 }, /* (124) using_opt ::= USING LP idlist RP */
  {  218,    0 }, /* (125) using_opt ::= */
  {  206,    0 }, /* (126) orderby_opt ::= */
  {  206,   -3 }, /* (127) orderby_opt ::= ORDER BY sortlist */
  {  188,   -4 }, /* (128) sortlist ::= sortlist COMMA expr sortorder */
  {  188,   -2 }, /* (129) sortlist ::= expr sortorder */
  {  177,   -1 }, /* (130) sortorder ::= ASC */
  {  177,   -1 }, /* (131) sortorder ::= DESC */
  {  177,    0 }, /* (132) sortorder ::= */
  {  204,    0 }, /* (133) groupby_opt ::= */
  {  204,   -3 }, /* (134) groupby_opt ::= GROUP BY nexprlist */
  {  205,    0 }, /* (135) having_opt ::= */
  {  205,   -2 }, /* (136) having_opt ::= HAVING expr */
  {  207,    0 }, /* (137) limit_opt ::= */
  {  207,   -2 }, /* (138) limit_opt ::= LIMIT expr */
  {  207,   -4 }, /* (139) limit_opt ::= LIMIT expr OFFSET expr */
  {  207,   -4 }, /* (140) limit_opt ::= LIMIT expr COMMA expr */
  {  150,   -6 }, /* (141) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
  {  203,    0 }, /* (142) where_opt ::= */
  {  203,   -2 }, /* (143) where_opt ::= WHERE expr */
  {  150,   -8 }, /* (144) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
  {  222,   -5 }, /* (145) setlist ::= setlist COMMA nm EQ expr */
  {  222,   -7 }, /* (146) setlist ::= setlist COMMA LP idlist RP EQ expr */
  {  222,   -3 }, /* (147) setlist ::= nm EQ expr */
  {  222,   -5 }, /* (148) setlist ::= LP idlist RP EQ expr */
  {  150,   -7 }, /* (149) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
  {  150,   -7 }, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
  {  225,    0 }, /* (151) upsert ::= */
  {  225,  -11 }, /* (152) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
  {  225,   -8 }, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
  {  225,   -4 }, /* (154) upsert ::= ON CONFLICT DO NOTHING */
  {  223,   -2 }, /* (155) insert_cmd ::= INSERT orconf */
  {  223,   -1 }, /* (156) insert_cmd ::= REPLACE */
  {  224,    0 }, /* (157) idlist_opt ::= */
  {  224,   -3 }, /* (158) idlist_opt ::= LP idlist RP */
  {  220,   -3 }, /* (159) idlist ::= idlist COMMA nm */
  {  220,   -1 }, /* (160) idlist ::= nm */
  {  175,   -3 }, /* (161) expr ::= LP expr RP */
  {  175,   -1 }, /* (162) expr ::= ID|INDEXED */
  {  175,   -1 }, /* (163) expr ::= JOIN_KW */
  {  175,   -3 }, /* (164) expr ::= nm DOT nm */
  {  175,   -5 }, /* (165) expr ::= nm DOT nm DOT nm */
  {  174,   -1 }, /* (166) term ::= NULL|FLOAT|BLOB */
  {  174,   -1 }, /* (167) term ::= STRING */
  {  174,   -1 }, /* (168) term ::= INTEGER */
  {  175,   -1 }, /* (169) expr ::= VARIABLE */
  {  175,   -3 }, /* (170) expr ::= expr COLLATE ID|STRING */
  {  175,   -6 }, /* (171) expr ::= CAST LP expr AS typetoken RP */
  {  175,   -5 }, /* (172) expr ::= ID|INDEXED LP distinct exprlist RP */
  {  175,   -4 }, /* (173) expr ::= ID|INDEXED LP STAR RP */
  {  174,   -1 }, /* (174) term ::= CTIME_KW */
  {  175,   -5 }, /* (175) expr ::= LP nexprlist COMMA expr RP */
  {  175,   -3 }, /* (176) expr ::= expr AND expr */
  {  175,   -3 }, /* (177) expr ::= expr OR expr */
  {  175,   -3 }, /* (178) expr ::= expr LT|GT|GE|LE expr */
  {  175,   -3 }, /* (179) expr ::= expr EQ|NE expr */
  {  175,   -3 }, /* (180) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
  {  175,   -3 }, /* (181) expr ::= expr PLUS|MINUS expr */
  {  175,   -3 }, /* (182) expr ::= expr STAR|SLASH|REM expr */
  {  175,   -3 }, /* (183) expr ::= expr CONCAT expr */
  {  226,   -2 }, /* (184) likeop ::= NOT LIKE_KW|MATCH */
  {  175,   -3 }, /* (185) expr ::= expr likeop expr */
  {  175,   -5 }, /* (186) expr ::= expr likeop expr ESCAPE expr */
  {  175,   -2 }, /* (187) expr ::= expr ISNULL|NOTNULL */
  {  175,   -3 }, /* (188) expr ::= expr NOT NULL */
  {  175,   -3 }, /* (189) expr ::= expr IS expr */
  {  175,   -4 }, /* (190) expr ::= expr IS NOT expr */
  {  175,   -2 }, /* (191) expr ::= NOT expr */
  {  175,   -2 }, /* (192) expr ::= BITNOT expr */
  {  175,   -2 }, /* (193) expr ::= MINUS expr */
  {  175,   -2 }, /* (194) expr ::= PLUS expr */
  {  227,   -1 }, /* (195) between_op ::= BETWEEN */
  {  227,   -2 }, /* (196) between_op ::= NOT BETWEEN */
  {  175,   -5 }, /* (197) expr ::= expr between_op expr AND expr */
  {  228,   -1 }, /* (198) in_op ::= IN */
  {  228,   -2 }, /* (199) in_op ::= NOT IN */
  {  175,   -5 }, /* (200) expr ::= expr in_op LP exprlist RP */
  {  175,   -3 }, /* (201) expr ::= LP select RP */
  {  175,   -5 }, /* (202) expr ::= expr in_op LP select RP */
  {  175,   -5 }, /* (203) expr ::= expr in_op nm dbnm paren_exprlist */
  {  175,   -4 }, /* (204) expr ::= EXISTS LP select RP */
  {  175,   -5 }, /* (205) expr ::= CASE case_operand case_exprlist case_else END */
  {  231,   -5 }, /* (206) case_exprlist ::= case_exprlist WHEN expr THEN expr */
  {  231,   -4 }, /* (207) case_exprlist ::= WHEN expr THEN expr */
  {  232,   -2 }, /* (208) case_else ::= ELSE expr */
  {  232,    0 }, /* (209) case_else ::= */
  {  230,   -1 }, /* (210) case_operand ::= expr */
  {  230,    0 }, /* (211) case_operand ::= */
  {  210,    0 }, /* (212) exprlist ::= */
  {  209,   -3 }, /* (213) nexprlist ::= nexprlist COMMA expr */
  {  209,   -1 }, /* (214) nexprlist ::= expr */
  {  229,    0 }, /* (215) paren_exprlist ::= */
  {  229,   -3 }, /* (216) paren_exprlist ::= LP exprlist RP */
  {  150,  -12 }, /* (217) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
  {  233,   -1 }, /* (218) uniqueflag ::= UNIQUE */
  {  233,    0 }, /* (219) uniqueflag ::= */
  {  179,    0 }, /* (220) eidlist_opt ::= */
  {  179,   -3 }, /* (221) eidlist_opt ::= LP eidlist RP */
  {  189,   -5 }, /* (222) eidlist ::= eidlist COMMA nm collate sortorder */
  {  189,   -3 }, /* (223) eidlist ::= nm collate sortorder */
  {  234,    0 }, /* (224) collate ::= */
  {  234,   -2 }, /* (225) collate ::= COLLATE ID|STRING */
  {  150,   -4 }, /* (226) cmd ::= DROP INDEX ifexists fullname */
  {  150,   -1 }, /* (227) cmd ::= VACUUM */
  {  150,   -2 }, /* (228) cmd ::= VACUUM nm */
  {  150,   -3 }, /* (229) cmd ::= PRAGMA nm dbnm */
  {  150,   -5 }, /* (230) cmd ::= PRAGMA nm dbnm EQ nmnum */
  {  150,   -6 }, /* (231) cmd ::= PRAGMA nm dbnm LP nmnum RP */
  {  150,   -5 }, /* (232) cmd ::= PRAGMA nm dbnm EQ minus_num */
  {  150,   -6 }, /* (233) cmd ::= PRAGMA nm dbnm LP minus_num RP */
  {  170,   -2 }, /* (234) plus_num ::= PLUS INTEGER|FLOAT */
  {  171,   -2 }, /* (235) minus_num ::= MINUS INTEGER|FLOAT */
  {  150,   -5 }, /* (236) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
  {  236,  -11 }, /* (237) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
  {  238,   -1 }, /* (238) trigger_time ::= BEFORE|AFTER */
  {  238,   -2 }, /* (239) trigger_time ::= INSTEAD OF */
  {  238,    0 }, /* (240) trigger_time ::= */
  {  239,   -1 }, /* (241) trigger_event ::= DELETE|INSERT */
  {  239,   -1 }, /* (242) trigger_event ::= UPDATE */
  {  239,   -3 }, /* (243) trigger_event ::= UPDATE OF idlist */
  {  241,    0 }, /* (244) when_clause ::= */
  {  241,   -2 }, /* (245) when_clause ::= WHEN expr */
  {  237,   -3 }, /* (246) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
  {  237,   -2 }, /* (247) trigger_cmd_list ::= trigger_cmd SEMI */
  {  243,   -3 }, /* (248) trnm ::= nm DOT nm */
  {  244,   -3 }, /* (249) tridxby ::= INDEXED BY nm */
  {  244,   -2 }, /* (250) tridxby ::= NOT INDEXED */
  {  242,   -8 }, /* (251) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
  {  242,   -8 }, /* (252) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
  {  242,   -6 }, /* (253) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
  {  242,   -3 }, /* (254) trigger_cmd ::= scanpt select scanpt */
  {  175,   -4 }, /* (255) expr ::= RAISE LP IGNORE RP */
  {  175,   -6 }, /* (256) expr ::= RAISE LP raisetype COMMA nm RP */
  {  193,   -1 }, /* (257) raisetype ::= ROLLBACK */
  {  193,   -1 }, /* (258) raisetype ::= ABORT */
  {  193,   -1 }, /* (259) raisetype ::= FAIL */
  {  150,   -4 }, /* (260) cmd ::= DROP TRIGGER ifexists fullname */
  {  150,   -6 }, /* (261) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
  {  150,   -3 }, /* (262) cmd ::= DETACH database_kw_opt expr */
  {  246,    0 }, /* (263) key_opt ::= */
  {  246,   -2 }, /* (264) key_opt ::= KEY expr */
  {  150,   -1 }, /* (265) cmd ::= REINDEX */
  {  150,   -3 }, /* (266) cmd ::= REINDEX nm dbnm */
  {  150,   -1 }, /* (267) cmd ::= ANALYZE */
  {  150,   -3 }, /* (268) cmd ::= ANALYZE nm dbnm */
  {  150,   -6 }, /* (269) cmd ::= ALTER TABLE fullname RENAME TO nm */
  {  150,   -7 }, /* (270) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
  {  247,   -1 }, /* (271) add_column_fullname ::= fullname */
  {  150,   -1 }, /* (272) cmd ::= create_vtab */
  {  150,   -4 }, /* (273) cmd ::= create_vtab LP vtabarglist RP */
  {  249,   -8 }, /* (274) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
  {  251,    0 }, /* (275) vtabarg ::= */
  {  252,   -1 }, /* (276) vtabargtoken ::= ANY */
  {  252,   -3 }, /* (277) vtabargtoken ::= lp anylist RP */
  {  253,   -1 }, /* (278) lp ::= LP */
  {  221,   -2 }, /* (279) with ::= WITH wqlist */
  {  221,   -3 }, /* (280) with ::= WITH RECURSIVE wqlist */
  {  198,   -6 }, /* (281) wqlist ::= nm eidlist_opt AS LP select RP */
  {  198,   -8 }, /* (282) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
  {  145,   -1 }, /* (283) input ::= cmdlist */
  {  146,   -2 }, /* (284) cmdlist ::= cmdlist ecmd */
  {  146,   -1 }, /* (285) cmdlist ::= ecmd */
  {  147,   -1 }, /* (286) ecmd ::= SEMI */
  {  147,   -2 }, /* (287) ecmd ::= cmdx SEMI */
  {  147,   -2 }, /* (288) ecmd ::= explain cmdx */
  {  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 */
  {  152,    0 }, /* (289) trans_opt ::= */
  {  152,   -1 }, /* (290) trans_opt ::= TRANSACTION */
  {  152,   -2 }, /* (291) trans_opt ::= TRANSACTION nm */
  {  154,   -1 }, /* (292) savepoint_opt ::= SAVEPOINT */
  {  154,    0 }, /* (293) savepoint_opt ::= */
  {  150,   -2 }, /* (294) cmd ::= create_table create_table_args */
  {  161,   -4 }, /* (295) columnlist ::= columnlist COMMA columnname carglist */
  {  161,   -2 }, /* (296) columnlist ::= columnname carglist */
  {  153,   -1 }, /* (297) nm ::= ID|INDEXED */
  {  153,   -1 }, /* (298) nm ::= STRING */
  {  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 ::= */
  {  153,   -1 }, /* (299) nm ::= JOIN_KW */
  {  167,   -1 }, /* (300) typetoken ::= typename */
  {  168,   -1 }, /* (301) typename ::= ID|STRING */
  {  169,   -1 }, /* (302) signed ::= plus_num */
  {  169,   -1 }, /* (303) signed ::= minus_num */
  {  166,   -2 }, /* (304) carglist ::= carglist ccons */
  {  166,    0 }, /* (305) carglist ::= */
  {  173,   -2 }, /* (306) ccons ::= NULL onconf */
  {  162,   -2 }, /* (307) conslist_opt ::= COMMA conslist */
  {  185,   -3 }, /* (308) conslist ::= conslist tconscomma tcons */
  {  185,   -1 }, /* (309) conslist ::= tcons */
  {  186,    0 }, /* (310) tconscomma ::= */
  {  190,   -1 }, /* (311) defer_subclause_opt ::= defer_subclause */
  {  192,   -1 }, /* (312) resolvetype ::= raisetype */
  {  196,   -1 }, /* (313) selectnowith ::= oneselect */
  {  197,   -1 }, /* (314) oneselect ::= values */
  {  211,   -2 }, /* (315) sclp ::= selcollist COMMA */
  {  212,   -1 }, /* (316) as ::= ID|STRING */
  {  175,   -1 }, /* (317) expr ::= term */
  {  226,   -1 }, /* (318) likeop ::= LIKE_KW|MATCH */
  {  210,   -1 }, /* (319) exprlist ::= nexprlist */
  {  235,   -1 }, /* (320) nmnum ::= plus_num */
  {  235,   -1 }, /* (321) nmnum ::= nm */
  {  235,   -1 }, /* (322) nmnum ::= ON */
  {  235,   -1 }, /* (323) nmnum ::= DELETE */
  {  235,   -1 }, /* (324) nmnum ::= DEFAULT */
  {  170,   -1 }, /* (325) plus_num ::= INTEGER|FLOAT */
  {  240,    0 }, /* (326) foreach_clause ::= */
  {  240,   -3 }, /* (327) foreach_clause ::= FOR EACH ROW */
  {  243,   -1 }, /* (328) trnm ::= nm */
  {  244,    0 }, /* (329) tridxby ::= */
  {  245,   -1 }, /* (330) database_kw_opt ::= DATABASE */
  {  245,    0 }, /* (331) database_kw_opt ::= */
  {  248,    0 }, /* (332) kwcolumn_opt ::= */
  {  248,   -1 }, /* (333) kwcolumn_opt ::= COLUMNKW */
  {  250,   -1 }, /* (334) vtabarglist ::= vtabarg */
  {  250,   -3 }, /* (335) vtabarglist ::= vtabarglist COMMA vtabarg */
  {  251,   -2 }, /* (336) vtabarg ::= vtabarg vtabargtoken */
  {  254,    0 }, /* (337) anylist ::= */
  {  254,   -4 }, /* (338) anylist ::= anylist LP anylist RP */
  {  254,   -2 }, /* (339) anylist ::= anylist ANY */
  {  221,    0 }, /* (340) with ::= */
};

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

/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
**
** The yyLookahead and yyLookaheadToken parameters provide reduce actions
** access to the lookahead token (if any).  The yyLookahead will be YYNOCODE
** if the lookahead token has already been consumed.  As this procedure is
** only called from one place, optimizing compilers will in-line it, which
** means that the extra parameters have no performance impact.
*/
static void yy_reduce(
static YYACTIONTYPE yy_reduce(
  yyParser *yypParser,         /* The parser */
  unsigned int yyruleno,       /* Number of the rule by which to reduce */
  int yyLookahead,             /* Lookahead token, or YYNOCODE if none */
  sqlite3ParserTOKENTYPE yyLookaheadToken  /* Value of the lookahead token */
  sqlite3ParserCTX_PDECL                   /* %extra_context */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  sqlite3ParserARG_FETCH;
  sqlite3ParserARG_FETCH
  (void)yyLookahead;
  (void)yyLookaheadToken;
  yymsp = yypParser->yytos;
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
    yysize = yyRuleInfo[yyruleno].nrhs;
    if( yysize ){
142282
142283
142284
142285
142286
142287
142288



142289

142290
142291
142292
142293
142294



142295

142296
142297
142298
142299
142300
142301
142302
143885
143886
143887
143888
143889
143890
143891
143892
143893
143894

143895
143896
143897
143898
143899
143900
143901
143902
143903

143904
143905
143906
143907
143908
143909
143910
143911







+
+
+
-
+





+
+
+
-
+







      yypParser->yyhwm++;
      assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
    }
#endif
#if YYSTACKDEPTH>0 
    if( yypParser->yytos>=yypParser->yystackEnd ){
      yyStackOverflow(yypParser);
      /* The call to yyStackOverflow() above pops the stack until it is
      ** empty, causing the main parser loop to exit.  So the return value
      ** is never used and does not matter. */
      return;
      return 0;
    }
#else
    if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
      if( yyGrowStack(yypParser) ){
        yyStackOverflow(yypParser);
        /* The call to yyStackOverflow() above pops the stack until it is
        ** empty, causing the main parser loop to exit.  So the return value
        ** is never used and does not matter. */
        return;
        return 0;
      }
      yymsp = yypParser->yytos;
    }
#endif
  }

  switch( yyruleno ){
142316
142317
142318
142319
142320
142321
142322
142323

142324
142325
142326

142327
142328
142329
142330
142331

142332
142333
142334
142335
142336
142337
142338
143925
143926
143927
143928
143929
143930
143931

143932
143933
143934

143935
143936
143937
143938
143939

143940
143941
143942
143943
143944
143945
143946
143947







-
+


-
+




-
+







      case 1: /* explain ::= EXPLAIN QUERY PLAN */
{ pParse->explain = 2; }
        break;
      case 2: /* cmdx ::= cmd */
{ sqlite3FinishCoding(pParse); }
        break;
      case 3: /* cmd ::= BEGIN transtype trans_opt */
{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy4);}
{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy502);}
        break;
      case 4: /* transtype ::= */
{yymsp[1].minor.yy4 = TK_DEFERRED;}
{yymsp[1].minor.yy502 = TK_DEFERRED;}
        break;
      case 5: /* transtype ::= DEFERRED */
      case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
      case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
{yymsp[0].minor.yy4 = yymsp[0].major; /*A-overwrites-X*/}
{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/}
        break;
      case 8: /* cmd ::= COMMIT|END trans_opt */
      case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
{sqlite3EndTransaction(pParse,yymsp[-1].major);}
        break;
      case 10: /* cmd ::= SAVEPOINT nm */
{
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
143956
143957
143958
143959
143960
143961
143962

143963
143964
143965
143966
143967
143968
143969
143970
143971
143972
143973
143974
143975
143976


143977
143978
143979
143980

143981
143982
143983
143984

143985
143986
143987
143988

143989
143990
143991
143992
143993


143994
143995
143996
143997
143998
143999
144000

144001
144002

144003
144004
144005
144006
144007
144008
144009
144010







-
+













-
-
+
+


-
+



-
+



-
+




-
-
+
+





-
+

-
+







      case 12: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
{
  sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
}
        break;
      case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
{
   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy4,0,0,yymsp[-2].minor.yy4);
   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy502,0,0,yymsp[-2].minor.yy502);
}
        break;
      case 14: /* createkw ::= CREATE */
{disableLookaside(pParse);}
        break;
      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;}
      case 224: /* collate ::= */ yytestcase(yyruleno==224);
{yymsp[1].minor.yy502 = 0;}
        break;
      case 16: /* ifnotexists ::= IF NOT EXISTS */
{yymsp[-2].minor.yy4 = 1;}
{yymsp[-2].minor.yy502 = 1;}
        break;
      case 17: /* temp ::= TEMP */
      case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
{yymsp[0].minor.yy4 = 1;}
{yymsp[0].minor.yy502 = 1;}
        break;
      case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
{
  sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy4,0);
  sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy502,0);
}
        break;
      case 20: /* create_table_args ::= AS select */
{
  sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy387);
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387);
  sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy399);
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399);
}
        break;
      case 22: /* table_options ::= WITHOUT nm */
{
  if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
    yymsp[-1].minor.yy4 = TF_WithoutRowid | TF_NoVisibleRowid;
    yymsp[-1].minor.yy502 = TF_WithoutRowid | TF_NoVisibleRowid;
  }else{
    yymsp[-1].minor.yy4 = 0;
    yymsp[-1].minor.yy502 = 0;
    sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
  }
}
        break;
      case 23: /* columnname ::= nm typetoken */
{sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
        break;
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

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
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
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
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
143095



143096
143097
143098


143099
143100
143101


143102
143103
143104
143105



143106
143107

143108
143109
143110
143111
143112
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
143489
143490
143491
143492
143493
143494
143495
143496
143497
143498
143499
143500
143501
143502
143503
143504
143505
143506
143507
143508
143509
143510
143511
143512
143513
143514
143515
143516
143517
143518
143519
143520
143521
143522
143523
143524
143525
143526
143527
143528
143529
143530
143531
143532
143533


























































143534
143535
143536
143537
143538
143539
143540
143541
143542
143543
143544
143545
143546
143547
143548
143549
143550
143551
143552
143553

143554
143555
143556
143557
143558
143559
143560
143561
143562
143563


143564
143565
143566
143567
143568
143569
143570
143571
143572
143573
143574


143575
143576
143577
143578
143579
143580
143581
143582
143583
143584
143585
143586


143587
143588
143589
143590
143591
143592
143593
143594
143595
143596
143597


143598
143599
143600
143601
143602
143603
143604
143605
143606


143607
143608
143609
143610
143611
143612
143613
143614
143615
143616
143617
143618
143619
143620


143621
143622
143623
143624
143625
143626
143627
144025
144026
144027
144028
144029
144030
144031

144032
144033
144034
144035
144036
144037
144038
144039

144040
144041
144042

144043
144044
144045

144046
144047
144048
144049


144050
144051
144052
144053
144054
144055
144056
144057
144058
144059
144060
144061
144062
144063
144064

144065
144066
144067

144068
144069
144070

144071
144072
144073
144074

144075
144076
144077

144078
144079
144080

144081
144082
144083
144084
144085
144086

144087
144088
144089

144090
144091
144092

144093
144094
144095

144096
144097
144098

144099
144100
144101

144102
144103
144104

144105
144106
144107

144108
144109
144110

144111
144112
144113

144114
144115
144116

144117
144118
144119

144120
144121
144122
144123


144124
144125
144126
144127
144128




144129
144130
144131
144132
144133
144134

144135
144136
144137
144138
144139
144140

144141
144142
144143

144144
144145
144146
144147

144148
144149
144150
144151


144152
144153
144154
144155
144156
144157

144158
144159
144160

144161
144162
144163

144164
144165
144166


144167
144168
144169
144170
144171

144172
144173
144174
144175
144176

144177
144178
144179
144180
144181

144182
144183
144184
144185
144186
144187


144188
144189
144190
144191
144192
144193

144194
144195

144196
144197
144198

144199
144200

144201
144202
144203
144204
144205

144206
144207

144208
144209
144210

144211
144212

144213
144214
144215
144216
144217

144218
144219
144220
144221

144222
144223
144224
144225
144226


144227
144228
144229
144230
144231
144232
144233
144234
144235
144236
144237

144238
144239
144240
144241

144242
144243
144244
144245

144246
144247
144248
144249
144250

144251
144252
144253

144254
144255
144256
144257
144258
144259
144260

144261
144262
144263
144264
144265
144266
144267
144268
144269
144270
144271

144272
144273
144274

144275
144276
144277
144278
144279
144280

144281
144282
144283
144284
144285
144286
144287
144288

144289
144290
144291
144292
144293


144294
144295
144296
144297
144298
144299

144300
144301

144302
144303
144304
144305
144306

144307
144308
144309

144310
144311
144312






144313
144314
144315
144316
144317
144318
144319
144320
144321



144322
144323
144324
144325
144326
144327
144328
144329

144330
144331
144332
144333
144334
144335
144336
144337

144338
144339
144340
144341
144342


144343
144344
144345
144346
144347

144348
144349
144350
144351


144352
144353
144354
144355
144356
144357

144358
144359
144360
144361

144362
144363
144364
144365


144366
144367
144368
144369
144370
144371


144372
144373
144374
144375
144376
144377

144378
144379
144380
144381
144382







144383
144384
144385
144386
144387
144388
144389
144390
144391
144392
144393
144394
144395

144396
144397
144398



144399
144400
144401
144402
144403
144404
144405

144406
144407
144408
144409
144410

144411
144412
144413
144414

144415
144416
144417
144418
144419
144420
144421
144422
144423
144424
144425
144426
144427
144428


144429
144430
144431


144432
144433
144434


144435
144436
144437


144438
144439
144440





144441
144442
144443
144444
144445
144446







144447
144448
144449
144450
144451
144452
144453
144454

144455
144456
144457

144458
144459
144460


144461
144462
144463



144464
144465
144466
144467



144468
144469
144470
144471

144472
144473


144474
144475
144476
144477

144478
144479


144480
144481
144482
144483


144484
144485
144486


144487
144488
144489


144490
144491
144492


144493
144494
144495


144496
144497
144498


144499
144500
144501

144502
144503


144504
144505
144506
144507

144508
144509



144510
144511
144512
144513
144514
144515
144516
144517
144518
144519
144520







144521
144522

144523
144524
144525

144526
144527


144528
144529
144530

144531
144532

144533
144534

144535
144536
144537

144538
144539

144540
144541
144542

144543
144544

144545
144546
144547





144548
144549
144550
144551
144552
144553
144554
144555
144556
144557
144558
144559
144560
144561
144562
144563
144564
144565


144566
144567
144568


144569
144570
144571



144572
144573
144574
144575

144576
144577
144578
144579

144580
144581

144582
144583

144584
144585
144586
144587
144588
144589

144590
144591

144592
144593



144594
144595
144596
144597

144598
144599

144600
144601

144602
144603

144604
144605
144606
144607


144608
144609
144610
144611
144612
144613
144614
144615
144616
144617

144618
144619


144620
144621
144622
144623
144624
144625

144626
144627

144628
144629
144630

144631
144632


144633
144634
144635
144636

144637
144638

144639
144640
144641



144642
144643
144644
144645
144646

144647
144648

144649
144650

144651
144652

144653
144654

144655
144656

144657
144658

144659
144660

144661
144662




144663
144664
144665
144666
144667
144668
144669
144670
144671









144672
144673
144674
144675
144676
144677
144678
144679
144680
144681

144682
144683
144684

144685
144686
144687
144688
144689





144690
144691
144692
144693
144694
144695
144696

144697
144698
144699
144700
144701






144702
144703
144704
144705
144706
144707
144708
144709


144710
144711
144712


144713
144714
144715

144716
144717


144718
144719
144720
144721

144722
144723


144724
144725
144726
144727



144728
144729
144730
144731


144732
144733
144734


144735
144736
144737



144738
144739
144740
144741

144742
144743





144744
144745
144746
144747
144748
144749
144750
144751

144752
144753
144754

144755
144756

144757
144758
144759
144760
144761
144762
144763
144764
144765



144766
144767
144768
144769
144770
144771
144772
144773
144774
144775
144776
144777
144778
144779
144780
144781
144782
144783
144784



144785
144786
144787
144788
144789
144790
144791
144792
144793

144794
144795




144796
144797
144798
144799
144800

144801
144802

144803
144804
144805
144806

144807
144808


144809
144810
144811
144812

144813
144814



144815
144816
144817
144818
144819

144820
144821
144822
144823




144824
144825
144826
144827
144828
144829

144830
144831
144832


144833
144834
144835
144836

144837
144838




144839
144840
144841
144842
144843


144844
144845
144846
144847
144848

144849
144850


144851
144852
144853
144854

144855
144856


144857
144858
144859
144860


144861
144862
144863


144864
144865
144866


144867
144868
144869



144870
144871
144872
144873

144874
144875
144876


144877
144878
144879
144880



144881
144882
144883
144884


144885
144886
144887

144888
144889

144890
144891
144892

144893
144894

144895
144896
144897


144898
144899
144900

144901
144902
144903

144904
144905
144906

144907
144908
144909

144910
144911
144912

144913
144914
144915

144916
144917
144918

144919
144920
144921

144922
144923
144924
144925
144926

144927
144928
144929

144930
144931

144932
144933
144934
144935


144936
144937
144938


144939
144940
144941


144942
144943
144944



144945
144946
144947
144948


144949
144950
144951



144952
144953
144954
144955



144956
144957
144958
144959

144960
144961



144962
144963
144964
144965
144966

144967
144968


144969
144970
144971
144972

144973
144974
144975
144976
144977
144978
144979
144980

144981
144982
144983
144984
144985
144986
144987

144988
144989
144990
144991
144992
144993
144994



144995
144996
144997
144998



144999
145000
145001
145002
145003
145004



145005
145006
145007
145008



145009
145010
145011
145012

145013
145014



145015
145016
145017
145018
145019
145020

145021
145022



145023
145024
145025
145026
145027
145028


145029
145030
145031


145032
145033
145034

145035
145036

145037
145038
145039

145040
145041

145042
145043
145044

145045
145046

145047
145048
145049

145050
145051
145052

145053
145054
145055

145056
145057
145058

145059
145060
145061

145062
145063

145064
145065
145066

145067
145068
145069
145070
145071
145072

145073
145074
145075

145076
145077
145078

145079
145080
145081

145082
145083
145084

145085
145086

145087
145088
145089

145090
145091
145092



145093
145094
145095
145096
145097



145098
145099
145100
145101

145102
145103

145104
145105
145106

145107
145108

145109
145110
145111
145112


























































145113
145114
145115
145116
145117
145118
145119
145120
145121
145122
145123
145124
145125
145126
145127
145128
145129
145130
145131
145132
145133
145134
145135
145136
145137
145138
145139
145140
145141
145142
145143
145144
145145
145146
145147
145148
145149
145150
145151
145152
145153
145154
145155
145156
145157
145158
145159
145160
145161
145162
145163
145164
145165
145166
145167
145168
145169
145170
145171
145172
145173
145174
145175
145176
145177
145178
145179
145180
145181
145182
145183
145184
145185
145186
145187
145188
145189
145190
145191
145192
145193
145194
145195
145196
145197
145198
145199
145200

145201
145202
145203
145204
145205
145206
145207
145208
145209
145210
145211
145212

145213
145214
145215
145216
145217
145218
145219
145220
145221
145222
145223
145224
145225

145226
145227
145228
145229
145230
145231
145232
145233
145234
145235
145236
145237

145238
145239
145240
145241
145242
145243
145244
145245
145246
145247

145248
145249
145250
145251
145252
145253
145254
145255
145256
145257
145258
145259
145260
145261
145262

145263
145264
145265
145266
145267
145268
145269
145270
145271







-
+







-
+


-
+


-
+



-
-
+
+













-
+


-
+


-
+



-
+


-
+


-
+





-
+


-
+


-
+


-
+


-
+


-
+


-
+


-
+


-
+


-
+


-
+


-
+



-
-
+
+



-
-
-
-
+
+
+
+


-
+





-
+


-
+



-
+



-
-
+
+




-
+


-
+


-
+


-
-
+
+



-
+




-
+




-
+





-
-
+
+




-
+

-
+


-
+

-
+




-
+

-
+


-
+

-
+




-
+



-
+




-
-
+
+









-
+



-
+



-
+




-
+


-
+






-
+










-
+


-
+





-
+







-
+




-
-
+
+




-
+

-
+




-
+


-
+


-
-
-
-
-
-
+
+
+
+
+
+



-
-
-
+
+
+





-
+







-
+




-
-
+
+



-
+



-
-
+
+




-
+



-
+



-
-
+
+




-
-
+
+




-
+




-
-
-
-
-
-
-
+
+
+
+
+
+
+






-
+


-
-
-
+
+
+




-
+



+
-
+


+
-
+

+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+

-
-
+
+

-
-
+
+

-
-
+
+

-
-
-
-
-
+
+
+
+
+

-
-
-
-
-
-
-
+
+
+
+
+
+
+

-
+


-
+


-
-
+
+

-
-
-
+
+
+

-
-
-
+
+
+

-
+

-
-
+
+


-
+

-
-
+
+


-
-
+
+

-
-
+
+

-
-
+
+

-
-
+
+

-
-
+
+

-
-
+
+

-
+

-
-
+
+


-
+

-
-
-
+
+
+
+
+
+
+
+
+


-
-
-
-
-
-
-
+

-
+


-
+

-
-
+
+

-
+

-
+

-
+


-
+

-
+


-
+

-
+


-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
+
+

-
-
+
+

-
-
-
+
+
+

-
+



-
+

-
+

-
+





-
+

-
+

-
-
-
+
+
+

-
+

-
+

-
+

-
+



-
-
+
+








-
+

-
-
+
+




-
+

-
+


-
+

-
-
+
+


-
+

-
+


-
-
-
+
+
+


-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
-
-
-
+
+
+
+





-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+

-
+


-
+




-
-
-
-
-
+
+
+
+
+


-
+




-
-
-
-
-
-
+
+
+
+
+
+


-
-
+
+

-
-
+
+

-
+

-
-
+
+


-
+

-
-
+
+


-
-
-
+
+
+

-
-
+
+

-
-
+
+

-
-
-
+
+
+

-
+

-
-
-
-
-
+
+
+
+
+



-
+


-
+

-
+








-
-
-
+
+
+
















-
-
-
+
+
+






-
+

-
-
-
-
+
+
+
+

-
+

-
+



-
+

-
-
+
+


-
+

-
-
-
+
+
+


-
+



-
-
-
-
+
+
+
+


-
+


-
-
+
+


-
+

-
-
-
-
+
+
+
+

-
-
+
+



-
+

-
-
+
+


-
+

-
-
+
+


-
-
+
+

-
-
+
+

-
-
+
+

-
-
-
+
+
+

-
+


-
-
+
+


-
-
-
+
+
+

-
-
+
+

-
+

-
+


-
+

-
+


-
-
+
+

-
+


-
+


-
+


-
+


-
+


-
+


-
+


-
+




-
+


-
+

-
+



-
-
+
+

-
-
+
+

-
-
+
+

-
-
-
+
+
+

-
-
+
+

-
-
-
+
+
+

-
-
-
+
+
+

-
+

-
-
-
+
+
+


-
+

-
-
+
+


-
+







-
+






-
+






-
-
-
+
+
+

-
-
-
+
+
+
+
+

-
-
-
+
+
+

-
-
-
+
+
+

-
+

-
-
-
+
+
+



-
+

-
-
-
+
+
+



-
-
+
+

-
-
+
+

-
+

-
+


-
+

-
+


-
+

-
+


-
+


-
+


-
+


-
+


-
+

-
+


-
+





-
+


-
+


-
+


-
+


-
+

-
+


-
+


-
-
-
+
+
+


-
-
-
+
+
+

-
+

-
+


-
+

-
+



-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+




















+









-
+
+










-
+
+











-
+
+










-
+
+








-
+
+













-
+
+







        break;
      case 27: /* typename ::= typename ID|STRING */
{yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
        break;
      case 28: /* scanpt ::= */
{
  assert( yyLookahead!=YYNOCODE );
  yymsp[1].minor.yy336 = yyLookaheadToken.z;
  yymsp[1].minor.yy36 = yyLookaheadToken.z;
}
        break;
      case 29: /* ccons ::= CONSTRAINT nm */
      case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
{pParse->constraintName = yymsp[0].minor.yy0;}
        break;
      case 30: /* ccons ::= DEFAULT scanpt term scanpt */
{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy314,yymsp[-2].minor.yy336,yymsp[0].minor.yy336);}
{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy36,yymsp[0].minor.yy36);}
        break;
      case 31: /* ccons ::= DEFAULT LP expr RP */
{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy314,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
        break;
      case 32: /* ccons ::= DEFAULT PLUS term scanpt */
{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy314,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy336);}
{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);}
        break;
      case 33: /* ccons ::= DEFAULT MINUS term scanpt */
{
  Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy314, 0);
  sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy336);
  Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy182, 0);
  sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);
}
        break;
      case 34: /* ccons ::= DEFAULT scanpt ID|INDEXED */
{
  Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0);
  if( p ){
    sqlite3ExprIdToTrueFalse(p);
    testcase( p->op==TK_TRUEFALSE && sqlite3ExprTruthValue(p) );
  }
  sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
}
        break;
      case 35: /* ccons ::= NOT NULL onconf */
{sqlite3AddNotNull(pParse, yymsp[0].minor.yy4);}
{sqlite3AddNotNull(pParse, yymsp[0].minor.yy502);}
        break;
      case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy4,yymsp[0].minor.yy4,yymsp[-2].minor.yy4);}
{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy502,yymsp[0].minor.yy502,yymsp[-2].minor.yy502);}
        break;
      case 37: /* ccons ::= UNIQUE onconf */
{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy4,0,0,0,0,
{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy502,0,0,0,0,
                                   SQLITE_IDXTYPE_UNIQUE);}
        break;
      case 38: /* ccons ::= CHECK LP expr RP */
{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy314);}
{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy182);}
        break;
      case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy322,yymsp[0].minor.yy4);}
{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy232,yymsp[0].minor.yy502);}
        break;
      case 40: /* ccons ::= defer_subclause */
{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy4);}
{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy502);}
        break;
      case 41: /* ccons ::= COLLATE ID|STRING */
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
        break;
      case 44: /* refargs ::= */
{ yymsp[1].minor.yy4 = OE_None*0x0101; /* EV: R-19803-45884 */}
{ yymsp[1].minor.yy502 = OE_None*0x0101; /* EV: R-19803-45884 */}
        break;
      case 45: /* refargs ::= refargs refarg */
{ yymsp[-1].minor.yy4 = (yymsp[-1].minor.yy4 & ~yymsp[0].minor.yy215.mask) | yymsp[0].minor.yy215.value; }
{ yymsp[-1].minor.yy502 = (yymsp[-1].minor.yy502 & ~yymsp[0].minor.yy107.mask) | yymsp[0].minor.yy107.value; }
        break;
      case 46: /* refarg ::= MATCH nm */
{ yymsp[-1].minor.yy215.value = 0;     yymsp[-1].minor.yy215.mask = 0x000000; }
{ yymsp[-1].minor.yy107.value = 0;     yymsp[-1].minor.yy107.mask = 0x000000; }
        break;
      case 47: /* refarg ::= ON INSERT refact */
{ yymsp[-2].minor.yy215.value = 0;     yymsp[-2].minor.yy215.mask = 0x000000; }
{ yymsp[-2].minor.yy107.value = 0;     yymsp[-2].minor.yy107.mask = 0x000000; }
        break;
      case 48: /* refarg ::= ON DELETE refact */
{ yymsp[-2].minor.yy215.value = yymsp[0].minor.yy4;     yymsp[-2].minor.yy215.mask = 0x0000ff; }
{ yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502;     yymsp[-2].minor.yy107.mask = 0x0000ff; }
        break;
      case 49: /* refarg ::= ON UPDATE refact */
{ yymsp[-2].minor.yy215.value = yymsp[0].minor.yy4<<8;  yymsp[-2].minor.yy215.mask = 0x00ff00; }
{ yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502<<8;  yymsp[-2].minor.yy107.mask = 0x00ff00; }
        break;
      case 50: /* refact ::= SET NULL */
{ yymsp[-1].minor.yy4 = OE_SetNull;  /* EV: R-33326-45252 */}
{ yymsp[-1].minor.yy502 = OE_SetNull;  /* EV: R-33326-45252 */}
        break;
      case 51: /* refact ::= SET DEFAULT */
{ yymsp[-1].minor.yy4 = OE_SetDflt;  /* EV: R-33326-45252 */}
{ yymsp[-1].minor.yy502 = OE_SetDflt;  /* EV: R-33326-45252 */}
        break;
      case 52: /* refact ::= CASCADE */
{ yymsp[0].minor.yy4 = OE_Cascade;  /* EV: R-33326-45252 */}
{ yymsp[0].minor.yy502 = OE_Cascade;  /* EV: R-33326-45252 */}
        break;
      case 53: /* refact ::= RESTRICT */
{ yymsp[0].minor.yy4 = OE_Restrict; /* EV: R-33326-45252 */}
{ yymsp[0].minor.yy502 = OE_Restrict; /* EV: R-33326-45252 */}
        break;
      case 54: /* refact ::= NO ACTION */
{ yymsp[-1].minor.yy4 = OE_None;     /* EV: R-33326-45252 */}
{ yymsp[-1].minor.yy502 = OE_None;     /* EV: R-33326-45252 */}
        break;
      case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
{yymsp[-2].minor.yy4 = 0;}
{yymsp[-2].minor.yy502 = 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;}
      case 155: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==155);
{yymsp[-1].minor.yy502 = yymsp[0].minor.yy502;}
        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;}
      case 196: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==196);
      case 199: /* in_op ::= NOT IN */ yytestcase(yyruleno==199);
      case 225: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==225);
{yymsp[-1].minor.yy502 = 1;}
        break;
      case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
{yymsp[-1].minor.yy4 = 0;}
{yymsp[-1].minor.yy502 = 0;}
        break;
      case 61: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}
        break;
      case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy322,yymsp[0].minor.yy4,yymsp[-2].minor.yy4,0);}
{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy232,yymsp[0].minor.yy502,yymsp[-2].minor.yy502,0);}
        break;
      case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy322,yymsp[0].minor.yy4,0,0,0,0,
{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy232,yymsp[0].minor.yy502,0,0,0,0,
                                       SQLITE_IDXTYPE_UNIQUE);}
        break;
      case 65: /* tcons ::= CHECK LP expr RP onconf */
{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy314);}
{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy182);}
        break;
      case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
{
    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy322, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy4);
    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy4);
    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy232, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy502);
    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy502);
}
        break;
      case 68: /* onconf ::= */
      case 70: /* orconf ::= */ yytestcase(yyruleno==70);
{yymsp[1].minor.yy4 = OE_Default;}
{yymsp[1].minor.yy502 = OE_Default;}
        break;
      case 69: /* onconf ::= ON CONFLICT resolvetype */
{yymsp[-2].minor.yy4 = yymsp[0].minor.yy4;}
{yymsp[-2].minor.yy502 = yymsp[0].minor.yy502;}
        break;
      case 72: /* resolvetype ::= IGNORE */
{yymsp[0].minor.yy4 = OE_Ignore;}
{yymsp[0].minor.yy502 = OE_Ignore;}
        break;
      case 73: /* resolvetype ::= REPLACE */
      case 148: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==148);
{yymsp[0].minor.yy4 = OE_Replace;}
      case 156: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==156);
{yymsp[0].minor.yy502 = OE_Replace;}
        break;
      case 74: /* cmd ::= DROP TABLE ifexists fullname */
{
  sqlite3DropTable(pParse, yymsp[0].minor.yy259, 0, yymsp[-1].minor.yy4);
  sqlite3DropTable(pParse, yymsp[0].minor.yy427, 0, yymsp[-1].minor.yy502);
}
        break;
      case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
{
  sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[0].minor.yy387, yymsp[-7].minor.yy4, yymsp[-5].minor.yy4);
  sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[0].minor.yy399, yymsp[-7].minor.yy502, yymsp[-5].minor.yy502);
}
        break;
      case 78: /* cmd ::= DROP VIEW ifexists fullname */
{
  sqlite3DropTable(pParse, yymsp[0].minor.yy259, 1, yymsp[-1].minor.yy4);
  sqlite3DropTable(pParse, yymsp[0].minor.yy427, 1, yymsp[-1].minor.yy502);
}
        break;
      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);
  sqlite3Select(pParse, yymsp[0].minor.yy399, &dest);
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399);
}
        break;
      case 80: /* select ::= WITH wqlist selectnowith */
{
  Select *p = yymsp[0].minor.yy387;
  Select *p = yymsp[0].minor.yy399;
  if( p ){
    p->pWith = yymsp[-1].minor.yy451;
    p->pWith = yymsp[-1].minor.yy91;
    parserDoubleLinkSelect(pParse, p);
  }else{
    sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy451);
    sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91);
  }
  yymsp[-2].minor.yy387 = p;
  yymsp[-2].minor.yy399 = p;
}
        break;
      case 81: /* select ::= WITH RECURSIVE wqlist selectnowith */
{
  Select *p = yymsp[0].minor.yy387;
  Select *p = yymsp[0].minor.yy399;
  if( p ){
    p->pWith = yymsp[-1].minor.yy451;
    p->pWith = yymsp[-1].minor.yy91;
    parserDoubleLinkSelect(pParse, p);
  }else{
    sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy451);
    sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91);
  }
  yymsp[-3].minor.yy387 = p;
  yymsp[-3].minor.yy399 = p;
}
        break;
      case 82: /* select ::= selectnowith */
{
  Select *p = yymsp[0].minor.yy387;
  Select *p = yymsp[0].minor.yy399;
  if( p ){
    parserDoubleLinkSelect(pParse, p);
  }
  yymsp[0].minor.yy387 = p; /*A-overwrites-X*/
  yymsp[0].minor.yy399 = p; /*A-overwrites-X*/
}
        break;
      case 83: /* selectnowith ::= selectnowith multiselect_op oneselect */
{
  Select *pRhs = yymsp[0].minor.yy387;
  Select *pLhs = yymsp[-2].minor.yy387;
  Select *pRhs = yymsp[0].minor.yy399;
  Select *pLhs = yymsp[-2].minor.yy399;
  if( pRhs && pRhs->pPrior ){
    SrcList *pFrom;
    Token x;
    x.n = 0;
    parserDoubleLinkSelect(pParse, pRhs);
    pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
    pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
  }
  if( pRhs ){
    pRhs->op = (u8)yymsp[-1].minor.yy4;
    pRhs->op = (u8)yymsp[-1].minor.yy502;
    pRhs->pPrior = pLhs;
    if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
    pRhs->selFlags &= ~SF_MultiValue;
    if( yymsp[-1].minor.yy4!=TK_ALL ) pParse->hasCompound = 1;
    if( yymsp[-1].minor.yy502!=TK_ALL ) pParse->hasCompound = 1;
  }else{
    sqlite3SelectDelete(pParse->db, pLhs);
  }
  yymsp[-2].minor.yy387 = pRhs;
  yymsp[-2].minor.yy399 = 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*/}
{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-OP*/}
        break;
      case 85: /* multiselect_op ::= UNION ALL */
{yymsp[-1].minor.yy4 = TK_ALL;}
{yymsp[-1].minor.yy502 = 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);
  yymsp[-8].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy232,yymsp[-5].minor.yy427,yymsp[-4].minor.yy182,yymsp[-3].minor.yy232,yymsp[-2].minor.yy182,yymsp[-1].minor.yy232,yymsp[-7].minor.yy502,yymsp[0].minor.yy182);
#if SELECTTRACE_ENABLED
  /* Populate the Select.zSelName[] string that is used to help with
  ** query planner debugging, to differentiate between multiple Select
  ** objects in a complex query.
  **
  ** If the SELECT keyword is immediately followed by a C-style comment
  ** then extract the first few alphanumeric characters from within that
  ** comment to be the zSelName value.  Otherwise, the label is #N where
  ** is an integer that is incremented with each SELECT statement seen.
  */
  if( yymsp[-8].minor.yy387!=0 ){
  if( yymsp[-8].minor.yy399!=0 ){
    const char *z = s.z+6;
    int i;
    sqlite3_snprintf(sizeof(yymsp[-8].minor.yy387->zSelName), yymsp[-8].minor.yy387->zSelName,"#%d",++pParse->nSelect);
    sqlite3_snprintf(sizeof(yymsp[-8].minor.yy399->zSelName), yymsp[-8].minor.yy399->zSelName,"#%d",++pParse->nSelect);
    while( z[0]==' ' ) z++;
    if( z[0]=='/' && z[1]=='*' ){
      z += 2;
      while( z[0]==' ' ) z++;
      for(i=0; sqlite3Isalnum(z[i]); i++){}
      sqlite3_snprintf(sizeof(yymsp[-8].minor.yy387->zSelName), yymsp[-8].minor.yy387->zSelName, "%.*s", i, z);
      sqlite3_snprintf(sizeof(yymsp[-8].minor.yy399->zSelName), yymsp[-8].minor.yy399->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);
  yymsp[-3].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,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);
  Select *pRight, *pLeft = yymsp[-4].minor.yy399;
  pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,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;
    yymsp[-4].minor.yy399 = pRight;
  }else{
    yymsp[-4].minor.yy387 = pLeft;
    yymsp[-4].minor.yy399 = pLeft;
  }
}
        break;
      case 90: /* distinct ::= DISTINCT */
{yymsp[0].minor.yy4 = SF_Distinct;}
{yymsp[0].minor.yy502 = SF_Distinct;}
        break;
      case 91: /* distinct ::= ALL */
{yymsp[0].minor.yy4 = SF_All;}
{yymsp[0].minor.yy502 = 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;}
      case 126: /* orderby_opt ::= */ yytestcase(yyruleno==126);
      case 133: /* groupby_opt ::= */ yytestcase(yyruleno==133);
      case 212: /* exprlist ::= */ yytestcase(yyruleno==212);
      case 215: /* paren_exprlist ::= */ yytestcase(yyruleno==215);
      case 220: /* eidlist_opt ::= */ yytestcase(yyruleno==220);
{yymsp[1].minor.yy232 = 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);
   yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy232, yymsp[-2].minor.yy182);
   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy232, &yymsp[0].minor.yy0, 1);
   sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy232,yymsp[-3].minor.yy36,yymsp[-1].minor.yy36);
}
        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);
  yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy232, 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);
  yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, 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);
      case 234: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==234);
      case 235: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==235);
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 99: /* from ::= */
{yymsp[1].minor.yy259 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy259));}
{yymsp[1].minor.yy427 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy427));}
        break;
      case 100: /* from ::= FROM seltablist */
{
  yymsp[-1].minor.yy259 = yymsp[0].minor.yy259;
  sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy259);
  yymsp[-1].minor.yy427 = yymsp[0].minor.yy427;
  sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy427);
}
        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;
   if( ALWAYS(yymsp[-1].minor.yy427 && yymsp[-1].minor.yy427->nSrc>0) ) yymsp[-1].minor.yy427->a[yymsp[-1].minor.yy427->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy502;
}
        break;
      case 102: /* stl_prefix ::= */
{yymsp[1].minor.yy259 = 0;}
{yymsp[1].minor.yy427 = 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);
  yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
  sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy427, &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);
  yymsp[-8].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy427,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
  sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy427, yymsp[-4].minor.yy232);
}
        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);
    yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy399,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
  }
        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];
        struct SrcList_item *pOld = yymsp[-4].minor.yy259->a;
    if( yymsp[-6].minor.yy427==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy182==0 && yymsp[0].minor.yy510==0 ){
      yymsp[-6].minor.yy427 = yymsp[-4].minor.yy427;
    }else if( yymsp[-4].minor.yy427->nSrc==1 ){
      yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
      if( yymsp[-6].minor.yy427 ){
        struct SrcList_item *pNew = &yymsp[-6].minor.yy427->a[yymsp[-6].minor.yy427->nSrc-1];
        struct SrcList_item *pOld = yymsp[-4].minor.yy427->a;
        pNew->zName = pOld->zName;
        pNew->zDatabase = pOld->zDatabase;
        pNew->pSelect = pOld->pSelect;
        pOld->zName = pOld->zDatabase = 0;
        pOld->pSelect = 0;
      }
      sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy259);
      sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy427);
    }else{
      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);
      sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy427);
      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy427,0,0,0,0,SF_NestedFrom,0);
      yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
    }
  }
        break;
      case 107: /* dbnm ::= */
      case 117: /* indexed_opt ::= */ yytestcase(yyruleno==117);
      case 121: /* indexed_opt ::= */ yytestcase(yyruleno==121);
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
        break;
      case 109: /* fullname ::= nm */
      case 111: /* xfullname ::= nm */ yytestcase(yyruleno==111);
{yymsp[0].minor.yy259 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
{yymsp[0].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
        break;
      case 110: /* fullname ::= nm DOT nm */
      case 112: /* xfullname ::= nm DOT nm */ yytestcase(yyruleno==112);
{yymsp[-2].minor.yy259 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
{yymsp[-2].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 113: /* xfullname ::= nm DOT nm AS nm */
{
   yymsp[-4].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
   if( yymsp[-4].minor.yy427 ) yymsp[-4].minor.yy427->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
        break;
      case 114: /* xfullname ::= nm AS nm */
{  
   yymsp[-2].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
   if( yymsp[-2].minor.yy427 ) yymsp[-2].minor.yy427->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
        break;
      case 111: /* joinop ::= COMMA|JOIN */
{ yymsp[0].minor.yy4 = JT_INNER; }
      case 115: /* joinop ::= COMMA|JOIN */
{ yymsp[0].minor.yy502 = JT_INNER; }
        break;
      case 112: /* joinop ::= JOIN_KW JOIN */
{yymsp[-1].minor.yy4 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}
      case 116: /* joinop ::= JOIN_KW JOIN */
{yymsp[-1].minor.yy502 = 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*/}
      case 117: /* joinop ::= JOIN_KW nm JOIN */
{yymsp[-2].minor.yy502 = 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*/}
      case 118: /* joinop ::= JOIN_KW nm nm JOIN */
{yymsp[-3].minor.yy502 = 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;}
      case 119: /* on_opt ::= ON expr */
      case 136: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==136);
      case 143: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==143);
      case 208: /* case_else ::= ELSE expr */ yytestcase(yyruleno==208);
{yymsp[-1].minor.yy182 = yymsp[0].minor.yy182;}
        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;}
      case 120: /* on_opt ::= */
      case 135: /* having_opt ::= */ yytestcase(yyruleno==135);
      case 137: /* limit_opt ::= */ yytestcase(yyruleno==137);
      case 142: /* where_opt ::= */ yytestcase(yyruleno==142);
      case 209: /* case_else ::= */ yytestcase(yyruleno==209);
      case 211: /* case_operand ::= */ yytestcase(yyruleno==211);
{yymsp[1].minor.yy182 = 0;}
        break;
      case 118: /* indexed_opt ::= INDEXED BY nm */
      case 122: /* indexed_opt ::= INDEXED BY nm */
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 119: /* indexed_opt ::= NOT INDEXED */
      case 123: /* 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;}
      case 124: /* using_opt ::= USING LP idlist RP */
{yymsp[-3].minor.yy510 = yymsp[-1].minor.yy510;}
        break;
      case 121: /* using_opt ::= */
      case 149: /* idlist_opt ::= */ yytestcase(yyruleno==149);
{yymsp[1].minor.yy384 = 0;}
      case 125: /* using_opt ::= */
      case 157: /* idlist_opt ::= */ yytestcase(yyruleno==157);
{yymsp[1].minor.yy510 = 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;}
      case 127: /* orderby_opt ::= ORDER BY sortlist */
      case 134: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==134);
{yymsp[-2].minor.yy232 = yymsp[0].minor.yy232;}
        break;
      case 124: /* sortlist ::= sortlist COMMA expr sortorder */
      case 128: /* 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);
  yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232,yymsp[-1].minor.yy182);
  sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy232,yymsp[0].minor.yy502);
}
        break;
      case 125: /* sortlist ::= expr sortorder */
      case 129: /* 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);
  yymsp[-1].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy182); /*A-overwrites-Y*/
  sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy232,yymsp[0].minor.yy502);
}
        break;
      case 126: /* sortorder ::= ASC */
{yymsp[0].minor.yy4 = SQLITE_SO_ASC;}
      case 130: /* sortorder ::= ASC */
{yymsp[0].minor.yy502 = SQLITE_SO_ASC;}
        break;
      case 127: /* sortorder ::= DESC */
{yymsp[0].minor.yy4 = SQLITE_SO_DESC;}
      case 131: /* sortorder ::= DESC */
{yymsp[0].minor.yy502 = SQLITE_SO_DESC;}
        break;
      case 128: /* sortorder ::= */
{yymsp[1].minor.yy4 = SQLITE_SO_UNDEFINED;}
      case 132: /* sortorder ::= */
{yymsp[1].minor.yy502 = SQLITE_SO_UNDEFINED;}
        break;
      case 134: /* limit_opt ::= LIMIT expr */
{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy314,0);}
      case 138: /* limit_opt ::= LIMIT expr */
{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,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);}
      case 139: /* limit_opt ::= LIMIT expr OFFSET expr */
{yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);}
        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);}
      case 140: /* limit_opt ::= LIMIT expr COMMA expr */
{yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,yymsp[-2].minor.yy182);}
        break;
      case 137: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
      case 141: /* cmd ::= with DELETE FROM xfullname 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);
  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy427, &yymsp[-1].minor.yy0);
  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy427,yymsp[0].minor.yy182,0,0);
}
        break;
      case 140: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
      case 144: /* cmd ::= with UPDATE orconf xfullname 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);
  sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy427, &yymsp[-3].minor.yy0);
  sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy232,"set list"); 
  sqlite3Update(pParse,yymsp[-4].minor.yy427,yymsp[-1].minor.yy232,yymsp[0].minor.yy182,yymsp[-5].minor.yy502,0,0,0);
}
        break;
      case 145: /* setlist ::= setlist COMMA nm EQ expr */
{
  yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy232, yymsp[0].minor.yy182);
  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, 1);
}
        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 */
      case 146: /* 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);
  yymsp[-6].minor.yy232 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy232, yymsp[-3].minor.yy510, yymsp[0].minor.yy182);
}
        break;
      case 143: /* setlist ::= nm EQ expr */
      case 147: /* setlist ::= nm EQ expr */
{
  yylhsminor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy314);
  sqlite3ExprListSetName(pParse, yylhsminor.yy322, &yymsp[-2].minor.yy0, 1);
  yylhsminor.yy232 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy182);
  sqlite3ExprListSetName(pParse, yylhsminor.yy232, &yymsp[-2].minor.yy0, 1);
}
  yymsp[-2].minor.yy322 = yylhsminor.yy322;
  yymsp[-2].minor.yy232 = yylhsminor.yy232;
        break;
      case 144: /* setlist ::= LP idlist RP EQ expr */
      case 148: /* setlist ::= LP idlist RP EQ expr */
{
  yymsp[-4].minor.yy322 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy384, yymsp[0].minor.yy314);
  yymsp[-4].minor.yy232 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy510, yymsp[0].minor.yy182);
}
        break;
      case 145: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
      case 149: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
{
  sqlite3Insert(pParse, yymsp[-2].minor.yy259, yymsp[0].minor.yy387, yymsp[-1].minor.yy384, yymsp[-4].minor.yy4);
  sqlite3Insert(pParse, yymsp[-3].minor.yy427, yymsp[-1].minor.yy399, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, yymsp[0].minor.yy198);
}
        break;
      case 146: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
      case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
{
  sqlite3Insert(pParse, yymsp[-3].minor.yy259, 0, yymsp[-2].minor.yy384, yymsp[-5].minor.yy4);
  sqlite3Insert(pParse, yymsp[-3].minor.yy427, 0, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, 0);
}
        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);}
      case 151: /* upsert ::= */
{ yymsp[1].minor.yy198 = 0; }
        break;
      case 152: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
{ yymsp[-10].minor.yy198 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy232,yymsp[-5].minor.yy182,yymsp[-1].minor.yy232,yymsp[0].minor.yy182);}
        break;
      case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
{ yymsp[-7].minor.yy198 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy232,yymsp[-2].minor.yy182,0,0); }
        break;
      case 154: /* upsert ::= ON CONFLICT DO NOTHING */
{ yymsp[-3].minor.yy198 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
        break;
      case 158: /* idlist_opt ::= LP idlist RP */
{yymsp[-2].minor.yy510 = yymsp[-1].minor.yy510;}
        break;
      case 159: /* idlist ::= idlist COMMA nm */
{yymsp[-2].minor.yy510 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy510,&yymsp[0].minor.yy0);}
        break;
      case 152: /* idlist ::= nm */
{yymsp[0].minor.yy384 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
      case 160: /* idlist ::= nm */
{yymsp[0].minor.yy510 = 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;}
      case 161: /* expr ::= LP expr RP */
{yymsp[-2].minor.yy182 = yymsp[-1].minor.yy182;}
        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*/}
      case 162: /* expr ::= ID|INDEXED */
      case 163: /* expr ::= JOIN_KW */ yytestcase(yyruleno==163);
{yymsp[0].minor.yy182=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 156: /* expr ::= nm DOT nm */
      case 164: /* 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);
  yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
}
  yymsp[-2].minor.yy314 = yylhsminor.yy314;
  yymsp[-2].minor.yy182 = yylhsminor.yy182;
        break;
      case 157: /* expr ::= nm DOT nm DOT nm */
      case 165: /* 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);
  yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
}
  yymsp[-4].minor.yy314 = yylhsminor.yy314;
  yymsp[-4].minor.yy182 = yylhsminor.yy182;
        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*/}
      case 166: /* term ::= NULL|FLOAT|BLOB */
      case 167: /* term ::= STRING */ yytestcase(yyruleno==167);
{yymsp[0].minor.yy182=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 160: /* term ::= INTEGER */
      case 168: /* term ::= INTEGER */
{
  yylhsminor.yy314 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
  yylhsminor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
}
  yymsp[0].minor.yy314 = yylhsminor.yy314;
  yymsp[0].minor.yy182 = yylhsminor.yy182;
        break;
      case 161: /* expr ::= VARIABLE */
      case 169: /* 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);
    yymsp[0].minor.yy182 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy182, n);
  }else{
    /* When doing a nested parse, one can include terms in an expression
    ** that look like this:   #1 #2 ...  These terms refer to registers
    ** in the virtual machine.  #N is the N-th register. */
    Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
    assert( t.n>=2 );
    if( pParse->nested==0 ){
      sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
      yymsp[0].minor.yy314 = 0;
      yymsp[0].minor.yy182 = 0;
    }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);
      yymsp[0].minor.yy182 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
      if( yymsp[0].minor.yy182 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy182->iTable);
    }
  }
}
        break;
      case 162: /* expr ::= expr COLLATE ID|STRING */
      case 170: /* expr ::= expr COLLATE ID|STRING */
{
  yymsp[-2].minor.yy314 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy314, &yymsp[0].minor.yy0, 1);
  yymsp[-2].minor.yy182 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy182, &yymsp[0].minor.yy0, 1);
}
        break;
      case 163: /* expr ::= CAST LP expr AS typetoken RP */
      case 171: /* 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);
  yymsp[-5].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy182, yymsp[-3].minor.yy182, 0);
}
        break;
      case 164: /* expr ::= ID|INDEXED LP distinct exprlist RP */
      case 172: /* expr ::= ID|INDEXED LP distinct exprlist RP */
{
  if( yymsp[-1].minor.yy322 && yymsp[-1].minor.yy322->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
  if( yymsp[-1].minor.yy232 && yymsp[-1].minor.yy232->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;
  yylhsminor.yy182 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy232, &yymsp[-4].minor.yy0);
  if( yymsp[-2].minor.yy502==SF_Distinct && yylhsminor.yy182 ){
    yylhsminor.yy182->flags |= EP_Distinct;
  }
}
  yymsp[-4].minor.yy314 = yylhsminor.yy314;
  yymsp[-4].minor.yy182 = yylhsminor.yy182;
        break;
      case 165: /* expr ::= ID|INDEXED LP STAR RP */
      case 173: /* expr ::= ID|INDEXED LP STAR RP */
{
  yylhsminor.yy314 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
  yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
}
  yymsp[-3].minor.yy314 = yylhsminor.yy314;
  yymsp[-3].minor.yy182 = yylhsminor.yy182;
        break;
      case 166: /* term ::= CTIME_KW */
      case 174: /* term ::= CTIME_KW */
{
  yylhsminor.yy314 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
  yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
}
  yymsp[0].minor.yy314 = yylhsminor.yy314;
  yymsp[0].minor.yy182 = yylhsminor.yy182;
        break;
      case 167: /* expr ::= LP nexprlist COMMA expr RP */
      case 175: /* 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;
  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy232, yymsp[-1].minor.yy182);
  yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
  if( yymsp[-4].minor.yy182 ){
    yymsp[-4].minor.yy182->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);}
      case 176: /* expr ::= expr AND expr */
      case 177: /* expr ::= expr OR expr */ yytestcase(yyruleno==177);
      case 178: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==178);
      case 179: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==179);
      case 180: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==180);
      case 181: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==181);
      case 182: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==182);
      case 183: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==183);
{yymsp[-2].minor.yy182=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);}
        break;
      case 176: /* likeop ::= NOT LIKE_KW|MATCH */
      case 184: /* 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 */
      case 185: /* 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;
  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy182);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy182);
  yymsp[-2].minor.yy182 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);
  if( bNot ) yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy182, 0);
  if( yymsp[-2].minor.yy182 ) yymsp[-2].minor.yy182->flags |= EP_InfixFunc;
}
        break;
      case 178: /* expr ::= expr likeop expr ESCAPE expr */
      case 186: /* 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;
  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy182);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy182);
  yymsp[-4].minor.yy182 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);
  if( bNot ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
  if( yymsp[-4].minor.yy182 ) yymsp[-4].minor.yy182->flags |= EP_InfixFunc;
}
        break;
      case 179: /* expr ::= expr ISNULL|NOTNULL */
{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy314,0);}
      case 187: /* expr ::= expr ISNULL|NOTNULL */
{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy182,0);}
        break;
      case 180: /* expr ::= expr NOT NULL */
{yymsp[-2].minor.yy314 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy314,0);}
      case 188: /* expr ::= expr NOT NULL */
{yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy182,0);}
        break;
      case 181: /* expr ::= expr IS expr */
      case 189: /* 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);
  yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy182, yymsp[-2].minor.yy182, TK_ISNULL);
}
        break;
      case 182: /* expr ::= expr IS NOT expr */
      case 190: /* 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);
  yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy182,yymsp[0].minor.yy182);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy182, yymsp[-3].minor.yy182, 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*/}
      case 191: /* expr ::= NOT expr */
      case 192: /* expr ::= BITNOT expr */ yytestcase(yyruleno==192);
{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy182, 0);/*A-overwrites-B*/}
        break;
      case 185: /* expr ::= MINUS expr */
{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy314, 0);}
      case 193: /* expr ::= MINUS expr */
{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy182, 0);}
        break;
      case 186: /* expr ::= PLUS expr */
{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse, TK_UPLUS, yymsp[0].minor.yy314, 0);}
      case 194: /* expr ::= PLUS expr */
{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, TK_UPLUS, yymsp[0].minor.yy182, 0);}
        break;
      case 187: /* between_op ::= BETWEEN */
      case 190: /* in_op ::= IN */ yytestcase(yyruleno==190);
{yymsp[0].minor.yy4 = 0;}
      case 195: /* between_op ::= BETWEEN */
      case 198: /* in_op ::= IN */ yytestcase(yyruleno==198);
{yymsp[0].minor.yy502 = 0;}
        break;
      case 189: /* expr ::= expr between_op expr AND expr */
      case 197: /* 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;
  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy182);
  yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy182, 0);
  if( yymsp[-4].minor.yy182 ){
    yymsp[-4].minor.yy182->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);
  if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
}
        break;
      case 192: /* expr ::= expr in_op LP exprlist RP */
      case 200: /* expr ::= expr in_op LP exprlist RP */
{
    if( yymsp[-1].minor.yy322==0 ){
    if( yymsp[-1].minor.yy232==0 ){
      /* Expressions of the form
      **
      **      expr1 IN ()
      **      expr1 NOT IN ()
      **
      ** simplify to constants 0 (false) and 1 (true), respectively,
      ** regardless of the value of expr1.
      */
      sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy314);
      yymsp[-4].minor.yy314 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy4],1);
    }else if( yymsp[-1].minor.yy322->nExpr==1 ){
      sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy182);
      yymsp[-4].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy502],1);
    }else if( yymsp[-1].minor.yy232->nExpr==1 ){
      /* Expressions of the form:
      **
      **      expr1 IN (?1)
      **      expr1 NOT IN (?2)
      **
      ** with exactly one value on the RHS can be simplified to something
      ** like this:
      **
      **      expr1 == ?1
      **      expr1 <> ?2
      **
      ** But, the RHS of the == or <> is marked with the EP_Generic flag
      ** so that it may not contribute to the computation of comparison
      ** affinity or the collating sequence to use for comparison.  Otherwise,
      ** the semantics would be subtly different from IN or NOT IN.
      */
      Expr *pRHS = yymsp[-1].minor.yy322->a[0].pExpr;
      yymsp[-1].minor.yy322->a[0].pExpr = 0;
      sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
      Expr *pRHS = yymsp[-1].minor.yy232->a[0].pExpr;
      yymsp[-1].minor.yy232->a[0].pExpr = 0;
      sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232);
      /* pRHS cannot be NULL because a malloc error would have been detected
      ** before now and control would have never reached this point */
      if( ALWAYS(pRHS) ){
        pRHS->flags &= ~EP_Collate;
        pRHS->flags |= EP_Generic;
      }
      yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, yymsp[-3].minor.yy4 ? TK_NE : TK_EQ, yymsp[-4].minor.yy314, pRHS);
      yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, yymsp[-3].minor.yy502 ? TK_NE : TK_EQ, yymsp[-4].minor.yy182, pRHS);
    }else{
      yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy314, 0);
      if( yymsp[-4].minor.yy314 ){
        yymsp[-4].minor.yy314->x.pList = yymsp[-1].minor.yy322;
        sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy314);
      yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
      if( yymsp[-4].minor.yy182 ){
        yymsp[-4].minor.yy182->x.pList = yymsp[-1].minor.yy232;
        sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy182);
      }else{
        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232);
      }
      if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
      if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
    }
  }
        break;
      case 193: /* expr ::= LP select RP */
      case 201: /* expr ::= LP select RP */
{
    yymsp[-2].minor.yy314 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy314, yymsp[-1].minor.yy387);
    yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy182, yymsp[-1].minor.yy399);
  }
        break;
      case 194: /* expr ::= expr in_op LP select RP */
      case 202: /* 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);
    yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy182, yymsp[-1].minor.yy399);
    if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
  }
        break;
      case 195: /* expr ::= expr in_op nm dbnm paren_exprlist */
      case 203: /* 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);
    if( yymsp[0].minor.yy232 )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy232);
    yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy182, pSelect);
    if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
  }
        break;
      case 196: /* expr ::= EXISTS LP select RP */
      case 204: /* 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);
    p = yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy399);
  }
        break;
      case 197: /* expr ::= CASE case_operand case_exprlist case_else END */
      case 205: /* 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);
  yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy182, 0);
  if( yymsp[-4].minor.yy182 ){
    yymsp[-4].minor.yy182->x.pList = yymsp[-1].minor.yy182 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[-1].minor.yy182) : yymsp[-2].minor.yy232;
    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy182);
  }else{
    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322);
    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy314);
    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy232);
    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy182);
  }
}
        break;
      case 198: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
      case 206: /* 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);
  yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, yymsp[-2].minor.yy182);
  yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, yymsp[0].minor.yy182);
}
        break;
      case 199: /* case_exprlist ::= WHEN expr THEN expr */
      case 207: /* 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);
  yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
  yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232, yymsp[0].minor.yy182);
}
        break;
      case 202: /* case_operand ::= expr */
{yymsp[0].minor.yy314 = yymsp[0].minor.yy314; /*A-overwrites-X*/}
      case 210: /* case_operand ::= expr */
{yymsp[0].minor.yy182 = yymsp[0].minor.yy182; /*A-overwrites-X*/}
        break;
      case 205: /* nexprlist ::= nexprlist COMMA expr */
{yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy314);}
      case 213: /* nexprlist ::= nexprlist COMMA expr */
{yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[0].minor.yy182);}
        break;
      case 206: /* nexprlist ::= expr */
{yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy314); /*A-overwrites-Y*/}
      case 214: /* nexprlist ::= expr */
{yymsp[0].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy182); /*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;}
      case 216: /* paren_exprlist ::= LP exprlist RP */
      case 221: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==221);
{yymsp[-2].minor.yy232 = yymsp[-1].minor.yy232;}
        break;
      case 209: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
      case 217: /* 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);
                     sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy232, yymsp[-10].minor.yy502,
                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy182, SQLITE_SO_ASC, yymsp[-8].minor.yy502, SQLITE_IDXTYPE_APPDEF);
}
        break;
      case 210: /* uniqueflag ::= UNIQUE */
      case 250: /* raisetype ::= ABORT */ yytestcase(yyruleno==250);
{yymsp[0].minor.yy4 = OE_Abort;}
      case 218: /* uniqueflag ::= UNIQUE */
      case 258: /* raisetype ::= ABORT */ yytestcase(yyruleno==258);
{yymsp[0].minor.yy502 = OE_Abort;}
        break;
      case 211: /* uniqueflag ::= */
{yymsp[1].minor.yy4 = OE_None;}
      case 219: /* uniqueflag ::= */
{yymsp[1].minor.yy502 = OE_None;}
        break;
      case 214: /* eidlist ::= eidlist COMMA nm collate sortorder */
      case 222: /* 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);
  yymsp[-4].minor.yy232 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502);
}
        break;
      case 215: /* eidlist ::= nm collate sortorder */
      case 223: /* 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*/
  yymsp[-2].minor.yy232 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502); /*A-overwrites-Y*/
}
        break;
      case 218: /* cmd ::= DROP INDEX ifexists fullname */
{sqlite3DropIndex(pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4);}
      case 226: /* cmd ::= DROP INDEX ifexists fullname */
{sqlite3DropIndex(pParse, yymsp[0].minor.yy427, yymsp[-1].minor.yy502);}
        break;
      case 219: /* cmd ::= VACUUM */
      case 227: /* cmd ::= VACUUM */
{sqlite3Vacuum(pParse,0);}
        break;
      case 220: /* cmd ::= VACUUM nm */
      case 228: /* cmd ::= VACUUM nm */
{sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
        break;
      case 221: /* cmd ::= PRAGMA nm dbnm */
      case 229: /* 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 */
      case 230: /* 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 */
      case 231: /* 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 */
      case 232: /* 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 */
      case 233: /* 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 */
      case 236: /* 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);
  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy47, &all);
}
        break;
      case 229: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
      case 237: /* 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);
  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy502, yymsp[-4].minor.yy300.a, yymsp[-4].minor.yy300.b, yymsp[-2].minor.yy427, yymsp[0].minor.yy182, yymsp[-10].minor.yy502, yymsp[-8].minor.yy502);
  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*/ }
      case 238: /* trigger_time ::= BEFORE|AFTER */
{ yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/ }
        break;
      case 231: /* trigger_time ::= INSTEAD OF */
{ yymsp[-1].minor.yy4 = TK_INSTEAD;}
      case 239: /* trigger_time ::= INSTEAD OF */
{ yymsp[-1].minor.yy502 = TK_INSTEAD;}
        break;
      case 232: /* trigger_time ::= */
{ yymsp[1].minor.yy4 = TK_BEFORE; }
      case 240: /* trigger_time ::= */
{ yymsp[1].minor.yy502 = 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;}
      case 241: /* trigger_event ::= DELETE|INSERT */
      case 242: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==242);
{yymsp[0].minor.yy300.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy300.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;}
      case 243: /* trigger_event ::= UPDATE OF idlist */
{yymsp[-2].minor.yy300.a = TK_UPDATE; yymsp[-2].minor.yy300.b = yymsp[0].minor.yy510;}
        break;
      case 236: /* when_clause ::= */
      case 255: /* key_opt ::= */ yytestcase(yyruleno==255);
{ yymsp[1].minor.yy314 = 0; }
      case 244: /* when_clause ::= */
      case 263: /* key_opt ::= */ yytestcase(yyruleno==263);
{ yymsp[1].minor.yy182 = 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; }
      case 245: /* when_clause ::= WHEN expr */
      case 264: /* key_opt ::= KEY expr */ yytestcase(yyruleno==264);
{ yymsp[-1].minor.yy182 = yymsp[0].minor.yy182; }
        break;
      case 238: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
      case 246: /* 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;
  assert( yymsp[-2].minor.yy47!=0 );
  yymsp[-2].minor.yy47->pLast->pNext = yymsp[-1].minor.yy47;
  yymsp[-2].minor.yy47->pLast = yymsp[-1].minor.yy47;
}
        break;
      case 239: /* trigger_cmd_list ::= trigger_cmd SEMI */
      case 247: /* trigger_cmd_list ::= trigger_cmd SEMI */
{ 
  assert( yymsp[-1].minor.yy203!=0 );
  yymsp[-1].minor.yy203->pLast = yymsp[-1].minor.yy203;
  assert( yymsp[-1].minor.yy47!=0 );
  yymsp[-1].minor.yy47->pLast = yymsp[-1].minor.yy47;
}
        break;
      case 240: /* trnm ::= nm DOT nm */
      case 248: /* 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 */
      case 249: /* 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 */
      case 250: /* 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;
      case 251: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
{yylhsminor.yy47 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy182, yymsp[-6].minor.yy502, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy36);}
  yymsp[-7].minor.yy47 = yylhsminor.yy47;
        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;
      case 252: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
{
   yylhsminor.yy47 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy510,yymsp[-2].minor.yy399,yymsp[-6].minor.yy502,yymsp[-1].minor.yy198,yymsp[-7].minor.yy36,yymsp[0].minor.yy36);/*yylhsminor.yy47-overwrites-yymsp[-6].minor.yy502*/
}
  yymsp[-7].minor.yy47 = yylhsminor.yy47;
        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;
      case 253: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
{yylhsminor.yy47 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy182, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy36);}
  yymsp[-5].minor.yy47 = yylhsminor.yy47;
        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;
      case 254: /* trigger_cmd ::= scanpt select scanpt */
{yylhsminor.yy47 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy399, yymsp[-2].minor.yy36, yymsp[0].minor.yy36); /*yylhsminor.yy47-overwrites-yymsp[-1].minor.yy399*/}
  yymsp[-2].minor.yy47 = yylhsminor.yy47;
        break;
      case 247: /* expr ::= RAISE LP IGNORE RP */
      case 255: /* 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;
  yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); 
  if( yymsp[-3].minor.yy182 ){
    yymsp[-3].minor.yy182->affinity = OE_Ignore;
  }
}
        break;
      case 248: /* expr ::= RAISE LP raisetype COMMA nm RP */
      case 256: /* 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;
  yymsp[-5].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); 
  if( yymsp[-5].minor.yy182 ) {
    yymsp[-5].minor.yy182->affinity = (char)yymsp[-3].minor.yy502;
  }
}
        break;
      case 249: /* raisetype ::= ROLLBACK */
{yymsp[0].minor.yy4 = OE_Rollback;}
      case 257: /* raisetype ::= ROLLBACK */
{yymsp[0].minor.yy502 = OE_Rollback;}
        break;
      case 251: /* raisetype ::= FAIL */
{yymsp[0].minor.yy4 = OE_Fail;}
      case 259: /* raisetype ::= FAIL */
{yymsp[0].minor.yy502 = OE_Fail;}
        break;
      case 252: /* cmd ::= DROP TRIGGER ifexists fullname */
      case 260: /* cmd ::= DROP TRIGGER ifexists fullname */
{
  sqlite3DropTrigger(pParse,yymsp[0].minor.yy259,yymsp[-1].minor.yy4);
  sqlite3DropTrigger(pParse,yymsp[0].minor.yy427,yymsp[-1].minor.yy502);
}
        break;
      case 253: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
      case 261: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
  sqlite3Attach(pParse, yymsp[-3].minor.yy314, yymsp[-1].minor.yy314, yymsp[0].minor.yy314);
  sqlite3Attach(pParse, yymsp[-3].minor.yy182, yymsp[-1].minor.yy182, yymsp[0].minor.yy182);
}
        break;
      case 254: /* cmd ::= DETACH database_kw_opt expr */
      case 262: /* cmd ::= DETACH database_kw_opt expr */
{
  sqlite3Detach(pParse, yymsp[0].minor.yy314);
  sqlite3Detach(pParse, yymsp[0].minor.yy182);
}
        break;
      case 257: /* cmd ::= REINDEX */
      case 265: /* cmd ::= REINDEX */
{sqlite3Reindex(pParse, 0, 0);}
        break;
      case 258: /* cmd ::= REINDEX nm dbnm */
      case 266: /* cmd ::= REINDEX nm dbnm */
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 259: /* cmd ::= ANALYZE */
      case 267: /* cmd ::= ANALYZE */
{sqlite3Analyze(pParse, 0, 0);}
        break;
      case 260: /* cmd ::= ANALYZE nm dbnm */
      case 268: /* cmd ::= ANALYZE nm dbnm */
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 261: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
      case 269: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy259,&yymsp[0].minor.yy0);
  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy427,&yymsp[0].minor.yy0);
}
        break;
      case 262: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
      case 270: /* 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 */
      case 271: /* add_column_fullname ::= fullname */
{
  disableLookaside(pParse);
  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy259);
  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy427);
}
        break;
      case 264: /* cmd ::= create_vtab */
      case 272: /* cmd ::= create_vtab */
{sqlite3VtabFinishParse(pParse,0);}
        break;
      case 265: /* cmd ::= create_vtab LP vtabarglist RP */
      case 273: /* 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 */
      case 274: /* 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);
    sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy502);
}
        break;
      case 267: /* vtabarg ::= */
      case 275: /* vtabarg ::= */
{sqlite3VtabArgInit(pParse);}
        break;
      case 268: /* vtabargtoken ::= ANY */
      case 269: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==269);
      case 270: /* lp ::= LP */ yytestcase(yyruleno==270);
      case 276: /* vtabargtoken ::= ANY */
      case 277: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==277);
      case 278: /* lp ::= LP */ yytestcase(yyruleno==278);
{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); }
      case 279: /* with ::= WITH wqlist */
      case 280: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==280);
{ sqlite3WithPush(pParse, yymsp[0].minor.yy91, 1); }
        break;
      case 273: /* wqlist ::= nm eidlist_opt AS LP select RP */
      case 281: /* 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*/
  yymsp[-5].minor.yy91 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy232, yymsp[-1].minor.yy399); /*A-overwrites-X*/
}
        break;
      case 274: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
      case 282: /* 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);
  yymsp[-7].minor.yy91 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy91, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy232, yymsp[-1].minor.yy399);
}
        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);
      /* (283) input ::= cmdlist */ yytestcase(yyruleno==283);
      /* (284) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==284);
      /* (285) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=285);
      /* (286) ecmd ::= SEMI */ yytestcase(yyruleno==286);
      /* (287) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==287);
      /* (288) ecmd ::= explain cmdx */ yytestcase(yyruleno==288);
      /* (289) trans_opt ::= */ yytestcase(yyruleno==289);
      /* (290) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==290);
      /* (291) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==291);
      /* (292) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==292);
      /* (293) savepoint_opt ::= */ yytestcase(yyruleno==293);
      /* (294) cmd ::= create_table create_table_args */ yytestcase(yyruleno==294);
      /* (295) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==295);
      /* (296) columnlist ::= columnname carglist */ yytestcase(yyruleno==296);
      /* (297) nm ::= ID|INDEXED */ yytestcase(yyruleno==297);
      /* (298) nm ::= STRING */ yytestcase(yyruleno==298);
      /* (299) nm ::= JOIN_KW */ yytestcase(yyruleno==299);
      /* (300) typetoken ::= typename */ yytestcase(yyruleno==300);
      /* (301) typename ::= ID|STRING */ yytestcase(yyruleno==301);
      /* (302) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=302);
      /* (303) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=303);
      /* (304) carglist ::= carglist ccons */ yytestcase(yyruleno==304);
      /* (305) carglist ::= */ yytestcase(yyruleno==305);
      /* (306) ccons ::= NULL onconf */ yytestcase(yyruleno==306);
      /* (307) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==307);
      /* (308) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==308);
      /* (309) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=309);
      /* (310) tconscomma ::= */ yytestcase(yyruleno==310);
      /* (311) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=311);
      /* (312) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=312);
      /* (313) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=313);
      /* (314) oneselect ::= values */ yytestcase(yyruleno==314);
      /* (315) sclp ::= selcollist COMMA */ yytestcase(yyruleno==315);
      /* (316) as ::= ID|STRING */ yytestcase(yyruleno==316);
      /* (317) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=317);
      /* (318) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==318);
      /* (319) exprlist ::= nexprlist */ yytestcase(yyruleno==319);
      /* (320) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=320);
      /* (321) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=321);
      /* (322) nmnum ::= ON */ yytestcase(yyruleno==322);
      /* (323) nmnum ::= DELETE */ yytestcase(yyruleno==323);
      /* (324) nmnum ::= DEFAULT */ yytestcase(yyruleno==324);
      /* (325) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==325);
      /* (326) foreach_clause ::= */ yytestcase(yyruleno==326);
      /* (327) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==327);
      /* (328) trnm ::= nm */ yytestcase(yyruleno==328);
      /* (329) tridxby ::= */ yytestcase(yyruleno==329);
      /* (330) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==330);
      /* (331) database_kw_opt ::= */ yytestcase(yyruleno==331);
      /* (332) kwcolumn_opt ::= */ yytestcase(yyruleno==332);
      /* (333) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==333);
      /* (334) vtabarglist ::= vtabarg */ yytestcase(yyruleno==334);
      /* (335) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==335);
      /* (336) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==336);
      /* (337) anylist ::= */ yytestcase(yyruleno==337);
      /* (338) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==338);
      /* (339) anylist ::= anylist ANY */ yytestcase(yyruleno==339);
      /* (340) with ::= */ yytestcase(yyruleno==340);
        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);

  /* There are no SHIFTREDUCE actions on nonterminals because the table
  ** generator has simplified them to pure REDUCE actions. */
  assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );

  /* It is not possible for a REDUCE to be followed by an error */
  assert( yyact!=YY_ERROR_ACTION );

  yymsp += yysize+1;
  yypParser->yytos = yymsp;
  yymsp->stateno = (YYACTIONTYPE)yyact;
  yymsp->major = (YYCODETYPE)yygoto;
  yyTraceShift(yypParser, yyact, "... then shift");
  return yyact;
}

/*
** The following code executes when the parse fails
*/
#ifndef YYNOERRORRECOVERY
static void yy_parse_failed(
  yyParser *yypParser           /* The parser */
){
  sqlite3ParserARG_FETCH;
  sqlite3ParserARG_FETCH
  sqlite3ParserCTX_FETCH
#ifndef NDEBUG
  if( yyTraceFILE ){
    fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
  }
#endif
  while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
  /* Here code is inserted which will be executed whenever the
  ** parser fails */
/************ Begin %parse_failure code ***************************************/
/************ End %parse_failure code *****************************************/
  sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
  sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
  sqlite3ParserCTX_STORE
}
#endif /* YYNOERRORRECOVERY */

/*
** The following code executes when a syntax error first occurs.
*/
static void yy_syntax_error(
  yyParser *yypParser,           /* The parser */
  int yymajor,                   /* The major type of the error token */
  sqlite3ParserTOKENTYPE yyminor         /* The minor type of the error token */
){
  sqlite3ParserARG_FETCH;
  sqlite3ParserARG_FETCH
  sqlite3ParserCTX_FETCH
#define TOKEN yyminor
/************ Begin %syntax_error code ****************************************/

  UNUSED_PARAMETER(yymajor);  /* Silence some compiler warnings */
  if( TOKEN.z[0] ){
    sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN);
  }else{
    sqlite3ErrorMsg(pParse, "incomplete input");
  }
/************ End %syntax_error code ******************************************/
  sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
  sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
  sqlite3ParserCTX_STORE
}

/*
** The following is executed when the parser accepts
*/
static void yy_accept(
  yyParser *yypParser           /* The parser */
){
  sqlite3ParserARG_FETCH;
  sqlite3ParserARG_FETCH
  sqlite3ParserCTX_FETCH
#ifndef NDEBUG
  if( yyTraceFILE ){
    fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
  }
#endif
#ifndef YYNOERRORRECOVERY
  yypParser->yyerrcnt = -1;
#endif
  assert( yypParser->yytos==yypParser->yystack );
  /* Here code is inserted which will be executed whenever the
  ** parser accepts */
/*********** Begin %parse_accept code *****************************************/
/*********** End %parse_accept code *******************************************/
  sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
  sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
  sqlite3ParserCTX_STORE
}

/* The main parser program.
** The first argument is a pointer to a structure obtained from
** "sqlite3ParserAlloc" which describes the current state of the parser.
** The second argument is the major token number.  The third is
** the minor token.  The fourth optional argument is whatever the
143642
143643
143644
143645
143646
143647
143648
143649

143650
143651
143652
143653
143654
143655
143656



143657
143658
143659
143660
143661
143662
143663
143664

143665
143666
143667
143668

143669
143670

143671
143672
143673

143674
143675
143676
143677
143678

143679

143680
143681


143682
143683
143684
143685
143686
143687

143688
143689
143690
143691
143692
143693
143694
145286
145287
145288
145289
145290
145291
145292

145293
145294
145295
145296
145297
145298
145299

145300
145301
145302
145303

145304
145305
145306
145307

145308
145309
145310
145311


145312
145313

145314
145315
145316

145317
145318
145319
145320
145321
145322
145323

145324
145325

145326
145327
145328
145329
145330
145331
145332

145333
145334
145335
145336
145337
145338
145339
145340







-
+






-
+
+
+

-




-

+


-
-
+

-
+


-
+





+
-
+

-
+
+





-
+







SQLITE_PRIVATE void sqlite3Parser(
  void *yyp,                   /* The parser */
  int yymajor,                 /* The major token code number */
  sqlite3ParserTOKENTYPE yyminor       /* The value for the token */
  sqlite3ParserARG_PDECL               /* Optional %extra_argument parameter */
){
  YYMINORTYPE yyminorunion;
  unsigned int yyact;   /* The parser action. */
  YYACTIONTYPE yyact;   /* The parser action. */
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
  int yyendofinput;     /* True if we are at the end of input */
#endif
#ifdef YYERRORSYMBOL
  int yyerrorhit = 0;   /* True if yymajor has invoked an error */
#endif
  yyParser *yypParser;  /* The parser */
  yyParser *yypParser = (yyParser*)yyp;  /* The parser */
  sqlite3ParserCTX_FETCH
  sqlite3ParserARG_STORE

  yypParser = (yyParser*)yyp;
  assert( yypParser->yytos!=0 );
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
  yyendofinput = (yymajor==0);
#endif
  sqlite3ParserARG_STORE;

  yyact = yypParser->yytos->stateno;
#ifndef NDEBUG
  if( yyTraceFILE ){
    int stateno = yypParser->yytos->stateno;
    if( stateno < YY_MIN_REDUCE ){
    if( yyact < YY_MIN_REDUCE ){
      fprintf(yyTraceFILE,"%sInput '%s' in state %d\n",
              yyTracePrompt,yyTokenName[yymajor],stateno);
              yyTracePrompt,yyTokenName[yymajor],yyact);
    }else{
      fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
              yyTracePrompt,yyTokenName[yymajor],stateno-YY_MIN_REDUCE);
              yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE);
    }
  }
#endif

  do{
    assert( yyact==yypParser->yytos->stateno );
    yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
    yyact = yy_find_shift_action(yymajor,yyact);
    if( yyact >= YY_MIN_REDUCE ){
      yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,yyminor);
      yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,
                        yyminor sqlite3ParserCTX_PARAM);
    }else if( yyact <= YY_MAX_SHIFTREDUCE ){
      yy_shift(yypParser,yyact,yymajor,yyminor);
#ifndef YYNOERRORRECOVERY
      yypParser->yyerrcnt--;
#endif
      yymajor = YYNOCODE;
      break;
    }else if( yyact==YY_ACCEPT_ACTION ){
      yypParser->yytos--;
      yy_accept(yypParser);
      return;
    }else{
      assert( yyact == YY_ERROR_ACTION );
      yyminorunion.yy0 = yyminor;
143751
143752
143753
143754
143755
143756
143757


143758
143759
143760
143761
143762
143763
143764
143765
143766
143767
143768
143769

143770
143771
143772
143773
143774
143775
143776
145397
145398
145399
145400
145401
145402
145403
145404
145405
145406
145407
145408
145409
145410
145411
145412
145413
145414
145415


145416
145417
145418
145419
145420
145421
145422
145423







+
+










-
-
+







          yymajor = YYNOCODE;
        }else if( yymx!=YYERRORSYMBOL ){
          yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
        }
      }
      yypParser->yyerrcnt = 3;
      yyerrorhit = 1;
      if( yymajor==YYNOCODE ) break;
      yyact = yypParser->yytos->stateno;
#elif defined(YYNOERRORRECOVERY)
      /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
      ** do any kind of error recovery.  Instead, simply invoke the syntax
      ** error routine and continue going as if nothing had happened.
      **
      ** Applications can set this macro (for example inside %include) if
      ** they intend to abandon the parse upon the first syntax error seen.
      */
      yy_syntax_error(yypParser,yymajor, yyminor);
      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
      yymajor = YYNOCODE;
      
      break;
#else  /* YYERRORSYMBOL is not defined */
      /* This is what we do if the grammar does not define ERROR:
      **
      **  * Report an error message, and throw away the input token.
      **
      **  * If the input token is $, then fail the parse.
      **
143784
143785
143786
143787
143788
143789
143790
143791

143792
143793
143794

143795
143796
143797
143798
143799
143800
143801
145431
145432
145433
145434
145435
145436
145437

145438
145439
145440

145441
145442
145443
145444
145445
145446
145447
145448







-
+


-
+







      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
      if( yyendofinput ){
        yy_parse_failed(yypParser);
#ifndef YYNOERRORRECOVERY
        yypParser->yyerrcnt = -1;
#endif
      }
      yymajor = YYNOCODE;
      break;
#endif
    }
  }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack );
  }while( yypParser->yytos>yypParser->yystack );
#ifndef NDEBUG
  if( yyTraceFILE ){
    yyStackEntry *i;
    char cDiv = '[';
    fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
    for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){
      fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]);
143964
143965
143966
143967
143968
143969
143970
143971
143972


143973
143974
143975
143976
143977
143978
143979
143980
143981
143982
143983







143984
143985
143986
143987
143988
143989
143990
143991
143992
143993
143994
143995
143996
143997
143998
143999
144000
144001
144002
144003
144004
144005
144006
144007
144008
144009
144010
144011
















144012
144013
144014



144015
144016
144017
144018
144019
144020
144021
144022
144023
144024
144025
144026
144027










144028
144029
144030
144031
144032

144033
144034
144035
144036
144037
144038
144039
144040
144041
144042






144043
144044
144045

144046
144047
144048
144049
144050
144051
144052
144053
144054
144055






144056
144057
144058
144059

144060
144061
144062
144063
144064
144065
144066
144067
144068
144069






144070
144071
144072

144073
144074
144075
144076
144077
144078
144079
144080
144081
144082
144083
144084
144085
144086
144087
144088
144089
144090
144091
144092
144093
144094











144095
144096
144097



144098
144099
144100
144101
144102
144103
144104
145611
145612
145613
145614
145615
145616
145617


145618
145619
145620
145621
145622
145623







145624
145625
145626
145627
145628
145629
145630
145631
145632
145633
145634
145635
145636
145637
145638
145639
145640
145641
145642
145643















145644
145645
145646
145647
145648
145649
145650
145651
145652
145653
145654
145655
145656
145657
145658
145659



145660
145661
145662
145663
145664
145665










145666
145667
145668
145669
145670
145671
145672
145673
145674
145675
145676
145677
145678
145679

145680
145681
145682
145683
145684






145685
145686
145687
145688
145689
145690
145691
145692

145693
145694
145695
145696
145697






145698
145699
145700
145701
145702
145703
145704
145705
145706

145707
145708
145709
145710
145711






145712
145713
145714
145715
145716
145717
145718
145719

145720
145721
145722
145723
145724
145725
145726
145727
145728
145729
145730
145731
145732










145733
145734
145735
145736
145737
145738
145739
145740
145741
145742
145743



145744
145745
145746
145747
145748
145749
145750
145751
145752
145753







-
-
+
+




-
-
-
-
-
-
-
+
+
+
+
+
+
+













-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+



-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+




-
+




-
-
-
-
-
-
+
+
+
+
+
+


-
+




-
-
-
-
-
-
+
+
+
+
+
+



-
+




-
-
-
-
-
-
+
+
+
+
+
+


-
+












-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+







** The code in this file implements a function that determines whether
** or not a given identifier is really an SQL keyword.  The same thing
** might be implemented more directly using a hand-written hash table.
** But by using this automatically generated code, the size of the code
** is substantially reduced.  This is important for embedded applications
** on platforms with limited memory.
*/
/* Hash score: 182 */
/* zKWText[] encodes 834 bytes of keyword text in 554 bytes */
/* Hash score: 185 */
/* zKWText[] encodes 845 bytes of keyword text in 561 bytes */
/*   REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT       */
/*   ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE         */
/*   XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY         */
/*   UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERECURSIVE         */
/*   BETWEENOTNULLIKECASCADELETECASECOLLATECREATECURRENT_DATEDETACH     */
/*   IMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHEN     */
/*   WHERENAMEAFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMIT         */
/*   CONFLICTCROSSCURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAIL        */
/*   FROMFULLGLOBYIFISNULLORDERESTRICTRIGHTROLLBACKROWUNIONUSING        */
/*   VACUUMVIEWINITIALLY                                                */
static const char zKWText[553] = {
/*   BETWEENOTHINGLOBYCASCADELETECASECOLLATECREATECURRENT_DATE          */
/*   DETACHIMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTVALUES          */
/*   VIRTUALIMITWHENOTNULLWHERENAMEAFTEREPLACEANDEFAULT                 */
/*   AUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMP        */
/*   RIMARYDEFERREDISTINCTDORDERESTRICTDROPFAILFROMFULLIFISNULL         */
/*   RIGHTROLLBACKROWUNIONUSINGVACUUMVIEWINITIALLY                      */
static const char zKWText[560] = {
  'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
  'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
  'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
  'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
  'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',
  'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I',
  'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E',
  'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',
  'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',
  'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',
  'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',
  'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',
  'T','E','B','E','G','I','N','N','E','R','E','C','U','R','S','I','V','E',
  'B','E','T','W','E','E','N','O','T','N','U','L','L','I','K','E','C','A',
  'S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L','A',
  'T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D','A',
  'T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E','J',
  'O','I','N','S','E','R','T','M','A','T','C','H','P','L','A','N','A','L',
  'Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U','E',
  'S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','W','H',
  'E','R','E','N','A','M','E','A','F','T','E','R','E','P','L','A','C','E',
  'A','N','D','E','F','A','U','L','T','A','U','T','O','I','N','C','R','E',
  'M','E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M','M',
  'I','T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U','R',
  'R','E','N','T','_','T','I','M','E','S','T','A','M','P','R','I','M','A',
  'R','Y','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D',
  'R','O','P','F','A','I','L','F','R','O','M','F','U','L','L','G','L','O',
  'B','Y','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S','T',
  'B','E','T','W','E','E','N','O','T','H','I','N','G','L','O','B','Y','C',
  'A','S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L',
  'A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D',
  'A','T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E',
  'J','O','I','N','S','E','R','T','L','I','K','E','M','A','T','C','H','P',
  'L','A','N','A','L','Y','Z','E','P','R','A','G','M','A','B','O','R','T',
  'V','A','L','U','E','S','V','I','R','T','U','A','L','I','M','I','T','W',
  'H','E','N','O','T','N','U','L','L','W','H','E','R','E','N','A','M','E',
  'A','F','T','E','R','E','P','L','A','C','E','A','N','D','E','F','A','U',
  'L','T','A','U','T','O','I','N','C','R','E','M','E','N','T','C','A','S',
  'T','C','O','L','U','M','N','C','O','M','M','I','T','C','O','N','F','L',
  'I','C','T','C','R','O','S','S','C','U','R','R','E','N','T','_','T','I',
  'M','E','S','T','A','M','P','R','I','M','A','R','Y','D','E','F','E','R',
  'R','E','D','I','S','T','I','N','C','T','D','O','R','D','E','R','E','S',
  'T','R','I','C','T','D','R','O','P','F','A','I','L','F','R','O','M','F',
  'U','L','L','I','F','I','S','N','U','L','L','R','I','G','H','T','R','O',
  'R','I','C','T','R','I','G','H','T','R','O','L','L','B','A','C','K','R',
  'O','W','U','N','I','O','N','U','S','I','N','G','V','A','C','U','U','M',
  'V','I','E','W','I','N','I','T','I','A','L','L','Y',
  'L','L','B','A','C','K','R','O','W','U','N','I','O','N','U','S','I','N',
  'G','V','A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L',
  'L','Y',
};
/* aKWHash[i] is the hash value for the i-th keyword */
static const unsigned char aKWHash[127] = {
    76, 105, 117,  74,   0,  45,   0,   0,  82,   0,  77,   0,   0,
    42,  12,  78,  15,   0, 116,  85,  54, 112,   0,  19,   0,   0,
   121,   0, 119, 115,   0,  22,  93,   0,   9,   0,   0,  70,  71,
     0,  69,   6,   0,  48,  90, 102,   0, 118, 101,   0,   0,  44,
     0, 103,  24,   0,  17,   0, 122,  53,  23,   0,   5, 110,  25,
    96,   0,   0, 124, 106,  60, 123,  57,  28,  55,   0,  91,   0,
   100,  26,   0,  99,   0,   0,   0,  95,  92,  97,  88, 109,  14,
    39, 108,   0,  81,   0,  18,  89, 111,  32,   0, 120,  80, 113,
    62,  46,  84,   0,   0,  94,  40,  59, 114,   0,  36,   0,   0,
    29,   0,  86,  63,  64,   0,  20,  61,   0,  56,
    74, 108, 119,  72,   0,  45,   0,   0,  81,   0,  76,  61,   0,
    42,  12,  77,  15,   0, 118,  84,  54, 116,   0,  19,   0,   0,
   123,   0, 121, 111,   0,  22,  96,   0,   9,   0,   0,  68,  69,
     0,  67,   6,   0,  48,  93, 105,   0, 120, 104,   0,   0,  44,
     0, 106,  24,   0,  17,   0, 124,  53,  23,   0,   5,  62,  25,
    99,   0,   0, 126, 112,  60, 125,  57,  28,  55,   0,  94,   0,
   103,  26,   0, 102,   0,   0,   0,  98,  95, 100,  91, 115,  14,
    39, 114,   0,  80,   0, 109,  92,  90,  32,   0, 122,  79, 117,
    86,  46,  83,   0,   0,  97,  40,  59, 110,   0,  36,   0,   0,
    29,   0,  89,  87,  88,   0,  20,  85,   0,  56,
};
/* aKWNext[] forms the hash collision chain.  If aKWHash[i]==0
** then the i-th keyword has no more hash collisions.  Otherwise,
** the next keyword with the same hash is aKWHash[i]-1. */
static const unsigned char aKWNext[124] = {
static const unsigned char aKWNext[126] = {
     0,   0,   0,   0,   4,   0,   0,   0,   0,   0,   0,   0,   0,
     0,   2,   0,   0,   0,   0,   0,   0,  13,   0,   0,   0,   0,
     0,   7,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
     0,   0,   0,   0,  33,   0,  21,   0,   0,   0,   0,   0,  50,
     0,  43,   3,  47,   0,   0,   0,   0,  30,   0,  58,   0,  38,
     0,   0,   0,   1,  66,   0,   0,  67,   0,  41,   0,   0,   0,
     0,   0,   0,  49,  65,   0,   0,   0,   0,  31,  52,  16,  34,
    10,   0,   0,   0,   0,   0,   0,   0,  11,  72,  79,   0,   8,
     0, 104,  98,   0, 107,   0,  87,   0,  75,  51,   0,  27,  37,
    73,  83,   0,  35,  68,   0,   0,
     0,  43,   3,  47,   0,   0,   0,   0,   0,   0,   0,   0,   0,
     0,   1,  64,   0,   0,  65,   0,  41,   0,  38,   0,   0,   0,
     0,   0,  49,  75,   0,   0,  30,   0,  58,   0,   0,  63,  31,
    52,  16,  34,  10,   0,   0,   0,   0,   0,   0,   0,  11,  70,
    78,   0,   8,   0,  18,  51,   0, 107, 101,   0, 113,   0,  73,
    27,  37,  71,  82,   0,  35,  66,   0,   0,
};
/* aKWLen[i] is the length (in bytes) of the i-th keyword */
static const unsigned char aKWLen[124] = {
static const unsigned char aKWLen[126] = {
     7,   7,   5,   4,   6,   4,   5,   3,   6,   7,   3,   6,   6,
     7,   7,   3,   8,   2,   6,   5,   4,   4,   3,  10,   4,   6,
    11,   6,   2,   7,   5,   5,   9,   6,   9,   9,   7,  10,  10,
     4,   6,   2,   3,   9,   4,   2,   6,   5,   7,   4,   5,   7,
     6,   6,   5,   6,   5,   5,   9,   7,   7,   3,   2,   4,   4,
     7,   3,   6,   4,   7,   6,  12,   6,   9,   4,   6,   5,   4,
     7,   6,   5,   6,   7,   5,   4,   5,   6,   5,   7,   3,   7,
    13,   2,   2,   4,   6,   6,   8,   5,  17,  12,   7,   8,   8,
     2,   4,   4,   4,   4,   4,   2,   2,   6,   5,   8,   5,   8,
     3,   5,   5,   6,   4,   9,   3,
     6,   6,   5,   6,   5,   5,   9,   7,   7,   4,   2,   7,   3,
     6,   4,   7,   6,  12,   6,   9,   4,   6,   4,   5,   4,   7,
     6,   5,   6,   7,   5,   4,   7,   3,   2,   4,   5,   6,   5,
     7,   3,   7,  13,   2,   2,   4,   6,   6,   8,   5,  17,  12,
     7,   8,   8,   2,   2,   5,   8,   4,   4,   4,   4,   2,   6,
     5,   8,   3,   5,   5,   6,   4,   9,   3,
};
/* aKWOffset[i] is the index into zKWText[] of the start of
** the text for the i-th keyword. */
static const unsigned short int aKWOffset[124] = {
static const unsigned short int aKWOffset[126] = {
     0,   2,   2,   8,   9,  14,  16,  20,  23,  25,  25,  29,  33,
    36,  41,  46,  48,  53,  54,  59,  62,  65,  67,  69,  78,  81,
    86,  91,  95,  96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
   159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,
   199, 204, 209, 212, 218, 221, 225, 234, 240, 240, 240, 243, 246,
   250, 251, 255, 261, 265, 272, 278, 290, 296, 305, 307, 313, 318,
   320, 327, 332, 337, 343, 349, 354, 358, 361, 367, 371, 378, 380,
   387, 389, 391, 400, 404, 410, 416, 424, 429, 429, 445, 452, 459,
   460, 467, 471, 475, 479, 483, 486, 488, 490, 496, 500, 508, 513,
   521, 524, 529, 534, 540, 544, 549,
   199, 204, 209, 212, 218, 221, 225, 234, 240, 246, 249, 251, 252,
   256, 262, 266, 273, 279, 291, 297, 306, 308, 314, 318, 323, 325,
   332, 337, 342, 348, 354, 359, 362, 362, 362, 365, 369, 372, 378,
   382, 389, 391, 398, 400, 402, 411, 415, 421, 427, 435, 440, 440,
   456, 463, 470, 471, 478, 479, 483, 491, 495, 499, 503, 507, 509,
   515, 520, 528, 531, 536, 541, 547, 551, 556,
};
/* aKWCode[i] is the parser symbol code for the i-th keyword */
static const unsigned char aKWCode[124] = {
static const unsigned char aKWCode[126] = {
  TK_REINDEX,    TK_INDEXED,    TK_INDEX,      TK_DESC,       TK_ESCAPE,     
  TK_EACH,       TK_CHECK,      TK_KEY,        TK_BEFORE,     TK_FOREIGN,    
  TK_FOR,        TK_IGNORE,     TK_LIKE_KW,    TK_EXPLAIN,    TK_INSTEAD,    
  TK_ADD,        TK_DATABASE,   TK_AS,         TK_SELECT,     TK_TABLE,      
  TK_JOIN_KW,    TK_THEN,       TK_END,        TK_DEFERRABLE, TK_ELSE,       
  TK_EXCEPT,     TK_TRANSACTION,TK_ACTION,     TK_ON,         TK_JOIN_KW,    
  TK_ALTER,      TK_RAISE,      TK_EXCLUSIVE,  TK_EXISTS,     TK_SAVEPOINT,  
  TK_INTERSECT,  TK_TRIGGER,    TK_REFERENCES, TK_CONSTRAINT, TK_INTO,       
  TK_OFFSET,     TK_OF,         TK_SET,        TK_TEMP,       TK_TEMP,       
  TK_OR,         TK_UNIQUE,     TK_QUERY,      TK_WITHOUT,    TK_WITH,       
  TK_JOIN_KW,    TK_RELEASE,    TK_ATTACH,     TK_HAVING,     TK_GROUP,      
  TK_UPDATE,     TK_BEGIN,      TK_JOIN_KW,    TK_RECURSIVE,  TK_BETWEEN,    
  TK_NOTNULL,    TK_NOT,        TK_NO,         TK_NULL,       TK_LIKE_KW,    
  TK_CASCADE,    TK_ASC,        TK_DELETE,     TK_CASE,       TK_COLLATE,    
  TK_CREATE,     TK_CTIME_KW,   TK_DETACH,     TK_IMMEDIATE,  TK_JOIN,       
  TK_INSERT,     TK_MATCH,      TK_PLAN,       TK_ANALYZE,    TK_PRAGMA,     
  TK_ABORT,      TK_VALUES,     TK_VIRTUAL,    TK_LIMIT,      TK_WHEN,       
  TK_WHERE,      TK_RENAME,     TK_AFTER,      TK_REPLACE,    TK_AND,        
  TK_DEFAULT,    TK_AUTOINCR,   TK_TO,         TK_IN,         TK_CAST,       
  TK_COLUMNKW,   TK_COMMIT,     TK_CONFLICT,   TK_JOIN_KW,    TK_CTIME_KW,   
  TK_CTIME_KW,   TK_PRIMARY,    TK_DEFERRED,   TK_DISTINCT,   TK_IS,         
  TK_DROP,       TK_FAIL,       TK_FROM,       TK_JOIN_KW,    TK_LIKE_KW,    
  TK_NOTHING,    TK_LIKE_KW,    TK_BY,         TK_CASCADE,    TK_ASC,        
  TK_DELETE,     TK_CASE,       TK_COLLATE,    TK_CREATE,     TK_CTIME_KW,   
  TK_DETACH,     TK_IMMEDIATE,  TK_JOIN,       TK_INSERT,     TK_LIKE_KW,    
  TK_MATCH,      TK_PLAN,       TK_ANALYZE,    TK_PRAGMA,     TK_ABORT,      
  TK_VALUES,     TK_VIRTUAL,    TK_LIMIT,      TK_WHEN,       TK_NOTNULL,    
  TK_NOT,        TK_NO,         TK_NULL,       TK_WHERE,      TK_RENAME,     
  TK_AFTER,      TK_REPLACE,    TK_AND,        TK_DEFAULT,    TK_AUTOINCR,   
  TK_TO,         TK_IN,         TK_CAST,       TK_COLUMNKW,   TK_COMMIT,     
  TK_CONFLICT,   TK_JOIN_KW,    TK_CTIME_KW,   TK_CTIME_KW,   TK_PRIMARY,    
  TK_DEFERRED,   TK_DISTINCT,   TK_IS,         TK_DO,         TK_ORDER,      
  TK_RESTRICT,   TK_DROP,       TK_FAIL,       TK_FROM,       TK_JOIN_KW,    
  TK_BY,         TK_IF,         TK_ISNULL,     TK_ORDER,      TK_RESTRICT,   
  TK_JOIN_KW,    TK_ROLLBACK,   TK_ROW,        TK_UNION,      TK_USING,      
  TK_VACUUM,     TK_VIEW,       TK_INITIALLY,  TK_ALL,        
  TK_IF,         TK_ISNULL,     TK_JOIN_KW,    TK_ROLLBACK,   TK_ROW,        
  TK_UNION,      TK_USING,      TK_VACUUM,     TK_VIEW,       TK_INITIALLY,  
  TK_ALL,        
};
/* Check to see if z[0..n-1] is a keyword. If it is, write the
** parser symbol code for that keyword into *pType.  Always
** return the integer n (the length of the token). */
static int keywordCode(const char *z, int n, int *pType){
  int i, j;
  const char *zKW;
144171
144172
144173
144174
144175
144176
144177
144178
144179
144180
144181
144182
144183
144184
144185
144186
144187
144188
144189
144190
144191
144192
144193
144194
144195
144196
144197
144198
144199
144200
144201
144202
144203
144204
144205
144206
144207
144208
144209
144210
144211
144212
144213
144214
144215
144216
144217
144218
144219
144220
144221
144222
144223
144224
144225
144226
144227
144228
144229
144230
144231
144232
144233
144234
144235
144236
144237
144238
144239
144240
144241


































































144242
144243
144244
144245
144246
144247
144248
144249
144250
144251
144252
144253











144254
144255
144256
144257
144258
144259
144260
145820
145821
145822
145823
145824
145825
145826
































































145827
145828
145829
145830
145831
145832
145833
145834
145835
145836
145837
145838
145839
145840
145841
145842
145843
145844
145845
145846
145847
145848
145849
145850
145851
145852
145853
145854
145855
145856
145857
145858
145859
145860
145861
145862
145863
145864
145865
145866
145867
145868
145869
145870
145871
145872
145873
145874
145875
145876
145877
145878
145879
145880
145881
145882
145883
145884
145885
145886
145887
145888
145889
145890
145891
145892
145893
145894
145895
145896
145897
145898
145899
145900
145901
145902
145903

145904
145905
145906
145907
145908
145909
145910
145911
145912
145913
145914
145915
145916
145917
145918
145919
145920
145921







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+











-
+
+
+
+
+
+
+
+
+
+
+







      testcase( i==53 ); /* HAVING */
      testcase( i==54 ); /* GROUP */
      testcase( i==55 ); /* UPDATE */
      testcase( i==56 ); /* BEGIN */
      testcase( i==57 ); /* INNER */
      testcase( i==58 ); /* RECURSIVE */
      testcase( i==59 ); /* BETWEEN */
      testcase( i==60 ); /* NOTNULL */
      testcase( i==61 ); /* NOT */
      testcase( i==62 ); /* NO */
      testcase( i==63 ); /* NULL */
      testcase( i==64 ); /* LIKE */
      testcase( i==65 ); /* CASCADE */
      testcase( i==66 ); /* ASC */
      testcase( i==67 ); /* DELETE */
      testcase( i==68 ); /* CASE */
      testcase( i==69 ); /* COLLATE */
      testcase( i==70 ); /* CREATE */
      testcase( i==71 ); /* CURRENT_DATE */
      testcase( i==72 ); /* DETACH */
      testcase( i==73 ); /* IMMEDIATE */
      testcase( i==74 ); /* JOIN */
      testcase( i==75 ); /* INSERT */
      testcase( i==76 ); /* MATCH */
      testcase( i==77 ); /* PLAN */
      testcase( i==78 ); /* ANALYZE */
      testcase( i==79 ); /* PRAGMA */
      testcase( i==80 ); /* ABORT */
      testcase( i==81 ); /* VALUES */
      testcase( i==82 ); /* VIRTUAL */
      testcase( i==83 ); /* LIMIT */
      testcase( i==84 ); /* WHEN */
      testcase( i==85 ); /* WHERE */
      testcase( i==86 ); /* RENAME */
      testcase( i==87 ); /* AFTER */
      testcase( i==88 ); /* REPLACE */
      testcase( i==89 ); /* AND */
      testcase( i==90 ); /* DEFAULT */
      testcase( i==91 ); /* AUTOINCREMENT */
      testcase( i==92 ); /* TO */
      testcase( i==93 ); /* IN */
      testcase( i==94 ); /* CAST */
      testcase( i==95 ); /* COLUMN */
      testcase( i==96 ); /* COMMIT */
      testcase( i==97 ); /* CONFLICT */
      testcase( i==98 ); /* CROSS */
      testcase( i==99 ); /* CURRENT_TIMESTAMP */
      testcase( i==100 ); /* CURRENT_TIME */
      testcase( i==101 ); /* PRIMARY */
      testcase( i==102 ); /* DEFERRED */
      testcase( i==103 ); /* DISTINCT */
      testcase( i==104 ); /* IS */
      testcase( i==105 ); /* DROP */
      testcase( i==106 ); /* FAIL */
      testcase( i==107 ); /* FROM */
      testcase( i==108 ); /* FULL */
      testcase( i==109 ); /* GLOB */
      testcase( i==110 ); /* BY */
      testcase( i==111 ); /* IF */
      testcase( i==112 ); /* ISNULL */
      testcase( i==113 ); /* ORDER */
      testcase( i==114 ); /* RESTRICT */
      testcase( i==115 ); /* RIGHT */
      testcase( i==116 ); /* ROLLBACK */
      testcase( i==117 ); /* ROW */
      testcase( i==118 ); /* UNION */
      testcase( i==119 ); /* USING */
      testcase( i==120 ); /* VACUUM */
      testcase( i==121 ); /* VIEW */
      testcase( i==122 ); /* INITIALLY */
      testcase( i==123 ); /* ALL */
      testcase( i==60 ); /* NOTHING */
      testcase( i==61 ); /* GLOB */
      testcase( i==62 ); /* BY */
      testcase( i==63 ); /* CASCADE */
      testcase( i==64 ); /* ASC */
      testcase( i==65 ); /* DELETE */
      testcase( i==66 ); /* CASE */
      testcase( i==67 ); /* COLLATE */
      testcase( i==68 ); /* CREATE */
      testcase( i==69 ); /* CURRENT_DATE */
      testcase( i==70 ); /* DETACH */
      testcase( i==71 ); /* IMMEDIATE */
      testcase( i==72 ); /* JOIN */
      testcase( i==73 ); /* INSERT */
      testcase( i==74 ); /* LIKE */
      testcase( i==75 ); /* MATCH */
      testcase( i==76 ); /* PLAN */
      testcase( i==77 ); /* ANALYZE */
      testcase( i==78 ); /* PRAGMA */
      testcase( i==79 ); /* ABORT */
      testcase( i==80 ); /* VALUES */
      testcase( i==81 ); /* VIRTUAL */
      testcase( i==82 ); /* LIMIT */
      testcase( i==83 ); /* WHEN */
      testcase( i==84 ); /* NOTNULL */
      testcase( i==85 ); /* NOT */
      testcase( i==86 ); /* NO */
      testcase( i==87 ); /* NULL */
      testcase( i==88 ); /* WHERE */
      testcase( i==89 ); /* RENAME */
      testcase( i==90 ); /* AFTER */
      testcase( i==91 ); /* REPLACE */
      testcase( i==92 ); /* AND */
      testcase( i==93 ); /* DEFAULT */
      testcase( i==94 ); /* AUTOINCREMENT */
      testcase( i==95 ); /* TO */
      testcase( i==96 ); /* IN */
      testcase( i==97 ); /* CAST */
      testcase( i==98 ); /* COLUMN */
      testcase( i==99 ); /* COMMIT */
      testcase( i==100 ); /* CONFLICT */
      testcase( i==101 ); /* CROSS */
      testcase( i==102 ); /* CURRENT_TIMESTAMP */
      testcase( i==103 ); /* CURRENT_TIME */
      testcase( i==104 ); /* PRIMARY */
      testcase( i==105 ); /* DEFERRED */
      testcase( i==106 ); /* DISTINCT */
      testcase( i==107 ); /* IS */
      testcase( i==108 ); /* DO */
      testcase( i==109 ); /* ORDER */
      testcase( i==110 ); /* RESTRICT */
      testcase( i==111 ); /* DROP */
      testcase( i==112 ); /* FAIL */
      testcase( i==113 ); /* FROM */
      testcase( i==114 ); /* FULL */
      testcase( i==115 ); /* IF */
      testcase( i==116 ); /* ISNULL */
      testcase( i==117 ); /* RIGHT */
      testcase( i==118 ); /* ROLLBACK */
      testcase( i==119 ); /* ROW */
      testcase( i==120 ); /* UNION */
      testcase( i==121 ); /* USING */
      testcase( i==122 ); /* VACUUM */
      testcase( i==123 ); /* VIEW */
      testcase( i==124 ); /* INITIALLY */
      testcase( i==125 ); /* ALL */
      *pType = aKWCode[i];
      break;
    }
  }
  return n;
}
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
  int id = TK_ID;
  keywordCode((char*)z, n, &id);
  return id;
}
#define SQLITE_N_KEYWORD 124
#define SQLITE_N_KEYWORD 126
SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
  if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
  *pzName = zKWText + aKWOffset[i];
  *pnName = aKWLen[i];
  return SQLITE_OK;
}
SQLITE_API int sqlite3_keyword_count(void){ return SQLITE_N_KEYWORD; }
SQLITE_API int sqlite3_keyword_check(const char *zName, int nName){
  return TK_ID!=sqlite3KeywordCode((const u8*)zName, nName);
}

/************** End of keywordhash.h *****************************************/
/************** Continuing where we left off in tokenize.c *******************/


/*
** If X is a character that can be used in an identifier then
144603
144604
144605
144606
144607
144608
144609
144610

144611
144612

144613
144614
144615
144616
144617
144618
144619
146264
146265
146266
146267
146268
146269
146270

146271
146272

146273
146274
146275
146276
146277
146278
146279
146280







-
+

-
+







  }
  pParse->rc = SQLITE_OK;
  pParse->zTail = zSql;
  assert( pzErrMsg!=0 );
  /* sqlite3ParserTrace(stdout, "parser: "); */
#ifdef sqlite3Parser_ENGINEALWAYSONSTACK
  pEngine = &sEngine;
  sqlite3ParserInit(pEngine);
  sqlite3ParserInit(pEngine, pParse);
#else
  pEngine = sqlite3ParserAlloc(sqlite3Malloc);
  pEngine = sqlite3ParserAlloc(sqlite3Malloc, pParse);
  if( pEngine==0 ){
    sqlite3OomFault(db);
    return SQLITE_NOMEM_BKPT;
  }
#endif
  assert( pParse->pNewTable==0 );
  assert( pParse->pNewTrigger==0 );
144649
144650
144651
144652
144653
144654
144655
144656

144657
144658
144659
144660
144661
144662
144663
146310
146311
146312
146313
146314
146315
146316

146317
146318
146319
146320
146321
146322
146323
146324







-
+







        sqlite3ErrorMsg(pParse, "unrecognized token: \"%.*s\"", n, zSql);
        break;
      }
      zSql += n;
    }else{
      pParse->sLastToken.z = zSql;
      pParse->sLastToken.n = n;
      sqlite3Parser(pEngine, tokenType, pParse->sLastToken, pParse);
      sqlite3Parser(pEngine, tokenType, pParse->sLastToken);
      lastTokenParsed = tokenType;
      zSql += n;
      if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;
    }
  }
  assert( nErr==0 );
  pParse->zTail = zSql;
145756
145757
145758
145759
145760
145761
145762











145763
145764
145765
145766
145767
145768
145769
147417
147418
147419
147420
147421
147422
147423
147424
147425
147426
147427
147428
147429
147430
147431
147432
147433
147434
147435
147436
147437
147438
147439
147440
147441







+
+
+
+
+
+
+
+
+
+
+







    }

    case SQLITE_CONFIG_STMTJRNL_SPILL: {
      sqlite3GlobalConfig.nStmtSpill = va_arg(ap, int);
      break;
    }

#ifdef SQLITE_ENABLE_SORTER_REFERENCES
    case SQLITE_CONFIG_SORTERREF_SIZE: {
      int iVal = va_arg(ap, int);
      if( iVal<0 ){
        iVal = SQLITE_DEFAULT_SORTERREF_SIZE;
      }
      sqlite3GlobalConfig.szSorterRef = (u32)iVal;
      break;
    }
#endif /* SQLITE_ENABLE_SORTER_REFERENCES */

    default: {
      rc = SQLITE_ERROR;
      break;
    }
  }
  va_end(ap);
  return rc;
145937
145938
145939
145940
145941
145942
145943

145944
145945
145946
145947
145948
145949
145950
147609
147610
147611
147612
147613
147614
147615
147616
147617
147618
147619
147620
147621
147622
147623







+







        { SQLITE_DBCONFIG_ENABLE_FKEY,           SQLITE_ForeignKeys    },
        { SQLITE_DBCONFIG_ENABLE_TRIGGER,        SQLITE_EnableTrigger  },
        { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer  },
        { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension  },
        { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE,      SQLITE_NoCkptOnClose  },
        { SQLITE_DBCONFIG_ENABLE_QPSG,           SQLITE_EnableQPSG     },
        { SQLITE_DBCONFIG_TRIGGER_EQP,           SQLITE_TriggerEQP     },
        { SQLITE_DBCONFIG_RESET_DATABASE,        SQLITE_ResetDatabase  },
      };
      unsigned int i;
      rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
      for(i=0; i<ArraySize(aFlagOp); i++){
        if( aFlagOp[i].op==op ){
          int onoff = va_arg(ap, int);
          int *pRes = va_arg(ap, int*);
146910
146911
146912
146913
146914
146915
146916
146917

146918

146919
146920
146921

146922
146923
146924
146925
146926
146927
146928
146929

146930
146931
146932
146933
146934
146935
146936
148583
148584
148585
148586
148587
148588
148589

148590
148591
148592
148593
148594
148595
148596
148597
148598
148599
148600
148601
148602
148603

148604
148605
148606
148607
148608
148609
148610
148611







-
+

+



+







-
+







#ifdef SQLITE_ENABLE_API_ARMOR
  if( !sqlite3SafetyCheckOk(db) ){
    return SQLITE_MISUSE_BKPT;
  }
#endif
  sqlite3_mutex_enter(db->mutex);
  if( xDestroy ){
    pArg = (FuncDestructor *)sqlite3DbMallocZero(db, sizeof(FuncDestructor));
    pArg = (FuncDestructor *)sqlite3Malloc(sizeof(FuncDestructor));
    if( !pArg ){
      sqlite3OomFault(db);
      xDestroy(p);
      goto out;
    }
    pArg->nRef = 0;
    pArg->xDestroy = xDestroy;
    pArg->pUserData = p;
  }
  rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p, xSFunc, xStep, xFinal, pArg);
  if( pArg && pArg->nRef==0 ){
    assert( rc!=SQLITE_OK );
    xDestroy(p);
    sqlite3DbFree(db, pArg);
    sqlite3_free(pArg);
  }

 out:
  rc = sqlite3ApiExit(db, rc);
  sqlite3_mutex_leave(db->mutex);
  return rc;
}
146959
146960
146961
146962
146963
146964
146965






















146966
146967
146968
146969
146970
146971
146972
146973
146974
146975
146976
146977
146978
146979
146980
146981
146982
146983
146984


146985
146986
146987
146988
146989
146990
146991
146992

146993
146994
146995
146996
146997
146998





146999
147000
147001
147002
147003
147004
147005
148634
148635
148636
148637
148638
148639
148640
148641
148642
148643
148644
148645
148646
148647
148648
148649
148650
148651
148652
148653
148654
148655
148656
148657
148658
148659
148660
148661
148662
148663
148664
148665
148666
148667
148668
148669
148670
148671
148672
148673
148674
148675
148676
148677
148678
148679
148680

148681
148682
148683
148684
148685
148686
148687
148688
148689

148690




148691

148692
148693
148694
148695
148696
148697
148698
148699
148700
148701
148702
148703







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


















-
+
+







-
+
-
-
-
-

-
+
+
+
+
+







  sqlite3DbFree(db, zFunc8);
  rc = sqlite3ApiExit(db, rc);
  sqlite3_mutex_leave(db->mutex);
  return rc;
}
#endif


/*
** The following is the implementation of an SQL function that always
** fails with an error message stating that the function is used in the
** wrong context.  The sqlite3_overload_function() API might construct
** SQL function that use this routine so that the functions will exist
** for name resolution but are actually overloaded by the xFindFunction
** method of virtual tables.
*/
static void sqlite3InvalidFunction(
  sqlite3_context *context,  /* The function calling context */
  int NotUsed,               /* Number of arguments to the function */
  sqlite3_value **NotUsed2   /* Value of each argument */
){
  const char *zName = (const char*)sqlite3_user_data(context);
  char *zErr;
  UNUSED_PARAMETER2(NotUsed, NotUsed2);
  zErr = sqlite3_mprintf(
      "unable to use function %s in the requested context", zName);
  sqlite3_result_error(context, zErr, -1);
  sqlite3_free(zErr);
}

/*
** Declare that a function has been overloaded by a virtual table.
**
** If the function already exists as a regular global function, then
** this routine is a no-op.  If the function does not exist, then create
** a new one that always throws a run-time error.  
**
** When virtual tables intend to provide an overloaded function, they
** should call this routine to make sure the global function exists.
** A global function must exist in order for name resolution to work
** properly.
*/
SQLITE_API int sqlite3_overload_function(
  sqlite3 *db,
  const char *zName,
  int nArg
){
  int rc = SQLITE_OK;
  int rc;
  char *zCopy;

#ifdef SQLITE_ENABLE_API_ARMOR
  if( !sqlite3SafetyCheckOk(db) || zName==0 || nArg<-2 ){
    return SQLITE_MISUSE_BKPT;
  }
#endif
  sqlite3_mutex_enter(db->mutex);
  if( sqlite3FindFunction(db, zName, nArg, SQLITE_UTF8, 0)==0 ){
  rc = sqlite3FindFunction(db, zName, nArg, SQLITE_UTF8, 0)!=0;
    rc = sqlite3CreateFunc(db, zName, nArg, SQLITE_UTF8,
                           0, sqlite3InvalidFunction, 0, 0, 0);
  }
  rc = sqlite3ApiExit(db, rc);
  sqlite3_mutex_leave(db->mutex);
  return rc;
  if( rc ) return SQLITE_OK;
  zCopy = sqlite3_mprintf(zName);
  if( zCopy==0 ) return SQLITE_NOMEM;
  return sqlite3_create_function_v2(db, zName, nArg, SQLITE_UTF8,
                           zCopy, sqlite3InvalidFunction, 0, 0, sqlite3_free);
}

#ifndef SQLITE_OMIT_TRACE
/*
** Register a trace function.  The pArg from the previously registered trace
** is returned.  
**
148964
148965
148966
148967
148968
148969
148970
148971
148972
148973
148974
148975
148976
148977
148978
148979
148980
148981
148982
148983
148984
148985
148986
148987
148988
148989
148990
148991
148992
148993
148994
148995
150662
150663
150664
150665
150666
150667
150668


















150669
150670
150671
150672
150673
150674
150675







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







    */
    case SQLITE_TESTCTRL_OPTIMIZATIONS: {
      sqlite3 *db = va_arg(ap, sqlite3*);
      db->dbOptFlags = (u16)(va_arg(ap, int) & 0xffff);
      break;
    }

#ifdef SQLITE_N_KEYWORD
    /* sqlite3_test_control(SQLITE_TESTCTRL_ISKEYWORD, const char *zWord)
    **
    ** If zWord is a keyword recognized by the parser, then return the
    ** number of keywords.  Or if zWord is not a keyword, return 0.
    ** 
    ** This test feature is only available in the amalgamation since
    ** the SQLITE_N_KEYWORD macro is not defined in this file if SQLite
    ** is built using separate source files.
    */
    case SQLITE_TESTCTRL_ISKEYWORD: {
      const char *zWord = va_arg(ap, const char*);
      int n = sqlite3Strlen30(zWord);
      rc = (sqlite3KeywordCode((u8*)zWord, n)!=TK_ID) ? SQLITE_N_KEYWORD : 0;
      break;
    }
#endif 

    /*   sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff);
    **
    ** If parameter onoff is non-zero, configure the wrappers so that all
    ** subsequent calls to localtime() and variants fail. If onoff is zero,
    ** undo this setting.
    */
    case SQLITE_TESTCTRL_LOCALTIME_FAULT: {
150848
150849
150850
150851
150852
150853
150854
150855

150856
150857
150858
150859
150860
150861
150862
152528
152529
152530
152531
152532
152533
152534

152535
152536
152537
152538
152539
152540
152541
152542







-
+








/* fts3_expr.c */
SQLITE_PRIVATE int sqlite3Fts3ExprParse(sqlite3_tokenizer *, int,
  char **, int, int, int, const char *, int, Fts3Expr **, char **
);
SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *);
#ifdef SQLITE_TEST
SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db);
SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db, Fts3Hash*);
SQLITE_PRIVATE int sqlite3Fts3InitTerm(sqlite3 *db);
#endif

SQLITE_PRIVATE int sqlite3Fts3OpenTokenizer(sqlite3_tokenizer *, int, const char *, int,
  sqlite3_tokenizer_cursor **
);

154558
154559
154560
154561
154562
154563
154564
154565

154566
154567
154568
154569
154570
154571
154572
156238
156239
156240
156241
156242
156243
156244

156245
156246
156247
156248
156249
156250
156251
156252







-
+







    ){
      rc = SQLITE_NOMEM;
    }
  }

#ifdef SQLITE_TEST
  if( rc==SQLITE_OK ){
    rc = sqlite3Fts3ExprInitTestInterface(db);
    rc = sqlite3Fts3ExprInitTestInterface(db, pHash);
  }
#endif

  /* Create the virtual table wrapper around the hash-table and overload 
  ** the four scalar functions. If this is successful, register the
  ** module with sqlite.
  */
158218
158219
158220
158221
158222
158223
158224
158225
158226
158227
158228
158229
158230
158231
158232
158233
158234
158235
158236
158237
158238
158239
158240
158241
158242
158243
158244
158245
158246
158247
158248
158249
158250
158251
158252
158253
158254
158255
158256
158257
158258
158259
159898
159899
159900
159901
159902
159903
159904




























159905
159906
159907
159908
159909
159910
159911







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







** Everything after this point is just test code.
*/

#ifdef SQLITE_TEST

/* #include <stdio.h> */

/*
** Function to query the hash-table of tokenizers (see README.tokenizers).
*/
static int queryTestTokenizer(
  sqlite3 *db, 
  const char *zName,  
  const sqlite3_tokenizer_module **pp
){
  int rc;
  sqlite3_stmt *pStmt;
  const char zSql[] = "SELECT fts3_tokenizer(?)";

  *pp = 0;
  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
  if( rc!=SQLITE_OK ){
    return rc;
  }

  sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);
  if( SQLITE_ROW==sqlite3_step(pStmt) ){
    if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){
      memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));
    }
  }

  return sqlite3_finalize(pStmt);
}

/*
** Return a pointer to a buffer containing a text representation of the
** expression passed as the first argument. The buffer is obtained from
** sqlite3_malloc(). It is the responsibility of the caller to use 
** sqlite3_free() to release the memory. If an OOM condition is encountered,
** NULL is returned.
**
158313
158314
158315
158316
158317
158318
158319
158320


158321
158322
158323
158324
158325
158326
158327
158328
158329
158330
158331
158332
158333
158334
158335



158336
158337
158338
158339
158340
158341
158342
158343
158344
158345
158346
158347





158348
158349
158350


158351
158352
158353


158354
158355
158356
158357

158358
158359
158360
158361
158362
158363
158364
158365
158366
158367
158368
158369
158370
158371
158372
158373
158374

158375
158376
158377
158378
158379
158380
158381
159965
159966
159967
159968
159969
159970
159971

159972
159973
159974
159975
159976
159977

159978
159979
159980
159981
159982
159983
159984
159985
159986

159987
159988
159989
159990
159991
159992
159993
159994
159995
159996
159997




159998
159999
160000
160001
160002



160003
160004



160005
160006




160007

160008

160009
160010
160011
160012
160013
160014
160015
160016
160017
160018
160019
160020
160021

160022
160023
160024
160025
160026
160027
160028
160029







-
+
+




-









-
+
+
+








-
-
-
-
+
+
+
+
+
-
-
-
+
+
-
-
-
+
+
-
-
-
-
+
-

-













-
+







** to parse the query expression (see README.tokenizers). The second argument
** is the query expression to parse. Each subsequent argument is the name
** of a column of the fts3 table that the query expression may refer to.
** For example:
**
**   SELECT fts3_exprtest('simple', 'Bill col2:Bloggs', 'col1', 'col2');
*/
static void fts3ExprTest(
static void fts3ExprTestCommon(
  int bRebalance,
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  sqlite3_tokenizer_module const *pModule = 0;
  sqlite3_tokenizer *pTokenizer = 0;
  int rc;
  char **azCol = 0;
  const char *zExpr;
  int nExpr;
  int nCol;
  int ii;
  Fts3Expr *pExpr;
  char *zBuf = 0;
  sqlite3 *db = sqlite3_context_db_handle(context);
  Fts3Hash *pHash = (Fts3Hash*)sqlite3_user_data(context);
  const char *zTokenizer = 0;
  char *zErr = 0;

  if( argc<3 ){
    sqlite3_result_error(context, 
        "Usage: fts3_exprtest(tokenizer, expr, col1, ...", -1
    );
    return;
  }

  rc = queryTestTokenizer(db,
                          (const char *)sqlite3_value_text(argv[0]), &pModule);
  if( rc==SQLITE_NOMEM ){
    sqlite3_result_error_nomem(context);
  zTokenizer = (const char*)sqlite3_value_text(argv[0]);
  rc = sqlite3Fts3InitTokenizer(pHash, zTokenizer, &pTokenizer, &zErr);
  if( rc!=SQLITE_OK ){
    if( rc==SQLITE_NOMEM ){
      sqlite3_result_error_nomem(context);
    goto exprtest_out;
  }else if( !pModule ){
    sqlite3_result_error(context, "No such tokenizer module", -1);
    }else{
      sqlite3_result_error(context, zErr, -1);
    goto exprtest_out;
  }

    }
    sqlite3_free(zErr);
  rc = pModule->xCreate(0, 0, &pTokenizer);
  assert( rc==SQLITE_NOMEM || rc==SQLITE_OK );
  if( rc==SQLITE_NOMEM ){
    sqlite3_result_error_nomem(context);
    return;
    goto exprtest_out;
  }
  pTokenizer->pModule = pModule;

  zExpr = (const char *)sqlite3_value_text(argv[1]);
  nExpr = sqlite3_value_bytes(argv[1]);
  nCol = argc-2;
  azCol = (char **)sqlite3_malloc(nCol*sizeof(char *));
  if( !azCol ){
    sqlite3_result_error_nomem(context);
    goto exprtest_out;
  }
  for(ii=0; ii<nCol; ii++){
    azCol[ii] = (char *)sqlite3_value_text(argv[ii+2]);
  }

  if( sqlite3_user_data(context) ){
  if( bRebalance ){
    char *zDummy = 0;
    rc = sqlite3Fts3ExprParse(
        pTokenizer, 0, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr, &zDummy
    );
    assert( rc==SQLITE_OK || pExpr==0 );
    sqlite3_free(zDummy);
  }else{
158393
158394
158395
158396
158397
158398
158399
158400
158401


158402
158403
158404















158405
158406
158407
158408
158409
158410

158411
158412

158413
158414
158415
158416

158417
158418
158419
158420
158421
158422
158423
160041
160042
160043
160044
160045
160046
160047


160048
160049
160050
160051
160052
160053
160054
160055
160056
160057
160058
160059
160060
160061
160062
160063
160064
160065
160066
160067
160068
160069
160070
160071
160072

160073
160074

160075
160076
160077
160078

160079
160080
160081
160082
160083
160084
160085
160086







-
-
+
+



+
+
+
+
+
+
+
+
+
+
+
+
+
+
+





-
+

-
+



-
+







    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
    sqlite3_free(zBuf);
  }

  sqlite3Fts3ExprFree(pExpr);

exprtest_out:
  if( pModule && pTokenizer ){
    rc = pModule->xDestroy(pTokenizer);
  if( pTokenizer ){
    rc = pTokenizer->pModule->xDestroy(pTokenizer);
  }
  sqlite3_free(azCol);
}

static void fts3ExprTest(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  fts3ExprTestCommon(0, context, argc, argv);
}
static void fts3ExprTestRebalance(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  fts3ExprTestCommon(1, context, argc, argv);
}

/*
** Register the query expression parser test function fts3_exprtest() 
** with database connection db. 
*/
SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3* db){
SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db, Fts3Hash *pHash){
  int rc = sqlite3_create_function(
      db, "fts3_exprtest", -1, SQLITE_UTF8, 0, fts3ExprTest, 0, 0
      db, "fts3_exprtest", -1, SQLITE_UTF8, (void*)pHash, fts3ExprTest, 0, 0
  );
  if( rc==SQLITE_OK ){
    rc = sqlite3_create_function(db, "fts3_exprtest_rebalance", 
        -1, SQLITE_UTF8, (void *)1, fts3ExprTest, 0, 0
        -1, SQLITE_UTF8, (void*)pHash, fts3ExprTestRebalance, 0, 0
    );
  }
  return rc;
}

#endif
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */
168870
168871
168872
168873
168874
168875
168876
168877

168878
168879
168880
168881
168882
168883
168884


168885
168886
168887
168888
168889
168890
168891
170533
170534
170535
170536
170537
170538
170539

170540
170541
170542
170543
170544
170545
170546

170547
170548
170549
170550
170551
170552
170553
170554
170555







-
+






-
+
+







** The data structure for a single virtual r-tree table is stored in three 
** native SQLite tables declared as follows. In each case, the '%' character
** in the table name is replaced with the user-supplied name of the r-tree
** table.
**
**   CREATE TABLE %_node(nodeno INTEGER PRIMARY KEY, data BLOB)
**   CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)
**   CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER)
**   CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER, ...)
**
** The data for each node of the r-tree structure is stored in the %_node
** table. For each node that is not the root node of the r-tree, there is
** an entry in the %_parent table associating the node with its parent.
** And for each row of data in the table, there is an entry in the %_rowid
** table that maps from the entries rowid to the id of the node that it
** is stored on.
** is stored on.  If the r-tree contains auxiliary columns, those are stored
** on the end of the %_rowid table.
**
** The root node of an r-tree always exists, even if the r-tree table is
** empty. The nodeno of the root node is always 1. All other nodes in the
** table must be the same size as the root node. The content of each node
** is formatted as follows:
**
**   1. If the node is the root node (node 1), then the first 2 bytes
168939
168940
168941
168942
168943
168944
168945



168946
168947
168948
168949
168950
168951
168952
170603
170604
170605
170606
170607
170608
170609
170610
170611
170612
170613
170614
170615
170616
170617
170618
170619







+
+
+







typedef struct RtreeMatchArg RtreeMatchArg;
typedef struct RtreeGeomCallback RtreeGeomCallback;
typedef union RtreeCoord RtreeCoord;
typedef struct RtreeSearchPoint RtreeSearchPoint;

/* The rtree may have between 1 and RTREE_MAX_DIMENSIONS dimensions. */
#define RTREE_MAX_DIMENSIONS 5

/* Maximum number of auxiliary columns */
#define RTREE_MAX_AUX_COLUMN 100

/* Size of hash table Rtree.aHash. This hash table is not expected to
** ever contain very many entries, so a fixed number of buckets is 
** used.
*/
#define HASHSIZE 97

168968
168969
168970
168971
168972
168973
168974

168975
168976
168977
168978
168979
168980


168981
168982
168983
168984
168985
168986
168987
170635
170636
170637
170638
170639
170640
170641
170642
170643
170644
170645
170646
170647
170648
170649
170650
170651
170652
170653
170654
170655
170656
170657







+






+
+







  sqlite3 *db;                /* Host database connection */
  int iNodeSize;              /* Size in bytes of each node in the node table */
  u8 nDim;                    /* Number of dimensions */
  u8 nDim2;                   /* Twice the number of dimensions */
  u8 eCoordType;              /* RTREE_COORD_REAL32 or RTREE_COORD_INT32 */
  u8 nBytesPerCell;           /* Bytes consumed per cell */
  u8 inWrTrans;               /* True if inside write transaction */
  u8 nAux;                    /* # of auxiliary columns in %_rowid */
  int iDepth;                 /* Current depth of the r-tree structure */
  char *zDb;                  /* Name of database containing r-tree table */
  char *zName;                /* Name of r-tree table */ 
  u32 nBusy;                  /* Current number of users of this structure */
  i64 nRowEst;                /* Estimated number of rows in this table */
  u32 nCursor;                /* Number of open cursors */
  u32 nNodeRef;               /* Number RtreeNodes with positive nRef */
  char *zReadAuxSql;          /* SQL for statement to read aux data */

  /* List of nodes removed during a CondenseTree operation. List is
  ** linked together via the pointer normally used for hash chains -
  ** RtreeNode.pNext. RtreeNode.iNode stores the depth of the sub-tree 
  ** headed by the node (leaf nodes have RtreeNode.iNode==0).
  */
  RtreeNode *pDeleted;
168999
169000
169001
169002
169003
169004
169005



169006
169007
169008
169009
169010
169011
169012
170669
170670
170671
170672
170673
170674
170675
170676
170677
170678
170679
170680
170681
170682
170683
170684
170685







+
+
+







  sqlite3_stmt *pWriteRowid;
  sqlite3_stmt *pDeleteRowid;

  /* Statements to read/write/delete a record from xxx_parent */
  sqlite3_stmt *pReadParent;
  sqlite3_stmt *pWriteParent;
  sqlite3_stmt *pDeleteParent;

  /* Statement for writing to the "aux:" fields, if there are any */
  sqlite3_stmt *pWriteAux;

  RtreeNode *aHash[HASHSIZE]; /* Hash table of in-memory nodes. */ 
};

/* Possible values for Rtree.eCoordType: */
#define RTREE_COORD_REAL32 0
#define RTREE_COORD_INT32  1
169076
169077
169078
169079
169080
169081
169082

169083
169084
169085
169086
169087
169088
169089

169090
169091
169092
169093
169094
169095
169096
170749
170750
170751
170752
170753
170754
170755
170756
170757
170758
170759
170760
170761
170762
170763
170764
170765
170766
170767
170768
170769
170770
170771







+







+







/* 
** An rtree cursor object.
*/
struct RtreeCursor {
  sqlite3_vtab_cursor base;         /* Base class.  Must be first */
  u8 atEOF;                         /* True if at end of search */
  u8 bPoint;                        /* True if sPoint is valid */
  u8 bAuxValid;                     /* True if pReadAux is valid */
  int iStrategy;                    /* Copy of idxNum search parameter */
  int nConstraint;                  /* Number of entries in aConstraint */
  RtreeConstraint *aConstraint;     /* Search constraints. */
  int nPointAlloc;                  /* Number of slots allocated for aPoint[] */
  int nPoint;                       /* Number of slots used in aPoint[] */
  int mxLevel;                      /* iLevel value for root of the tree */
  RtreeSearchPoint *aPoint;         /* Priority queue for search points */
  sqlite3_stmt *pReadAux;           /* Statement to read aux-data */
  RtreeSearchPoint sPoint;          /* Cached next search point */
  RtreeNode *aNode[RTREE_CACHE_SZ]; /* Rtree node cache */
  u32 anQueue[RTREE_MAX_DEPTH+1];   /* Number of queued entries by iLevel */
};

/* Return the Rtree of a RtreeCursor */
#define RTREE_OF_CURSOR(X)   ((Rtree*)((X)->base.pVtab))
169369
169370
169371
169372
169373
169374
169375

169376
169377
169378
169379
169380
169381
169382
171044
171045
171046
171047
171048
171049
171050
171051
171052
171053
171054
171055
171056
171057
171058







+







}

/*
** Increment the reference count of node p.
*/
static void nodeReference(RtreeNode *p){
  if( p ){
    assert( p->nRef>0 );
    p->nRef++;
  }
}

/*
** Clear the content of node p (set all bytes to 0x00).
*/
169436
169437
169438
169439
169440
169441
169442

169443
169444
169445
169446
169447
169448
169449
171112
171113
171114
171115
171116
171117
171118
171119
171120
171121
171122
171123
171124
171125
171126







+







static RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){
  RtreeNode *pNode;
  pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);
  if( pNode ){
    memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);
    pNode->zData = (u8 *)&pNode[1];
    pNode->nRef = 1;
    pRtree->nNodeRef++;
    pNode->pParent = pParent;
    pNode->isDirty = 1;
    nodeReference(pParent);
  }
  return pNode;
}

169469
169470
169471
169472
169473
169474
169475
169476

169477
169478
169479

169480
169481
169482
169483
169484
169485
169486
171146
171147
171148
171149
171150
171151
171152

171153
171154
171155

171156
171157
171158
171159
171160
171161
171162
171163







-
+


-
+







){
  int rc = SQLITE_OK;
  RtreeNode *pNode = 0;

  /* Check if the requested node is already in the hash table. If so,
  ** increase its reference count and return it.
  */
  if( (pNode = nodeHashLookup(pRtree, iNode)) ){
  if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){
    assert( !pParent || !pNode->pParent || pNode->pParent==pParent );
    if( pParent && !pNode->pParent ){
      nodeReference(pParent);
      pParent->nRef++;
      pNode->pParent = pParent;
    }
    pNode->nRef++;
    *ppNode = pNode;
    return SQLITE_OK;
  }

169511
169512
169513
169514
169515
169516
169517

169518
169519
169520
169521
169522
169523
169524
171188
171189
171190
171191
171192
171193
171194
171195
171196
171197
171198
171199
171200
171201
171202







+







    pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize);
    if( !pNode ){
      rc = SQLITE_NOMEM;
    }else{
      pNode->pParent = pParent;
      pNode->zData = (u8 *)&pNode[1];
      pNode->nRef = 1;
      pRtree->nNodeRef++;
      pNode->iNode = iNode;
      pNode->isDirty = 0;
      pNode->pNext = 0;
      rc = sqlite3_blob_read(pRtree->pNodeBlob, pNode->zData,
                             pRtree->iNodeSize, 0);
      nodeReference(pParent);
    }
169551
169552
169553
169554
169555
169556
169557


169558


169559
169560
169561
169562
169563
169564
169565
171229
171230
171231
171232
171233
171234
171235
171236
171237

171238
171239
171240
171241
171242
171243
171244
171245
171246







+
+
-
+
+







    if( pNode!=0 ){
      nodeHashInsert(pRtree, pNode);
    }else{
      rc = SQLITE_CORRUPT_VTAB;
    }
    *ppNode = pNode;
  }else{
    if( pNode ){
      pRtree->nNodeRef--;
    sqlite3_free(pNode);
      sqlite3_free(pNode);
    }
    *ppNode = 0;
  }

  return rc;
}

/*
169648
169649
169650
169651
169652
169653
169654

169655
169656

169657
169658
169659
169660
169661
169662
169663
171329
171330
171331
171332
171333
171334
171335
171336
171337
171338
171339
171340
171341
171342
171343
171344
171345
171346







+


+







** Release a reference to a node. If the node is dirty and the reference
** count drops to zero, the node data is written to the database.
*/
static int nodeRelease(Rtree *pRtree, RtreeNode *pNode){
  int rc = SQLITE_OK;
  if( pNode ){
    assert( pNode->nRef>0 );
    assert( pRtree->nNodeRef>0 );
    pNode->nRef--;
    if( pNode->nRef==0 ){
      pRtree->nNodeRef--;
      if( pNode->iNode==1 ){
        pRtree->iDepth = -1;
      }
      if( pNode->pParent ){
        rc = nodeRelease(pRtree, pNode->pParent);
      }
      if( rc==SQLITE_OK ){
169766
169767
169768
169769
169770
169771
169772
169773

169774

169775
169776
169777
169778
169779
169780
169781
169782


169783
169784
169785
169786
169787
169788
169789
171449
171450
171451
171452
171453
171454
171455

171456
171457
171458
171459
171460
171461
171462
171463
171464
171465
171466
171467
171468
171469
171470
171471
171472
171473
171474
171475







-
+

+








+
+







** Decrement the r-tree reference count. When the reference count reaches
** zero the structure is deleted.
*/
static void rtreeRelease(Rtree *pRtree){
  pRtree->nBusy--;
  if( pRtree->nBusy==0 ){
    pRtree->inWrTrans = 0;
    pRtree->nCursor = 0;
    assert( pRtree->nCursor==0 );
    nodeBlobReset(pRtree);
    assert( pRtree->nNodeRef==0 );
    sqlite3_finalize(pRtree->pWriteNode);
    sqlite3_finalize(pRtree->pDeleteNode);
    sqlite3_finalize(pRtree->pReadRowid);
    sqlite3_finalize(pRtree->pWriteRowid);
    sqlite3_finalize(pRtree->pDeleteRowid);
    sqlite3_finalize(pRtree->pReadParent);
    sqlite3_finalize(pRtree->pWriteParent);
    sqlite3_finalize(pRtree->pDeleteParent);
    sqlite3_finalize(pRtree->pWriteAux);
    sqlite3_free(pRtree->zReadAuxSql);
    sqlite3_free(pRtree);
  }
}

/* 
** Rtree virtual table module xDisconnect method.
*/
169864
169865
169866
169867
169868
169869
169870

169871
169872
169873
169874
169875
169876
169877
171550
171551
171552
171553
171554
171555
171556
171557
171558
171559
171560
171561
171562
171563
171564







+







*/
static int rtreeClose(sqlite3_vtab_cursor *cur){
  Rtree *pRtree = (Rtree *)(cur->pVtab);
  int ii;
  RtreeCursor *pCsr = (RtreeCursor *)cur;
  assert( pRtree->nCursor>0 );
  freeCursorConstraints(pCsr);
  sqlite3_finalize(pCsr->pReadAux);
  sqlite3_free(pCsr->aPoint);
  for(ii=0; ii<RTREE_CACHE_SZ; ii++) nodeRelease(pRtree, pCsr->aNode[ii]);
  sqlite3_free(pCsr);
  pRtree->nCursor--;
  nodeBlobReset(pRtree);
  return SQLITE_OK;
}
170235
170236
170237
170238
170239
170240
170241
170242

170243
170244
170245
170246
170247
170248
170249
171922
171923
171924
171925
171926
171927
171928

171929
171930
171931
171932
171933
171934
171935
171936







-
+







      int ii;
      pNew = rtreeEnqueue(pCur, rScore, iLevel);
      if( pNew==0 ) return 0;
      ii = (int)(pNew - pCur->aPoint) + 1;
      if( ii<RTREE_CACHE_SZ ){
        assert( pCur->aNode[ii]==0 );
        pCur->aNode[ii] = pCur->aNode[0];
       }else{
      }else{
        nodeRelease(RTREE_OF_CURSOR(pCur), pCur->aNode[0]);
      }
      pCur->aNode[0] = 0;
      *pNew = pCur->sPoint;
    }
    pCur->sPoint.rScore = rScore;
    pCur->sPoint.iLevel = iLevel;
170406
170407
170408
170409
170410
170411
170412




170413
170414
170415
170416
170417
170418
170419
172093
172094
172095
172096
172097
172098
172099
172100
172101
172102
172103
172104
172105
172106
172107
172108
172109
172110







+
+
+
+







*/
static int rtreeNext(sqlite3_vtab_cursor *pVtabCursor){
  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;
  int rc = SQLITE_OK;

  /* Move to the next entry that matches the configured constraints. */
  RTREE_QUEUE_TRACE(pCsr, "POP-Nx:");
  if( pCsr->bAuxValid ){
    pCsr->bAuxValid = 0;
    sqlite3_reset(pCsr->pReadAux);
  }
  rtreeSearchPointPop(pCsr);
  rc = rtreeStepToLeaf(pCsr);
  return rc;
}

/* 
** Rtree virtual table module xRowid method.
170440
170441
170442
170443
170444
170445
170446
170447

170448
170449
170450
170451
170452
170453
170454
170455
170456
170457






170458















170459
170460
170461
170462
170463
170464
170465
172131
172132
172133
172134
172135
172136
172137

172138
172139
172140
172141
172142
172143
172144
172145
172146
172147
172148
172149
172150
172151
172152
172153
172154

172155
172156
172157
172158
172159
172160
172161
172162
172163
172164
172165
172166
172167
172168
172169
172170
172171
172172
172173
172174
172175
172176







-
+










+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  int rc = SQLITE_OK;
  RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc);

  if( rc ) return rc;
  if( p==0 ) return SQLITE_OK;
  if( i==0 ){
    sqlite3_result_int64(ctx, nodeGetRowid(pRtree, pNode, p->iCell));
  }else{
  }else if( i<=pRtree->nDim2 ){
    nodeGetCoord(pRtree, pNode, p->iCell, i-1, &c);
#ifndef SQLITE_RTREE_INT_ONLY
    if( pRtree->eCoordType==RTREE_COORD_REAL32 ){
      sqlite3_result_double(ctx, c.f);
    }else
#endif
    {
      assert( pRtree->eCoordType==RTREE_COORD_INT32 );
      sqlite3_result_int(ctx, c.i);
    }
  }else{
    if( !pCsr->bAuxValid ){
      if( pCsr->pReadAux==0 ){
        rc = sqlite3_prepare_v3(pRtree->db, pRtree->zReadAuxSql, -1, 0,
                                &pCsr->pReadAux, 0);
        if( rc ) return rc;
  }
      }
      sqlite3_bind_int64(pCsr->pReadAux, 1, 
          nodeGetRowid(pRtree, pNode, p->iCell));
      rc = sqlite3_step(pCsr->pReadAux);
      if( rc==SQLITE_ROW ){
        pCsr->bAuxValid = 1;
      }else{
        sqlite3_reset(pCsr->pReadAux);
        if( rc==SQLITE_DONE ) rc = SQLITE_OK;
        return rc;
      }
    }
    sqlite3_result_value(ctx,
         sqlite3_column_value(pCsr->pReadAux, i - pRtree->nDim2 + 1));
  }  
  return SQLITE_OK;
}

/* 
** Use nodeAcquire() to obtain the leaf node containing the record with 
** rowid iRowid. If successful, set *ppLeaf to point to the node and
** return SQLITE_OK. If there is no such record in the table, set
170529
170530
170531
170532
170533
170534
170535

170536
170537
170538
170539
170540
170541

170542
170543

170544
170545
170546
170547
170548
170549
170550
172240
172241
172242
172243
172244
172245
172246
172247
172248
172249
172250
172251
172252
172253
172254
172255
172256
172257
172258
172259
172260
172261
172262
172263
172264







+






+


+







){
  Rtree *pRtree = (Rtree *)pVtabCursor->pVtab;
  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;
  RtreeNode *pRoot = 0;
  int ii;
  int rc = SQLITE_OK;
  int iCell = 0;
  sqlite3_stmt *pStmt;

  rtreeReference(pRtree);

  /* Reset the cursor to the same state as rtreeOpen() leaves it in. */
  freeCursorConstraints(pCsr);
  sqlite3_free(pCsr->aPoint);
  pStmt = pCsr->pReadAux;
  memset(pCsr, 0, sizeof(RtreeCursor));
  pCsr->base.pVtab = (sqlite3_vtab*)pRtree;
  pCsr->pReadAux = pStmt;

  pCsr->iStrategy = idxNum;
  if( idxNum==1 ){
    /* Special case - lookup by rowid. */
    RtreeNode *pLeaf;        /* Leaf on which the required cell resides */
    RtreeSearchPoint *p;     /* Search point for the leaf */
    i64 iRowid = sqlite3_value_int64(argv[0]);
170699
170700
170701
170702
170703
170704
170705

170706
170707
170708


170709


170710
170711
170712
170713
170714
170715
170716
172413
172414
172415
172416
172417
172418
172419
172420
172421
172422
172423
172424
172425

172426
172427
172428
172429
172430
172431
172432
172433
172434







+



+
+
-
+
+







      ** and then a linear search of an R-Tree node. This should be 
      ** considered almost as quick as a direct rowid lookup (for which 
      ** sqlite uses an internal cost of 0.0). It is expected to return
      ** a single row.
      */ 
      pIdxInfo->estimatedCost = 30.0;
      pIdxInfo->estimatedRows = 1;
      pIdxInfo->idxFlags = SQLITE_INDEX_SCAN_UNIQUE;
      return SQLITE_OK;
    }

    if( p->usable
    && ((p->iColumn>0 && p->iColumn<=pRtree->nDim2)
    if( p->usable && (p->iColumn>0 || p->op==SQLITE_INDEX_CONSTRAINT_MATCH) ){
        || p->op==SQLITE_INDEX_CONSTRAINT_MATCH)
    ){
      u8 op;
      switch( p->op ){
        case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; break;
        case SQLITE_INDEX_CONSTRAINT_GT: op = RTREE_GT; break;
        case SQLITE_INDEX_CONSTRAINT_LE: op = RTREE_LE; break;
        case SQLITE_INDEX_CONSTRAINT_LT: op = RTREE_LT; break;
        case SQLITE_INDEX_CONSTRAINT_GE: op = RTREE_GE; break;
171275
171276
171277
171278
171279
171280
171281
171282

171283
171284
171285
171286
171287
171288
171289
172993
172994
172995
172996
172997
172998
172999

173000
173001
173002
173003
173004
173005
173006
173007







-
+







    pLeft = nodeNew(pRtree, pNode);
    pRtree->iDepth++;
    pNode->isDirty = 1;
    writeInt16(pNode->zData, pRtree->iDepth);
  }else{
    pLeft = pNode;
    pRight = nodeNew(pRtree, pLeft->pParent);
    nodeReference(pLeft);
    pLeft->nRef++;
  }

  if( !pLeft || !pRight ){
    rc = SQLITE_NOMEM;
    goto splitnode_out;
  }

171765
171766
171767
171768
171769
171770
171771

171772
171773
171774
171775
171776
171777
171778
173483
173484
173485
173486
173487
173488
173489
173490
173491
173492
173493
173494
173495
173496
173497







+








  /* Re-insert the contents of any underfull nodes removed from the tree. */
  for(pLeaf=pRtree->pDeleted; pLeaf; pLeaf=pRtree->pDeleted){
    if( rc==SQLITE_OK ){
      rc = reinsertNodeContent(pRtree, pLeaf);
    }
    pRtree->pDeleted = pLeaf->pNext;
    pRtree->nNodeRef--;
    sqlite3_free(pLeaf);
  }

  /* Release the reference to the root node. */
  if( rc==SQLITE_OK ){
    rc = nodeRelease(pRtree, pRoot);
  }else{
171861
171862
171863
171864
171865
171866
171867
171868

171869
171870
171871
171872
171873
171874
171875






171876
171877
171878
171879
171880
171881
171882
171883
171884
171885
171886
171887
171888
171889
171890
171891
171892
171893

171894

171895

171896
171897
171898
171899
171900
171901
171902
171903
171904
171905
171906
171907
171908
171909



171910
171911
171912
171913
171914
171915
171916
171917
171918
171919
171920



171921
171922
171923
171924
171925
171926
171927
171928
171929
171930
171931
171932
171933




171934
171935
171936
171937
171938
171939
171940
171941
171942
171943
171944
171945
171946
171947
171948
171949
171950
171951
171952

171953
171954
171955
171956
171957


171958
171959
171960
171961


171962
171963
171964
171965
171966
171967
171968
173580
173581
173582
173583
173584
173585
173586

173587
173588
173589
173590
173591
173592
173593
173594
173595
173596
173597
173598
173599
173600
173601
173602
173603
173604
173605
173606
173607
173608
173609
173610
173611
173612
173613
173614
173615
173616
173617
173618
173619
173620
173621

173622
173623
173624
173625
173626
173627
173628
173629

173630
173631
173632



173633
173634
173635
173636
173637
173638
173639
173640
173641
173642
173643



173644
173645
173646
173647
173648
173649
173650
173651
173652
173653
173654
173655




173656
173657
173658
173659
173660
173661
173662
173663
173664
173665
173666
173667
173668
173669
173670
173671
173672
173673
173674
173675
173676
173677

173678
173679
173680
173681


173682
173683
173684
173685


173686
173687
173688
173689
173690
173691
173692
173693
173694







-
+







+
+
+
+
+
+


















+

+
-
+







-



-
-
-
+
+
+








-
-
-
+
+
+









-
-
-
-
+
+
+
+


















-
+



-
-
+
+


-
-
+
+








/*
** The xUpdate method for rtree module virtual tables.
*/
static int rtreeUpdate(
  sqlite3_vtab *pVtab, 
  int nData, 
  sqlite3_value **azData, 
  sqlite3_value **aData, 
  sqlite_int64 *pRowid
){
  Rtree *pRtree = (Rtree *)pVtab;
  int rc = SQLITE_OK;
  RtreeCell cell;                 /* New cell to insert if nData>1 */
  int bHaveRowid = 0;             /* Set to 1 after new rowid is determined */

  if( pRtree->nNodeRef ){
    /* Unable to write to the btree while another cursor is reading from it,
    ** since the write might do a rebalance which would disrupt the read
    ** cursor. */
    return SQLITE_LOCKED_VTAB;
  }
  rtreeReference(pRtree);
  assert(nData>=1);

  cell.iRowid = 0;  /* Used only to suppress a compiler warning */

  /* Constraint handling. A write operation on an r-tree table may return
  ** SQLITE_CONSTRAINT for two reasons:
  **
  **   1. A duplicate rowid value, or
  **   2. The supplied data violates the "x2>=x1" constraint.
  **
  ** In the first case, if the conflict-handling mode is REPLACE, then
  ** the conflicting row can be removed before proceeding. In the second
  ** case, SQLITE_CONSTRAINT must be returned regardless of the
  ** conflict-handling mode specified by the user.
  */
  if( nData>1 ){
    int ii;
    int nn = nData - 4;

    if( nn > pRtree->nDim2 ) nn = pRtree->nDim2;
    /* Populate the cell.aCoord[] array. The first coordinate is azData[3].
    /* Populate the cell.aCoord[] array. The first coordinate is aData[3].
    **
    ** NB: nData can only be less than nDim*2+3 if the rtree is mis-declared
    ** with "column" that are interpreted as table constraints.
    ** Example:  CREATE VIRTUAL TABLE bad USING rtree(x,y,CHECK(y>5));
    ** This problem was discovered after years of use, so we silently ignore
    ** these kinds of misdeclared tables to avoid breaking any legacy.
    */
    assert( nData<=(pRtree->nDim2 + 3) );

#ifndef SQLITE_RTREE_INT_ONLY
    if( pRtree->eCoordType==RTREE_COORD_REAL32 ){
      for(ii=0; ii<nData-4; ii+=2){
        cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]);
        cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]);
      for(ii=0; ii<nn; ii+=2){
        cell.aCoord[ii].f = rtreeValueDown(aData[ii+3]);
        cell.aCoord[ii+1].f = rtreeValueUp(aData[ii+4]);
        if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){
          rc = rtreeConstraintError(pRtree, ii+1);
          goto constraint;
        }
      }
    }else
#endif
    {
      for(ii=0; ii<nData-4; ii+=2){
        cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]);
        cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]);
      for(ii=0; ii<nn; ii+=2){
        cell.aCoord[ii].i = sqlite3_value_int(aData[ii+3]);
        cell.aCoord[ii+1].i = sqlite3_value_int(aData[ii+4]);
        if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){
          rc = rtreeConstraintError(pRtree, ii+1);
          goto constraint;
        }
      }
    }

    /* If a rowid value was supplied, check if it is already present in 
    ** the table. If so, the constraint has failed. */
    if( sqlite3_value_type(azData[2])!=SQLITE_NULL ){
      cell.iRowid = sqlite3_value_int64(azData[2]);
      if( sqlite3_value_type(azData[0])==SQLITE_NULL
       || sqlite3_value_int64(azData[0])!=cell.iRowid
    if( sqlite3_value_type(aData[2])!=SQLITE_NULL ){
      cell.iRowid = sqlite3_value_int64(aData[2]);
      if( sqlite3_value_type(aData[0])==SQLITE_NULL
       || sqlite3_value_int64(aData[0])!=cell.iRowid
      ){
        int steprc;
        sqlite3_bind_int64(pRtree->pReadRowid, 1, cell.iRowid);
        steprc = sqlite3_step(pRtree->pReadRowid);
        rc = sqlite3_reset(pRtree->pReadRowid);
        if( SQLITE_ROW==steprc ){
          if( sqlite3_vtab_on_conflict(pRtree->db)==SQLITE_REPLACE ){
            rc = rtreeDeleteRowid(pRtree, cell.iRowid);
          }else{
            rc = rtreeConstraintError(pRtree, 0);
            goto constraint;
          }
        }
      }
      bHaveRowid = 1;
    }
  }

  /* If azData[0] is not an SQL NULL value, it is the rowid of a
  /* If aData[0] is not an SQL NULL value, it is the rowid of a
  ** record to delete from the r-tree table. The following block does
  ** just that.
  */
  if( sqlite3_value_type(azData[0])!=SQLITE_NULL ){
    rc = rtreeDeleteRowid(pRtree, sqlite3_value_int64(azData[0]));
  if( sqlite3_value_type(aData[0])!=SQLITE_NULL ){
    rc = rtreeDeleteRowid(pRtree, sqlite3_value_int64(aData[0]));
  }

  /* If the azData[] array contains more than one element, elements
  ** (azData[2]..azData[argc-1]) contain a new record to insert into
  /* If the aData[] array contains more than one element, elements
  ** (aData[2]..aData[argc-1]) contain a new record to insert into
  ** the r-tree structure.
  */
  if( rc==SQLITE_OK && nData>1 ){
    /* Insert the new record into the r-tree */
    RtreeNode *pLeaf = 0;

    /* Figure out the rowid of the new row. */
171979
171980
171981
171982
171983
171984
171985










171986
171987
171988
171989
171990
171991
171992
173705
173706
173707
173708
173709
173710
173711
173712
173713
173714
173715
173716
173717
173718
173719
173720
173721
173722
173723
173724
173725
173726
173727
173728







+
+
+
+
+
+
+
+
+
+







      pRtree->iReinsertHeight = -1;
      rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0);
      rc2 = nodeRelease(pRtree, pLeaf);
      if( rc==SQLITE_OK ){
        rc = rc2;
      }
    }
    if( pRtree->nAux ){
      sqlite3_stmt *pUp = pRtree->pWriteAux;
      int jj;
      sqlite3_bind_int64(pUp, 1, *pRowid);
      for(jj=0; jj<pRtree->nAux; jj++){
        sqlite3_bind_value(pUp, jj+2, aData[pRtree->nDim2+3+jj]);
      }
      sqlite3_step(pUp);
      rc = sqlite3_reset(pUp);
    }
  }

constraint:
  rtreeRelease(pRtree);
  return rc;
}

172135
172136
172137
172138
172139
172140
172141
172142
172143


172144
172145
172146
172147
172148



172149
172150
172151
172152
172153



172154
172155
172156
172157
172158
172159
172160
172161
172162
172163
172164
172165
172166
172167
172168



















172169
172170
172171
172172
172173
172174
172175
173871
173872
173873
173874
173875
173876
173877


173878
173879
173880
173881



173882
173883
173884
173885
173886



173887
173888
173889
173890
173891
173892
173893
173894
173895
173896








173897
173898
173899
173900
173901
173902
173903
173904
173905
173906
173907
173908
173909
173910
173911
173912
173913
173914
173915
173916
173917
173918
173919
173920
173921
173922







-
-
+
+


-
-
-
+
+
+


-
-
-
+
+
+







-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  int isCreate
){
  int rc = SQLITE_OK;

  #define N_STATEMENT 8
  static const char *azSql[N_STATEMENT] = {
    /* Write the xxx_node table */
    "INSERT OR REPLACE INTO '%q'.'%q_node' VALUES(:1, :2)",
    "DELETE FROM '%q'.'%q_node' WHERE nodeno = :1",
    "INSERT OR REPLACE INTO '%q'.'%q_node' VALUES(?1, ?2)",
    "DELETE FROM '%q'.'%q_node' WHERE nodeno = ?1",

    /* Read and write the xxx_rowid table */
    "SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = :1",
    "INSERT OR REPLACE INTO '%q'.'%q_rowid' VALUES(:1, :2)",
    "DELETE FROM '%q'.'%q_rowid' WHERE rowid = :1",
    "SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = ?1",
    "INSERT OR REPLACE INTO '%q'.'%q_rowid' VALUES(?1, ?2)",
    "DELETE FROM '%q'.'%q_rowid' WHERE rowid = ?1",

    /* Read and write the xxx_parent table */
    "SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = :1",
    "INSERT OR REPLACE INTO '%q'.'%q_parent' VALUES(:1, :2)",
    "DELETE FROM '%q'.'%q_parent' WHERE nodeno = :1"
    "SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = ?1",
    "INSERT OR REPLACE INTO '%q'.'%q_parent' VALUES(?1, ?2)",
    "DELETE FROM '%q'.'%q_parent' WHERE nodeno = ?1"
  };
  sqlite3_stmt **appStmt[N_STATEMENT];
  int i;

  pRtree->db = db;

  if( isCreate ){
    char *zCreate = sqlite3_mprintf(
"CREATE TABLE \"%w\".\"%w_node\"(nodeno INTEGER PRIMARY KEY, data BLOB);"
"CREATE TABLE \"%w\".\"%w_rowid\"(rowid INTEGER PRIMARY KEY, nodeno INTEGER);"
"CREATE TABLE \"%w\".\"%w_parent\"(nodeno INTEGER PRIMARY KEY,"
                                  " parentnode INTEGER);"
"INSERT INTO '%q'.'%q_node' VALUES(1, zeroblob(%d))",
      zDb, zPrefix, zDb, zPrefix, zDb, zPrefix, zDb, zPrefix, pRtree->iNodeSize
    );
    char *zCreate;
    sqlite3_str *p = sqlite3_str_new(db);
    int ii;
    sqlite3_str_appendf(p,
       "CREATE TABLE \"%w\".\"%w_rowid\"(rowid INTEGER PRIMARY KEY,nodeno",
       zDb, zPrefix);
    for(ii=0; ii<pRtree->nAux; ii++){
      sqlite3_str_appendf(p,",a%d",ii);
    }
    sqlite3_str_appendf(p,
      ");CREATE TABLE \"%w\".\"%w_node\"(nodeno INTEGER PRIMARY KEY,data);",
      zDb, zPrefix);
    sqlite3_str_appendf(p,
    "CREATE TABLE \"%w\".\"%w_parent\"(nodeno INTEGER PRIMARY KEY,parentnode);",
      zDb, zPrefix);
    sqlite3_str_appendf(p,
       "INSERT INTO \"%w\".\"%w_node\"VALUES(1,zeroblob(%d))",
       zDb, zPrefix, pRtree->iNodeSize);
    zCreate = sqlite3_str_finish(p);
    if( !zCreate ){
      return SQLITE_NOMEM;
    }
    rc = sqlite3_exec(db, zCreate, 0, 0, 0);
    sqlite3_free(zCreate);
    if( rc!=SQLITE_OK ){
      return rc;
172183
172184
172185
172186
172187
172188
172189
172190











172191
172192
172193
172194
172195
172196
172197


























172198
172199
172200
172201
172202
172203
172204
173930
173931
173932
173933
173934
173935
173936

173937
173938
173939
173940
173941
173942
173943
173944
173945
173946
173947
173948
173949
173950
173951
173952
173953
173954
173955
173956
173957
173958
173959
173960
173961
173962
173963
173964
173965
173966
173967
173968
173969
173970
173971
173972
173973
173974
173975
173976
173977
173978
173979
173980
173981
173982
173983
173984
173985
173986
173987







-
+
+
+
+
+
+
+
+
+
+
+







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  appStmt[4] = &pRtree->pDeleteRowid;
  appStmt[5] = &pRtree->pReadParent;
  appStmt[6] = &pRtree->pWriteParent;
  appStmt[7] = &pRtree->pDeleteParent;

  rc = rtreeQueryStat1(db, pRtree);
  for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){
    char *zSql = sqlite3_mprintf(azSql[i], zDb, zPrefix);
    char *zSql;
    const char *zFormat;
    if( i!=3 || pRtree->nAux==0 ){
       zFormat = azSql[i];
    }else {
       /* An UPSERT is very slightly slower than REPLACE, but it is needed
       ** if there are auxiliary columns */
       zFormat = "INSERT INTO\"%w\".\"%w_rowid\"(rowid,nodeno)VALUES(?1,?2)"
                  "ON CONFLICT(rowid)DO UPDATE SET nodeno=excluded.nodeno";
    }
    zSql = sqlite3_mprintf(zFormat, zDb, zPrefix);
    if( zSql ){
      rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
                              appStmt[i], 0); 
    }else{
      rc = SQLITE_NOMEM;
    }
    sqlite3_free(zSql);
  }
  if( pRtree->nAux ){
    pRtree->zReadAuxSql = sqlite3_mprintf(
       "SELECT * FROM \"%w\".\"%w_rowid\" WHERE rowid=?1",
       zDb, zPrefix);
    if( pRtree->zReadAuxSql==0 ){
      rc = SQLITE_NOMEM;
    }else{
      sqlite3_str *p = sqlite3_str_new(db);
      int ii;
      char *zSql;
      sqlite3_str_appendf(p, "UPDATE \"%w\".\"%w_rowid\"SET ", zDb, zPrefix);
      for(ii=0; ii<pRtree->nAux; ii++){
        if( ii ) sqlite3_str_append(p, ",", 1);
        sqlite3_str_appendf(p,"a%d=?%d",ii,ii+2);
      }
      sqlite3_str_appendf(p, " WHERE rowid=?1");
      zSql = sqlite3_str_finish(p);
      if( zSql==0 ){
        rc = SQLITE_NOMEM;
      }else{
        rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
                                &pRtree->pWriteAux, 0); 
        sqlite3_free(zSql);
      }
    }
  }

  return rc;
}

/*
** The second argument to this function contains the text of an SQL statement
172294
172295
172296
172297
172298
172299
172300




172301
172302
172303
172304
172305
172306


172307
172308
172309
172310
172311



172312
172313
172314
172315
172316
172317
172318
172319
172320
172321
172322
172323
172324
172325
172326
172327
172328
172329
172330
172331
172332
172333
172334
172335
172336
172337
172338
172339
172340
172341
172342



172343
172344
172345





172346





172347

172348
172349
172350
172351
172352
172353
172354
172355
172356
172357

















172358
172359
172360




172361
172362
172363
172364
172365
172366












172367
172368
172369
172370
172371
172372
172373
172374








172375
172376
172377
172378
172379
172380
172381
172382
174077
174078
174079
174080
174081
174082
174083
174084
174085
174086
174087
174088
174089
174090
174091
174092

174093
174094
174095
174096



174097
174098
174099
174100
174101
174102
174103
174104
174105
174106
174107
174108
174109
174110
174111
174112
174113
174114
174115
174116



174117
174118
174119
174120


174121
174122
174123
174124
174125
174126
174127
174128



174129
174130
174131
174132
174133
174134
174135
174136
174137
174138
174139

174140










174141
174142
174143
174144
174145
174146
174147
174148
174149
174150
174151
174152
174153
174154
174155
174156
174157



174158
174159
174160
174161






174162
174163
174164
174165
174166
174167
174168
174169
174170
174171
174172
174173
174174
174175






174176
174177
174178
174179
174180
174181
174182
174183

174184
174185
174186
174187
174188
174189
174190







+
+
+
+





-
+
+


-
-
-
+
+
+

















-
-
-




-
-





+
+
+
-
-
-
+
+
+
+
+

+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+


-
-
-
-
-
-
+
+
+
+
+
+
+
+
-







  int isCreate                        /* True for xCreate, false for xConnect */
){
  int rc = SQLITE_OK;
  Rtree *pRtree;
  int nDb;              /* Length of string argv[1] */
  int nName;            /* Length of string argv[2] */
  int eCoordType = (pAux ? RTREE_COORD_INT32 : RTREE_COORD_REAL32);
  sqlite3_str *pSql;
  char *zSql;
  int ii = 4;
  int iErr;

  const char *aErrMsg[] = {
    0,                                                    /* 0 */
    "Wrong number of columns for an rtree table",         /* 1 */
    "Too few columns for an rtree table",                 /* 2 */
    "Too many columns for an rtree table"                 /* 3 */
    "Too many columns for an rtree table",                /* 3 */
    "Auxiliary rtree columns must be last"                /* 4 */
  };

  int iErr = (argc<6) ? 2 : argc>(RTREE_MAX_DIMENSIONS*2+4) ? 3 : argc%2;
  if( aErrMsg[iErr] ){
    *pzErr = sqlite3_mprintf("%s", aErrMsg[iErr]);
  assert( RTREE_MAX_AUX_COLUMN<256 ); /* Aux columns counted by a u8 */
  if( argc>RTREE_MAX_AUX_COLUMN+3 ){
    *pzErr = sqlite3_mprintf("%s", aErrMsg[3]);
    return SQLITE_ERROR;
  }

  sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);

  /* Allocate the sqlite3_vtab structure */
  nDb = (int)strlen(argv[1]);
  nName = (int)strlen(argv[2]);
  pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2);
  if( !pRtree ){
    return SQLITE_NOMEM;
  }
  memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2);
  pRtree->nBusy = 1;
  pRtree->base.pModule = &rtreeModule;
  pRtree->zDb = (char *)&pRtree[1];
  pRtree->zName = &pRtree->zDb[nDb+1];
  pRtree->nDim = (u8)((argc-4)/2);
  pRtree->nDim2 = pRtree->nDim*2;
  pRtree->nBytesPerCell = 8 + pRtree->nDim2*4;
  pRtree->eCoordType = (u8)eCoordType;
  memcpy(pRtree->zDb, argv[1], nDb);
  memcpy(pRtree->zName, argv[2], nName);

  /* Figure out the node size to use. */
  rc = getNodeSize(db, pRtree, isCreate, pzErr);

  /* Create/Connect to the underlying relational database schema. If
  ** that is successful, call sqlite3_declare_vtab() to configure
  ** the r-tree table schema.
  */
  pSql = sqlite3_str_new(db);
  sqlite3_str_appendf(pSql, "CREATE TABLE x(%s", argv[3]);
  for(ii=4; ii<argc; ii++){
  if( rc==SQLITE_OK ){
    if( (rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate)) ){
      *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
    if( argv[ii][0]=='+' ){
      pRtree->nAux++;
      sqlite3_str_appendf(pSql, ",%s", argv[ii]+1);
    }else if( pRtree->nAux>0 ){
      break;
    }else{
      pRtree->nDim2++;
      sqlite3_str_appendf(pSql, ",%s", argv[ii]);
    }
  }
  sqlite3_str_appendf(pSql, ");");
      char *zSql = sqlite3_mprintf("CREATE TABLE x(%s", argv[3]);
  zSql = sqlite3_str_finish(pSql);
      char *zTmp;
      int ii;
      for(ii=4; zSql && ii<argc; ii++){
        zTmp = zSql;
        zSql = sqlite3_mprintf("%s, %s", zTmp, argv[ii]);
        sqlite3_free(zTmp);
      }
      if( zSql ){
        zTmp = zSql;
        zSql = sqlite3_mprintf("%s);", zTmp);
  if( !zSql ){
    rc = SQLITE_NOMEM;
  }else if( ii<argc ){
    *pzErr = sqlite3_mprintf("%s", aErrMsg[4]);
    rc = SQLITE_ERROR;
  }else if( SQLITE_OK!=(rc = sqlite3_declare_vtab(db, zSql)) ){
    *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
  }
  sqlite3_free(zSql);
  if( rc ) goto rtreeInit_fail;
  pRtree->nDim = pRtree->nDim2/2;
  if( pRtree->nDim<1 ){
    iErr = 2;
  }else if( pRtree->nDim2>RTREE_MAX_DIMENSIONS*2 ){
    iErr = 3;
  }else if( pRtree->nDim2 % 2 ){
    iErr = 1;
        sqlite3_free(zTmp);
      }
      if( !zSql ){
  }else{
    iErr = 0;
  }
  if( iErr ){
        rc = SQLITE_NOMEM;
      }else if( SQLITE_OK!=(rc = sqlite3_declare_vtab(db, zSql)) ){
        *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
      }
      sqlite3_free(zSql);
    }
    *pzErr = sqlite3_mprintf("%s", aErrMsg[iErr]);
    goto rtreeInit_fail;
  }
  pRtree->nBytesPerCell = 8 + pRtree->nDim2*4;

  /* Figure out the node size to use. */
  rc = getNodeSize(db, pRtree, isCreate, pzErr);
  if( rc ) goto rtreeInit_fail;
  rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate);
  if( rc ){
    *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
    goto rtreeInit_fail;
  }

  if( rc==SQLITE_OK ){
    *ppVtab = (sqlite3_vtab *)pRtree;
  }else{
    assert( *ppVtab==0 );
    assert( pRtree->nBusy==1 );
    rtreeRelease(pRtree);
  *ppVtab = (sqlite3_vtab *)pRtree;
  return SQLITE_OK;

rtreeInit_fail:
  if( rc==SQLITE_OK ) rc = SQLITE_ERROR;
  assert( *ppVtab==0 );
  assert( pRtree->nBusy==1 );
  rtreeRelease(pRtree);
  }
  return rc;
}


/*
** Implementation of a scalar function that decodes r-tree nodes to
** human readable strings. This can be used for debugging and analysis.
172597
172598
172599
172600
172601
172602
172603
172604

172605
172606
172607
172608
172609
172610
172611
172612
172613
172614
172615
172616
172617
172618
172619
172620


172621
172622
172623
172624
172625
172626
172627
174405
174406
174407
174408
174409
174410
174411

174412
174413
174414
174415
174416
174417
174418
174419
174420
174421
174422
174423
174424
174425
174426


174427
174428
174429
174430
174431
174432
174433
174434
174435







-
+














-
-
+
+








/*
** This function is used to check that the %_parent (if bLeaf==0) or %_rowid
** (if bLeaf==1) table contains a specified entry. The schemas of the
** two tables are:
**
**   CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)
**   CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER)
**   CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER, ...)
**
** In both cases, this function checks that there exists an entry with
** IPK value iKey and the second column set to iVal.
**
*/
static void rtreeCheckMapping(
  RtreeCheck *pCheck,             /* RtreeCheck object */
  int bLeaf,                      /* True for a leaf cell, false for interior */
  i64 iKey,                       /* Key for mapping */
  i64 iVal                        /* Expected value for mapping */
){
  int rc;
  sqlite3_stmt *pStmt;
  const char *azSql[2] = {
    "SELECT parentnode FROM %Q.'%q_parent' WHERE nodeno=?",
    "SELECT nodeno FROM %Q.'%q_rowid' WHERE rowid=?"
    "SELECT parentnode FROM %Q.'%q_parent' WHERE nodeno=?1",
    "SELECT nodeno FROM %Q.'%q_rowid' WHERE rowid=?1"
  };

  assert( bLeaf==0 || bLeaf==1 );
  if( pCheck->aCheckMapping[bLeaf]==0 ){
    pCheck->aCheckMapping[bLeaf] = rtreeCheckPrepare(pCheck,
        azSql[bLeaf], pCheck->zDb, pCheck->zTab
    );
172797
172798
172799
172800
172801
172802
172803

172804
172805
172806
172807
172808
172809
172810
172811
172812
172813
172814
172815
172816
172817










172818
172819
172820
172821
172822
172823

172824
172825
172826
172827
172828
172829
172830
174605
174606
174607
174608
174609
174610
174611
174612
174613
174614
174615
174616
174617
174618
174619
174620
174621
174622
174623
174624
174625
174626
174627
174628
174629
174630
174631
174632
174633
174634
174635
174636
174637
174638
174639
174640
174641

174642
174643
174644
174645
174646
174647
174648
174649







+














+
+
+
+
+
+
+
+
+
+





-
+







  const char *zDb,                /* Name of db ("main", "temp" etc.) */
  const char *zTab,               /* Name of rtree table to check */
  char **pzReport                 /* OUT: sqlite3_malloc'd report text */
){
  RtreeCheck check;               /* Common context for various routines */
  sqlite3_stmt *pStmt = 0;        /* Used to find column count of rtree table */
  int bEnd = 0;                   /* True if transaction should be closed */
  int nAux = 0;                   /* Number of extra columns. */

  /* Initialize the context object */
  memset(&check, 0, sizeof(check));
  check.db = db;
  check.zDb = zDb;
  check.zTab = zTab;

  /* If there is not already an open transaction, open one now. This is
  ** to ensure that the queries run as part of this integrity-check operate
  ** on a consistent snapshot.  */
  if( sqlite3_get_autocommit(db) ){
    check.rc = sqlite3_exec(db, "BEGIN", 0, 0, 0);
    bEnd = 1;
  }

  /* Find the number of auxiliary columns */
  if( check.rc==SQLITE_OK ){
    pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab);
    if( pStmt ){
      nAux = sqlite3_column_count(pStmt) - 2;
      sqlite3_finalize(pStmt);
    }
    check.rc = SQLITE_OK;
  }

  /* Find number of dimensions in the rtree table. */
  pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.%Q", zDb, zTab);
  if( pStmt ){
    int rc;
    check.nDim = (sqlite3_column_count(pStmt) - 1) / 2;
    check.nDim = (sqlite3_column_count(pStmt) - 1 - nAux) / 2;
    if( check.nDim<1 ){
      rtreeCheckAppendMsg(&check, "Schema corrupt or not an rtree");
    }else if( SQLITE_ROW==sqlite3_step(pStmt) ){
      check.bInt = (sqlite3_column_type(pStmt, 1)==SQLITE_INTEGER);
    }
    rc = sqlite3_finalize(pStmt);
    if( rc!=SQLITE_CORRUPT ) check.rc = rc;
174666
174667
174668
174669
174670
174671
174672




174673
174674
174675
174676
174677
174678
174679
174680
174681
174682

174683
174684
174685
174686
174687
174688
174689
176485
176486
176487
176488
176489
176490
176491
176492
176493
176494
176495
176496
176497
176498
176499
176500
176501
176502
176503
176504
176505
176506
176507
176508
176509
176510
176511
176512
176513







+
+
+
+










+







**
** RBU_STATE_COOKIE:
**   Valid if STAGE==1. The current change-counter cookie value in the 
**   target db file.
**
** RBU_STATE_OALSZ:
**   Valid if STAGE==1. The size in bytes of the *-oal file.
**
** RBU_STATE_DATATBL:
**   Only valid if STAGE==1. The RBU database name of the table 
**   currently being read.
*/
#define RBU_STATE_STAGE        1
#define RBU_STATE_TBL          2
#define RBU_STATE_IDX          3
#define RBU_STATE_ROW          4
#define RBU_STATE_PROGRESS     5
#define RBU_STATE_CKPT         6
#define RBU_STATE_COOKIE       7
#define RBU_STATE_OALSZ        8
#define RBU_STATE_PHASEONESTEP 9
#define RBU_STATE_DATATBL     10

#define RBU_STAGE_OAL         1
#define RBU_STAGE_MOVE        2
#define RBU_STAGE_CAPTURE     3
#define RBU_STAGE_CKPT        4
#define RBU_STAGE_DONE        5

174718
174719
174720
174721
174722
174723
174724

174725
174726
174727
174728
174729
174730
174731
176542
176543
176544
176545
176546
176547
176548
176549
176550
176551
176552
176553
176554
176555
176556







+








/*
** A structure to store values read from the rbu_state table in memory.
*/
struct RbuState {
  int eStage;
  char *zTbl;
  char *zDataTbl;
  char *zIdx;
  i64 iWalCksum;
  int nRow;
  i64 nProgress;
  u32 iCookie;
  i64 iOalSz;
  i64 nPhaseOneStep;
176781
176782
176783
176784
176785
176786
176787

176788
176789
176790
176791
176792
176793
176794
178606
178607
178608
178609
178610
178611
178612
178613
178614
178615
178616
178617
178618
178619
178620







+








/*
** Free an RbuState object allocated by rbuLoadState().
*/
static void rbuFreeState(RbuState *p){
  if( p ){
    sqlite3_free(p->zTbl);
    sqlite3_free(p->zDataTbl);
    sqlite3_free(p->zIdx);
    sqlite3_free(p);
  }
}

/*
** Allocate an RbuState object and load the contents of the rbu_state 
176850
176851
176852
176853
176854
176855
176856




176857
176858
176859
176860
176861
176862
176863
178676
178677
178678
178679
178680
178681
178682
178683
178684
178685
178686
178687
178688
178689
178690
178691
178692
178693







+
+
+
+







      case RBU_STATE_OALSZ:
        pRet->iOalSz = (u32)sqlite3_column_int64(pStmt, 1);
        break;

      case RBU_STATE_PHASEONESTEP:
        pRet->nPhaseOneStep = sqlite3_column_int64(pStmt, 1);
        break;

      case RBU_STATE_DATATBL:
        pRet->zDataTbl = rbuStrndup((char*)sqlite3_column_text(pStmt, 1), &rc);
        break;

      default:
        rc = SQLITE_CORRUPT;
        break;
    }
  }
  rc2 = sqlite3_finalize(pStmt);
177625
177626
177627
177628
177629
177630
177631
177632


177633
177634
177635
177636
177637
177638
177639
177640
177641
177642


177643
177644
177645
177646
177647
177648
177649
179455
179456
179457
179458
179459
179460
179461

179462
179463
179464
179465
179466
179467
179468
179469
179470
179471
179472

179473
179474
179475
179476
179477
179478
179479
179480
179481







-
+
+









-
+
+







          "(%d, %Q), "
          "(%d, %Q), "
          "(%d, %d), "
          "(%d, %d), "
          "(%d, %lld), "
          "(%d, %lld), "
          "(%d, %lld), "
          "(%d, %lld) ",
          "(%d, %lld), "
          "(%d, %Q)  ",
          p->zStateDb,
          RBU_STATE_STAGE, eStage,
          RBU_STATE_TBL, p->objiter.zTbl, 
          RBU_STATE_IDX, p->objiter.zIdx, 
          RBU_STATE_ROW, p->nStep, 
          RBU_STATE_PROGRESS, p->nProgress,
          RBU_STATE_CKPT, p->iWalCksum,
          RBU_STATE_COOKIE, (i64)pFd->iCookie,
          RBU_STATE_OALSZ, p->iOalSz,
          RBU_STATE_PHASEONESTEP, p->nPhaseOneStep
          RBU_STATE_PHASEONESTEP, p->nPhaseOneStep,
          RBU_STATE_DATATBL, p->objiter.zDataTbl
      )
    );
    assert( pInsert==0 || rc==SQLITE_OK );

    if( rc==SQLITE_OK ){
      sqlite3_step(pInsert);
      rc = sqlite3_finalize(pInsert);
177891
177892
177893
177894
177895
177896
177897
177898


177899
177900
177901
177902
177903
177904
177905
179723
179724
179725
179726
179727
179728
179729

179730
179731
179732
179733
179734
179735
179736
179737
179738







-
+
+







  assert( p->rc==SQLITE_OK );
  if( pState->zTbl ){
    RbuObjIter *pIter = &p->objiter;
    int rc = SQLITE_OK;

    while( rc==SQLITE_OK && pIter->zTbl && (pIter->bCleanup 
       || rbuStrCompare(pIter->zIdx, pState->zIdx)
       || rbuStrCompare(pIter->zTbl, pState->zTbl) 
       || (pState->zDataTbl==0 && rbuStrCompare(pIter->zTbl, pState->zTbl))
       || (pState->zDataTbl && rbuStrCompare(pIter->zDataTbl, pState->zDataTbl))
    )){
      rc = rbuObjIterNext(p, pIter);
    }

    if( rc==SQLITE_OK && !pIter->zTbl ){
      rc = SQLITE_ERROR;
      p->zErrmsg = sqlite3_mprintf("rbu_state mismatch error");
188010
188011
188012
188013
188014
188015
188016
188017

188018
188019
188020
188021
188022
188023
188024
189843
189844
189845
189846
189847
189848
189849

189850
189851
189852
189853
189854
189855
189856
189857







-
+







        if( p->zRoot ){
          jsonAppendRaw(&x, p->zRoot, (int)strlen(p->zRoot));
        }else{
          jsonAppendChar(&x, '$');
        }
        if( p->eType==JSON_ARRAY ){
          jsonPrintf(30, &x, "[%d]", p->iRowid);
        }else{
        }else if( p->eType==JSON_OBJECT ){
          jsonPrintf(pThis->n, &x, ".%.*s", pThis->n-2, pThis->u.zJContent+1);
        }
      }
      jsonResult(&x);
      break;
    }
    case JEACH_PATH: {
189815
189816
189817
189818
189819
189820
189821

189822
189823

189824
189825
189826
189827
189828
189829
189830
189831
189832
189833
189834
189835
189836
189837
189838
189839
189840
189841
189842
189843

189844
189845
189846
189847
189848
189849
189850
189851



189852
189853

189854
189855
189856
189857
189858
189859

189860
189861







189862
189863
189864
189865
189866
189867
189868
191648
191649
191650
191651
191652
191653
191654
191655
191656
191657
191658
191659
191660
191661
191662
191663
191664
191665
191666
191667
191668
191669
191670
191671
191672
191673
191674
191675
191676
191677

191678
191679
191680
191681
191682
191683
191684


191685
191686
191687


191688
191689
191690
191691
191692
191693
191694
191695


191696
191697
191698
191699
191700
191701
191702
191703
191704
191705
191706
191707
191708
191709







+


+



















-
+






-
-
+
+
+
-
-
+






+
-
-
+
+
+
+
+
+
+







**                       This is typically a union of many types, one of
**                       which is sqlite3Fts5ParserFTS5TOKENTYPE.  The entry in the union
**                       for terminal symbols is called "fts5yy0".
**    fts5YYSTACKDEPTH       is the maximum depth of the parser's stack.  If
**                       zero the stack is dynamically sized using realloc()
**    sqlite3Fts5ParserARG_SDECL     A static variable declaration for the %extra_argument
**    sqlite3Fts5ParserARG_PDECL     A parameter declaration for the %extra_argument
**    sqlite3Fts5ParserARG_PARAM     Code to pass %extra_argument as a subroutine parameter
**    sqlite3Fts5ParserARG_STORE     Code to store %extra_argument into fts5yypParser
**    sqlite3Fts5ParserARG_FETCH     Code to extract %extra_argument from fts5yypParser
**    sqlite3Fts5ParserCTX_*         As sqlite3Fts5ParserARG_ except for %extra_context
**    fts5YYERRORSYMBOL      is the code number of the error symbol.  If not
**                       defined, then do no error processing.
**    fts5YYNSTATE           the combined number of states.
**    fts5YYNRULE            the number of rules in the grammar
**    fts5YYNFTS5TOKEN           Number of terminal symbols
**    fts5YY_MAX_SHIFT       Maximum value for shift actions
**    fts5YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
**    fts5YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
**    fts5YY_ERROR_ACTION    The fts5yy_action[] code for syntax error
**    fts5YY_ACCEPT_ACTION   The fts5yy_action[] code for accept
**    fts5YY_NO_ACTION       The fts5yy_action[] code for no-op
**    fts5YY_MIN_REDUCE      Minimum value for reduce actions
**    fts5YY_MAX_REDUCE      Maximum value for reduce actions
*/
#ifndef INTERFACE
# define INTERFACE 1
#endif
/************* Begin control #defines *****************************************/
#define fts5YYCODETYPE unsigned char
#define fts5YYNOCODE 29
#define fts5YYNOCODE 27
#define fts5YYACTIONTYPE unsigned char
#define sqlite3Fts5ParserFTS5TOKENTYPE Fts5Token
typedef union {
  int fts5yyinit;
  sqlite3Fts5ParserFTS5TOKENTYPE fts5yy0;
  int fts5yy4;
  Fts5ExprPhrase* fts5yy11;
  Fts5ExprNearset* fts5yy14;
  Fts5Colset* fts5yy11;
  Fts5ExprNode* fts5yy24;
  Fts5ExprNearset* fts5yy46;
  Fts5Colset* fts5yy43;
  Fts5ExprNode* fts5yy54;
  Fts5ExprPhrase* fts5yy53;
} fts5YYMINORTYPE;
#ifndef fts5YYSTACKDEPTH
#define fts5YYSTACKDEPTH 100
#endif
#define sqlite3Fts5ParserARG_SDECL Fts5Parse *pParse;
#define sqlite3Fts5ParserARG_PDECL ,Fts5Parse *pParse
#define sqlite3Fts5ParserARG_PARAM ,pParse
#define sqlite3Fts5ParserARG_FETCH Fts5Parse *pParse = fts5yypParser->pParse
#define sqlite3Fts5ParserARG_STORE fts5yypParser->pParse = pParse
#define sqlite3Fts5ParserARG_FETCH Fts5Parse *pParse=fts5yypParser->pParse;
#define sqlite3Fts5ParserARG_STORE fts5yypParser->pParse=pParse;
#define sqlite3Fts5ParserCTX_SDECL
#define sqlite3Fts5ParserCTX_PDECL
#define sqlite3Fts5ParserCTX_PARAM
#define sqlite3Fts5ParserCTX_FETCH
#define sqlite3Fts5ParserCTX_STORE
#define fts5YYNSTATE             35
#define fts5YYNRULE              28
#define fts5YYNFTS5TOKEN             16
#define fts5YY_MAX_SHIFT         34
#define fts5YY_MIN_SHIFTREDUCE   52
#define fts5YY_MAX_SHIFTREDUCE   79
#define fts5YY_ERROR_ACTION      80
189935
189936
189937
189938
189939
189940
189941
189942
189943
189944
189945
189946
189947
189948
189949
189950









189951
189952
189953
189954
189955
189956
189957
189958
189959
189960
189961
189962
189963
189964
189965













189966
189967
189968
189969

189970
189971
189972
189973
189974




189975
189976
189977
189978


189979
189980
189981


189982
189983
189984
189985
189986
189987
189988
191776
191777
191778
191779
191780
191781
191782









191783
191784
191785
191786
191787
191788
191789
191790
191791
191792
191793













191794
191795
191796
191797
191798
191799
191800
191801
191802
191803
191804
191805
191806
191807
191808
191809

191810
191811




191812
191813
191814
191815
191816
191817


191818
191819
191820


191821
191822
191823
191824
191825
191826
191827
191828
191829







-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+


-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+



-
+

-
-
-
-
+
+
+
+


-
-
+
+

-
-
+
+







**  fts5yy_default[]       Default action for each state.
**
*********** Begin parsing tables **********************************************/
#define fts5YY_ACTTAB_COUNT (105)
static const fts5YYACTIONTYPE fts5yy_action[] = {
 /*     0 */    81,   20,   96,    6,   28,   99,   98,   26,   26,   18,
 /*    10 */    96,    6,   28,   17,   98,   56,   26,   19,   96,    6,
 /*    20 */    28,   14,   98,  108,   26,   92,   96,    6,   28,   25,
 /*    30 */    98,   78,   26,   21,   96,    6,   28,  107,   98,   58,
 /*    40 */    26,   29,   96,    6,   28,   32,   98,   22,   26,   24,
 /*    50 */    16,   23,   11,    1,   14,   13,   24,   16,   31,   11,
 /*    60 */     3,   97,   13,   27,    8,   98,   82,   26,    7,    4,
 /*    70 */     5,    3,    4,    5,    3,   83,    4,    5,    3,   63,
 /*    80 */    33,   34,   62,   12,    2,   86,   13,   10,   12,   71,
 /*    90 */    10,   13,   78,    5,    3,   78,    9,   30,   75,   82,
 /*   100 */    54,   57,   53,   57,   15,
 /*    20 */    28,   14,   98,   14,   26,   31,   92,   96,    6,   28,
 /*    30 */   108,   98,   25,   26,   21,   96,    6,   28,   78,   98,
 /*    40 */    58,   26,   29,   96,    6,   28,  107,   98,   22,   26,
 /*    50 */    24,   16,   12,   11,    1,   13,   13,   24,   16,   23,
 /*    60 */    11,   33,   34,   13,   97,    8,   27,   32,   98,    7,
 /*    70 */    26,    3,    4,    5,    3,    4,    5,    3,   83,    4,
 /*    80 */     5,    3,   63,    5,    3,   62,   12,    2,   86,   13,
 /*    90 */     9,   30,   10,   10,   54,   57,   75,   78,   78,   53,
 /*   100 */    57,   15,   82,   82,   71,
};
static const fts5YYCODETYPE fts5yy_lookahead[] = {
 /*     0 */    17,   18,   19,   20,   21,   23,   23,   25,   25,   18,
 /*    10 */    19,   20,   21,    7,   23,    9,   25,   18,   19,   20,
 /*    20 */    21,    9,   23,   27,   25,   18,   19,   20,   21,   25,
 /*    30 */    23,   15,   25,   18,   19,   20,   21,   27,   23,    9,
 /*    40 */    25,   18,   19,   20,   21,   14,   23,   22,   25,    6,
 /*    50 */     7,   22,    9,   10,    9,   12,    6,    7,   13,    9,
 /*    60 */     3,   19,   12,   21,    5,   23,   28,   25,    5,    1,
 /*    70 */     2,    3,    1,    2,    3,    0,    1,    2,    3,   11,
 /*    80 */    25,   26,   11,    9,   10,    5,   12,   10,    9,   11,
 /*    90 */    10,   12,   15,    2,    3,   15,   24,   25,    9,   28,
 /*   100 */     8,    9,    8,    9,    9,   28,   28,   28,   28,   28,
 /*   110 */    28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
 /*   120 */    28,
 /*     0 */    16,   17,   18,   19,   20,   22,   22,   24,   24,   17,
 /*    10 */    18,   19,   20,    7,   22,    9,   24,   17,   18,   19,
 /*    20 */    20,    9,   22,    9,   24,   13,   17,   18,   19,   20,
 /*    30 */    26,   22,   24,   24,   17,   18,   19,   20,   15,   22,
 /*    40 */     9,   24,   17,   18,   19,   20,   26,   22,   21,   24,
 /*    50 */     6,    7,    9,    9,   10,   12,   12,    6,    7,   21,
 /*    60 */     9,   24,   25,   12,   18,    5,   20,   14,   22,    5,
 /*    70 */    24,    3,    1,    2,    3,    1,    2,    3,    0,    1,
 /*    80 */     2,    3,   11,    2,    3,   11,    9,   10,    5,   12,
 /*    90 */    23,   24,   10,   10,    8,    9,    9,   15,   15,    8,
 /*   100 */     9,    9,   27,   27,   11,   27,   27,   27,   27,   27,
 /*   110 */    27,   27,   27,   27,   27,   27,   27,   27,   27,   27,
 /*   120 */    27,
};
#define fts5YY_SHIFT_COUNT    (34)
#define fts5YY_SHIFT_MIN      (0)
#define fts5YY_SHIFT_MAX      (95)
#define fts5YY_SHIFT_MAX      (93)
static const unsigned char fts5yy_shift_ofst[] = {
 /*     0 */    43,   43,   43,   43,   43,   43,   50,   74,   79,   45,
 /*    10 */    12,   80,   77,   12,   16,   16,   30,   30,   68,   71,
 /*    20 */    75,   91,   92,   94,    6,   31,   31,   59,   63,   57,
 /*    30 */    31,   89,   95,   31,   78,
 /*     0 */    44,   44,   44,   44,   44,   44,   51,   77,   43,   12,
 /*    10 */    14,   83,   82,   14,   23,   23,   31,   31,   71,   74,
 /*    20 */    78,   81,   86,   91,    6,   53,   53,   60,   64,   68,
 /*    30 */    53,   87,   92,   53,   93,
};
#define fts5YY_REDUCE_COUNT (17)
#define fts5YY_REDUCE_MIN   (-18)
#define fts5YY_REDUCE_MAX   (72)
#define fts5YY_REDUCE_MIN   (-17)
#define fts5YY_REDUCE_MAX   (67)
static const signed char fts5yy_reduce_ofst[] = {
 /*     0 */   -17,   -9,   -1,    7,   15,   23,   42,  -18,  -18,   55,
 /*    10 */    72,   -4,   -4,    4,   -4,   10,   25,   29,
 /*     0 */   -16,   -8,    0,    9,   17,   25,   46,  -17,  -17,   37,
 /*    10 */    67,    4,    4,    8,    4,   20,   27,   38,
};
static const fts5YYACTIONTYPE fts5yy_default[] = {
 /*     0 */    80,   80,   80,   80,   80,   80,   95,   80,   80,  105,
 /*    10 */    80,  110,  110,   80,  110,  110,   80,   80,   80,   80,
 /*    20 */    80,   91,   80,   80,   80,  101,  100,   80,   80,   90,
 /*    30 */   103,   80,   80,  104,   80,
};
190039
190040
190041
190042
190043
190044
190045

190046
190047
190048
190049
190050
190051
190052
191880
191881
191882
191883
191884
191885
191886
191887
191888
191889
191890
191891
191892
191893
191894







+







#ifdef fts5YYTRACKMAXSTACKDEPTH
  int fts5yyhwm;                    /* High-water mark of the stack */
#endif
#ifndef fts5YYNOERRORRECOVERY
  int fts5yyerrcnt;                 /* Shifts left before out of the error */
#endif
  sqlite3Fts5ParserARG_SDECL                /* A place to hold %extra_argument */
  sqlite3Fts5ParserCTX_SDECL                /* A place to hold %extra_context */
#if fts5YYSTACKDEPTH<=0
  int fts5yystksz;                  /* Current side of the stack */
  fts5yyStackEntry *fts5yystack;        /* The parser's stack */
  fts5yyStackEntry fts5yystk0;          /* First stack entry */
#else
  fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH];  /* The parser's stack */
  fts5yyStackEntry *fts5yystackEnd;            /* Last entry in the stack */
190102
190103
190104
190105
190106
190107
190108
190109
190110
190111
190112
190113
190114
190115
190116
190117
190118
190119











190120
190121
190122
190123
190124
190125
190126
190127
191944
191945
191946
191947
191948
191949
191950











191951
191952
191953
191954
191955
191956
191957
191958
191959
191960
191961

191962
191963
191964
191965
191966
191967
191968







-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-







  /*    9 */ "STRING",
  /*   10 */ "LP",
  /*   11 */ "RP",
  /*   12 */ "CARET",
  /*   13 */ "COMMA",
  /*   14 */ "PLUS",
  /*   15 */ "STAR",
  /*   16 */ "error",
  /*   17 */ "input",
  /*   18 */ "expr",
  /*   19 */ "cnearset",
  /*   20 */ "exprlist",
  /*   21 */ "colset",
  /*   22 */ "colsetlist",
  /*   23 */ "nearset",
  /*   24 */ "nearphrases",
  /*   25 */ "phrase",
  /*   26 */ "neardist_opt",
  /*   16 */ "input",
  /*   17 */ "expr",
  /*   18 */ "cnearset",
  /*   19 */ "exprlist",
  /*   20 */ "colset",
  /*   21 */ "colsetlist",
  /*   22 */ "nearset",
  /*   23 */ "nearphrases",
  /*   24 */ "phrase",
  /*   25 */ "neardist_opt",
  /*   26 */ "star_opt",
  /*   27 */ "star_opt",
};
#endif /* defined(fts5YYCOVERAGE) || !defined(NDEBUG) */

#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
*/
static const char *const fts5yyRuleName[] = {
190197
190198
190199
190200
190201
190202
190203
190204
190205



190206
190207

190208
190209
190210
190211
190212
190213
190214
190215






190216
190217
190218
190219

190220
190221
190222
190223



190224
190225

190226
190227
190228
190229
190230
190231
190232
190233
190234
190235
190236
190237
190238
190239
190240
190241
190242
190243
190244
190245
190246








190247
190248
190249
190250
190251
190252
190253
190254
190255
190256
190257
190258
190259
190260
190261
190262
190263


190264
190265
190266
190267
190268
190269
190270
190271
190272
190273
190274
190275
190276

190277
190278
190279
190280
190281
190282
190283



190284
190285

190286
190287
190288
190289


190290
190291

190292
190293
190294
190295


190296
190297

190298
190299
190300

190301
190302

190303
190304
190305
190306
190307
190308
190309
192038
192039
192040
192041
192042
192043
192044


192045
192046
192047
192048

192049
192050
192051






192052
192053
192054
192055
192056
192057
192058
192059
192060

192061
192062



192063
192064
192065
192066

192067
192068
192069
192070
192071
192072
192073
192074
192075
192076
192077
192078
192079
192080
192081
192082
192083





192084
192085
192086
192087
192088
192089
192090
192091
192092
192093
192094
192095
192096
192097
192098
192099
192100
192101
192102
192103
192104
192105
192106
192107

192108
192109
192110
192111
192112
192113
192114
192115
192116
192117
192118
192119
192120
192121

192122
192123
192124
192125
192126



192127
192128
192129
192130

192131
192132
192133


192134
192135
192136

192137
192138
192139


192140
192141
192142

192143
192144
192145

192146
192147

192148
192149
192150
192151
192152
192153
192154
192155







-
-
+
+
+

-
+


-
-
-
-
-
-
+
+
+
+
+
+



-
+

-
-
-
+
+
+

-
+
















-
-
-
-
-
+
+
+
+
+
+
+
+
















-
+
+












-
+




-
-
-
+
+
+

-
+


-
-
+
+

-
+


-
-
+
+

-
+


-
+

-
+







*/
#ifndef fts5YYMALLOCARGTYPE
# define fts5YYMALLOCARGTYPE size_t
#endif

/* Initialize a new parser that has already been allocated.
*/
static void sqlite3Fts5ParserInit(void *fts5yypParser){
  fts5yyParser *pParser = (fts5yyParser*)fts5yypParser;
static void sqlite3Fts5ParserInit(void *fts5yypRawParser sqlite3Fts5ParserCTX_PDECL){
  fts5yyParser *fts5yypParser = (fts5yyParser*)fts5yypRawParser;
  sqlite3Fts5ParserCTX_STORE
#ifdef fts5YYTRACKMAXSTACKDEPTH
  pParser->fts5yyhwm = 0;
  fts5yypParser->fts5yyhwm = 0;
#endif
#if fts5YYSTACKDEPTH<=0
  pParser->fts5yytos = NULL;
  pParser->fts5yystack = NULL;
  pParser->fts5yystksz = 0;
  if( fts5yyGrowStack(pParser) ){
    pParser->fts5yystack = &pParser->fts5yystk0;
    pParser->fts5yystksz = 1;
  fts5yypParser->fts5yytos = NULL;
  fts5yypParser->fts5yystack = NULL;
  fts5yypParser->fts5yystksz = 0;
  if( fts5yyGrowStack(fts5yypParser) ){
    fts5yypParser->fts5yystack = &fts5yypParser->fts5yystk0;
    fts5yypParser->fts5yystksz = 1;
  }
#endif
#ifndef fts5YYNOERRORRECOVERY
  pParser->fts5yyerrcnt = -1;
  fts5yypParser->fts5yyerrcnt = -1;
#endif
  pParser->fts5yytos = pParser->fts5yystack;
  pParser->fts5yystack[0].stateno = 0;
  pParser->fts5yystack[0].major = 0;
  fts5yypParser->fts5yytos = fts5yypParser->fts5yystack;
  fts5yypParser->fts5yystack[0].stateno = 0;
  fts5yypParser->fts5yystack[0].major = 0;
#if fts5YYSTACKDEPTH>0
  pParser->fts5yystackEnd = &pParser->fts5yystack[fts5YYSTACKDEPTH-1];
  fts5yypParser->fts5yystackEnd = &fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1];
#endif
}

#ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK
/* 
** This function allocates a new parser.
** The only argument is a pointer to a function which works like
** malloc.
**
** Inputs:
** A pointer to the function used to allocate memory.
**
** Outputs:
** A pointer to a parser.  This pointer is used in subsequent calls
** to sqlite3Fts5Parser and sqlite3Fts5ParserFree.
*/
static void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE)){
  fts5yyParser *pParser;
  pParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) );
  if( pParser ) sqlite3Fts5ParserInit(pParser);
  return pParser;
static void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE) sqlite3Fts5ParserCTX_PDECL){
  fts5yyParser *fts5yypParser;
  fts5yypParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) );
  if( fts5yypParser ){
    sqlite3Fts5ParserCTX_STORE
    sqlite3Fts5ParserInit(fts5yypParser sqlite3Fts5ParserCTX_PARAM);
  }
  return (void*)fts5yypParser;
}
#endif /* sqlite3Fts5Parser_ENGINEALWAYSONSTACK */


/* The following function deletes the "minor type" or semantic value
** associated with a symbol.  The symbol can be either a terminal
** or nonterminal. "fts5yymajor" is the symbol code, and "fts5yypminor" is
** a pointer to the value to be deleted.  The code used to do the 
** deletions is derived from the %destructor and/or %token_destructor
** directives of the input grammar.
*/
static void fts5yy_destructor(
  fts5yyParser *fts5yypParser,    /* The parser */
  fts5YYCODETYPE fts5yymajor,     /* Type code for object to destroy */
  fts5YYMINORTYPE *fts5yypminor   /* The object to be destroyed */
){
  sqlite3Fts5ParserARG_FETCH;
  sqlite3Fts5ParserARG_FETCH
  sqlite3Fts5ParserCTX_FETCH
  switch( fts5yymajor ){
    /* Here is inserted the actions which take place when a
    ** terminal or non-terminal is destroyed.  This can happen
    ** when the symbol is popped from the stack during a
    ** reduce or during error processing or when a parser is 
    ** being destroyed before it is finished parsing.
    **
    ** Note: during a reduce, the only symbols destroyed are those
    ** which appear on the RHS of the rule, but which are *not* used
    ** inside the C code.
    */
/********* Begin destructor definitions ***************************************/
    case 17: /* input */
    case 16: /* input */
{
 (void)pParse; 
}
      break;
    case 18: /* expr */
    case 19: /* cnearset */
    case 20: /* exprlist */
    case 17: /* expr */
    case 18: /* cnearset */
    case 19: /* exprlist */
{
 sqlite3Fts5ParseNodeFree((fts5yypminor->fts5yy54)); 
 sqlite3Fts5ParseNodeFree((fts5yypminor->fts5yy24)); 
}
      break;
    case 21: /* colset */
    case 22: /* colsetlist */
    case 20: /* colset */
    case 21: /* colsetlist */
{
 sqlite3_free((fts5yypminor->fts5yy43)); 
 sqlite3_free((fts5yypminor->fts5yy11)); 
}
      break;
    case 23: /* nearset */
    case 24: /* nearphrases */
    case 22: /* nearset */
    case 23: /* nearphrases */
{
 sqlite3Fts5ParseNearsetFree((fts5yypminor->fts5yy14)); 
 sqlite3Fts5ParseNearsetFree((fts5yypminor->fts5yy46)); 
}
      break;
    case 25: /* phrase */
    case 24: /* phrase */
{
 sqlite3Fts5ParsePhraseFree((fts5yypminor->fts5yy11)); 
 sqlite3Fts5ParsePhraseFree((fts5yypminor->fts5yy53)); 
}
      break;
/********* End destructor definitions *****************************************/
    default:  break;   /* If no destructor action specified: do nothing */
  }
}

190407
190408
190409
190410
190411
190412
190413
190414

190415
190416


190417
190418
190419
190420

190421
190422
190423
190424
190425
190426
190427
192253
192254
192255
192256
192257
192258
192259

192260


192261
192262
192263
192264


192265
192266
192267
192268
192269
192270
192271
192272







-
+
-
-
+
+


-
-
+







}
#endif

/*
** Find the appropriate action for a parser given the terminal
** look-ahead token iLookAhead.
*/
static unsigned int fts5yy_find_shift_action(
static fts5YYACTIONTYPE fts5yy_find_shift_action(
  fts5yyParser *pParser,        /* The parser */
  fts5YYCODETYPE iLookAhead     /* The look-ahead token */
  fts5YYCODETYPE iLookAhead,    /* The look-ahead token */
  fts5YYACTIONTYPE stateno      /* Current state number */
){
  int i;
  int stateno = pParser->fts5yytos->stateno;
 

  if( stateno>fts5YY_MAX_SHIFT ) return stateno;
  assert( stateno <= fts5YY_SHIFT_COUNT );
#if defined(fts5YYCOVERAGE)
  fts5yycoverage[stateno][iLookAhead] = 1;
#endif
  do{
    i = fts5yy_shift_ofst[stateno];
190477
190478
190479
190480
190481
190482
190483
190484

190485
190486
190487
190488
190489
190490
190491
192322
192323
192324
192325
192326
192327
192328

192329
192330
192331
192332
192333
192334
192335
192336







-
+







}

/*
** Find the appropriate action for a parser given the non-terminal
** look-ahead token iLookAhead.
*/
static int fts5yy_find_reduce_action(
  int stateno,              /* Current state number */
  fts5YYACTIONTYPE stateno,     /* Current state number */
  fts5YYCODETYPE iLookAhead     /* The look-ahead token */
){
  int i;
#ifdef fts5YYERRORSYMBOL
  if( stateno>fts5YY_REDUCE_COUNT ){
    return fts5yy_default[stateno];
  }
190506
190507
190508
190509
190510
190511
190512
190513


190514
190515
190516
190517
190518
190519
190520
190521
190522
190523
190524
190525
190526


190527
190528
190529
190530
190531
190532
190533
192351
192352
192353
192354
192355
192356
192357

192358
192359
192360
192361
192362
192363
192364
192365
192366
192367
192368
192369
192370
192371

192372
192373
192374
192375
192376
192377
192378
192379
192380







-
+
+












-
+
+







  return fts5yy_action[i];
}

/*
** The following routine is called if the stack overflows.
*/
static void fts5yyStackOverflow(fts5yyParser *fts5yypParser){
   sqlite3Fts5ParserARG_FETCH;
   sqlite3Fts5ParserARG_FETCH
   sqlite3Fts5ParserCTX_FETCH
#ifndef NDEBUG
   if( fts5yyTraceFILE ){
     fprintf(fts5yyTraceFILE,"%sStack Overflow!\n",fts5yyTracePrompt);
   }
#endif
   while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);
   /* Here code is inserted which will execute if the parser
   ** stack every overflows */
/******** Begin %stack_overflow code ******************************************/

  sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow");
/******** End %stack_overflow code ********************************************/
   sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument var */
   sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument var */
   sqlite3Fts5ParserCTX_STORE
}

/*
** Print tracing information for a SHIFT action
*/
#ifndef NDEBUG
static void fts5yyTraceShift(fts5yyParser *fts5yypParser, int fts5yyNewState, const char *zTag){
190548
190549
190550
190551
190552
190553
190554
190555
190556


190557
190558
190559
190560
190561
190562
190563
192395
192396
192397
192398
192399
192400
192401


192402
192403
192404
192405
192406
192407
192408
192409
192410







-
-
+
+







#endif

/*
** Perform a shift action.
*/
static void fts5yy_shift(
  fts5yyParser *fts5yypParser,          /* The parser to be shifted */
  int fts5yyNewState,               /* The new state to shift in */
  int fts5yyMajor,                  /* The major token to shift in */
  fts5YYACTIONTYPE fts5yyNewState,      /* The new state to shift in */
  fts5YYCODETYPE fts5yyMajor,           /* The major token to shift in */
  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyMinor        /* The minor token to shift in */
){
  fts5yyStackEntry *fts5yytos;
  fts5yypParser->fts5yytos++;
#ifdef fts5YYTRACKMAXSTACKDEPTH
  if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){
    fts5yypParser->fts5yyhwm++;
190579
190580
190581
190582
190583
190584
190585
190586
190587


190588
190589
190590
190591
190592
190593
190594
190595
190596
190597
190598
190599
190600
190601
190602
190603
190604
190605
190606
190607
190608
190609
190610
190611
190612
190613
190614
190615
190616
190617
190618
190619
190620
190621
190622
190623
190624
190625
190626




























190627
190628
190629
190630
190631
190632
190633
190634
190635
190636
190637
190638
190639
190640
190641

190642
190643
190644
190645

190646
190647
190648
190649
190650
190651

190652
190653
190654
190655
190656
190657
190658
192426
192427
192428
192429
192430
192431
192432


192433
192434
192435
192436
192437
192438
192439
192440
192441
192442
192443
192444
192445




























192446
192447
192448
192449
192450
192451
192452
192453
192454
192455
192456
192457
192458
192459
192460
192461
192462
192463
192464
192465
192466
192467
192468
192469
192470
192471
192472
192473
192474
192475
192476
192477
192478
192479
192480
192481
192482
192483
192484
192485
192486
192487

192488
192489
192490
192491
192492
192493
192494
192495
192496
192497
192498

192499
192500
192501
192502
192503
192504
192505
192506







-
-
+
+











-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+














-
+




+





-
+







    }
  }
#endif
  if( fts5yyNewState > fts5YY_MAX_SHIFT ){
    fts5yyNewState += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
  }
  fts5yytos = fts5yypParser->fts5yytos;
  fts5yytos->stateno = (fts5YYACTIONTYPE)fts5yyNewState;
  fts5yytos->major = (fts5YYCODETYPE)fts5yyMajor;
  fts5yytos->stateno = fts5yyNewState;
  fts5yytos->major = fts5yyMajor;
  fts5yytos->minor.fts5yy0 = fts5yyMinor;
  fts5yyTraceShift(fts5yypParser, fts5yyNewState, "Shift");
}

/* The following table contains information about every rule that
** is used during the reduce.
*/
static const struct {
  fts5YYCODETYPE lhs;       /* Symbol on the left-hand side of the rule */
  signed char nrhs;     /* Negative of the number of RHS symbols in the rule */
} fts5yyRuleInfo[] = {
  {   17,   -1 }, /* (0) input ::= expr */
  {   21,   -4 }, /* (1) colset ::= MINUS LCP colsetlist RCP */
  {   21,   -3 }, /* (2) colset ::= LCP colsetlist RCP */
  {   21,   -1 }, /* (3) colset ::= STRING */
  {   21,   -2 }, /* (4) colset ::= MINUS STRING */
  {   22,   -2 }, /* (5) colsetlist ::= colsetlist STRING */
  {   22,   -1 }, /* (6) colsetlist ::= STRING */
  {   18,   -3 }, /* (7) expr ::= expr AND expr */
  {   18,   -3 }, /* (8) expr ::= expr OR expr */
  {   18,   -3 }, /* (9) expr ::= expr NOT expr */
  {   18,   -5 }, /* (10) expr ::= colset COLON LP expr RP */
  {   18,   -3 }, /* (11) expr ::= LP expr RP */
  {   18,   -1 }, /* (12) expr ::= exprlist */
  {   20,   -1 }, /* (13) exprlist ::= cnearset */
  {   20,   -2 }, /* (14) exprlist ::= exprlist cnearset */
  {   19,   -1 }, /* (15) cnearset ::= nearset */
  {   19,   -3 }, /* (16) cnearset ::= colset COLON nearset */
  {   23,   -1 }, /* (17) nearset ::= phrase */
  {   23,   -2 }, /* (18) nearset ::= CARET phrase */
  {   23,   -5 }, /* (19) nearset ::= STRING LP nearphrases neardist_opt RP */
  {   24,   -1 }, /* (20) nearphrases ::= phrase */
  {   24,   -2 }, /* (21) nearphrases ::= nearphrases phrase */
  {   26,    0 }, /* (22) neardist_opt ::= */
  {   26,   -2 }, /* (23) neardist_opt ::= COMMA STRING */
  {   25,   -4 }, /* (24) phrase ::= phrase PLUS STRING star_opt */
  {   25,   -2 }, /* (25) phrase ::= STRING star_opt */
  {   27,   -1 }, /* (26) star_opt ::= STAR */
  {   27,    0 }, /* (27) star_opt ::= */
  {   16,   -1 }, /* (0) input ::= expr */
  {   20,   -4 }, /* (1) colset ::= MINUS LCP colsetlist RCP */
  {   20,   -3 }, /* (2) colset ::= LCP colsetlist RCP */
  {   20,   -1 }, /* (3) colset ::= STRING */
  {   20,   -2 }, /* (4) colset ::= MINUS STRING */
  {   21,   -2 }, /* (5) colsetlist ::= colsetlist STRING */
  {   21,   -1 }, /* (6) colsetlist ::= STRING */
  {   17,   -3 }, /* (7) expr ::= expr AND expr */
  {   17,   -3 }, /* (8) expr ::= expr OR expr */
  {   17,   -3 }, /* (9) expr ::= expr NOT expr */
  {   17,   -5 }, /* (10) expr ::= colset COLON LP expr RP */
  {   17,   -3 }, /* (11) expr ::= LP expr RP */
  {   17,   -1 }, /* (12) expr ::= exprlist */
  {   19,   -1 }, /* (13) exprlist ::= cnearset */
  {   19,   -2 }, /* (14) exprlist ::= exprlist cnearset */
  {   18,   -1 }, /* (15) cnearset ::= nearset */
  {   18,   -3 }, /* (16) cnearset ::= colset COLON nearset */
  {   22,   -1 }, /* (17) nearset ::= phrase */
  {   22,   -2 }, /* (18) nearset ::= CARET phrase */
  {   22,   -5 }, /* (19) nearset ::= STRING LP nearphrases neardist_opt RP */
  {   23,   -1 }, /* (20) nearphrases ::= phrase */
  {   23,   -2 }, /* (21) nearphrases ::= nearphrases phrase */
  {   25,    0 }, /* (22) neardist_opt ::= */
  {   25,   -2 }, /* (23) neardist_opt ::= COMMA STRING */
  {   24,   -4 }, /* (24) phrase ::= phrase PLUS STRING star_opt */
  {   24,   -2 }, /* (25) phrase ::= STRING star_opt */
  {   26,   -1 }, /* (26) star_opt ::= STAR */
  {   26,    0 }, /* (27) star_opt ::= */
};

static void fts5yy_accept(fts5yyParser*);  /* Forward Declaration */

/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
**
** The fts5yyLookahead and fts5yyLookaheadToken parameters provide reduce actions
** access to the lookahead token (if any).  The fts5yyLookahead will be fts5YYNOCODE
** if the lookahead token has already been consumed.  As this procedure is
** only called from one place, optimizing compilers will in-line it, which
** means that the extra parameters have no performance impact.
*/
static void fts5yy_reduce(
static fts5YYACTIONTYPE fts5yy_reduce(
  fts5yyParser *fts5yypParser,         /* The parser */
  unsigned int fts5yyruleno,       /* Number of the rule by which to reduce */
  int fts5yyLookahead,             /* Lookahead token, or fts5YYNOCODE if none */
  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyLookaheadToken  /* Value of the lookahead token */
  sqlite3Fts5ParserCTX_PDECL                   /* %extra_context */
){
  int fts5yygoto;                     /* The next state */
  int fts5yyact;                      /* The next action */
  fts5yyStackEntry *fts5yymsp;            /* The top of the parser's stack */
  int fts5yysize;                     /* Amount to pop the stack */
  sqlite3Fts5ParserARG_FETCH;
  sqlite3Fts5ParserARG_FETCH
  (void)fts5yyLookahead;
  (void)fts5yyLookaheadToken;
  fts5yymsp = fts5yypParser->fts5yytos;
#ifndef NDEBUG
  if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
    fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
    if( fts5yysize ){
190675
190676
190677
190678
190679
190680
190681



190682

190683
190684
190685
190686
190687



190688

190689
190690
190691
190692
190693
190694
190695
190696
190697
190698
190699
190700
190701
190702
190703
190704
190705
190706
190707

190708
190709
190710
190711

190712
190713
190714
190715

190716
190717
190718
190719

190720
190721

190722
190723
190724
190725
190726


190727
190728
190729
190730
190731
190732


190733
190734
190735
190736

190737
190738

190739
190740
190741
190742

190743
190744

190745
190746
190747
190748

190749
190750

190751
190752
190753
190754

190755
190756

190757
190758
190759
190760
190761


190762
190763

190764
190765
190766

190767
190768
190769
190770
190771


190772
190773
190774
190775

190776
190777

190778
190779
190780
190781

190782
190783

190784
190785
190786
190787
190788


190789
190790

190791
190792
190793
190794


190795
190796
190797
190798
190799


190800
190801
190802
190803
190804
190805
190806


190807
190808

190809
190810
190811
190812

190813
190814

190815
190816
190817
190818

190819
190820

190821
190822
190823
190824
190825
190826
190827
190828
190829
190830

190831
190832

190833
190834
190835
190836

190837
190838

190839
190840
190841
190842
190843
190844
190845
192523
192524
192525
192526
192527
192528
192529
192530
192531
192532

192533
192534
192535
192536
192537
192538
192539
192540
192541

192542
192543
192544
192545
192546
192547
192548
192549
192550
192551
192552
192553
192554
192555
192556
192557
192558
192559
192560

192561
192562
192563
192564

192565
192566
192567
192568

192569
192570
192571
192572

192573
192574

192575
192576
192577
192578


192579
192580
192581
192582
192583
192584


192585
192586
192587
192588
192589

192590
192591

192592
192593
192594
192595

192596
192597

192598
192599
192600
192601

192602
192603

192604
192605
192606
192607

192608
192609

192610
192611
192612
192613


192614
192615
192616

192617
192618
192619

192620
192621
192622
192623


192624
192625
192626
192627
192628

192629
192630

192631
192632
192633
192634

192635
192636

192637
192638
192639
192640


192641
192642
192643

192644
192645
192646


192647
192648
192649
192650
192651


192652
192653
192654
192655
192656
192657
192658


192659
192660
192661

192662
192663
192664
192665

192666
192667

192668
192669
192670
192671

192672
192673

192674
192675
192676
192677
192678
192679
192680
192681
192682
192683

192684
192685

192686
192687
192688
192689

192690
192691

192692
192693
192694
192695
192696
192697
192698
192699







+
+
+
-
+





+
+
+
-
+


















-
+



-
+



-
+



-
+

-
+



-
-
+
+




-
-
+
+



-
+

-
+



-
+

-
+



-
+

-
+



-
+

-
+



-
-
+
+

-
+


-
+



-
-
+
+



-
+

-
+



-
+

-
+



-
-
+
+

-
+


-
-
+
+



-
-
+
+





-
-
+
+

-
+



-
+

-
+



-
+

-
+









-
+

-
+



-
+

-
+







      fts5yypParser->fts5yyhwm++;
      assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));
    }
#endif
#if fts5YYSTACKDEPTH>0 
    if( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystackEnd ){
      fts5yyStackOverflow(fts5yypParser);
      /* The call to fts5yyStackOverflow() above pops the stack until it is
      ** empty, causing the main parser loop to exit.  So the return value
      ** is never used and does not matter. */
      return;
      return 0;
    }
#else
    if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){
      if( fts5yyGrowStack(fts5yypParser) ){
        fts5yyStackOverflow(fts5yypParser);
        /* The call to fts5yyStackOverflow() above pops the stack until it is
        ** empty, causing the main parser loop to exit.  So the return value
        ** is never used and does not matter. */
        return;
        return 0;
      }
      fts5yymsp = fts5yypParser->fts5yytos;
    }
#endif
  }

  switch( fts5yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
/********** Begin reduce actions **********************************************/
        fts5YYMINORTYPE fts5yylhsminor;
      case 0: /* input ::= expr */
{ sqlite3Fts5ParseFinished(pParse, fts5yymsp[0].minor.fts5yy54); }
{ sqlite3Fts5ParseFinished(pParse, fts5yymsp[0].minor.fts5yy24); }
        break;
      case 1: /* colset ::= MINUS LCP colsetlist RCP */
{ 
    fts5yymsp[-3].minor.fts5yy43 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy43);
    fts5yymsp[-3].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11);
}
        break;
      case 2: /* colset ::= LCP colsetlist RCP */
{ fts5yymsp[-2].minor.fts5yy43 = fts5yymsp[-1].minor.fts5yy43; }
{ fts5yymsp[-2].minor.fts5yy11 = fts5yymsp[-1].minor.fts5yy11; }
        break;
      case 3: /* colset ::= STRING */
{
  fts5yylhsminor.fts5yy43 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);
  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);
}
  fts5yymsp[0].minor.fts5yy43 = fts5yylhsminor.fts5yy43;
  fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
        break;
      case 4: /* colset ::= MINUS STRING */
{
  fts5yymsp[-1].minor.fts5yy43 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);
  fts5yymsp[-1].minor.fts5yy43 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy43);
  fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);
  fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11);
}
        break;
      case 5: /* colsetlist ::= colsetlist STRING */
{ 
  fts5yylhsminor.fts5yy43 = sqlite3Fts5ParseColset(pParse, fts5yymsp[-1].minor.fts5yy43, &fts5yymsp[0].minor.fts5yy0); }
  fts5yymsp[-1].minor.fts5yy43 = fts5yylhsminor.fts5yy43;
  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, fts5yymsp[-1].minor.fts5yy11, &fts5yymsp[0].minor.fts5yy0); }
  fts5yymsp[-1].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
        break;
      case 6: /* colsetlist ::= STRING */
{ 
  fts5yylhsminor.fts5yy43 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); 
  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); 
}
  fts5yymsp[0].minor.fts5yy43 = fts5yylhsminor.fts5yy43;
  fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
        break;
      case 7: /* expr ::= expr AND expr */
{
  fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_AND, fts5yymsp[-2].minor.fts5yy54, fts5yymsp[0].minor.fts5yy54, 0);
  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_AND, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);
}
  fts5yymsp[-2].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 8: /* expr ::= expr OR expr */
{
  fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_OR, fts5yymsp[-2].minor.fts5yy54, fts5yymsp[0].minor.fts5yy54, 0);
  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_OR, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);
}
  fts5yymsp[-2].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 9: /* expr ::= expr NOT expr */
{
  fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, fts5yymsp[-2].minor.fts5yy54, fts5yymsp[0].minor.fts5yy54, 0);
  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);
}
  fts5yymsp[-2].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 10: /* expr ::= colset COLON LP expr RP */
{
  sqlite3Fts5ParseSetColset(pParse, fts5yymsp[-1].minor.fts5yy54, fts5yymsp[-4].minor.fts5yy43);
  fts5yylhsminor.fts5yy54 = fts5yymsp[-1].minor.fts5yy54;
  sqlite3Fts5ParseSetColset(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[-4].minor.fts5yy11);
  fts5yylhsminor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;
}
  fts5yymsp[-4].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
  fts5yymsp[-4].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 11: /* expr ::= LP expr RP */
{fts5yymsp[-2].minor.fts5yy54 = fts5yymsp[-1].minor.fts5yy54;}
{fts5yymsp[-2].minor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;}
        break;
      case 12: /* expr ::= exprlist */
      case 13: /* exprlist ::= cnearset */ fts5yytestcase(fts5yyruleno==13);
{fts5yylhsminor.fts5yy54 = fts5yymsp[0].minor.fts5yy54;}
  fts5yymsp[0].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
{fts5yylhsminor.fts5yy24 = fts5yymsp[0].minor.fts5yy24;}
  fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 14: /* exprlist ::= exprlist cnearset */
{
  fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseImplicitAnd(pParse, fts5yymsp[-1].minor.fts5yy54, fts5yymsp[0].minor.fts5yy54);
  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseImplicitAnd(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24);
}
  fts5yymsp[-1].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
  fts5yymsp[-1].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 15: /* cnearset ::= nearset */
{ 
  fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy14); 
  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); 
}
  fts5yymsp[0].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
  fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 16: /* cnearset ::= colset COLON nearset */
{ 
  fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy14); 
  sqlite3Fts5ParseSetColset(pParse, fts5yylhsminor.fts5yy54, fts5yymsp[-2].minor.fts5yy43);
  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); 
  sqlite3Fts5ParseSetColset(pParse, fts5yylhsminor.fts5yy24, fts5yymsp[-2].minor.fts5yy11);
}
  fts5yymsp[-2].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 17: /* nearset ::= phrase */
{ fts5yylhsminor.fts5yy14 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy11); }
  fts5yymsp[0].minor.fts5yy14 = fts5yylhsminor.fts5yy14;
{ fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); }
  fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46;
        break;
      case 18: /* nearset ::= CARET phrase */
{ 
  sqlite3Fts5ParseSetCaret(fts5yymsp[0].minor.fts5yy11);
  fts5yymsp[-1].minor.fts5yy14 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy11); 
  sqlite3Fts5ParseSetCaret(fts5yymsp[0].minor.fts5yy53);
  fts5yymsp[-1].minor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); 
}
        break;
      case 19: /* nearset ::= STRING LP nearphrases neardist_opt RP */
{
  sqlite3Fts5ParseNear(pParse, &fts5yymsp[-4].minor.fts5yy0);
  sqlite3Fts5ParseSetDistance(pParse, fts5yymsp[-2].minor.fts5yy14, &fts5yymsp[-1].minor.fts5yy0);
  fts5yylhsminor.fts5yy14 = fts5yymsp[-2].minor.fts5yy14;
  sqlite3Fts5ParseSetDistance(pParse, fts5yymsp[-2].minor.fts5yy46, &fts5yymsp[-1].minor.fts5yy0);
  fts5yylhsminor.fts5yy46 = fts5yymsp[-2].minor.fts5yy46;
}
  fts5yymsp[-4].minor.fts5yy14 = fts5yylhsminor.fts5yy14;
  fts5yymsp[-4].minor.fts5yy46 = fts5yylhsminor.fts5yy46;
        break;
      case 20: /* nearphrases ::= phrase */
{ 
  fts5yylhsminor.fts5yy14 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy11); 
  fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); 
}
  fts5yymsp[0].minor.fts5yy14 = fts5yylhsminor.fts5yy14;
  fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46;
        break;
      case 21: /* nearphrases ::= nearphrases phrase */
{
  fts5yylhsminor.fts5yy14 = sqlite3Fts5ParseNearset(pParse, fts5yymsp[-1].minor.fts5yy14, fts5yymsp[0].minor.fts5yy11);
  fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, fts5yymsp[-1].minor.fts5yy46, fts5yymsp[0].minor.fts5yy53);
}
  fts5yymsp[-1].minor.fts5yy14 = fts5yylhsminor.fts5yy14;
  fts5yymsp[-1].minor.fts5yy46 = fts5yylhsminor.fts5yy46;
        break;
      case 22: /* neardist_opt ::= */
{ fts5yymsp[1].minor.fts5yy0.p = 0; fts5yymsp[1].minor.fts5yy0.n = 0; }
        break;
      case 23: /* neardist_opt ::= COMMA STRING */
{ fts5yymsp[-1].minor.fts5yy0 = fts5yymsp[0].minor.fts5yy0; }
        break;
      case 24: /* phrase ::= phrase PLUS STRING star_opt */
{ 
  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseTerm(pParse, fts5yymsp[-3].minor.fts5yy11, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);
  fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, fts5yymsp[-3].minor.fts5yy53, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);
}
  fts5yymsp[-3].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
  fts5yymsp[-3].minor.fts5yy53 = fts5yylhsminor.fts5yy53;
        break;
      case 25: /* phrase ::= STRING star_opt */
{ 
  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseTerm(pParse, 0, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);
  fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, 0, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);
}
  fts5yymsp[-1].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
  fts5yymsp[-1].minor.fts5yy53 = fts5yylhsminor.fts5yy53;
        break;
      case 26: /* star_opt ::= STAR */
{ fts5yymsp[0].minor.fts5yy4 = 1; }
        break;
      case 27: /* star_opt ::= */
{ fts5yymsp[1].minor.fts5yy4 = 0; }
        break;
190860
190861
190862
190863
190864
190865
190866

190867
190868
190869
190870
190871
190872
190873
190874
190875
190876


190877
190878
190879
190880
190881
190882
190883
190884
190885
190886
190887


190888
190889
190890
190891
190892
190893
190894
190895
190896
190897
190898
190899


190900
190901
190902
190903
190904
190905
190906
190907
190908


190909
190910
190911
190912
190913
190914
190915
190916
190917


190918
190919
190920
190921
190922
190923
190924
190925
190926
190927
190928
190929
190930
190931


190932
190933
190934
190935
190936
190937
190938
192714
192715
192716
192717
192718
192719
192720
192721
192722
192723
192724
192725
192726
192727
192728
192729
192730

192731
192732
192733
192734
192735
192736
192737
192738
192739
192740
192741
192742

192743
192744
192745
192746
192747
192748
192749
192750
192751
192752
192753
192754
192755

192756
192757
192758
192759
192760
192761
192762
192763
192764
192765

192766
192767
192768
192769
192770
192771
192772
192773
192774
192775

192776
192777
192778
192779
192780
192781
192782
192783
192784
192785
192786
192787
192788
192789
192790

192791
192792
192793
192794
192795
192796
192797
192798
192799







+









-
+
+










-
+
+











-
+
+








-
+
+








-
+
+













-
+
+







  assert( fts5yyact!=fts5YY_ERROR_ACTION );

  fts5yymsp += fts5yysize+1;
  fts5yypParser->fts5yytos = fts5yymsp;
  fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;
  fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;
  fts5yyTraceShift(fts5yypParser, fts5yyact, "... then shift");
  return fts5yyact;
}

/*
** The following code executes when the parse fails
*/
#ifndef fts5YYNOERRORRECOVERY
static void fts5yy_parse_failed(
  fts5yyParser *fts5yypParser           /* The parser */
){
  sqlite3Fts5ParserARG_FETCH;
  sqlite3Fts5ParserARG_FETCH
  sqlite3Fts5ParserCTX_FETCH
#ifndef NDEBUG
  if( fts5yyTraceFILE ){
    fprintf(fts5yyTraceFILE,"%sFail!\n",fts5yyTracePrompt);
  }
#endif
  while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);
  /* Here code is inserted which will be executed whenever the
  ** parser fails */
/************ Begin %parse_failure code ***************************************/
/************ End %parse_failure code *****************************************/
  sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
  sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
  sqlite3Fts5ParserCTX_STORE
}
#endif /* fts5YYNOERRORRECOVERY */

/*
** The following code executes when a syntax error first occurs.
*/
static void fts5yy_syntax_error(
  fts5yyParser *fts5yypParser,           /* The parser */
  int fts5yymajor,                   /* The major type of the error token */
  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyminor         /* The minor type of the error token */
){
  sqlite3Fts5ParserARG_FETCH;
  sqlite3Fts5ParserARG_FETCH
  sqlite3Fts5ParserCTX_FETCH
#define FTS5TOKEN fts5yyminor
/************ Begin %syntax_error code ****************************************/

  UNUSED_PARAM(fts5yymajor); /* Silence a compiler warning */
  sqlite3Fts5ParseError(
    pParse, "fts5: syntax error near \"%.*s\"",FTS5TOKEN.n,FTS5TOKEN.p
  );
/************ End %syntax_error code ******************************************/
  sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
  sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
  sqlite3Fts5ParserCTX_STORE
}

/*
** The following is executed when the parser accepts
*/
static void fts5yy_accept(
  fts5yyParser *fts5yypParser           /* The parser */
){
  sqlite3Fts5ParserARG_FETCH;
  sqlite3Fts5ParserARG_FETCH
  sqlite3Fts5ParserCTX_FETCH
#ifndef NDEBUG
  if( fts5yyTraceFILE ){
    fprintf(fts5yyTraceFILE,"%sAccept!\n",fts5yyTracePrompt);
  }
#endif
#ifndef fts5YYNOERRORRECOVERY
  fts5yypParser->fts5yyerrcnt = -1;
#endif
  assert( fts5yypParser->fts5yytos==fts5yypParser->fts5yystack );
  /* Here code is inserted which will be executed whenever the
  ** parser accepts */
/*********** Begin %parse_accept code *****************************************/
/*********** End %parse_accept code *******************************************/
  sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
  sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
  sqlite3Fts5ParserCTX_STORE
}

/* The main parser program.
** The first argument is a pointer to a structure obtained from
** "sqlite3Fts5ParserAlloc" which describes the current state of the parser.
** The second argument is the major token number.  The third is
** the minor token.  The fourth optional argument is whatever the
190953
190954
190955
190956
190957
190958
190959
190960

190961
190962
190963
190964
190965
190966
190967



190968
190969
190970
190971
190972
190973
190974
190975

190976
190977
190978
190979

190980
190981

190982
190983
190984

190985
190986
190987
190988
190989

190990

190991
190992


190993
190994
190995
190996
190997
190998

190999
191000
191001
191002
191003
191004
191005
192814
192815
192816
192817
192818
192819
192820

192821
192822
192823
192824
192825
192826
192827

192828
192829
192830
192831

192832
192833
192834
192835

192836
192837
192838
192839


192840
192841

192842
192843
192844

192845
192846
192847
192848
192849
192850
192851

192852
192853

192854
192855
192856
192857
192858
192859
192860

192861
192862
192863
192864
192865
192866
192867
192868







-
+






-
+
+
+

-




-

+


-
-
+

-
+


-
+





+
-
+

-
+
+





-
+







static void sqlite3Fts5Parser(
  void *fts5yyp,                   /* The parser */
  int fts5yymajor,                 /* The major token code number */
  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyminor       /* The value for the token */
  sqlite3Fts5ParserARG_PDECL               /* Optional %extra_argument parameter */
){
  fts5YYMINORTYPE fts5yyminorunion;
  unsigned int fts5yyact;   /* The parser action. */
  fts5YYACTIONTYPE fts5yyact;   /* The parser action. */
#if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)
  int fts5yyendofinput;     /* True if we are at the end of input */
#endif
#ifdef fts5YYERRORSYMBOL
  int fts5yyerrorhit = 0;   /* True if fts5yymajor has invoked an error */
#endif
  fts5yyParser *fts5yypParser;  /* The parser */
  fts5yyParser *fts5yypParser = (fts5yyParser*)fts5yyp;  /* The parser */
  sqlite3Fts5ParserCTX_FETCH
  sqlite3Fts5ParserARG_STORE

  fts5yypParser = (fts5yyParser*)fts5yyp;
  assert( fts5yypParser->fts5yytos!=0 );
#if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)
  fts5yyendofinput = (fts5yymajor==0);
#endif
  sqlite3Fts5ParserARG_STORE;

  fts5yyact = fts5yypParser->fts5yytos->stateno;
#ifndef NDEBUG
  if( fts5yyTraceFILE ){
    int stateno = fts5yypParser->fts5yytos->stateno;
    if( stateno < fts5YY_MIN_REDUCE ){
    if( fts5yyact < fts5YY_MIN_REDUCE ){
      fprintf(fts5yyTraceFILE,"%sInput '%s' in state %d\n",
              fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],stateno);
              fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],fts5yyact);
    }else{
      fprintf(fts5yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
              fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],stateno-fts5YY_MIN_REDUCE);
              fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],fts5yyact-fts5YY_MIN_REDUCE);
    }
  }
#endif

  do{
    assert( fts5yyact==fts5yypParser->fts5yytos->stateno );
    fts5yyact = fts5yy_find_shift_action(fts5yypParser,(fts5YYCODETYPE)fts5yymajor);
    fts5yyact = fts5yy_find_shift_action(fts5yymajor,fts5yyact);
    if( fts5yyact >= fts5YY_MIN_REDUCE ){
      fts5yy_reduce(fts5yypParser,fts5yyact-fts5YY_MIN_REDUCE,fts5yymajor,fts5yyminor);
      fts5yyact = fts5yy_reduce(fts5yypParser,fts5yyact-fts5YY_MIN_REDUCE,fts5yymajor,
                        fts5yyminor sqlite3Fts5ParserCTX_PARAM);
    }else if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
      fts5yy_shift(fts5yypParser,fts5yyact,fts5yymajor,fts5yyminor);
#ifndef fts5YYNOERRORRECOVERY
      fts5yypParser->fts5yyerrcnt--;
#endif
      fts5yymajor = fts5YYNOCODE;
      break;
    }else if( fts5yyact==fts5YY_ACCEPT_ACTION ){
      fts5yypParser->fts5yytos--;
      fts5yy_accept(fts5yypParser);
      return;
    }else{
      assert( fts5yyact == fts5YY_ERROR_ACTION );
      fts5yyminorunion.fts5yy0 = fts5yyminor;
191062
191063
191064
191065
191066
191067
191068


191069
191070
191071
191072
191073
191074
191075
191076
191077
191078
191079
191080

191081
191082
191083
191084
191085
191086
191087
192925
192926
192927
192928
192929
192930
192931
192932
192933
192934
192935
192936
192937
192938
192939
192940
192941
192942
192943


192944
192945
192946
192947
192948
192949
192950
192951







+
+










-
-
+







          fts5yymajor = fts5YYNOCODE;
        }else if( fts5yymx!=fts5YYERRORSYMBOL ){
          fts5yy_shift(fts5yypParser,fts5yyact,fts5YYERRORSYMBOL,fts5yyminor);
        }
      }
      fts5yypParser->fts5yyerrcnt = 3;
      fts5yyerrorhit = 1;
      if( fts5yymajor==fts5YYNOCODE ) break;
      fts5yyact = fts5yypParser->fts5yytos->stateno;
#elif defined(fts5YYNOERRORRECOVERY)
      /* If the fts5YYNOERRORRECOVERY macro is defined, then do not attempt to
      ** do any kind of error recovery.  Instead, simply invoke the syntax
      ** error routine and continue going as if nothing had happened.
      **
      ** Applications can set this macro (for example inside %include) if
      ** they intend to abandon the parse upon the first syntax error seen.
      */
      fts5yy_syntax_error(fts5yypParser,fts5yymajor, fts5yyminor);
      fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
      fts5yymajor = fts5YYNOCODE;
      
      break;
#else  /* fts5YYERRORSYMBOL is not defined */
      /* This is what we do if the grammar does not define ERROR:
      **
      **  * Report an error message, and throw away the input token.
      **
      **  * If the input token is $, then fail the parse.
      **
191095
191096
191097
191098
191099
191100
191101
191102

191103
191104
191105

191106
191107
191108
191109
191110
191111
191112
192959
192960
192961
192962
192963
192964
192965

192966
192967
192968

192969
192970
192971
192972
192973
192974
192975
192976







-
+


-
+







      fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
      if( fts5yyendofinput ){
        fts5yy_parse_failed(fts5yypParser);
#ifndef fts5YYNOERRORRECOVERY
        fts5yypParser->fts5yyerrcnt = -1;
#endif
      }
      fts5yymajor = fts5YYNOCODE;
      break;
#endif
    }
  }while( fts5yymajor!=fts5YYNOCODE && fts5yypParser->fts5yytos>fts5yypParser->fts5yystack );
  }while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack );
#ifndef NDEBUG
  if( fts5yyTraceFILE ){
    fts5yyStackEntry *i;
    char cDiv = '[';
    fprintf(fts5yyTraceFILE,"%sReturn. Stack=",fts5yyTracePrompt);
    for(i=&fts5yypParser->fts5yystack[1]; i<=fts5yypParser->fts5yytos; i++){
      fprintf(fts5yyTraceFILE,"%c%s", cDiv, fts5yyTokenName[i->major]);
205710
205711
205712
205713
205714
205715
205716
205717

205718
205719
205720
205721
205722
205723
205724
207574
207575
207576
207577
207578
207579
207580

207581
207582
207583
207584
207585
207586
207587
207588







-
+







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-28 01:48:40 f677065aab61037914fc980456caaa60132a19b387d6d717ec1a6b6fa7c61a10", -1, SQLITE_TRANSIENT);
  sqlite3_result_text(pCtx, "fts5: 2018-05-28 18:29:46 469a62ca33081854e54f3af6d93ab5a350484b149c8c8c4ee8be0ae5418382d9", -1, SQLITE_TRANSIENT);
}

static int fts5Init(sqlite3 *db){
  static const sqlite3_module fts5Mod = {
    /* iVersion      */ 2,
    /* xCreate       */ fts5CreateMethod,
    /* xConnect      */ fts5ConnectMethod,
209980
209981
209982
209983
209984
209985
209986
209987

209988
209989

209990
209991
209992
209993
211844
211845
211846
211847
211848
211849
211850

211851
211852

211853
211854
211855
211856
211857







-
+

-
+




#endif
  return rc;
}
#endif /* SQLITE_CORE */
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */

/************** End of stmt.c ************************************************/
#if __LINE__!=209987
#if __LINE__!=211851
#undef SQLITE_SOURCE_ID
#define SQLITE_SOURCE_ID      "2018-04-28 01:48:40 f677065aab61037914fc980456caaa60132a19b387d6d717ec1a6b6fa7c6alt2"
#define SQLITE_SOURCE_ID      "2018-05-28 18:29:46 469a62ca33081854e54f3af6d93ab5a350484b149c8c8c4ee8be0ae54183alt2"
#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 SQLite.Interop/src/core/sqlite3.h.
119
120
121
122
123
124
125
126
127
128



129
130
131
132
133
134
135
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.2"
#define SQLITE_VERSION_NUMBER 3023002
#define SQLITE_SOURCE_ID      "2018-04-28 01:48:40 f677065aab61037914fc980456caaa60132a19b387d6d717ec1a6b6fa7c6alt1"
#define SQLITE_VERSION        "3.24.0"
#define SQLITE_VERSION_NUMBER 3024000
#define SQLITE_SOURCE_ID      "2018-05-28 18:29:46 469a62ca33081854e54f3af6d93ab5a350484b149c8c8c4ee8be0ae5418382d9"

/*
** 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
500
501
502
503
504
505
506

507
508
509
510
511
512
513

514
515
516
517
518
519
520
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522







+







+







#define SQLITE_IOERR_CONVPATH          (SQLITE_IOERR | (26<<8))
#define SQLITE_IOERR_VNODE             (SQLITE_IOERR | (27<<8))
#define SQLITE_IOERR_AUTH              (SQLITE_IOERR | (28<<8))
#define SQLITE_IOERR_BEGIN_ATOMIC      (SQLITE_IOERR | (29<<8))
#define SQLITE_IOERR_COMMIT_ATOMIC     (SQLITE_IOERR | (30<<8))
#define SQLITE_IOERR_ROLLBACK_ATOMIC   (SQLITE_IOERR | (31<<8))
#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))
#define SQLITE_LOCKED_VTAB             (SQLITE_LOCKED |  (2<<8))
#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
#define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))
#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))
#define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))
#define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))
#define SQLITE_CANTOPEN_CONVPATH       (SQLITE_CANTOPEN | (4<<8))
#define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))
#define SQLITE_CORRUPT_SEQUENCE        (SQLITE_CORRUPT | (2<<8))
#define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))
#define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))
#define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))
#define SQLITE_READONLY_DBMOVED        (SQLITE_READONLY | (4<<8))
#define SQLITE_READONLY_CANTINIT       (SQLITE_READONLY | (5<<8))
#define SQLITE_READONLY_DIRECTORY      (SQLITE_READONLY | (6<<8))
#define SQLITE_ABORT_ROLLBACK          (SQLITE_ABORT | (2<<8))
1926
1927
1928
1929
1930
1931
1932
















1933
1934
1935
1936
1937
1938
1939
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







** Or if the threshold is -1, statement journals are always held
** exclusively in memory.
** Since many statement journals never become large, setting the spill
** threshold to a value such as 64KiB can greatly reduce the amount of
** I/O required to support statement rollback.
** The default value for this setting is controlled by the
** [SQLITE_STMTJRNL_SPILL] compile-time option.
**
** [[SQLITE_CONFIG_SORTERREF_SIZE]]
** <dt>SQLITE_CONFIG_SORTERREF_SIZE
** <dd>The SQLITE_CONFIG_SORTERREF_SIZE option accepts a single parameter
** of type (int) - the new value of the sorter-reference size threshold.
** Usually, when SQLite uses an external sort to order records according
** to an ORDER BY clause, all fields required by the caller are present in the
** sorted records. However, if SQLite determines based on the declared type
** of a table column that its values are likely to be very large - larger
** than the configured sorter-reference size threshold - then a reference
** is stored in each sorted record and the required column values loaded
** from the database as records are returned in sorted order. The default
** value for this option is to never use this optimization. Specifying a 
** negative value for this option restores the default behaviour.
** This option is only available if SQLite is compiled with the
** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.
** </dl>
*/
#define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
#define SQLITE_CONFIG_MULTITHREAD   2  /* nil */
#define SQLITE_CONFIG_SERIALIZED    3  /* nil */
#define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */
#define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */
1955
1956
1957
1958
1959
1960
1961

1962
1963
1964
1965
1966
1967
1968
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987







+







#define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */
#define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */
#define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */
#define SQLITE_CONFIG_PCACHE_HDRSZ        24  /* int *psz */
#define SQLITE_CONFIG_PMASZ               25  /* unsigned int szPma */
#define SQLITE_CONFIG_STMTJRNL_SPILL      26  /* int nByte */
#define SQLITE_CONFIG_SMALL_MALLOC        27  /* boolean */
#define SQLITE_CONFIG_SORTERREF_SIZE      28  /* int nByte */

/*
** CAPI3REF: Database Connection Configuration Options
**
** These constants are the available integer configuration options that
** can be passed as the second argument to the [sqlite3_db_config()] interface.
**
2091
2092
2093
2094
2095
2096
2097















2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108

2109

2110
2111
2112
2113
2114
2115
2116
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143

2144
2145
2146
2147
2148
2149
2150
2151







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+











+
-
+







** behavior. The first parameter passed to this operation is an integer -
** positive to enable output for trigger programs, or zero to disable it,
** or negative to leave the setting unchanged.
** The second parameter is a pointer to an integer into which is written 
** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if 
** it is not disabled, 1 if it is.  
** </dd>
**
** <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
** [VACUUM] in order to reset a database back to an empty database
** with no schema and no content. The following process works even for
** a badly corrupted database file:
** <ol>
** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
** <li> [sqlite3_exec](db, "[VACUUM]", 0, 0, 0);
** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
** </ol>
** Because resetting a database is destructive and irreversible, the
** process requires the use of this obscure API and multiple steps to help
** ensure that it does not happen by accident.
** </dd>
** </dl>
*/
#define SQLITE_DBCONFIG_MAINDBNAME            1000 /* const char* */
#define SQLITE_DBCONFIG_LOOKASIDE             1001 /* void* int int */
#define SQLITE_DBCONFIG_ENABLE_FKEY           1002 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_TRIGGER        1003 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE      1006 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_QPSG           1007 /* int int* */
#define SQLITE_DBCONFIG_TRIGGER_EQP           1008 /* int int* */
#define SQLITE_DBCONFIG_RESET_DATABASE        1009 /* int int* */
#define SQLITE_DBCONFIG_MAX                   1008 /* Largest DBCONFIG */
#define SQLITE_DBCONFIG_MAX                   1009 /* Largest DBCONFIG */

/*
** CAPI3REF: Enable Or Disable Extended Result Codes
** METHOD: sqlite3
**
** ^The sqlite3_extended_result_codes() routine enables or disables the
** [extended result codes] feature of SQLite. ^The extended result
6255
6256
6257
6258
6259
6260
6261




6262
6263
6264
6265
6266
6267
6268
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307







+
+
+
+







  int idxFlags;              /* Mask of SQLITE_INDEX_SCAN_* flags */
  /* Fields below are only available in SQLite 3.10.0 and later */
  sqlite3_uint64 colUsed;    /* Input: Mask of columns used by statement */
};

/*
** CAPI3REF: Virtual Table Scan Flags
**
** Virtual table implementations are allowed to set the 
** [sqlite3_index_info].idxFlags field to some combination of
** these bits.
*/
#define SQLITE_INDEX_SCAN_UNIQUE      1     /* Scan visits at most 1 row */

/*
** CAPI3REF: Virtual Table Constraint Operator Codes
**
** These macros defined the allowed values for the
7030
7031
7032
7033
7034
7035
7036
7037

7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050























































































































































































7051
7052
7053
7054
7055
7056
7057
7069
7070
7071
7072
7073
7074
7075

7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279







-
+













+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







#define SQLITE_TESTCTRL_FAULT_INSTALL            9
#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS     10
#define SQLITE_TESTCTRL_PENDING_BYTE            11
#define SQLITE_TESTCTRL_ASSERT                  12
#define SQLITE_TESTCTRL_ALWAYS                  13
#define SQLITE_TESTCTRL_RESERVE                 14
#define SQLITE_TESTCTRL_OPTIMIZATIONS           15
#define SQLITE_TESTCTRL_ISKEYWORD               16
#define SQLITE_TESTCTRL_ISKEYWORD               16  /* NOT USED */
#define SQLITE_TESTCTRL_SCRATCHMALLOC           17  /* NOT USED */
#define SQLITE_TESTCTRL_LOCALTIME_FAULT         18
#define SQLITE_TESTCTRL_EXPLAIN_STMT            19  /* NOT USED */
#define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD    19
#define SQLITE_TESTCTRL_NEVER_CORRUPT           20
#define SQLITE_TESTCTRL_VDBE_COVERAGE           21
#define SQLITE_TESTCTRL_BYTEORDER               22
#define SQLITE_TESTCTRL_ISINIT                  23
#define SQLITE_TESTCTRL_SORTER_MMAP             24
#define SQLITE_TESTCTRL_IMPOSTER                25
#define SQLITE_TESTCTRL_PARSER_COVERAGE         26
#define SQLITE_TESTCTRL_LAST                    26  /* Largest TESTCTRL */

/*
** CAPI3REF: SQL Keyword Checking
**
** These routines provide access to the set of SQL language keywords 
** recognized by SQLite.  Applications can uses these routines to determine
** whether or not a specific identifier needs to be escaped (for example,
** by enclosing in double-quotes) so as not to confuse the parser.
**
** The sqlite3_keyword_count() interface returns the number of distinct
** keywords understood by SQLite.
**
** The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and
** makes *Z point to that keyword expressed as UTF8 and writes the number
** of bytes in the keyword into *L.  The string that *Z points to is not
** zero-terminated.  The sqlite3_keyword_name(N,Z,L) routine returns
** SQLITE_OK if N is within bounds and SQLITE_ERROR if not. If either Z
** or L are NULL or invalid pointers then calls to
** sqlite3_keyword_name(N,Z,L) result in undefined behavior.
**
** The sqlite3_keyword_check(Z,L) interface checks to see whether or not
** the L-byte UTF8 identifier that Z points to is a keyword, returning non-zero
** if it is and zero if not.
**
** The parser used by SQLite is forgiving.  It is often possible to use
** a keyword as an identifier as long as such use does not result in a
** parsing ambiguity.  For example, the statement
** "CREATE TABLE BEGIN(REPLACE,PRAGMA,END);" is accepted by SQLite, and
** creates a new table named "BEGIN" with three columns named
** "REPLACE", "PRAGMA", and "END".  Nevertheless, best practice is to avoid
** using keywords as identifiers.  Common techniques used to avoid keyword
** name collisions include:
** <ul>
** <li> Put all identifier names inside double-quotes.  This is the official
**      SQL way to escape identifier names.
** <li> Put identifier names inside &#91;...&#93;.  This is not standard SQL,
**      but it is what SQL Server does and so lots of programmers use this
**      technique.
** <li> Begin every identifier with the letter "Z" as no SQL keywords start
**      with "Z".
** <li> Include a digit somewhere in every identifier name.
** </ul>
**
** Note that the number of keywords understood by SQLite can depend on
** compile-time options.  For example, "VACUUM" is not a keyword if
** SQLite is compiled with the [-DSQLITE_OMIT_VACUUM] option.  Also,
** new keywords may be added to future releases of SQLite.
*/
SQLITE_API int sqlite3_keyword_count(void);
SQLITE_API int sqlite3_keyword_name(int,const char**,int*);
SQLITE_API int sqlite3_keyword_check(const char*,int);

/*
** CAPI3REF: Dynamic String Object
** KEYWORDS: {dynamic string}
**
** An instance of the sqlite3_str object contains a dynamically-sized
** string under construction.
**
** The lifecycle of an sqlite3_str object is as follows:
** <ol>
** <li> ^The sqlite3_str object is created using [sqlite3_str_new()].
** <li> ^Text is appended to the sqlite3_str object using various
** methods, such as [sqlite3_str_appendf()].
** <li> ^The sqlite3_str object is destroyed and the string it created
** is returned using the [sqlite3_str_finish()] interface.
** </ol>
*/
typedef struct sqlite3_str sqlite3_str;

/*
** CAPI3REF: Create A New Dynamic String Object
** CONSTRUCTOR: sqlite3_str
**
** ^The [sqlite3_str_new(D)] interface allocates and initializes
** a new [sqlite3_str] object.  To avoid memory leaks, the object returned by
** [sqlite3_str_new()] must be freed by a subsequent call to 
** [sqlite3_str_finish(X)].
**
** ^The [sqlite3_str_new(D)] interface always returns a pointer to a
** valid [sqlite3_str] object, though in the event of an out-of-memory
** error the returned object might be a special singleton that will
** silently reject new text, always return SQLITE_NOMEM from 
** [sqlite3_str_errcode()], always return 0 for 
** [sqlite3_str_length()], and always return NULL from
** [sqlite3_str_finish(X)].  It is always safe to use the value
** returned by [sqlite3_str_new(D)] as the sqlite3_str parameter
** to any of the other [sqlite3_str] methods.
**
** The D parameter to [sqlite3_str_new(D)] may be NULL.  If the
** D parameter in [sqlite3_str_new(D)] is not NULL, then the maximum
** length of the string contained in the [sqlite3_str] object will be
** the value set for [sqlite3_limit](D,[SQLITE_LIMIT_LENGTH]) instead
** of [SQLITE_MAX_LENGTH].
*/
SQLITE_API sqlite3_str *sqlite3_str_new(sqlite3*);

/*
** CAPI3REF: Finalize A Dynamic String
** DESTRUCTOR: sqlite3_str
**
** ^The [sqlite3_str_finish(X)] interface destroys the sqlite3_str object X
** and returns a pointer to a memory buffer obtained from [sqlite3_malloc64()]
** that contains the constructed string.  The calling application should
** pass the returned value to [sqlite3_free()] to avoid a memory leak.
** ^The [sqlite3_str_finish(X)] interface may return a NULL pointer if any
** errors were encountered during construction of the string.  ^The
** [sqlite3_str_finish(X)] interface will also return a NULL pointer if the
** string in [sqlite3_str] object X is zero bytes long.
*/
SQLITE_API char *sqlite3_str_finish(sqlite3_str*);

/*
** CAPI3REF: Add Content To A Dynamic String
** METHOD: sqlite3_str
**
** These interfaces add content to an sqlite3_str object previously obtained
** from [sqlite3_str_new()].
**
** ^The [sqlite3_str_appendf(X,F,...)] and 
** [sqlite3_str_vappendf(X,F,V)] interfaces uses the [built-in printf]
** functionality of SQLite to append formatted text onto the end of 
** [sqlite3_str] object X.
**
** ^The [sqlite3_str_append(X,S,N)] method appends exactly N bytes from string S
** onto the end of the [sqlite3_str] object X.  N must be non-negative.
** S must contain at least N non-zero bytes of content.  To append a
** zero-terminated string in its entirety, use the [sqlite3_str_appendall()]
** method instead.
**
** ^The [sqlite3_str_appendall(X,S)] method appends the complete content of
** zero-terminated string S onto the end of [sqlite3_str] object X.
**
** ^The [sqlite3_str_appendchar(X,N,C)] method appends N copies of the
** single-byte character C onto the end of [sqlite3_str] object X.
** ^This method can be used, for example, to add whitespace indentation.
**
** ^The [sqlite3_str_reset(X)] method resets the string under construction
** inside [sqlite3_str] object X back to zero bytes in length.  
**
** These methods do not return a result code.  ^If an error occurs, that fact
** is recorded in the [sqlite3_str] object and can be recovered by a
** subsequent call to [sqlite3_str_errcode(X)].
*/
SQLITE_API void sqlite3_str_appendf(sqlite3_str*, const char *zFormat, ...);
SQLITE_API void sqlite3_str_vappendf(sqlite3_str*, const char *zFormat, va_list);
SQLITE_API void sqlite3_str_append(sqlite3_str*, const char *zIn, int N);
SQLITE_API void sqlite3_str_appendall(sqlite3_str*, const char *zIn);
SQLITE_API void sqlite3_str_appendchar(sqlite3_str*, int N, char C);
SQLITE_API void sqlite3_str_reset(sqlite3_str*);

/*
** CAPI3REF: Status Of A Dynamic String
** METHOD: sqlite3_str
**
** These interfaces return the current status of an [sqlite3_str] object.
**
** ^If any prior errors have occurred while constructing the dynamic string
** in sqlite3_str X, then the [sqlite3_str_errcode(X)] method will return
** an appropriate error code.  ^The [sqlite3_str_errcode(X)] method returns
** [SQLITE_NOMEM] following any out-of-memory error, or
** [SQLITE_TOOBIG] if the size of the dynamic string exceeds
** [SQLITE_MAX_LENGTH], or [SQLITE_OK] if there have been no errors.
**
** ^The [sqlite3_str_length(X)] method returns the current length, in bytes,
** of the dynamic string under construction in [sqlite3_str] object X.
** ^The length returned by [sqlite3_str_length(X)] does not include the
** zero-termination byte.
**
** ^The [sqlite3_str_value(X)] method returns a pointer to the current
** content of the dynamic string under construction in X.  The value
** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X
** and might be freed or altered by any subsequent method on the same
** [sqlite3_str] object.  Applications must not used the pointer returned
** [sqlite3_str_value(X)] after any subsequent method call on the same
** object.  ^Applications may change the content of the string returned
** by [sqlite3_str_value(X)] as long as they do not write into any bytes
** outside the range of 0 to [sqlite3_str_length(X)] and do not read or
** write any byte after any subsequent sqlite3_str method call.
*/
SQLITE_API int sqlite3_str_errcode(sqlite3_str*);
SQLITE_API int sqlite3_str_length(sqlite3_str*);
SQLITE_API char *sqlite3_str_value(sqlite3_str*);

/*
** CAPI3REF: SQLite Runtime Status
**
** ^These interfaces are used to retrieve runtime status information
** about the performance of SQLite, and optionally to reset various
** highwater marks.  ^The first argument is an integer code for
** the specific parameter to measure.  ^(Recognized integer codes
8313
8314
8315
8316
8317
8318
8319
8320
8321


8322
8323
8324

8325
8326
8327
8328
8329
8330
8331
8535
8536
8537
8538
8539
8540
8541


8542
8543
8544
8545

8546
8547
8548
8549
8550
8551
8552
8553







-
-
+
+


-
+







/*
** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE
**
** If the sqlite3_vtab_nochange(X) routine is called within the [xColumn]
** method of a [virtual table], then it returns true if and only if the
** column is being fetched as part of an UPDATE operation during which the
** column value will not change.  Applications might use this to substitute
** a lighter-weight value to return that the corresponding [xUpdate] method
** understands as a "no-change" value.
** a return value that is less expensive to compute and that the corresponding
** [xUpdate] method understands as a "no-change" value.
**
** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that
** the column is not changed by the UPDATE statement, they the xColumn
** the column is not changed by the UPDATE statement, then the xColumn
** method can optionally return without setting a result, without calling
** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].
** In that case, [sqlite3_value_nochange(X)] will return true for the
** same column in the [xUpdate] method.
*/
SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);

Changes to SQLite.Interop/src/core/sqlite3ext.h.
291
292
293
294
295
296
297















298
299
300
301
302
303
304
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







                      sqlite3_stmt**,const void**);
  int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*));
  void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*));
  void *(*value_pointer)(sqlite3_value*,const char*);
  int (*vtab_nochange)(sqlite3_context*);
  int (*value_nochange)(sqlite3_value*);
  const char *(*vtab_collation)(sqlite3_index_info*,int);
  /* Version 3.24.0 and later */
  int (*keyword_count)(void);
  int (*keyword_name)(int,const char**,int*);
  int (*keyword_check)(const char*,int);
  sqlite3_str *(*str_new)(sqlite3*);
  char *(*str_finish)(sqlite3_str*);
  void (*str_appendf)(sqlite3_str*, const char *zFormat, ...);
  void (*str_vappendf)(sqlite3_str*, const char *zFormat, va_list);
  void (*str_append)(sqlite3_str*, const char *zIn, int N);
  void (*str_appendall)(sqlite3_str*, const char *zIn);
  void (*str_appendchar)(sqlite3_str*, int N, char C);
  void (*str_reset)(sqlite3_str*);
  int (*str_errcode)(sqlite3_str*);
  int (*str_length)(sqlite3_str*);
  char *(*str_value)(sqlite3_str*);
};

/*
** This is the function signature used for all extension entry points.  It
** is also defined in the file "loadext.c".
*/
typedef int (*sqlite3_loadext_entry)(
561
562
563
564
565
566
567















568
569
570
571
572
573
574
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







#define sqlite3_bind_pointer           sqlite3_api->bind_pointer
#define sqlite3_result_pointer         sqlite3_api->result_pointer
#define sqlite3_value_pointer          sqlite3_api->value_pointer
/* Version 3.22.0 and later */
#define sqlite3_vtab_nochange          sqlite3_api->vtab_nochange
#define sqlite3_value_nochange         sqlite3_api->value_nochange
#define sqlite3_vtab_collation         sqlite3_api->vtab_collation
/* Version 3.24.0 and later */
#define sqlite3_keyword_count          sqlite3_api->keyword_count
#define sqlite3_keyword_name           sqlite3_api->keyword_name
#define sqlite3_keyword_check          sqlite3_api->keyword_check
#define sqlite3_str_new                sqlite3_api->str_new
#define sqlite3_str_finish             sqlite3_api->str_finish
#define sqlite3_str_appendf            sqlite3_api->str_appendf
#define sqlite3_str_vappendf           sqlite3_api->str_vappendf
#define sqlite3_str_append             sqlite3_api->str_append
#define sqlite3_str_appendall          sqlite3_api->str_appendall
#define sqlite3_str_appendchar         sqlite3_api->str_appendchar
#define sqlite3_str_reset              sqlite3_api->str_reset
#define sqlite3_str_errcode            sqlite3_api->str_errcode
#define sqlite3_str_length             sqlite3_api->str_length
#define sqlite3_str_value              sqlite3_api->str_value
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */

#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
  /* This case when the file really is being compiled as a loadable 
  ** extension */
# define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api=0;
# define SQLITE_EXTENSION_INIT2(v)  sqlite3_api=v;
Changes to SQLite.Interop/src/ext/fts5.c.
1495
1496
1497
1498
1499
1500
1501

1502
1503

1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523

1524
1525
1526
1527
1528
1529
1530
1531



1532
1533

1534
1535
1536
1537
1538
1539

1540
1541







1542
1543
1544
1545
1546
1547
1548
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524

1525
1526
1527
1528
1529
1530
1531


1532
1533
1534


1535
1536
1537
1538
1539
1540
1541
1542


1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556







+


+



















-
+






-
-
+
+
+
-
-
+






+
-
-
+
+
+
+
+
+
+







**                       This is typically a union of many types, one of
**                       which is sqlite3Fts5ParserFTS5TOKENTYPE.  The entry in the union
**                       for terminal symbols is called "fts5yy0".
**    fts5YYSTACKDEPTH       is the maximum depth of the parser's stack.  If
**                       zero the stack is dynamically sized using realloc()
**    sqlite3Fts5ParserARG_SDECL     A static variable declaration for the %extra_argument
**    sqlite3Fts5ParserARG_PDECL     A parameter declaration for the %extra_argument
**    sqlite3Fts5ParserARG_PARAM     Code to pass %extra_argument as a subroutine parameter
**    sqlite3Fts5ParserARG_STORE     Code to store %extra_argument into fts5yypParser
**    sqlite3Fts5ParserARG_FETCH     Code to extract %extra_argument from fts5yypParser
**    sqlite3Fts5ParserCTX_*         As sqlite3Fts5ParserARG_ except for %extra_context
**    fts5YYERRORSYMBOL      is the code number of the error symbol.  If not
**                       defined, then do no error processing.
**    fts5YYNSTATE           the combined number of states.
**    fts5YYNRULE            the number of rules in the grammar
**    fts5YYNFTS5TOKEN           Number of terminal symbols
**    fts5YY_MAX_SHIFT       Maximum value for shift actions
**    fts5YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
**    fts5YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
**    fts5YY_ERROR_ACTION    The fts5yy_action[] code for syntax error
**    fts5YY_ACCEPT_ACTION   The fts5yy_action[] code for accept
**    fts5YY_NO_ACTION       The fts5yy_action[] code for no-op
**    fts5YY_MIN_REDUCE      Minimum value for reduce actions
**    fts5YY_MAX_REDUCE      Maximum value for reduce actions
*/
#ifndef INTERFACE
# define INTERFACE 1
#endif
/************* Begin control #defines *****************************************/
#define fts5YYCODETYPE unsigned char
#define fts5YYNOCODE 29
#define fts5YYNOCODE 27
#define fts5YYACTIONTYPE unsigned char
#define sqlite3Fts5ParserFTS5TOKENTYPE Fts5Token
typedef union {
  int fts5yyinit;
  sqlite3Fts5ParserFTS5TOKENTYPE fts5yy0;
  int fts5yy4;
  Fts5ExprPhrase* fts5yy11;
  Fts5ExprNearset* fts5yy14;
  Fts5Colset* fts5yy11;
  Fts5ExprNode* fts5yy24;
  Fts5ExprNearset* fts5yy46;
  Fts5Colset* fts5yy43;
  Fts5ExprNode* fts5yy54;
  Fts5ExprPhrase* fts5yy53;
} fts5YYMINORTYPE;
#ifndef fts5YYSTACKDEPTH
#define fts5YYSTACKDEPTH 100
#endif
#define sqlite3Fts5ParserARG_SDECL Fts5Parse *pParse;
#define sqlite3Fts5ParserARG_PDECL ,Fts5Parse *pParse
#define sqlite3Fts5ParserARG_PARAM ,pParse
#define sqlite3Fts5ParserARG_FETCH Fts5Parse *pParse = fts5yypParser->pParse
#define sqlite3Fts5ParserARG_STORE fts5yypParser->pParse = pParse
#define sqlite3Fts5ParserARG_FETCH Fts5Parse *pParse=fts5yypParser->pParse;
#define sqlite3Fts5ParserARG_STORE fts5yypParser->pParse=pParse;
#define sqlite3Fts5ParserCTX_SDECL
#define sqlite3Fts5ParserCTX_PDECL
#define sqlite3Fts5ParserCTX_PARAM
#define sqlite3Fts5ParserCTX_FETCH
#define sqlite3Fts5ParserCTX_STORE
#define fts5YYNSTATE             35
#define fts5YYNRULE              28
#define fts5YYNFTS5TOKEN             16
#define fts5YY_MAX_SHIFT         34
#define fts5YY_MIN_SHIFTREDUCE   52
#define fts5YY_MAX_SHIFTREDUCE   79
#define fts5YY_ERROR_ACTION      80
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630









1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645













1646
1647
1648
1649

1650
1651
1652
1653
1654




1655
1656
1657
1658


1659
1660
1661


1662
1663
1664
1665
1666
1667
1668
1623
1624
1625
1626
1627
1628
1629









1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640













1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656

1657
1658




1659
1660
1661
1662
1663
1664


1665
1666
1667


1668
1669
1670
1671
1672
1673
1674
1675
1676







-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+


-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+



-
+

-
-
-
-
+
+
+
+


-
-
+
+

-
-
+
+







**  fts5yy_default[]       Default action for each state.
**
*********** Begin parsing tables **********************************************/
#define fts5YY_ACTTAB_COUNT (105)
static const fts5YYACTIONTYPE fts5yy_action[] = {
 /*     0 */    81,   20,   96,    6,   28,   99,   98,   26,   26,   18,
 /*    10 */    96,    6,   28,   17,   98,   56,   26,   19,   96,    6,
 /*    20 */    28,   14,   98,  108,   26,   92,   96,    6,   28,   25,
 /*    30 */    98,   78,   26,   21,   96,    6,   28,  107,   98,   58,
 /*    40 */    26,   29,   96,    6,   28,   32,   98,   22,   26,   24,
 /*    50 */    16,   23,   11,    1,   14,   13,   24,   16,   31,   11,
 /*    60 */     3,   97,   13,   27,    8,   98,   82,   26,    7,    4,
 /*    70 */     5,    3,    4,    5,    3,   83,    4,    5,    3,   63,
 /*    80 */    33,   34,   62,   12,    2,   86,   13,   10,   12,   71,
 /*    90 */    10,   13,   78,    5,    3,   78,    9,   30,   75,   82,
 /*   100 */    54,   57,   53,   57,   15,
 /*    20 */    28,   14,   98,   14,   26,   31,   92,   96,    6,   28,
 /*    30 */   108,   98,   25,   26,   21,   96,    6,   28,   78,   98,
 /*    40 */    58,   26,   29,   96,    6,   28,  107,   98,   22,   26,
 /*    50 */    24,   16,   12,   11,    1,   13,   13,   24,   16,   23,
 /*    60 */    11,   33,   34,   13,   97,    8,   27,   32,   98,    7,
 /*    70 */    26,    3,    4,    5,    3,    4,    5,    3,   83,    4,
 /*    80 */     5,    3,   63,    5,    3,   62,   12,    2,   86,   13,
 /*    90 */     9,   30,   10,   10,   54,   57,   75,   78,   78,   53,
 /*   100 */    57,   15,   82,   82,   71,
};
static const fts5YYCODETYPE fts5yy_lookahead[] = {
 /*     0 */    17,   18,   19,   20,   21,   23,   23,   25,   25,   18,
 /*    10 */    19,   20,   21,    7,   23,    9,   25,   18,   19,   20,
 /*    20 */    21,    9,   23,   27,   25,   18,   19,   20,   21,   25,
 /*    30 */    23,   15,   25,   18,   19,   20,   21,   27,   23,    9,
 /*    40 */    25,   18,   19,   20,   21,   14,   23,   22,   25,    6,
 /*    50 */     7,   22,    9,   10,    9,   12,    6,    7,   13,    9,
 /*    60 */     3,   19,   12,   21,    5,   23,   28,   25,    5,    1,
 /*    70 */     2,    3,    1,    2,    3,    0,    1,    2,    3,   11,
 /*    80 */    25,   26,   11,    9,   10,    5,   12,   10,    9,   11,
 /*    90 */    10,   12,   15,    2,    3,   15,   24,   25,    9,   28,
 /*   100 */     8,    9,    8,    9,    9,   28,   28,   28,   28,   28,
 /*   110 */    28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
 /*   120 */    28,
 /*     0 */    16,   17,   18,   19,   20,   22,   22,   24,   24,   17,
 /*    10 */    18,   19,   20,    7,   22,    9,   24,   17,   18,   19,
 /*    20 */    20,    9,   22,    9,   24,   13,   17,   18,   19,   20,
 /*    30 */    26,   22,   24,   24,   17,   18,   19,   20,   15,   22,
 /*    40 */     9,   24,   17,   18,   19,   20,   26,   22,   21,   24,
 /*    50 */     6,    7,    9,    9,   10,   12,   12,    6,    7,   21,
 /*    60 */     9,   24,   25,   12,   18,    5,   20,   14,   22,    5,
 /*    70 */    24,    3,    1,    2,    3,    1,    2,    3,    0,    1,
 /*    80 */     2,    3,   11,    2,    3,   11,    9,   10,    5,   12,
 /*    90 */    23,   24,   10,   10,    8,    9,    9,   15,   15,    8,
 /*   100 */     9,    9,   27,   27,   11,   27,   27,   27,   27,   27,
 /*   110 */    27,   27,   27,   27,   27,   27,   27,   27,   27,   27,
 /*   120 */    27,
};
#define fts5YY_SHIFT_COUNT    (34)
#define fts5YY_SHIFT_MIN      (0)
#define fts5YY_SHIFT_MAX      (95)
#define fts5YY_SHIFT_MAX      (93)
static const unsigned char fts5yy_shift_ofst[] = {
 /*     0 */    43,   43,   43,   43,   43,   43,   50,   74,   79,   45,
 /*    10 */    12,   80,   77,   12,   16,   16,   30,   30,   68,   71,
 /*    20 */    75,   91,   92,   94,    6,   31,   31,   59,   63,   57,
 /*    30 */    31,   89,   95,   31,   78,
 /*     0 */    44,   44,   44,   44,   44,   44,   51,   77,   43,   12,
 /*    10 */    14,   83,   82,   14,   23,   23,   31,   31,   71,   74,
 /*    20 */    78,   81,   86,   91,    6,   53,   53,   60,   64,   68,
 /*    30 */    53,   87,   92,   53,   93,
};
#define fts5YY_REDUCE_COUNT (17)
#define fts5YY_REDUCE_MIN   (-18)
#define fts5YY_REDUCE_MAX   (72)
#define fts5YY_REDUCE_MIN   (-17)
#define fts5YY_REDUCE_MAX   (67)
static const signed char fts5yy_reduce_ofst[] = {
 /*     0 */   -17,   -9,   -1,    7,   15,   23,   42,  -18,  -18,   55,
 /*    10 */    72,   -4,   -4,    4,   -4,   10,   25,   29,
 /*     0 */   -16,   -8,    0,    9,   17,   25,   46,  -17,  -17,   37,
 /*    10 */    67,    4,    4,    8,    4,   20,   27,   38,
};
static const fts5YYACTIONTYPE fts5yy_default[] = {
 /*     0 */    80,   80,   80,   80,   80,   80,   95,   80,   80,  105,
 /*    10 */    80,  110,  110,   80,  110,  110,   80,   80,   80,   80,
 /*    20 */    80,   91,   80,   80,   80,  101,  100,   80,   80,   90,
 /*    30 */   103,   80,   80,  104,   80,
};
1719
1720
1721
1722
1723
1724
1725

1726
1727
1728
1729
1730
1731
1732
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741







+







#ifdef fts5YYTRACKMAXSTACKDEPTH
  int fts5yyhwm;                    /* High-water mark of the stack */
#endif
#ifndef fts5YYNOERRORRECOVERY
  int fts5yyerrcnt;                 /* Shifts left before out of the error */
#endif
  sqlite3Fts5ParserARG_SDECL                /* A place to hold %extra_argument */
  sqlite3Fts5ParserCTX_SDECL                /* A place to hold %extra_context */
#if fts5YYSTACKDEPTH<=0
  int fts5yystksz;                  /* Current side of the stack */
  fts5yyStackEntry *fts5yystack;        /* The parser's stack */
  fts5yyStackEntry fts5yystk0;          /* First stack entry */
#else
  fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH];  /* The parser's stack */
  fts5yyStackEntry *fts5yystackEnd;            /* Last entry in the stack */
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799











1800
1801
1802
1803
1804
1805
1806
1807
1791
1792
1793
1794
1795
1796
1797











1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808

1809
1810
1811
1812
1813
1814
1815







-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-







  /*    9 */ "STRING",
  /*   10 */ "LP",
  /*   11 */ "RP",
  /*   12 */ "CARET",
  /*   13 */ "COMMA",
  /*   14 */ "PLUS",
  /*   15 */ "STAR",
  /*   16 */ "error",
  /*   17 */ "input",
  /*   18 */ "expr",
  /*   19 */ "cnearset",
  /*   20 */ "exprlist",
  /*   21 */ "colset",
  /*   22 */ "colsetlist",
  /*   23 */ "nearset",
  /*   24 */ "nearphrases",
  /*   25 */ "phrase",
  /*   26 */ "neardist_opt",
  /*   16 */ "input",
  /*   17 */ "expr",
  /*   18 */ "cnearset",
  /*   19 */ "exprlist",
  /*   20 */ "colset",
  /*   21 */ "colsetlist",
  /*   22 */ "nearset",
  /*   23 */ "nearphrases",
  /*   24 */ "phrase",
  /*   25 */ "neardist_opt",
  /*   26 */ "star_opt",
  /*   27 */ "star_opt",
};
#endif /* defined(fts5YYCOVERAGE) || !defined(NDEBUG) */

#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
*/
static const char *const fts5yyRuleName[] = {
1877
1878
1879
1880
1881
1882
1883
1884
1885



1886
1887

1888
1889
1890
1891
1892
1893
1894
1895






1896
1897
1898
1899

1900
1901
1902
1903



1904
1905

1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926








1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943


1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956

1957
1958
1959
1960

1961
1962
1963
1964
1965



1966
1967
1968
1969


1970
1971
1972
1973


1974
1975
1976
1977


1978
1979
1980
1981


1982
1983
1984
1985


1986
1987
1988

1989
1990
1991
1992


1993
1994
1995
1996
1997
1998
1999
1885
1886
1887
1888
1889
1890
1891


1892
1893
1894
1895

1896
1897
1898






1899
1900
1901
1902
1903
1904
1905
1906
1907

1908
1909



1910
1911
1912
1913

1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930





1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954

1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968

1969
1970
1971
1972

1973
1974
1975



1976
1977
1978
1979
1980


1981
1982
1983
1984


1985
1986
1987
1988


1989
1990
1991
1992


1993
1994
1995
1996


1997
1998
1999
2000

2001
2002
2003


2004
2005
2006
2007
2008
2009
2010
2011
2012







-
-
+
+
+

-
+


-
-
-
-
-
-
+
+
+
+
+
+



-
+

-
-
-
+
+
+

-
+
















-
-
-
-
-
+
+
+
+
+
+
+
+
















-
+
+












-
+



-
+


-
-
-
+
+
+


-
-
+
+


-
-
+
+


-
-
+
+


-
-
+
+


-
-
+
+


-
+


-
-
+
+







*/
#ifndef fts5YYMALLOCARGTYPE
# define fts5YYMALLOCARGTYPE size_t
#endif

/* Initialize a new parser that has already been allocated.
*/
static void sqlite3Fts5ParserInit(void *fts5yypParser){
  fts5yyParser *pParser = (fts5yyParser*)fts5yypParser;
static void sqlite3Fts5ParserInit(void *fts5yypRawParser sqlite3Fts5ParserCTX_PDECL){
  fts5yyParser *fts5yypParser = (fts5yyParser*)fts5yypRawParser;
  sqlite3Fts5ParserCTX_STORE
#ifdef fts5YYTRACKMAXSTACKDEPTH
  pParser->fts5yyhwm = 0;
  fts5yypParser->fts5yyhwm = 0;
#endif
#if fts5YYSTACKDEPTH<=0
  pParser->fts5yytos = NULL;
  pParser->fts5yystack = NULL;
  pParser->fts5yystksz = 0;
  if( fts5yyGrowStack(pParser) ){
    pParser->fts5yystack = &pParser->fts5yystk0;
    pParser->fts5yystksz = 1;
  fts5yypParser->fts5yytos = NULL;
  fts5yypParser->fts5yystack = NULL;
  fts5yypParser->fts5yystksz = 0;
  if( fts5yyGrowStack(fts5yypParser) ){
    fts5yypParser->fts5yystack = &fts5yypParser->fts5yystk0;
    fts5yypParser->fts5yystksz = 1;
  }
#endif
#ifndef fts5YYNOERRORRECOVERY
  pParser->fts5yyerrcnt = -1;
  fts5yypParser->fts5yyerrcnt = -1;
#endif
  pParser->fts5yytos = pParser->fts5yystack;
  pParser->fts5yystack[0].stateno = 0;
  pParser->fts5yystack[0].major = 0;
  fts5yypParser->fts5yytos = fts5yypParser->fts5yystack;
  fts5yypParser->fts5yystack[0].stateno = 0;
  fts5yypParser->fts5yystack[0].major = 0;
#if fts5YYSTACKDEPTH>0
  pParser->fts5yystackEnd = &pParser->fts5yystack[fts5YYSTACKDEPTH-1];
  fts5yypParser->fts5yystackEnd = &fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1];
#endif
}

#ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK
/* 
** This function allocates a new parser.
** The only argument is a pointer to a function which works like
** malloc.
**
** Inputs:
** A pointer to the function used to allocate memory.
**
** Outputs:
** A pointer to a parser.  This pointer is used in subsequent calls
** to sqlite3Fts5Parser and sqlite3Fts5ParserFree.
*/
static void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE)){
  fts5yyParser *pParser;
  pParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) );
  if( pParser ) sqlite3Fts5ParserInit(pParser);
  return pParser;
static void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE) sqlite3Fts5ParserCTX_PDECL){
  fts5yyParser *fts5yypParser;
  fts5yypParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) );
  if( fts5yypParser ){
    sqlite3Fts5ParserCTX_STORE
    sqlite3Fts5ParserInit(fts5yypParser sqlite3Fts5ParserCTX_PARAM);
  }
  return (void*)fts5yypParser;
}
#endif /* sqlite3Fts5Parser_ENGINEALWAYSONSTACK */


/* The following function deletes the "minor type" or semantic value
** associated with a symbol.  The symbol can be either a terminal
** or nonterminal. "fts5yymajor" is the symbol code, and "fts5yypminor" is
** a pointer to the value to be deleted.  The code used to do the 
** deletions is derived from the %destructor and/or %token_destructor
** directives of the input grammar.
*/
static void fts5yy_destructor(
  fts5yyParser *fts5yypParser,    /* The parser */
  fts5YYCODETYPE fts5yymajor,     /* Type code for object to destroy */
  fts5YYMINORTYPE *fts5yypminor   /* The object to be destroyed */
){
  sqlite3Fts5ParserARG_FETCH;
  sqlite3Fts5ParserARG_FETCH
  sqlite3Fts5ParserCTX_FETCH
  switch( fts5yymajor ){
    /* Here is inserted the actions which take place when a
    ** terminal or non-terminal is destroyed.  This can happen
    ** when the symbol is popped from the stack during a
    ** reduce or during error processing or when a parser is 
    ** being destroyed before it is finished parsing.
    **
    ** Note: during a reduce, the only symbols destroyed are those
    ** which appear on the RHS of the rule, but which are *not* used
    ** inside the C code.
    */
/********* Begin destructor definitions ***************************************/
    case 17: /* input */
    case 16: /* input */
{
#line 83 "fts5parse.y"
 (void)pParse; 
#line 555 "fts5parse.c"
#line 568 "fts5parse.c"
}
      break;
    case 18: /* expr */
    case 19: /* cnearset */
    case 20: /* exprlist */
    case 17: /* expr */
    case 18: /* cnearset */
    case 19: /* exprlist */
{
#line 89 "fts5parse.y"
 sqlite3Fts5ParseNodeFree((fts5yypminor->fts5yy54)); 
#line 564 "fts5parse.c"
 sqlite3Fts5ParseNodeFree((fts5yypminor->fts5yy24)); 
#line 577 "fts5parse.c"
}
      break;
    case 21: /* colset */
    case 22: /* colsetlist */
    case 20: /* colset */
    case 21: /* colsetlist */
{
#line 93 "fts5parse.y"
 sqlite3_free((fts5yypminor->fts5yy43)); 
#line 572 "fts5parse.c"
 sqlite3_free((fts5yypminor->fts5yy11)); 
#line 585 "fts5parse.c"
}
      break;
    case 23: /* nearset */
    case 24: /* nearphrases */
    case 22: /* nearset */
    case 23: /* nearphrases */
{
#line 148 "fts5parse.y"
 sqlite3Fts5ParseNearsetFree((fts5yypminor->fts5yy14)); 
#line 580 "fts5parse.c"
 sqlite3Fts5ParseNearsetFree((fts5yypminor->fts5yy46)); 
#line 593 "fts5parse.c"
}
      break;
    case 25: /* phrase */
    case 24: /* phrase */
{
#line 183 "fts5parse.y"
 sqlite3Fts5ParsePhraseFree((fts5yypminor->fts5yy11)); 
#line 587 "fts5parse.c"
 sqlite3Fts5ParsePhraseFree((fts5yypminor->fts5yy53)); 
#line 600 "fts5parse.c"
}
      break;
/********* End destructor definitions *****************************************/
    default:  break;   /* If no destructor action specified: do nothing */
  }
}

2097
2098
2099
2100
2101
2102
2103
2104

2105
2106


2107
2108
2109
2110

2111
2112
2113
2114
2115
2116
2117
2110
2111
2112
2113
2114
2115
2116

2117


2118
2119
2120
2121


2122
2123
2124
2125
2126
2127
2128
2129







-
+
-
-
+
+


-
-
+







}
#endif

/*
** Find the appropriate action for a parser given the terminal
** look-ahead token iLookAhead.
*/
static unsigned int fts5yy_find_shift_action(
static fts5YYACTIONTYPE fts5yy_find_shift_action(
  fts5yyParser *pParser,        /* The parser */
  fts5YYCODETYPE iLookAhead     /* The look-ahead token */
  fts5YYCODETYPE iLookAhead,    /* The look-ahead token */
  fts5YYACTIONTYPE stateno      /* Current state number */
){
  int i;
  int stateno = pParser->fts5yytos->stateno;
 

  if( stateno>fts5YY_MAX_SHIFT ) return stateno;
  assert( stateno <= fts5YY_SHIFT_COUNT );
#if defined(fts5YYCOVERAGE)
  fts5yycoverage[stateno][iLookAhead] = 1;
#endif
  do{
    i = fts5yy_shift_ofst[stateno];
2167
2168
2169
2170
2171
2172
2173
2174

2175
2176
2177
2178
2179
2180
2181
2179
2180
2181
2182
2183
2184
2185

2186
2187
2188
2189
2190
2191
2192
2193







-
+







}

/*
** Find the appropriate action for a parser given the non-terminal
** look-ahead token iLookAhead.
*/
static int fts5yy_find_reduce_action(
  int stateno,              /* Current state number */
  fts5YYACTIONTYPE stateno,     /* Current state number */
  fts5YYCODETYPE iLookAhead     /* The look-ahead token */
){
  int i;
#ifdef fts5YYERRORSYMBOL
  if( stateno>fts5YY_REDUCE_COUNT ){
    return fts5yy_default[stateno];
  }
2196
2197
2198
2199
2200
2201
2202
2203


2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216

2217
2218


2219
2220
2221
2222
2223
2224
2225
2208
2209
2210
2211
2212
2213
2214

2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228

2229
2230

2231
2232
2233
2234
2235
2236
2237
2238
2239







-
+
+












-
+

-
+
+







  return fts5yy_action[i];
}

/*
** The following routine is called if the stack overflows.
*/
static void fts5yyStackOverflow(fts5yyParser *fts5yypParser){
   sqlite3Fts5ParserARG_FETCH;
   sqlite3Fts5ParserARG_FETCH
   sqlite3Fts5ParserCTX_FETCH
#ifndef NDEBUG
   if( fts5yyTraceFILE ){
     fprintf(fts5yyTraceFILE,"%sStack Overflow!\n",fts5yyTracePrompt);
   }
#endif
   while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);
   /* Here code is inserted which will execute if the parser
   ** stack every overflows */
/******** Begin %stack_overflow code ******************************************/
#line 36 "fts5parse.y"

  sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow");
#line 811 "fts5parse.c"
#line 824 "fts5parse.c"
/******** End %stack_overflow code ********************************************/
   sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument var */
   sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument var */
   sqlite3Fts5ParserCTX_STORE
}

/*
** Print tracing information for a SHIFT action
*/
#ifndef NDEBUG
static void fts5yyTraceShift(fts5yyParser *fts5yypParser, int fts5yyNewState, const char *zTag){
2240
2241
2242
2243
2244
2245
2246
2247
2248


2249
2250
2251
2252
2253
2254
2255
2254
2255
2256
2257
2258
2259
2260


2261
2262
2263
2264
2265
2266
2267
2268
2269







-
-
+
+







#endif

/*
** Perform a shift action.
*/
static void fts5yy_shift(
  fts5yyParser *fts5yypParser,          /* The parser to be shifted */
  int fts5yyNewState,               /* The new state to shift in */
  int fts5yyMajor,                  /* The major token to shift in */
  fts5YYACTIONTYPE fts5yyNewState,      /* The new state to shift in */
  fts5YYCODETYPE fts5yyMajor,           /* The major token to shift in */
  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyMinor        /* The minor token to shift in */
){
  fts5yyStackEntry *fts5yytos;
  fts5yypParser->fts5yytos++;
#ifdef fts5YYTRACKMAXSTACKDEPTH
  if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){
    fts5yypParser->fts5yyhwm++;
2271
2272
2273
2274
2275
2276
2277
2278
2279


2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318




























2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333

2334
2335
2336
2337

2338
2339
2340
2341
2342
2343

2344
2345
2346
2347
2348
2349
2350
2285
2286
2287
2288
2289
2290
2291


2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304




























2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346

2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357

2358
2359
2360
2361
2362
2363
2364
2365







-
-
+
+











-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+














-
+




+





-
+







    }
  }
#endif
  if( fts5yyNewState > fts5YY_MAX_SHIFT ){
    fts5yyNewState += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
  }
  fts5yytos = fts5yypParser->fts5yytos;
  fts5yytos->stateno = (fts5YYACTIONTYPE)fts5yyNewState;
  fts5yytos->major = (fts5YYCODETYPE)fts5yyMajor;
  fts5yytos->stateno = fts5yyNewState;
  fts5yytos->major = fts5yyMajor;
  fts5yytos->minor.fts5yy0 = fts5yyMinor;
  fts5yyTraceShift(fts5yypParser, fts5yyNewState, "Shift");
}

/* The following table contains information about every rule that
** is used during the reduce.
*/
static const struct {
  fts5YYCODETYPE lhs;       /* Symbol on the left-hand side of the rule */
  signed char nrhs;     /* Negative of the number of RHS symbols in the rule */
} fts5yyRuleInfo[] = {
  {   17,   -1 }, /* (0) input ::= expr */
  {   21,   -4 }, /* (1) colset ::= MINUS LCP colsetlist RCP */
  {   21,   -3 }, /* (2) colset ::= LCP colsetlist RCP */
  {   21,   -1 }, /* (3) colset ::= STRING */
  {   21,   -2 }, /* (4) colset ::= MINUS STRING */
  {   22,   -2 }, /* (5) colsetlist ::= colsetlist STRING */
  {   22,   -1 }, /* (6) colsetlist ::= STRING */
  {   18,   -3 }, /* (7) expr ::= expr AND expr */
  {   18,   -3 }, /* (8) expr ::= expr OR expr */
  {   18,   -3 }, /* (9) expr ::= expr NOT expr */
  {   18,   -5 }, /* (10) expr ::= colset COLON LP expr RP */
  {   18,   -3 }, /* (11) expr ::= LP expr RP */
  {   18,   -1 }, /* (12) expr ::= exprlist */
  {   20,   -1 }, /* (13) exprlist ::= cnearset */
  {   20,   -2 }, /* (14) exprlist ::= exprlist cnearset */
  {   19,   -1 }, /* (15) cnearset ::= nearset */
  {   19,   -3 }, /* (16) cnearset ::= colset COLON nearset */
  {   23,   -1 }, /* (17) nearset ::= phrase */
  {   23,   -2 }, /* (18) nearset ::= CARET phrase */
  {   23,   -5 }, /* (19) nearset ::= STRING LP nearphrases neardist_opt RP */
  {   24,   -1 }, /* (20) nearphrases ::= phrase */
  {   24,   -2 }, /* (21) nearphrases ::= nearphrases phrase */
  {   26,    0 }, /* (22) neardist_opt ::= */
  {   26,   -2 }, /* (23) neardist_opt ::= COMMA STRING */
  {   25,   -4 }, /* (24) phrase ::= phrase PLUS STRING star_opt */
  {   25,   -2 }, /* (25) phrase ::= STRING star_opt */
  {   27,   -1 }, /* (26) star_opt ::= STAR */
  {   27,    0 }, /* (27) star_opt ::= */
  {   16,   -1 }, /* (0) input ::= expr */
  {   20,   -4 }, /* (1) colset ::= MINUS LCP colsetlist RCP */
  {   20,   -3 }, /* (2) colset ::= LCP colsetlist RCP */
  {   20,   -1 }, /* (3) colset ::= STRING */
  {   20,   -2 }, /* (4) colset ::= MINUS STRING */
  {   21,   -2 }, /* (5) colsetlist ::= colsetlist STRING */
  {   21,   -1 }, /* (6) colsetlist ::= STRING */
  {   17,   -3 }, /* (7) expr ::= expr AND expr */
  {   17,   -3 }, /* (8) expr ::= expr OR expr */
  {   17,   -3 }, /* (9) expr ::= expr NOT expr */
  {   17,   -5 }, /* (10) expr ::= colset COLON LP expr RP */
  {   17,   -3 }, /* (11) expr ::= LP expr RP */
  {   17,   -1 }, /* (12) expr ::= exprlist */
  {   19,   -1 }, /* (13) exprlist ::= cnearset */
  {   19,   -2 }, /* (14) exprlist ::= exprlist cnearset */
  {   18,   -1 }, /* (15) cnearset ::= nearset */
  {   18,   -3 }, /* (16) cnearset ::= colset COLON nearset */
  {   22,   -1 }, /* (17) nearset ::= phrase */
  {   22,   -2 }, /* (18) nearset ::= CARET phrase */
  {   22,   -5 }, /* (19) nearset ::= STRING LP nearphrases neardist_opt RP */
  {   23,   -1 }, /* (20) nearphrases ::= phrase */
  {   23,   -2 }, /* (21) nearphrases ::= nearphrases phrase */
  {   25,    0 }, /* (22) neardist_opt ::= */
  {   25,   -2 }, /* (23) neardist_opt ::= COMMA STRING */
  {   24,   -4 }, /* (24) phrase ::= phrase PLUS STRING star_opt */
  {   24,   -2 }, /* (25) phrase ::= STRING star_opt */
  {   26,   -1 }, /* (26) star_opt ::= STAR */
  {   26,    0 }, /* (27) star_opt ::= */
};

static void fts5yy_accept(fts5yyParser*);  /* Forward Declaration */

/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
**
** The fts5yyLookahead and fts5yyLookaheadToken parameters provide reduce actions
** access to the lookahead token (if any).  The fts5yyLookahead will be fts5YYNOCODE
** if the lookahead token has already been consumed.  As this procedure is
** only called from one place, optimizing compilers will in-line it, which
** means that the extra parameters have no performance impact.
*/
static void fts5yy_reduce(
static fts5YYACTIONTYPE fts5yy_reduce(
  fts5yyParser *fts5yypParser,         /* The parser */
  unsigned int fts5yyruleno,       /* Number of the rule by which to reduce */
  int fts5yyLookahead,             /* Lookahead token, or fts5YYNOCODE if none */
  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyLookaheadToken  /* Value of the lookahead token */
  sqlite3Fts5ParserCTX_PDECL                   /* %extra_context */
){
  int fts5yygoto;                     /* The next state */
  int fts5yyact;                      /* The next action */
  fts5yyStackEntry *fts5yymsp;            /* The top of the parser's stack */
  int fts5yysize;                     /* Amount to pop the stack */
  sqlite3Fts5ParserARG_FETCH;
  sqlite3Fts5ParserARG_FETCH
  (void)fts5yyLookahead;
  (void)fts5yyLookaheadToken;
  fts5yymsp = fts5yypParser->fts5yytos;
#ifndef NDEBUG
  if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
    fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
    if( fts5yysize ){
2367
2368
2369
2370
2371
2372
2373



2374

2375
2376
2377
2378
2379



2380

2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401


2402
2403
2404
2405
2406

2407
2408

2409
2410
2411
2412
2413


2414
2415
2416
2417
2418

2419
2420
2421


2422
2423
2424
2425
2426
2427


2428
2429

2430
2431
2432
2433
2434
2435
2436



2437
2438
2439
2440
2441

2442
2443
2444


2445
2446
2447
2448
2449

2450
2451
2452


2453
2454
2455
2456
2457

2458
2459
2460


2461
2462
2463
2464
2465

2466
2467
2468


2469
2470
2471
2472
2473
2474


2475
2476
2477


2478
2479
2480
2481
2482


2483
2484
2485
2486
2487
2488
2489



2490
2491
2492
2493
2494

2495
2496
2497


2498
2499
2500
2501
2502

2503
2504
2505


2506
2507
2508
2509
2510
2511


2512
2513
2514


2515
2516
2517
2518
2519
2520



2521
2522
2523
2524
2525
2526


2527
2528

2529
2530
2531
2532
2533
2534
2535


2536
2537
2538


2539
2540
2541
2542
2543

2544
2545
2546


2547
2548
2549
2550
2551

2552
2553
2554


2555
2556
2557
2558
2559

2560
2561
2562
2563
2564

2565
2566
2567
2568
2569

2570
2571
2572


2573
2574
2575
2576
2577

2578
2579
2580


2581
2582
2583
2584
2585

2586
2587
2588
2589
2590

2591
2592
2593
2594
2595
2596
2597
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391

2392
2393
2394
2395
2396
2397
2398
2399
2400

2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420


2421
2422
2423
2424
2425
2426

2427
2428

2429
2430
2431
2432


2433
2434
2435
2436
2437
2438

2439
2440


2441
2442
2443
2444
2445
2446


2447
2448
2449

2450
2451
2452
2453
2454



2455
2456
2457
2458
2459
2460
2461

2462
2463


2464
2465
2466
2467
2468
2469

2470
2471


2472
2473
2474
2475
2476
2477

2478
2479


2480
2481
2482
2483
2484
2485

2486
2487


2488
2489
2490
2491
2492
2493


2494
2495
2496


2497
2498
2499
2500
2501


2502
2503
2504
2505
2506
2507



2508
2509
2510
2511
2512
2513
2514

2515
2516


2517
2518
2519
2520
2521
2522

2523
2524


2525
2526
2527
2528
2529
2530


2531
2532
2533


2534
2535
2536
2537
2538



2539
2540
2541
2542
2543
2544
2545


2546
2547
2548

2549
2550
2551
2552
2553
2554


2555
2556
2557


2558
2559
2560
2561
2562
2563

2564
2565


2566
2567
2568
2569
2570
2571

2572
2573


2574
2575
2576
2577
2578
2579

2580
2581
2582
2583
2584

2585
2586
2587
2588
2589

2590
2591


2592
2593
2594
2595
2596
2597

2598
2599


2600
2601
2602
2603
2604
2605

2606
2607
2608
2609
2610

2611
2612
2613
2614
2615
2616
2617
2618







+
+
+
-
+





+
+
+
-
+



















-
-
+
+




-
+

-
+



-
-
+
+




-
+

-
-
+
+




-
-
+
+

-
+




-
-
-
+
+
+




-
+

-
-
+
+




-
+

-
-
+
+




-
+

-
-
+
+




-
+

-
-
+
+




-
-
+
+

-
-
+
+



-
-
+
+




-
-
-
+
+
+




-
+

-
-
+
+




-
+

-
-
+
+




-
-
+
+

-
-
+
+



-
-
-
+
+
+




-
-
+
+

-
+





-
-
+
+

-
-
+
+




-
+

-
-
+
+




-
+

-
-
+
+




-
+




-
+




-
+

-
-
+
+




-
+

-
-
+
+




-
+




-
+







      fts5yypParser->fts5yyhwm++;
      assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));
    }
#endif
#if fts5YYSTACKDEPTH>0 
    if( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystackEnd ){
      fts5yyStackOverflow(fts5yypParser);
      /* The call to fts5yyStackOverflow() above pops the stack until it is
      ** empty, causing the main parser loop to exit.  So the return value
      ** is never used and does not matter. */
      return;
      return 0;
    }
#else
    if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){
      if( fts5yyGrowStack(fts5yypParser) ){
        fts5yyStackOverflow(fts5yypParser);
        /* The call to fts5yyStackOverflow() above pops the stack until it is
        ** empty, causing the main parser loop to exit.  So the return value
        ** is never used and does not matter. */
        return;
        return 0;
      }
      fts5yymsp = fts5yypParser->fts5yytos;
    }
#endif
  }

  switch( fts5yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
/********** Begin reduce actions **********************************************/
        fts5YYMINORTYPE fts5yylhsminor;
      case 0: /* input ::= expr */
#line 82 "fts5parse.y"
{ sqlite3Fts5ParseFinished(pParse, fts5yymsp[0].minor.fts5yy54); }
#line 996 "fts5parse.c"
{ sqlite3Fts5ParseFinished(pParse, fts5yymsp[0].minor.fts5yy24); }
#line 1017 "fts5parse.c"
        break;
      case 1: /* colset ::= MINUS LCP colsetlist RCP */
#line 97 "fts5parse.y"
{ 
    fts5yymsp[-3].minor.fts5yy43 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy43);
    fts5yymsp[-3].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11);
}
#line 1003 "fts5parse.c"
#line 1024 "fts5parse.c"
        break;
      case 2: /* colset ::= LCP colsetlist RCP */
#line 100 "fts5parse.y"
{ fts5yymsp[-2].minor.fts5yy43 = fts5yymsp[-1].minor.fts5yy43; }
#line 1008 "fts5parse.c"
{ fts5yymsp[-2].minor.fts5yy11 = fts5yymsp[-1].minor.fts5yy11; }
#line 1029 "fts5parse.c"
        break;
      case 3: /* colset ::= STRING */
#line 101 "fts5parse.y"
{
  fts5yylhsminor.fts5yy43 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);
  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);
}
#line 1015 "fts5parse.c"
  fts5yymsp[0].minor.fts5yy43 = fts5yylhsminor.fts5yy43;
#line 1036 "fts5parse.c"
  fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
        break;
      case 4: /* colset ::= MINUS STRING */
#line 104 "fts5parse.y"
{
  fts5yymsp[-1].minor.fts5yy43 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);
  fts5yymsp[-1].minor.fts5yy43 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy43);
  fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);
  fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11);
}
#line 1024 "fts5parse.c"
#line 1045 "fts5parse.c"
        break;
      case 5: /* colsetlist ::= colsetlist STRING */
#line 109 "fts5parse.y"
{ 
  fts5yylhsminor.fts5yy43 = sqlite3Fts5ParseColset(pParse, fts5yymsp[-1].minor.fts5yy43, &fts5yymsp[0].minor.fts5yy0); }
#line 1030 "fts5parse.c"
  fts5yymsp[-1].minor.fts5yy43 = fts5yylhsminor.fts5yy43;
  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, fts5yymsp[-1].minor.fts5yy11, &fts5yymsp[0].minor.fts5yy0); }
#line 1051 "fts5parse.c"
  fts5yymsp[-1].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
        break;
      case 6: /* colsetlist ::= STRING */
#line 111 "fts5parse.y"
{ 
  fts5yylhsminor.fts5yy43 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); 
  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); 
}
#line 1038 "fts5parse.c"
  fts5yymsp[0].minor.fts5yy43 = fts5yylhsminor.fts5yy43;
#line 1059 "fts5parse.c"
  fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
        break;
      case 7: /* expr ::= expr AND expr */
#line 115 "fts5parse.y"
{
  fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_AND, fts5yymsp[-2].minor.fts5yy54, fts5yymsp[0].minor.fts5yy54, 0);
  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_AND, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);
}
#line 1046 "fts5parse.c"
  fts5yymsp[-2].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
#line 1067 "fts5parse.c"
  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 8: /* expr ::= expr OR expr */
#line 118 "fts5parse.y"
{
  fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_OR, fts5yymsp[-2].minor.fts5yy54, fts5yymsp[0].minor.fts5yy54, 0);
  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_OR, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);
}
#line 1054 "fts5parse.c"
  fts5yymsp[-2].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
#line 1075 "fts5parse.c"
  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 9: /* expr ::= expr NOT expr */
#line 121 "fts5parse.y"
{
  fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, fts5yymsp[-2].minor.fts5yy54, fts5yymsp[0].minor.fts5yy54, 0);
  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);
}
#line 1062 "fts5parse.c"
  fts5yymsp[-2].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
#line 1083 "fts5parse.c"
  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 10: /* expr ::= colset COLON LP expr RP */
#line 125 "fts5parse.y"
{
  sqlite3Fts5ParseSetColset(pParse, fts5yymsp[-1].minor.fts5yy54, fts5yymsp[-4].minor.fts5yy43);
  fts5yylhsminor.fts5yy54 = fts5yymsp[-1].minor.fts5yy54;
  sqlite3Fts5ParseSetColset(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[-4].minor.fts5yy11);
  fts5yylhsminor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;
}
#line 1071 "fts5parse.c"
  fts5yymsp[-4].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
#line 1092 "fts5parse.c"
  fts5yymsp[-4].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 11: /* expr ::= LP expr RP */
#line 129 "fts5parse.y"
{fts5yymsp[-2].minor.fts5yy54 = fts5yymsp[-1].minor.fts5yy54;}
#line 1077 "fts5parse.c"
{fts5yymsp[-2].minor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;}
#line 1098 "fts5parse.c"
        break;
      case 12: /* expr ::= exprlist */
      case 13: /* exprlist ::= cnearset */ fts5yytestcase(fts5yyruleno==13);
#line 130 "fts5parse.y"
{fts5yylhsminor.fts5yy54 = fts5yymsp[0].minor.fts5yy54;}
#line 1083 "fts5parse.c"
  fts5yymsp[0].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
{fts5yylhsminor.fts5yy24 = fts5yymsp[0].minor.fts5yy24;}
#line 1104 "fts5parse.c"
  fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 14: /* exprlist ::= exprlist cnearset */
#line 133 "fts5parse.y"
{
  fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseImplicitAnd(pParse, fts5yymsp[-1].minor.fts5yy54, fts5yymsp[0].minor.fts5yy54);
  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseImplicitAnd(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24);
}
#line 1091 "fts5parse.c"
  fts5yymsp[-1].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
#line 1112 "fts5parse.c"
  fts5yymsp[-1].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 15: /* cnearset ::= nearset */
#line 137 "fts5parse.y"
{ 
  fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy14); 
  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); 
}
#line 1099 "fts5parse.c"
  fts5yymsp[0].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
#line 1120 "fts5parse.c"
  fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 16: /* cnearset ::= colset COLON nearset */
#line 140 "fts5parse.y"
{ 
  fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy14); 
  sqlite3Fts5ParseSetColset(pParse, fts5yylhsminor.fts5yy54, fts5yymsp[-2].minor.fts5yy43);
  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); 
  sqlite3Fts5ParseSetColset(pParse, fts5yylhsminor.fts5yy24, fts5yymsp[-2].minor.fts5yy11);
}
#line 1108 "fts5parse.c"
  fts5yymsp[-2].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
#line 1129 "fts5parse.c"
  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
        break;
      case 17: /* nearset ::= phrase */
#line 151 "fts5parse.y"
{ fts5yylhsminor.fts5yy14 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy11); }
#line 1114 "fts5parse.c"
  fts5yymsp[0].minor.fts5yy14 = fts5yylhsminor.fts5yy14;
{ fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); }
#line 1135 "fts5parse.c"
  fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46;
        break;
      case 18: /* nearset ::= CARET phrase */
#line 152 "fts5parse.y"
{ 
  sqlite3Fts5ParseSetCaret(fts5yymsp[0].minor.fts5yy11);
  fts5yymsp[-1].minor.fts5yy14 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy11); 
  sqlite3Fts5ParseSetCaret(fts5yymsp[0].minor.fts5yy53);
  fts5yymsp[-1].minor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); 
}
#line 1123 "fts5parse.c"
#line 1144 "fts5parse.c"
        break;
      case 19: /* nearset ::= STRING LP nearphrases neardist_opt RP */
#line 156 "fts5parse.y"
{
  sqlite3Fts5ParseNear(pParse, &fts5yymsp[-4].minor.fts5yy0);
  sqlite3Fts5ParseSetDistance(pParse, fts5yymsp[-2].minor.fts5yy14, &fts5yymsp[-1].minor.fts5yy0);
  fts5yylhsminor.fts5yy14 = fts5yymsp[-2].minor.fts5yy14;
  sqlite3Fts5ParseSetDistance(pParse, fts5yymsp[-2].minor.fts5yy46, &fts5yymsp[-1].minor.fts5yy0);
  fts5yylhsminor.fts5yy46 = fts5yymsp[-2].minor.fts5yy46;
}
#line 1132 "fts5parse.c"
  fts5yymsp[-4].minor.fts5yy14 = fts5yylhsminor.fts5yy14;
#line 1153 "fts5parse.c"
  fts5yymsp[-4].minor.fts5yy46 = fts5yylhsminor.fts5yy46;
        break;
      case 20: /* nearphrases ::= phrase */
#line 162 "fts5parse.y"
{ 
  fts5yylhsminor.fts5yy14 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy11); 
  fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); 
}
#line 1140 "fts5parse.c"
  fts5yymsp[0].minor.fts5yy14 = fts5yylhsminor.fts5yy14;
#line 1161 "fts5parse.c"
  fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46;
        break;
      case 21: /* nearphrases ::= nearphrases phrase */
#line 165 "fts5parse.y"
{
  fts5yylhsminor.fts5yy14 = sqlite3Fts5ParseNearset(pParse, fts5yymsp[-1].minor.fts5yy14, fts5yymsp[0].minor.fts5yy11);
  fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, fts5yymsp[-1].minor.fts5yy46, fts5yymsp[0].minor.fts5yy53);
}
#line 1148 "fts5parse.c"
  fts5yymsp[-1].minor.fts5yy14 = fts5yylhsminor.fts5yy14;
#line 1169 "fts5parse.c"
  fts5yymsp[-1].minor.fts5yy46 = fts5yylhsminor.fts5yy46;
        break;
      case 22: /* neardist_opt ::= */
#line 172 "fts5parse.y"
{ fts5yymsp[1].minor.fts5yy0.p = 0; fts5yymsp[1].minor.fts5yy0.n = 0; }
#line 1154 "fts5parse.c"
#line 1175 "fts5parse.c"
        break;
      case 23: /* neardist_opt ::= COMMA STRING */
#line 173 "fts5parse.y"
{ fts5yymsp[-1].minor.fts5yy0 = fts5yymsp[0].minor.fts5yy0; }
#line 1159 "fts5parse.c"
#line 1180 "fts5parse.c"
        break;
      case 24: /* phrase ::= phrase PLUS STRING star_opt */
#line 185 "fts5parse.y"
{ 
  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseTerm(pParse, fts5yymsp[-3].minor.fts5yy11, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);
  fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, fts5yymsp[-3].minor.fts5yy53, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);
}
#line 1166 "fts5parse.c"
  fts5yymsp[-3].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
#line 1187 "fts5parse.c"
  fts5yymsp[-3].minor.fts5yy53 = fts5yylhsminor.fts5yy53;
        break;
      case 25: /* phrase ::= STRING star_opt */
#line 188 "fts5parse.y"
{ 
  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseTerm(pParse, 0, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);
  fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, 0, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);
}
#line 1174 "fts5parse.c"
  fts5yymsp[-1].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
#line 1195 "fts5parse.c"
  fts5yymsp[-1].minor.fts5yy53 = fts5yylhsminor.fts5yy53;
        break;
      case 26: /* star_opt ::= STAR */
#line 196 "fts5parse.y"
{ fts5yymsp[0].minor.fts5yy4 = 1; }
#line 1180 "fts5parse.c"
#line 1201 "fts5parse.c"
        break;
      case 27: /* star_opt ::= */
#line 197 "fts5parse.y"
{ fts5yymsp[1].minor.fts5yy4 = 0; }
#line 1185 "fts5parse.c"
#line 1206 "fts5parse.c"
        break;
      default:
        break;
/********** End reduce actions ************************************************/
  };
  assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) );
  fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs;
2606
2607
2608
2609
2610
2611
2612

2613
2614
2615
2616
2617
2618
2619
2620
2621
2622


2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633


2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645


2646
2647
2648
2649
2650
2651
2652
2653
2654

2655
2656


2657
2658
2659
2660
2661
2662
2663
2664
2665


2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679


2680
2681
2682
2683
2684
2685
2686
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643

2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655

2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668

2669
2670
2671
2672
2673
2674
2675
2676
2677
2678

2679
2680

2681
2682
2683
2684
2685
2686
2687
2688
2689
2690

2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705

2706
2707
2708
2709
2710
2711
2712
2713
2714







+









-
+
+










-
+
+











-
+
+








-
+

-
+
+








-
+
+













-
+
+







  assert( fts5yyact!=fts5YY_ERROR_ACTION );

  fts5yymsp += fts5yysize+1;
  fts5yypParser->fts5yytos = fts5yymsp;
  fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;
  fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;
  fts5yyTraceShift(fts5yypParser, fts5yyact, "... then shift");
  return fts5yyact;
}

/*
** The following code executes when the parse fails
*/
#ifndef fts5YYNOERRORRECOVERY
static void fts5yy_parse_failed(
  fts5yyParser *fts5yypParser           /* The parser */
){
  sqlite3Fts5ParserARG_FETCH;
  sqlite3Fts5ParserARG_FETCH
  sqlite3Fts5ParserCTX_FETCH
#ifndef NDEBUG
  if( fts5yyTraceFILE ){
    fprintf(fts5yyTraceFILE,"%sFail!\n",fts5yyTracePrompt);
  }
#endif
  while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);
  /* Here code is inserted which will be executed whenever the
  ** parser fails */
/************ Begin %parse_failure code ***************************************/
/************ End %parse_failure code *****************************************/
  sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
  sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
  sqlite3Fts5ParserCTX_STORE
}
#endif /* fts5YYNOERRORRECOVERY */

/*
** The following code executes when a syntax error first occurs.
*/
static void fts5yy_syntax_error(
  fts5yyParser *fts5yypParser,           /* The parser */
  int fts5yymajor,                   /* The major type of the error token */
  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyminor         /* The minor type of the error token */
){
  sqlite3Fts5ParserARG_FETCH;
  sqlite3Fts5ParserARG_FETCH
  sqlite3Fts5ParserCTX_FETCH
#define FTS5TOKEN fts5yyminor
/************ Begin %syntax_error code ****************************************/
#line 30 "fts5parse.y"

  UNUSED_PARAM(fts5yymajor); /* Silence a compiler warning */
  sqlite3Fts5ParseError(
    pParse, "fts5: syntax error near \"%.*s\"",FTS5TOKEN.n,FTS5TOKEN.p
  );
#line 1249 "fts5parse.c"
#line 1274 "fts5parse.c"
/************ End %syntax_error code ******************************************/
  sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
  sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
  sqlite3Fts5ParserCTX_STORE
}

/*
** The following is executed when the parser accepts
*/
static void fts5yy_accept(
  fts5yyParser *fts5yypParser           /* The parser */
){
  sqlite3Fts5ParserARG_FETCH;
  sqlite3Fts5ParserARG_FETCH
  sqlite3Fts5ParserCTX_FETCH
#ifndef NDEBUG
  if( fts5yyTraceFILE ){
    fprintf(fts5yyTraceFILE,"%sAccept!\n",fts5yyTracePrompt);
  }
#endif
#ifndef fts5YYNOERRORRECOVERY
  fts5yypParser->fts5yyerrcnt = -1;
#endif
  assert( fts5yypParser->fts5yytos==fts5yypParser->fts5yystack );
  /* Here code is inserted which will be executed whenever the
  ** parser accepts */
/*********** Begin %parse_accept code *****************************************/
/*********** End %parse_accept code *******************************************/
  sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
  sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
  sqlite3Fts5ParserCTX_STORE
}

/* The main parser program.
** The first argument is a pointer to a structure obtained from
** "sqlite3Fts5ParserAlloc" which describes the current state of the parser.
** The second argument is the major token number.  The third is
** the minor token.  The fourth optional argument is whatever the
2701
2702
2703
2704
2705
2706
2707
2708

2709
2710
2711
2712
2713
2714
2715



2716
2717
2718
2719
2720
2721
2722
2723

2724
2725
2726
2727

2728
2729

2730
2731
2732

2733
2734
2735
2736
2737

2738

2739
2740


2741
2742
2743
2744
2745
2746

2747
2748
2749
2750
2751
2752
2753
2729
2730
2731
2732
2733
2734
2735

2736
2737
2738
2739
2740
2741
2742

2743
2744
2745
2746

2747
2748
2749
2750

2751
2752
2753
2754


2755
2756

2757
2758
2759

2760
2761
2762
2763
2764
2765
2766

2767
2768

2769
2770
2771
2772
2773
2774
2775

2776
2777
2778
2779
2780
2781
2782
2783







-
+






-
+
+
+

-




-

+


-
-
+

-
+


-
+





+
-
+

-
+
+





-
+







static void sqlite3Fts5Parser(
  void *fts5yyp,                   /* The parser */
  int fts5yymajor,                 /* The major token code number */
  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyminor       /* The value for the token */
  sqlite3Fts5ParserARG_PDECL               /* Optional %extra_argument parameter */
){
  fts5YYMINORTYPE fts5yyminorunion;
  unsigned int fts5yyact;   /* The parser action. */
  fts5YYACTIONTYPE fts5yyact;   /* The parser action. */
#if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)
  int fts5yyendofinput;     /* True if we are at the end of input */
#endif
#ifdef fts5YYERRORSYMBOL
  int fts5yyerrorhit = 0;   /* True if fts5yymajor has invoked an error */
#endif
  fts5yyParser *fts5yypParser;  /* The parser */
  fts5yyParser *fts5yypParser = (fts5yyParser*)fts5yyp;  /* The parser */
  sqlite3Fts5ParserCTX_FETCH
  sqlite3Fts5ParserARG_STORE

  fts5yypParser = (fts5yyParser*)fts5yyp;
  assert( fts5yypParser->fts5yytos!=0 );
#if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)
  fts5yyendofinput = (fts5yymajor==0);
#endif
  sqlite3Fts5ParserARG_STORE;

  fts5yyact = fts5yypParser->fts5yytos->stateno;
#ifndef NDEBUG
  if( fts5yyTraceFILE ){
    int stateno = fts5yypParser->fts5yytos->stateno;
    if( stateno < fts5YY_MIN_REDUCE ){
    if( fts5yyact < fts5YY_MIN_REDUCE ){
      fprintf(fts5yyTraceFILE,"%sInput '%s' in state %d\n",
              fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],stateno);
              fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],fts5yyact);
    }else{
      fprintf(fts5yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
              fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],stateno-fts5YY_MIN_REDUCE);
              fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],fts5yyact-fts5YY_MIN_REDUCE);
    }
  }
#endif

  do{
    assert( fts5yyact==fts5yypParser->fts5yytos->stateno );
    fts5yyact = fts5yy_find_shift_action(fts5yypParser,(fts5YYCODETYPE)fts5yymajor);
    fts5yyact = fts5yy_find_shift_action(fts5yymajor,fts5yyact);
    if( fts5yyact >= fts5YY_MIN_REDUCE ){
      fts5yy_reduce(fts5yypParser,fts5yyact-fts5YY_MIN_REDUCE,fts5yymajor,fts5yyminor);
      fts5yyact = fts5yy_reduce(fts5yypParser,fts5yyact-fts5YY_MIN_REDUCE,fts5yymajor,
                        fts5yyminor sqlite3Fts5ParserCTX_PARAM);
    }else if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
      fts5yy_shift(fts5yypParser,fts5yyact,fts5yymajor,fts5yyminor);
#ifndef fts5YYNOERRORRECOVERY
      fts5yypParser->fts5yyerrcnt--;
#endif
      fts5yymajor = fts5YYNOCODE;
      break;
    }else if( fts5yyact==fts5YY_ACCEPT_ACTION ){
      fts5yypParser->fts5yytos--;
      fts5yy_accept(fts5yypParser);
      return;
    }else{
      assert( fts5yyact == fts5YY_ERROR_ACTION );
      fts5yyminorunion.fts5yy0 = fts5yyminor;
2810
2811
2812
2813
2814
2815
2816


2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828

2829
2830
2831
2832
2833
2834
2835
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858


2859
2860
2861
2862
2863
2864
2865
2866







+
+










-
-
+







          fts5yymajor = fts5YYNOCODE;
        }else if( fts5yymx!=fts5YYERRORSYMBOL ){
          fts5yy_shift(fts5yypParser,fts5yyact,fts5YYERRORSYMBOL,fts5yyminor);
        }
      }
      fts5yypParser->fts5yyerrcnt = 3;
      fts5yyerrorhit = 1;
      if( fts5yymajor==fts5YYNOCODE ) break;
      fts5yyact = fts5yypParser->fts5yytos->stateno;
#elif defined(fts5YYNOERRORRECOVERY)
      /* If the fts5YYNOERRORRECOVERY macro is defined, then do not attempt to
      ** do any kind of error recovery.  Instead, simply invoke the syntax
      ** error routine and continue going as if nothing had happened.
      **
      ** Applications can set this macro (for example inside %include) if
      ** they intend to abandon the parse upon the first syntax error seen.
      */
      fts5yy_syntax_error(fts5yypParser,fts5yymajor, fts5yyminor);
      fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
      fts5yymajor = fts5YYNOCODE;
      
      break;
#else  /* fts5YYERRORSYMBOL is not defined */
      /* This is what we do if the grammar does not define ERROR:
      **
      **  * Report an error message, and throw away the input token.
      **
      **  * If the input token is $, then fail the parse.
      **
2843
2844
2845
2846
2847
2848
2849
2850

2851
2852
2853

2854
2855
2856
2857
2858
2859
2860
2874
2875
2876
2877
2878
2879
2880

2881
2882
2883

2884
2885
2886
2887
2888
2889
2890
2891







-
+


-
+







      fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
      if( fts5yyendofinput ){
        fts5yy_parse_failed(fts5yypParser);
#ifndef fts5YYNOERRORRECOVERY
        fts5yypParser->fts5yyerrcnt = -1;
#endif
      }
      fts5yymajor = fts5YYNOCODE;
      break;
#endif
    }
  }while( fts5yymajor!=fts5YYNOCODE && fts5yypParser->fts5yytos>fts5yypParser->fts5yystack );
  }while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack );
#ifndef NDEBUG
  if( fts5yyTraceFILE ){
    fts5yyStackEntry *i;
    char cDiv = '[';
    fprintf(fts5yyTraceFILE,"%sReturn. Stack=",fts5yyTracePrompt);
    for(i=&fts5yypParser->fts5yystack[1]; i<=fts5yypParser->fts5yytos; i++){
      fprintf(fts5yyTraceFILE,"%c%s", cDiv, fts5yyTokenName[i->major]);
17465
17466
17467
17468
17469
17470
17471
17472

17473
17474
17475
17476
17477
17478
17479
17496
17497
17498
17499
17500
17501
17502

17503
17504
17505
17506
17507
17508
17509
17510







-
+







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-28 01:48:40 f677065aab61037914fc980456caaa60132a19b387d6d717ec1a6b6fa7c61a10", -1, SQLITE_TRANSIENT);
  sqlite3_result_text(pCtx, "fts5: 2018-05-28 18:29:46 469a62ca33081854e54f3af6d93ab5a350484b149c8c8c4ee8be0ae5418382d9", -1, SQLITE_TRANSIENT);
}

static int fts5Init(sqlite3 *db){
  static const sqlite3_module fts5Mod = {
    /* iVersion      */ 2,
    /* xCreate       */ fts5CreateMethod,
    /* xConnect      */ fts5ConnectMethod,
Changes to SQLite.Interop/src/ext/json1.c.
2114
2115
2116
2117
2118
2119
2120
2121

2122
2123
2124
2125
2126
2127
2128
2114
2115
2116
2117
2118
2119
2120

2121
2122
2123
2124
2125
2126
2127
2128







-
+







        if( p->zRoot ){
          jsonAppendRaw(&x, p->zRoot, (int)strlen(p->zRoot));
        }else{
          jsonAppendChar(&x, '$');
        }
        if( p->eType==JSON_ARRAY ){
          jsonPrintf(30, &x, "[%d]", p->iRowid);
        }else{
        }else if( p->eType==JSON_OBJECT ){
          jsonPrintf(pThis->n, &x, ".%.*s", pThis->n-2, pThis->u.zJContent+1);
        }
      }
      jsonResult(&x);
      break;
    }
    case JEACH_PATH: {
Changes to readme.htm.
1
2
3
4
5
6
7
8
9


10
11
12
13
14
15
16
1
2
3
4
5
6
7


8
9
10
11
12
13
14
15
16







-
-
+
+







<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
ADO.NET SQLite Data Provider<br />
Version 1.0.109.0 - May XX, 2018 <font color="red">(release scheduled)</font><br />
Using <a href="https://www.sqlite.org/releaselog/3_23_2.html">SQLite 3.23.2</a><br />Originally written by Robert Simpson<br />
Version 1.0.109.0 - June XX, 2018 <font color="red">(release scheduled)</font><br />
Using <a href="https://www.sqlite.org/draft/releaselog/3_24_0.html">SQLite 3.24.0</a><br />Originally written by Robert Simpson<br />
Released to the public domain, use at your own risk!<br />
Official provider website:&nbsp;<a href="https://system.data.sqlite.org/">https://system.data.sqlite.org/</a><br />
Legacy versions:&nbsp;<a href="https://sourceforge.net/projects/sqlite-dotnet2/">https://sourceforge.net/projects/sqlite-dotnet2/</a><br />
<br />
The current development version can be downloaded from <a href="https://system.data.sqlite.org/index.html/timeline?y=ci">
https://system.data.sqlite.org/index.html/timeline?y=ci</a>
<br />
204
205
206
207
208
209
210
211

212
213
214
215
216
217
218
204
205
206
207
208
209
210

211
212
213
214
215
216
217
218







-
+







designed for robustness and maximum backward compatibility with previously
released versions of System.Data.SQLite.
</p>

<h2><b>Version History</b></h2>

<p>
    <b>1.0.109.0 - May XX, 2018 <font color="red">(release scheduled)</font></b>
    <b>1.0.109.0 - June XX, 2018 <font color="red">(release scheduled)</font></b>
</p>
<ul>
    <li>Updated to <a href="https://www.sqlite.org/releaselog/3_23_2.html">SQLite 3.23.2</a>.</li>
    <li>Prevent GetSchemaTable from throwing InvalidCastException. Fix for [baf42ee135].</li>
    <li>Add preliminary support for the .NET Framework 4.7.2.</li>
    <li>Add preliminary support for .NET Core 2.0 and the .NET Standard 2.0. Pursuant to [5c89cecd1b].</li>
    <li>Add simpler overload for the SQLiteBlob.Create method. Pursuant to [dfc8133ba2].</li>
Changes to www/news.wiki.
41
42
43
44
45
46
47
48

49
50
51

52
53
54
55
56
57
58
41
42
43
44
45
46
47

48
49
50

51
52
53
54
55
56
57
58







-
+


-
+







    Access to archived release packages will be granted on a case-by-case basis.
  </li>
</ul>

<div align="center"><h2><b>Version History</b></h2></div>

<p>
    <b>1.0.109.0 - May XX, 2018 <font color="red">(release scheduled)</font></b>
    <b>1.0.109.0 - June XX, 2018 <font color="red">(release scheduled)</font></b>
</p>
<ul>
    <li>Updated to [https://www.sqlite.org/releaselog/3_23_2.html|SQLite 3.23.2].</li>
    <li>Updated to [https://www.sqlite.org/draft/releaselog/3_24_0.html|SQLite 3.24.0].</li>
    <li>Prevent GetSchemaTable from throwing InvalidCastException. Fix for [baf42ee135].</li>
    <li>Add preliminary support for the .NET Framework 4.7.2.</li>
    <li>Add preliminary support for .NET Core 2.0 and the .NET Standard 2.0. Pursuant to [5c89cecd1b].</li>
    <li>Add simpler overload for the SQLiteBlob.Create method. Pursuant to [dfc8133ba2].</li>
    <li>Add GetFieldAffinity method to the SQLiteDataReader class.</li>
</ul>
<p>