Fossil

Check-in [3b99d2ca26]
Login

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

Overview
Comment:Update the built-in SQLite to the latest 3.46.0 pre-release for beta-testing.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3b99d2ca2634dd52264ea7d53181a3987d8bab9e94c5d32c03647efc76545d49
User & Date: drh 2024-03-09 18:52:08.064
Context
2024-03-09
19:17
Add the to2=LABEL query parameter to timeline. This is intended as a backup name for to=END in case the END label cannot be resolved. check-in: 1ff12ea630 user: drh tags: trunk
18:52
Update the built-in SQLite to the latest 3.46.0 pre-release for beta-testing. check-in: 3b99d2ca26 user: drh tags: trunk
07:52
Document the optional IP: part of (server --port IP:PORT), per [forum:88f7f8245e|forum post 88f7f8245e]. check-in: 3815c85746 user: stephan tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to extsrc/shell.c.
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
#endif

  /* Copy the entire schema of database [db] into [dbm]. */
  if( rc==SQLITE_OK ){
    sqlite3_stmt *pSql = 0;
    rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg, 
        "SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'"
        " AND sql NOT LIKE 'CREATE VIRTUAL %%'"
    );
    while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
      const char *zSql = (const char*)sqlite3_column_text(pSql, 0);
      if( zSql ) rc = sqlite3_exec(pNew->dbm, zSql, 0, 0, pzErrmsg);
    }
    idxFinalize(&rc, pSql);
  }







|







13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
#endif

  /* Copy the entire schema of database [db] into [dbm]. */
  if( rc==SQLITE_OK ){
    sqlite3_stmt *pSql = 0;
    rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg, 
        "SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'"
        " AND sql NOT LIKE 'CREATE VIRTUAL %%' ORDER BY rowid"
    );
    while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
      const char *zSql = (const char*)sqlite3_column_text(pSql, 0);
      if( zSql ) rc = sqlite3_exec(pNew->dbm, zSql, 0, 0, pzErrmsg);
    }
    idxFinalize(&rc, pSql);
  }
14005
14006
14007
14008
14009
14010
14011






























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































14012
14013
14014
14015
14016
14017
14018
    sqlite3_free(p);
  }
}

#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */

/************************* End ../ext/expert/sqlite3expert.c ********************/































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
#define SQLITE_SHELL_HAVE_RECOVER 1
#else
#define SQLITE_SHELL_HAVE_RECOVER 0
#endif
#if SQLITE_SHELL_HAVE_RECOVER







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







14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
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
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
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
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
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
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
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
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
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
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
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
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
    sqlite3_free(p);
  }
}

#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */

/************************* End ../ext/expert/sqlite3expert.c ********************/

/************************* Begin ../ext/intck/sqlite3intck.h ******************/
/*
** 2024-02-08
**
** 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.
**
*************************************************************************
*/

/*
** Incremental Integrity-Check Extension
** -------------------------------------
**
** This module contains code to check whether or not an SQLite database
** is well-formed or corrupt. This is the same task as performed by SQLite's
** built-in "PRAGMA integrity_check" command. This module differs from
** "PRAGMA integrity_check" in that:
**
**   +  It is less thorough - this module does not detect certain types
**      of corruption that are detected by the PRAGMA command. However,
**      it does detect all kinds of corruption that are likely to cause
**      errors in SQLite applications.
**
**   +  It is slower. Sometimes up to three times slower.
**
**   +  It allows integrity-check operations to be split into multiple
**      transactions, so that the database does not need to be read-locked
**      for the duration of the integrity-check.
**
** One way to use the API to run integrity-check on the "main" database
** of handle db is:
**
**   int rc = SQLITE_OK;
**   sqlite3_intck *p = 0;
**
**   sqlite3_intck_open(db, "main", &p);
**   while( SQLITE_OK==sqlite3_intck_step(p) ){
**     const char *zMsg = sqlite3_intck_message(p);
**     if( zMsg ) printf("corruption: %s\n", zMsg);
**   }
**   rc = sqlite3_intck_error(p, &zErr);
**   if( rc!=SQLITE_OK ){
**     printf("error occured (rc=%d), (errmsg=%s)\n", rc, zErr);
**   }
**   sqlite3_intck_close(p);
**
** Usually, the sqlite3_intck object opens a read transaction within the
** first call to sqlite3_intck_step() and holds it open until the 
** integrity-check is complete. However, if sqlite3_intck_unlock() is
** called, the read transaction is ended and a new read transaction opened
** by the subsequent call to sqlite3_intck_step().
*/

#ifndef _SQLITE_INTCK_H
#define _SQLITE_INTCK_H

/* #include "sqlite3.h" */

#ifdef __cplusplus
extern "C" {
#endif

/*
** An ongoing incremental integrity-check operation is represented by an
** opaque pointer of the following type.
*/
typedef struct sqlite3_intck sqlite3_intck;

/*
** Open a new incremental integrity-check object. If successful, populate
** output variable (*ppOut) with the new object handle and return SQLITE_OK.
** Or, if an error occurs, set (*ppOut) to NULL and return an SQLite error
** code (e.g. SQLITE_NOMEM).
**
** The integrity-check will be conducted on database zDb (which must be "main",
** "temp", or the name of an attached database) of database handle db. Once
** this function has been called successfully, the caller should not use 
** database handle db until the integrity-check object has been destroyed
** using sqlite3_intck_close().
*/
int sqlite3_intck_open(
  sqlite3 *db,                    /* Database handle */
  const char *zDb,                /* Database name ("main", "temp" etc.) */
  sqlite3_intck **ppOut           /* OUT: New sqlite3_intck handle */
);

/*
** Close and release all resources associated with a handle opened by an
** earlier call to sqlite3_intck_open(). The results of using an
** integrity-check handle after it has been passed to this function are
** undefined.
*/
void sqlite3_intck_close(sqlite3_intck *pCk);

/*
** Do the next step of the integrity-check operation specified by the handle
** passed as the only argument. This function returns SQLITE_DONE if the 
** integrity-check operation is finished, or an SQLite error code if
** an error occurs, or SQLITE_OK if no error occurs but the integrity-check
** is not finished. It is not considered an error if database corruption
** is encountered.
**
** Following a successful call to sqlite3_intck_step() (one that returns
** SQLITE_OK), sqlite3_intck_message() returns a non-NULL value if 
** corruption was detected in the db.
**
** If an error occurs and a value other than SQLITE_OK or SQLITE_DONE is
** returned, then the integrity-check handle is placed in an error state.
** In this state all subsequent calls to sqlite3_intck_step() or 
** sqlite3_intck_unlock() will immediately return the same error. The 
** sqlite3_intck_error() method may be used to obtain an English language 
** error message in this case.
*/
int sqlite3_intck_step(sqlite3_intck *pCk);

/*
** If the previous call to sqlite3_intck_step() encountered corruption 
** within the database, then this function returns a pointer to a buffer
** containing a nul-terminated string describing the corruption in 
** English. If the previous call to sqlite3_intck_step() did not encounter
** corruption, or if there was no previous call, this function returns 
** NULL.
*/
const char *sqlite3_intck_message(sqlite3_intck *pCk);

/*
** Close any read-transaction opened by an earlier call to 
** sqlite3_intck_step(). Any subsequent call to sqlite3_intck_step() will
** open a new transaction. Return SQLITE_OK if successful, or an SQLite error
** code otherwise.
**
** If an error occurs, then the integrity-check handle is placed in an error
** state. In this state all subsequent calls to sqlite3_intck_step() or 
** sqlite3_intck_unlock() will immediately return the same error. The 
** sqlite3_intck_error() method may be used to obtain an English language 
** error message in this case.
*/
int sqlite3_intck_unlock(sqlite3_intck *pCk);

/*
** If an error has occurred in an earlier call to sqlite3_intck_step()
** or sqlite3_intck_unlock(), then this method returns the associated 
** SQLite error code. Additionally, if pzErr is not NULL, then (*pzErr)
** may be set to point to a nul-terminated string containing an English
** language error message. Or, if no error message is available, to
** NULL.
**
** If no error has occurred within sqlite3_intck_step() or
** sqlite_intck_unlock() calls on the handle passed as the first argument, 
** then SQLITE_OK is returned and (*pzErr) set to NULL.
*/
int sqlite3_intck_error(sqlite3_intck *pCk, const char **pzErr);

/*
** This API is used for testing only. It returns the full-text of an SQL
** statement used to test object zObj, which may be a table or index.
** The returned buffer is valid until the next call to either this function
** or sqlite3_intck_close() on the same sqlite3_intck handle.
*/
const char *sqlite3_intck_test_sql(sqlite3_intck *pCk, const char *zObj);


#ifdef __cplusplus
}  /* end of the 'extern "C"' block */
#endif

#endif /* ifndef _SQLITE_INTCK_H */

/************************* End ../ext/intck/sqlite3intck.h ********************/
/************************* Begin ../ext/intck/sqlite3intck.c ******************/
/*
** 2024-02-08
**
** 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.
**
*************************************************************************
*/

/* #include "sqlite3intck.h" */
#include <string.h>
#include <assert.h>

#include <stdio.h>
#include <stdlib.h>

/*
** nKeyVal:
**   The number of values that make up the 'key' for the current pCheck
**   statement.
**
** rc:
**   Error code returned by most recent sqlite3_intck_step() or 
**   sqlite3_intck_unlock() call. This is set to SQLITE_DONE when
**   the integrity-check operation is finished.
**
** zErr:
**   If the object has entered the error state, this is the error message.
**   Is freed using sqlite3_free() when the object is deleted.
**
** zTestSql:
**   The value returned by the most recent call to sqlite3_intck_testsql().
**   Each call to testsql() frees the previous zTestSql value (using
**   sqlite3_free()) and replaces it with the new value it will return.
*/
struct sqlite3_intck {
  sqlite3 *db;
  const char *zDb;                /* Copy of zDb parameter to _open() */
  char *zObj;                     /* Current object. Or NULL. */

  sqlite3_stmt *pCheck;           /* Current check statement */
  char *zKey;
  int nKeyVal;

  char *zMessage;
  int bCorruptSchema;

  int rc;                         /* Error code */
  char *zErr;                     /* Error message */
  char *zTestSql;                 /* Returned by sqlite3_intck_test_sql() */
};


/*
** Some error has occurred while using database p->db. Save the error message
** and error code currently held by the database handle in p->rc and p->zErr.
*/
static void intckSaveErrmsg(sqlite3_intck *p){
  p->rc = sqlite3_errcode(p->db);
  sqlite3_free(p->zErr);
  p->zErr = sqlite3_mprintf("%s", sqlite3_errmsg(p->db));
}

/*
** If the handle passed as the first argument is already in the error state,
** then this function is a no-op (returns NULL immediately). Otherwise, if an
** error occurs within this function, it leaves an error in said handle.
**
** Otherwise, this function attempts to prepare SQL statement zSql and
** return the resulting statement handle to the user.
*/
static sqlite3_stmt *intckPrepare(sqlite3_intck *p, const char *zSql){
  sqlite3_stmt *pRet = 0;
  if( p->rc==SQLITE_OK ){
    p->rc = sqlite3_prepare_v2(p->db, zSql, -1, &pRet, 0);
    if( p->rc!=SQLITE_OK ){
      intckSaveErrmsg(p);
      assert( pRet==0 );
    }
  }
  return pRet;
}

/*
** If the handle passed as the first argument is already in the error state,
** then this function is a no-op (returns NULL immediately). Otherwise, if an
** error occurs within this function, it leaves an error in said handle.
**
** Otherwise, this function treats argument zFmt as a printf() style format
** string. It formats it according to the trailing arguments and then 
** attempts to prepare the results and return the resulting prepared
** statement.
*/
static sqlite3_stmt *intckPrepareFmt(sqlite3_intck *p, const char *zFmt, ...){
  sqlite3_stmt *pRet = 0;
  va_list ap;
  char *zSql = 0;
  va_start(ap, zFmt);
  zSql = sqlite3_vmprintf(zFmt, ap);
  if( p->rc==SQLITE_OK && zSql==0 ){
    p->rc = SQLITE_NOMEM;
  }
  pRet = intckPrepare(p, zSql);
  sqlite3_free(zSql);
  va_end(ap);
  return pRet;
}

/*
** Finalize SQL statement pStmt. If an error occurs and the handle passed
** as the first argument does not already contain an error, store the
** error in the handle.
*/
static void intckFinalize(sqlite3_intck *p, sqlite3_stmt *pStmt){
  int rc = sqlite3_finalize(pStmt);
  if( p->rc==SQLITE_OK && rc!=SQLITE_OK ){
    intckSaveErrmsg(p);
  }
}

/*
** If there is already an error in handle p, return it. Otherwise, call
** sqlite3_step() on the statement handle and return that value.
*/
static int intckStep(sqlite3_intck *p, sqlite3_stmt *pStmt){
  if( p->rc ) return p->rc;
  return sqlite3_step(pStmt);
}

/*
** Execute SQL statement zSql. There is no way to obtain any results 
** returned by the statement. This function uses the sqlite3_intck error
** code convention.
*/
static void intckExec(sqlite3_intck *p, const char *zSql){
  sqlite3_stmt *pStmt = 0;
  pStmt = intckPrepare(p, zSql);
  intckStep(p, pStmt);
  intckFinalize(p, pStmt);
}

/*
** A wrapper around sqlite3_mprintf() that uses the sqlite3_intck error
** code convention.
*/
static char *intckMprintf(sqlite3_intck *p, const char *zFmt, ...){
  va_list ap;
  char *zRet = 0;
  va_start(ap, zFmt);
  zRet = sqlite3_vmprintf(zFmt, ap);
  if( p->rc==SQLITE_OK ){
    if( zRet==0 ){
      p->rc = SQLITE_NOMEM;
    }
  }else{
    sqlite3_free(zRet);
    zRet = 0;
  }
  return zRet;
}

/*
** This is used by sqlite3_intck_unlock() to save the vector key value 
** required to restart the current pCheck query as a nul-terminated string 
** in p->zKey.
*/
static void intckSaveKey(sqlite3_intck *p){
  int ii;
  char *zSql = 0;
  sqlite3_stmt *pStmt = 0;
  sqlite3_stmt *pXinfo = 0;
  const char *zDir = 0;

  assert( p->pCheck );
  assert( p->zKey==0 );

  pXinfo = intckPrepareFmt(p, 
      "SELECT group_concat(desc, '') FROM %Q.sqlite_schema s, "
      "pragma_index_xinfo(%Q, %Q) "
      "WHERE s.type='index' AND s.name=%Q",
      p->zDb, p->zObj, p->zDb, p->zObj
  );
  if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXinfo) ){
    zDir = (const char*)sqlite3_column_text(pXinfo, 0);
  }

  if( zDir==0 ){
    /* Object is a table, not an index. This is the easy case,as there are 
    ** no DESC columns or NULL values in a primary key.  */
    const char *zSep = "SELECT '(' || ";
    for(ii=0; ii<p->nKeyVal; ii++){
      zSql = intckMprintf(p, "%z%squote(?)", zSql, zSep);
      zSep = " || ', ' || ";
    }
    zSql = intckMprintf(p, "%z || ')'", zSql);
  }else{

    /* Object is an index. */
    assert( p->nKeyVal>1 );
    for(ii=p->nKeyVal; ii>0; ii--){
      int bLastIsDesc = zDir[ii-1]=='1';
      int bLastIsNull = sqlite3_column_type(p->pCheck, ii)==SQLITE_NULL;
      const char *zLast = sqlite3_column_name(p->pCheck, ii);
      char *zLhs = 0;
      char *zRhs = 0;
      char *zWhere = 0;

      if( bLastIsNull ){
        if( bLastIsDesc ) continue;
        zWhere = intckMprintf(p, "'%s IS NOT NULL'", zLast);
      }else{
        const char *zOp = bLastIsDesc ? "<" : ">";
        zWhere = intckMprintf(p, "'%s %s ' || quote(?%d)", zLast, zOp, ii);
      }

      if( ii>1 ){
        const char *zLhsSep = "";
        const char *zRhsSep = "";
        int jj;
        for(jj=0; jj<ii-1; jj++){
          const char *zAlias = (const char*)sqlite3_column_name(p->pCheck,jj+1);
          zLhs = intckMprintf(p, "%z%s%s", zLhs, zLhsSep, zAlias);
          zRhs = intckMprintf(p, "%z%squote(?%d)", zRhs, zRhsSep, jj+1);
          zLhsSep = ",";
          zRhsSep = " || ',' || ";
        }

        zWhere = intckMprintf(p, 
            "'(%z) IS (' || %z || ') AND ' || %z",
            zLhs, zRhs, zWhere);
      }
      zWhere = intckMprintf(p, "'WHERE ' || %z", zWhere);

      zSql = intckMprintf(p, "%z%s(quote( %z ) )",
          zSql,
          (zSql==0 ? "VALUES" : ",\n      "),
          zWhere
      );
    }
    zSql = intckMprintf(p, 
        "WITH wc(q) AS (\n%z\n)"
        "SELECT 'VALUES' || group_concat('(' || q || ')', ',\n      ') FROM wc"
        , zSql
    );
  }

  pStmt = intckPrepare(p, zSql);
  if( p->rc==SQLITE_OK ){
    for(ii=0; ii<p->nKeyVal; ii++){
      sqlite3_bind_value(pStmt, ii+1, sqlite3_column_value(p->pCheck, ii+1));
    }
    if( SQLITE_ROW==sqlite3_step(pStmt) ){
      p->zKey = intckMprintf(p,"%s",(const char*)sqlite3_column_text(pStmt, 0));
    }
    intckFinalize(p, pStmt);
  }

  sqlite3_free(zSql);
  intckFinalize(p, pXinfo);
}

/*
** Find the next database object (table or index) to check. If successful,
** set sqlite3_intck.zObj to point to a nul-terminated buffer containing
** the object's name before returning.
*/
static void intckFindObject(sqlite3_intck *p){
  sqlite3_stmt *pStmt = 0;
  char *zPrev = p->zObj;
  p->zObj = 0;

  assert( p->rc==SQLITE_OK );
  assert( p->pCheck==0 );

  pStmt = intckPrepareFmt(p, 
    "WITH tables(table_name) AS (" 
    "  SELECT name"
    "  FROM %Q.sqlite_schema WHERE (type='table' OR type='index') AND rootpage"
    "  UNION ALL "
    "  SELECT 'sqlite_schema'"
    ")"
    "SELECT table_name FROM tables "
    "WHERE ?1 IS NULL OR table_name%s?1 "
    "ORDER BY 1"
    , p->zDb, (p->zKey ? ">=" : ">")
  );

  if( p->rc==SQLITE_OK ){
    sqlite3_bind_text(pStmt, 1, zPrev, -1, SQLITE_TRANSIENT);
    if( sqlite3_step(pStmt)==SQLITE_ROW ){
      p->zObj = intckMprintf(p,"%s",(const char*)sqlite3_column_text(pStmt, 0));
    }
  }
  intckFinalize(p, pStmt);

  /* If this is a new object, ensure the previous key value is cleared. */
  if( sqlite3_stricmp(p->zObj, zPrev) ){
    sqlite3_free(p->zKey);
    p->zKey = 0;
  }

  sqlite3_free(zPrev);
}

/*
** Return the size in bytes of the first token in nul-terminated buffer z.
** For the purposes of this call, a token is either:
**
**   *  a quoted SQL string,
*    *  a contiguous series of ascii alphabet characters, or
*    *  any other single byte.
*/
static int intckGetToken(const char *z){
  char c = z[0];
  int iRet = 1;
  if( c=='\'' || c=='"' || c=='`' ){
    while( 1 ){
      if( z[iRet]==c ){
        iRet++;
        if( z[iRet]!=c ) break;
      }
      iRet++;
    }
  }
  else if( c=='[' ){
    while( z[iRet++]!=']' && z[iRet] );
  }
  else if( (c>='A' && c<='Z') || (c>='a' && c<='z') ){
    while( (z[iRet]>='A' && z[iRet]<='Z') || (z[iRet]>='a' && z[iRet]<='z') ){
      iRet++;
    }
  }

  return iRet;
}

/*
** Return true if argument c is an ascii whitespace character.
*/
static int intckIsSpace(char c){
  return (c==' ' || c=='\t' || c=='\n' || c=='\r');
}

/*
** Argument z points to the text of a CREATE INDEX statement. This function
** identifies the part of the text that contains either the index WHERE 
** clause (if iCol<0) or the iCol'th column of the index.
**
** If (iCol<0), the identified fragment does not include the "WHERE" keyword,
** only the expression that follows it. If (iCol>=0) then the identified
** fragment does not include any trailing sort-order keywords - "ASC" or 
** "DESC".
**
** If the CREATE INDEX statement does not contain the requested field or
** clause, NULL is returned and (*pnByte) is set to 0. Otherwise, a pointer to
** the identified fragment is returned and output parameter (*pnByte) set
** to its size in bytes.
*/
static const char *intckParseCreateIndex(const char *z, int iCol, int *pnByte){
  int iOff = 0;
  int iThisCol = 0;
  int iStart = 0;
  int nOpen = 0;

  const char *zRet = 0;
  int nRet = 0;

  int iEndOfCol = 0;

  /* Skip forward until the first "(" token */
  while( z[iOff]!='(' ){
    iOff += intckGetToken(&z[iOff]);
    if( z[iOff]=='\0' ) return 0;
  }
  assert( z[iOff]=='(' );

  nOpen = 1;
  iOff++;
  iStart = iOff;
  while( z[iOff] ){
    const char *zToken = &z[iOff];
    int nToken = 0;

    /* Check if this is the end of the current column - either a "," or ")"
    ** when nOpen==1.  */
    if( nOpen==1 ){
      if( z[iOff]==',' || z[iOff]==')' ){
        if( iCol==iThisCol ){
          int iEnd = iEndOfCol ? iEndOfCol : iOff;
          nRet = (iEnd - iStart);
          zRet = &z[iStart];
          break;
        }
        iStart = iOff+1;
        while( intckIsSpace(z[iStart]) ) iStart++;
        iThisCol++;
      }
      if( z[iOff]==')' ) break;
    }
    if( z[iOff]=='(' ) nOpen++;
    if( z[iOff]==')' ) nOpen--;
    nToken = intckGetToken(zToken);

    if( (nToken==3 && 0==sqlite3_strnicmp(zToken, "ASC", nToken))
     || (nToken==4 && 0==sqlite3_strnicmp(zToken, "DESC", nToken))
    ){
      iEndOfCol = iOff;
    }else if( 0==intckIsSpace(zToken[0]) ){
      iEndOfCol = 0;
    }

    iOff += nToken;
  }

  /* iStart is now the byte offset of 1 byte passed the final ')' in the
  ** CREATE INDEX statement. Try to find a WHERE clause to return.  */
  while( zRet==0 && z[iOff] ){
    int n = intckGetToken(&z[iOff]);
    if( n==5 && 0==sqlite3_strnicmp(&z[iOff], "where", 5) ){
      zRet = &z[iOff+5];
      nRet = (int)strlen(zRet);
    }
    iOff += n;
  }

  /* Trim any whitespace from the start and end of the returned string. */
  if( zRet ){
    while( intckIsSpace(zRet[0]) ){
      nRet--;
      zRet++;
    }
    while( nRet>0 && intckIsSpace(zRet[nRet-1]) ) nRet--;
  }

  *pnByte = nRet;
  return zRet;
}

/*
** User-defined SQL function wrapper for intckParseCreateIndex():
**
**     SELECT parse_create_index(<sql>, <icol>);
*/
static void intckParseCreateIndexFunc(
  sqlite3_context *pCtx, 
  int nVal, 
  sqlite3_value **apVal
){
  const char *zSql = (const char*)sqlite3_value_text(apVal[0]);
  int idx = sqlite3_value_int(apVal[1]);
  const char *zRes = 0;
  int nRes = 0;

  assert( nVal==2 );
  if( zSql ){
    zRes = intckParseCreateIndex(zSql, idx, &nRes);
  }
  sqlite3_result_text(pCtx, zRes, nRes, SQLITE_TRANSIENT);
}

/*
** Return true if sqlite3_intck.db has automatic indexes enabled, false
** otherwise.
*/
static int intckGetAutoIndex(sqlite3_intck *p){
  int bRet = 0;
  sqlite3_stmt *pStmt = 0;
  pStmt = intckPrepare(p, "PRAGMA automatic_index");
  if( SQLITE_ROW==intckStep(p, pStmt) ){
    bRet = sqlite3_column_int(pStmt, 0);
  }
  intckFinalize(p, pStmt);
  return bRet;
}

/*
** Return true if zObj is an index, or false otherwise.
*/
static int intckIsIndex(sqlite3_intck *p, const char *zObj){
  int bRet = 0;
  sqlite3_stmt *pStmt = 0;
  pStmt = intckPrepareFmt(p, 
      "SELECT 1 FROM %Q.sqlite_schema WHERE name=%Q AND type='index'",
      p->zDb, zObj
  );
  if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
    bRet = 1;
  }
  intckFinalize(p, pStmt);
  return bRet;
}

/*
** Return a pointer to a nul-terminated buffer containing the SQL statement
** used to check database object zObj (a table or index) for corruption.
** If parameter zPrev is not NULL, then it must be a string containing the
** vector key required to restart the check where it left off last time.
** If pnKeyVal is not NULL, then (*pnKeyVal) is set to the number of
** columns in the vector key value for the specified object.
**
** This function uses the sqlite3_intck error code convention.
*/
static char *intckCheckObjectSql(
  sqlite3_intck *p,               /* Integrity check object */
  const char *zObj,               /* Object (table or index) to scan */
  const char *zPrev,              /* Restart key vector, if any */
  int *pnKeyVal                   /* OUT: Number of key-values for this scan */
){
  char *zRet = 0;
  sqlite3_stmt *pStmt = 0;
  int bAutoIndex = 0;
  int bIsIndex = 0;

  const char *zCommon = 
      /* Relation without_rowid also contains just one row. Column "b" is
      ** set to true if the table being examined is a WITHOUT ROWID table,
      ** or false otherwise.  */
      ", without_rowid(b) AS ("
      "  SELECT EXISTS ("
      "    SELECT 1 FROM tabname, pragma_index_list(tab, db) AS l"
      "      WHERE origin='pk' "
      "      AND NOT EXISTS (SELECT 1 FROM sqlite_schema WHERE name=l.name)"
      "  )"
      ")"
      ""
      /* Table idx_cols contains 1 row for each column in each index on the
      ** table being checked. Columns are:
      **
      **   idx_name: Name of the index.
      **   idx_ispk: True if this index is the PK of a WITHOUT ROWID table.
      **   col_name: Name of indexed column, or NULL for index on expression.
      **   col_expr: Indexed expression, including COLLATE clause.
      **   col_alias: Alias used for column in 'intck_wrapper' table.
      */
      ", idx_cols(idx_name, idx_ispk, col_name, col_expr, col_alias) AS ("
      "  SELECT l.name, (l.origin=='pk' AND w.b), i.name, COALESCE(("
      "    SELECT parse_create_index(sql, i.seqno) FROM "
      "    sqlite_schema WHERE name = l.name"
      "  ), format('\"%w\"', i.name) || ' COLLATE ' || quote(i.coll)),"
      "  'c' || row_number() OVER ()"
      "  FROM "
      "      tabname t,"
      "      without_rowid w,"
      "      pragma_index_list(t.tab, t.db) l,"
      "      pragma_index_xinfo(l.name) i"
      "      WHERE i.key"
      "  UNION ALL"
      "  SELECT '', 1, '_rowid_', '_rowid_', 'r1' FROM without_rowid WHERE b=0"
      ")"
      ""
      ""
      /*
      ** For a PK declared as "PRIMARY KEY(a, b) ... WITHOUT ROWID", where
      ** the intck_wrapper aliases of "a" and "b" are "c1" and "c2":
      **
      **   o_pk:   "o.c1, o.c2"
      **   i_pk:   "i.'a', i.'b'"
      **   ...
      **   n_pk:   2
      */ 
      ", tabpk(db, tab, idx, o_pk, i_pk, q_pk, eq_pk, ps_pk, pk_pk, n_pk) AS ("
      "    WITH pkfields(f, a) AS ("
      "      SELECT i.col_name, i.col_alias FROM idx_cols i WHERE i.idx_ispk"
      "    )"
      "    SELECT t.db, t.tab, t.idx, "
      "           group_concat(a, ', '), "
      "           group_concat('i.'||quote(f), ', '), "
      "           group_concat('quote(o.'||a||')', ' || '','' || '),  "
      "           format('(%s)==(%s)',"
      "               group_concat('o.'||a, ', '), "
      "               group_concat(format('\"%w\"', f), ', ')"
      "           ),"
      "           group_concat('%s', ','),"
      "           group_concat('quote('||a||')', ', '),  "
      "           count(*)"
      "    FROM tabname t, pkfields"
      ")"
      ""
      ", idx(name, match_expr, partial, partial_alias, idx_ps, idx_idx) AS ("
      "  SELECT idx_name,"
      "    format('(%s,%s) IS (%s,%s)', "
      "           group_concat(i.col_expr, ', '), i_pk,"
      "           group_concat('o.'||i.col_alias, ', '), o_pk"
      "    ), "
      "    parse_create_index("
      "        (SELECT sql FROM sqlite_schema WHERE name=idx_name), -1"
      "    ),"
      "    'cond' || row_number() OVER ()"
      "    , group_concat('%s', ',')"
      "    , group_concat('quote('||i.col_alias||')', ', ')"
      "  FROM tabpk t, "
      "       without_rowid w,"
      "       idx_cols i"
      "  WHERE i.idx_ispk==0 "
      "  GROUP BY idx_name"
      ")"
      ""
      ", wrapper_with(s) AS ("
      "  SELECT 'intck_wrapper AS (\n  SELECT\n    ' || ("
      "      WITH f(a, b) AS ("
      "        SELECT col_expr, col_alias FROM idx_cols"
      "          UNION ALL "
      "        SELECT partial, partial_alias FROM idx WHERE partial IS NOT NULL"
      "      )"
      "      SELECT group_concat(format('%s AS %s', a, b), ',\n    ') FROM f"
      "    )"
      "    || format('\n  FROM %Q.%Q ', t.db, t.tab)"
           /* If the object being checked is a table, append "NOT INDEXED".
           ** Otherwise, append "INDEXED BY <index>", and then, if the index 
           ** is a partial index " WHERE <condition>".  */
      "    || CASE WHEN t.idx IS NULL THEN "
      "        'NOT INDEXED'"
      "       ELSE"
      "        format('INDEXED BY %Q%s', t.idx, ' WHERE '||i.partial)"
      "       END"
      "    || '\n)'"
      "    FROM tabname t LEFT JOIN idx i ON (i.name=t.idx)"
      ")"
      ""
  ;

  bAutoIndex = intckGetAutoIndex(p);
  if( bAutoIndex ) intckExec(p, "PRAGMA automatic_index = 0");

  bIsIndex = intckIsIndex(p, zObj);
  if( bIsIndex ){
    pStmt = intckPrepareFmt(p,
      /* Table idxname contains a single row. The first column, "db", contains
      ** the name of the db containing the table (e.g. "main") and the second,
      ** "tab", the name of the table itself.  */
      "WITH tabname(db, tab, idx) AS ("
      "  SELECT %Q, (SELECT tbl_name FROM %Q.sqlite_schema WHERE name=%Q), %Q "
      ")"
      ""
      ", whereclause(w_c) AS (%s)"
      ""
      "%s" /* zCommon */
      ""
      ", case_statement(c) AS ("
      "  SELECT "
      "    'CASE WHEN (' || group_concat(col_alias, ', ') || ', 1) IS (\n' "
      "    || '      SELECT ' || group_concat(col_expr, ', ') || ', 1 FROM '"
      "    || format('%%Q.%%Q NOT INDEXED WHERE %%s\n', t.db, t.tab, p.eq_pk)"
      "    || '    )\n  THEN NULL\n    '"
      "    || 'ELSE format(''surplus entry ('"
      "    ||   group_concat('%%s', ',') || ',' || p.ps_pk"
      "    || ') in index ' || t.idx || ''', ' "
      "    ||   group_concat('quote('||i.col_alias||')', ', ') || ', ' || p.pk_pk"
      "    || ')'"
      "    || '\n  END AS error_message'"
      "  FROM tabname t, tabpk p, idx_cols i WHERE i.idx_name=t.idx"
      ")"
      ""
      ", thiskey(k, n) AS ("
      "    SELECT group_concat(i.col_alias, ', ') || ', ' || p.o_pk, "
      "           count(*) + p.n_pk "
      "    FROM tabpk p, idx_cols i WHERE i.idx_name=p.idx"
      ")"
      ""
      ", main_select(m, n) AS ("
      "  SELECT format("
      "      'WITH %%s\n' ||"
      "      ', idx_checker AS (\n' ||"
      "      '  SELECT %%s,\n' ||"
      "      '  %%s\n' || "
      "      '  FROM intck_wrapper AS o\n' ||"
      "      ')\n',"
      "      ww.s, c, t.k"
      "  ), t.n"
      "  FROM case_statement, wrapper_with ww, thiskey t"
      ")"

      "SELECT m || "
      "    group_concat('SELECT * FROM idx_checker ' || w_c, ' UNION ALL '), n"
      " FROM "
      "main_select, whereclause "
      , p->zDb, p->zDb, zObj, zObj
      , zPrev ? zPrev : "VALUES('')", zCommon
      );
  }else{
    pStmt = intckPrepareFmt(p,
      /* Table tabname contains a single row. The first column, "db", contains
      ** the name of the db containing the table (e.g. "main") and the second,
      ** "tab", the name of the table itself.  */
      "WITH tabname(db, tab, idx, prev) AS (SELECT %Q, %Q, NULL, %Q)"
      ""
      "%s" /* zCommon */

      /* expr(e) contains one row for each index on table zObj. Value e
      ** is set to an expression that evaluates to NULL if the required
      ** entry is present in the index, or an error message otherwise.  */
      ", expr(e, p) AS ("
      "  SELECT format('CASE WHEN EXISTS \n"
      "    (SELECT 1 FROM %%Q.%%Q AS i INDEXED BY %%Q WHERE %%s%%s)\n"
      "    THEN NULL\n"
      "    ELSE format(''entry (%%s,%%s) missing from index %%s'', %%s, %%s)\n"
      "  END\n'"
      "    , t.db, t.tab, i.name, i.match_expr, ' AND (' || partial || ')',"
      "      i.idx_ps, t.ps_pk, i.name, i.idx_idx, t.pk_pk),"
      "    CASE WHEN partial IS NULL THEN NULL ELSE i.partial_alias END"
      "  FROM tabpk t, idx i"
      ")"

      ", numbered(ii, cond, e) AS ("
      "  SELECT 0, 'n.ii=0', 'NULL'"
      "    UNION ALL "
      "  SELECT row_number() OVER (),"
      "      '(n.ii='||row_number() OVER ()||COALESCE(' AND '||p||')', ')'), e"
      "  FROM expr"
      ")"

      ", counter_with(w) AS ("
      "    SELECT 'WITH intck_counter(ii) AS (\n  ' || "
      "       group_concat('SELECT '||ii, ' UNION ALL\n  ') "
      "    || '\n)' FROM numbered"
      ")"
      ""
      ", case_statement(c) AS ("
      "    SELECT 'CASE ' || "
      "    group_concat(format('\n  WHEN %%s THEN (%%s)', cond, e), '') ||"
      "    '\nEND AS error_message'"
      "    FROM numbered"
      ")"
      ""

      /* This table contains a single row consisting of a single value -
      ** the text of an SQL expression that may be used by the main SQL
      ** statement to output an SQL literal that can be used to resume
      ** the scan if it is suspended. e.g. for a rowid table, an expression
      ** like:
      **
      **     format('(%d,%d)', _rowid_, n.ii)
      */
      ", thiskey(k, n) AS ("
      "    SELECT o_pk || ', ii', n_pk+1 FROM tabpk"
      ")"
      ""
      ", whereclause(w_c) AS ("
      "    SELECT CASE WHEN prev!='' THEN "
      "    '\nWHERE (' || o_pk ||', n.ii) > ' || prev"
      "    ELSE ''"
      "    END"
      "    FROM tabpk, tabname"
      ")"
      ""
      ", main_select(m, n) AS ("
      "  SELECT format("
      "      '%%s, %%s\nSELECT %%s,\n%%s\nFROM intck_wrapper AS o"
               ", intck_counter AS n%%s\nORDER BY %%s', "
      "      w, ww.s, c, thiskey.k, whereclause.w_c, t.o_pk"
      "  ), thiskey.n"
      "  FROM case_statement, tabpk t, counter_with, "
      "       wrapper_with ww, thiskey, whereclause"
      ")"

      "SELECT m, n FROM main_select",
      p->zDb, zObj, zPrev, zCommon
    );
  }

  while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
    zRet = intckMprintf(p, "%s", (const char*)sqlite3_column_text(pStmt, 0));
    if( pnKeyVal ){
      *pnKeyVal = sqlite3_column_int(pStmt, 1);
    }
  }
  intckFinalize(p, pStmt);

  if( bAutoIndex ) intckExec(p, "PRAGMA automatic_index = 1");
  return zRet;
}

/*
** Open a new integrity-check object.
*/
int sqlite3_intck_open(
  sqlite3 *db,                    /* Database handle to operate on */
  const char *zDbArg,             /* "main", "temp" etc. */
  sqlite3_intck **ppOut           /* OUT: New integrity-check handle */
){
  sqlite3_intck *pNew = 0;
  int rc = SQLITE_OK;
  const char *zDb = zDbArg ? zDbArg : "main";
  int nDb = (int)strlen(zDb);

  pNew = (sqlite3_intck*)sqlite3_malloc(sizeof(*pNew) + nDb + 1);
  if( pNew==0 ){
    rc = SQLITE_NOMEM;
  }else{
    memset(pNew, 0, sizeof(*pNew));
    pNew->db = db;
    pNew->zDb = (const char*)&pNew[1];
    memcpy(&pNew[1], zDb, nDb+1);
    rc = sqlite3_create_function(db, "parse_create_index", 
        2, SQLITE_UTF8, 0, intckParseCreateIndexFunc, 0, 0
    );
    if( rc!=SQLITE_OK ){
      sqlite3_intck_close(pNew);
      pNew = 0;
    }
  }

  *ppOut = pNew;
  return rc;
}

/*
** Free the integrity-check object.
*/
void sqlite3_intck_close(sqlite3_intck *p){
  if( p ){
    sqlite3_finalize(p->pCheck);
    sqlite3_create_function(
        p->db, "parse_create_index", 1, SQLITE_UTF8, 0, 0, 0, 0
    );
    sqlite3_free(p->zObj);
    sqlite3_free(p->zKey);
    sqlite3_free(p->zTestSql);
    sqlite3_free(p->zErr);
    sqlite3_free(p->zMessage);
    sqlite3_free(p);
  }
}

/*
** Step the integrity-check object.
*/
int sqlite3_intck_step(sqlite3_intck *p){
  if( p->rc==SQLITE_OK ){

    if( p->zMessage ){
      sqlite3_free(p->zMessage);
      p->zMessage = 0;
    }

    if( p->bCorruptSchema ){
      p->rc = SQLITE_DONE;
    }else
    if( p->pCheck==0 ){
      intckFindObject(p);
      if( p->rc==SQLITE_OK ){
        if( p->zObj ){
          char *zSql = 0;
          zSql = intckCheckObjectSql(p, p->zObj, p->zKey, &p->nKeyVal);
          p->pCheck = intckPrepare(p, zSql);
          sqlite3_free(zSql);
          sqlite3_free(p->zKey);
          p->zKey = 0;
        }else{
          p->rc = SQLITE_DONE;
        }
      }else if( p->rc==SQLITE_CORRUPT ){
        p->rc = SQLITE_OK;
        p->zMessage = intckMprintf(p, "%s",
            "corruption found while reading database schema"
        );
        p->bCorruptSchema = 1;
      }
    }

    if( p->pCheck ){
      assert( p->rc==SQLITE_OK );
      if( sqlite3_step(p->pCheck)==SQLITE_ROW ){
        /* Normal case, do nothing. */
      }else{
        intckFinalize(p, p->pCheck);
        p->pCheck = 0;
        p->nKeyVal = 0;
        if( p->rc==SQLITE_CORRUPT ){
          p->rc = SQLITE_OK;
          p->zMessage = intckMprintf(p, 
              "corruption found while scanning database object %s", p->zObj
          );
        }
      }
    }
  }

  return p->rc;
}

/*
** Return a message describing the corruption encountered by the most recent
** call to sqlite3_intck_step(), or NULL if no corruption was encountered.
*/
const char *sqlite3_intck_message(sqlite3_intck *p){
  assert( p->pCheck==0 || p->zMessage==0 );
  if( p->zMessage ){
    return p->zMessage;
  }
  if( p->pCheck ){
    return (const char*)sqlite3_column_text(p->pCheck, 0);
  }
  return 0;
}

/*
** Return the error code and message.
*/
int sqlite3_intck_error(sqlite3_intck *p, const char **pzErr){
  if( pzErr ) *pzErr = p->zErr;
  return (p->rc==SQLITE_DONE ? SQLITE_OK : p->rc);
}

/*
** Close any read transaction the integrity-check object is holding open
** on the database.
*/
int sqlite3_intck_unlock(sqlite3_intck *p){
  if( p->rc==SQLITE_OK && p->pCheck ){
    assert( p->zKey==0 && p->nKeyVal>0 );
    intckSaveKey(p);
    intckFinalize(p, p->pCheck);
    p->pCheck = 0;
  }
  return p->rc;
}

/*
** Return the SQL statement used to check object zObj. Or, if zObj is 
** NULL, the current SQL statement.
*/
const char *sqlite3_intck_test_sql(sqlite3_intck *p, const char *zObj){
  sqlite3_free(p->zTestSql);
  if( zObj ){
    p->zTestSql = intckCheckObjectSql(p, zObj, 0, 0);
  }else{
    if( p->zObj ){
      p->zTestSql = intckCheckObjectSql(p, p->zObj, p->zKey, 0);
    }else{
      sqlite3_free(p->zTestSql);
      p->zTestSql = 0;
    }
  }
  return p->zTestSql;
}

/************************* End ../ext/intck/sqlite3intck.c ********************/

#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
#define SQLITE_SHELL_HAVE_RECOVER 1
#else
#define SQLITE_SHELL_HAVE_RECOVER 0
#endif
#if SQLITE_SHELL_HAVE_RECOVER
20639
20640
20641
20642
20643
20644
20645

20646
20647
20648
20649
20650
20651
20652
  int bw = p->cmOpts.bWordWrap;
  const char *zEmpty = "";
  const char *zShowNull = p->nullValue;

  rc = sqlite3_step(pStmt);
  if( rc!=SQLITE_ROW ) return;
  nColumn = sqlite3_column_count(pStmt);

  nAlloc = nColumn*4;
  if( nAlloc<=0 ) nAlloc = 1;
  azData = sqlite3_malloc64( nAlloc*sizeof(char*) );
  shell_check_oom(azData);
  azNextLine = sqlite3_malloc64( nColumn*sizeof(char*) );
  shell_check_oom(azNextLine);
  memset((void*)azNextLine, 0, nColumn*sizeof(char*) );







>







21757
21758
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
21771
  int bw = p->cmOpts.bWordWrap;
  const char *zEmpty = "";
  const char *zShowNull = p->nullValue;

  rc = sqlite3_step(pStmt);
  if( rc!=SQLITE_ROW ) return;
  nColumn = sqlite3_column_count(pStmt);
  if( nColumn==0 ) goto columnar_end;
  nAlloc = nColumn*4;
  if( nAlloc<=0 ) nAlloc = 1;
  azData = sqlite3_malloc64( nAlloc*sizeof(char*) );
  shell_check_oom(azData);
  azNextLine = sqlite3_malloc64( nColumn*sizeof(char*) );
  shell_check_oom(azNextLine);
  memset((void*)azNextLine, 0, nColumn*sizeof(char*) );
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
    z = azData[i];
    if( z==0 ) z = (char*)zEmpty;
    n = strlenChar(z);
    j = i%nColumn;
    if( n>p->actualWidth[j] ) p->actualWidth[j] = n;
  }
  if( seenInterrupt ) goto columnar_end;
  if( nColumn==0 ) goto columnar_end;
  switch( p->cMode ){
    case MODE_Column: {
      colSep = "  ";
      rowSep = "\n";
      if( p->showHeader ){
        for(i=0; i<nColumn; i++){
          w = p->actualWidth[i];







<







21843
21844
21845
21846
21847
21848
21849

21850
21851
21852
21853
21854
21855
21856
    z = azData[i];
    if( z==0 ) z = (char*)zEmpty;
    n = strlenChar(z);
    j = i%nColumn;
    if( n>p->actualWidth[j] ) p->actualWidth[j] = n;
  }
  if( seenInterrupt ) goto columnar_end;

  switch( p->cMode ){
    case MODE_Column: {
      colSep = "  ";
      rowSep = "\n";
      if( p->showHeader ){
        for(i=0; i<nColumn; i++){
          w = p->actualWidth[i];
21607
21608
21609
21610
21611
21612
21613

21614
21615
21616
21617
21618
21619
21620
#endif
#ifndef SQLITE_OMIT_TEST_CONTROL
  ",imposter INDEX TABLE    Create imposter table TABLE on index INDEX",
#endif
  ".indexes ?TABLE?         Show names of indexes",
  "                           If TABLE is specified, only show indexes for",
  "                           tables matching TABLE using the LIKE operator.",

#ifdef SQLITE_ENABLE_IOTRACE
  ",iotrace FILE            Enable I/O diagnostic logging to FILE",
#endif
  ".limit ?LIMIT? ?VAL?     Display or change the value of an SQLITE_LIMIT",
  ".lint OPTIONS            Report potential schema issues.",
  "     Options:",
  "        fkey-indexes     Find missing foreign key indexes",







>







22725
22726
22727
22728
22729
22730
22731
22732
22733
22734
22735
22736
22737
22738
22739
#endif
#ifndef SQLITE_OMIT_TEST_CONTROL
  ",imposter INDEX TABLE    Create imposter table TABLE on index INDEX",
#endif
  ".indexes ?TABLE?         Show names of indexes",
  "                           If TABLE is specified, only show indexes for",
  "                           tables matching TABLE using the LIKE operator.",
  ".intck ?STEPS_PER_UNLOCK?  Run an incremental integrity check on the db",
#ifdef SQLITE_ENABLE_IOTRACE
  ",iotrace FILE            Enable I/O diagnostic logging to FILE",
#endif
  ".limit ?LIMIT? ?VAL?     Display or change the value of an SQLITE_LIMIT",
  ".lint OPTIONS            Report potential schema issues.",
  "     Options:",
  "        fkey-indexes     Find missing foreign key indexes",
24516
24517
24518
24519
24520
24521
24522


































24523
24524
24525
24526
24527
24528
24529
    eputf("sql error: %s (%d)\n", zErr, errCode);
  }
  rc = sqlite3_recover_finish(p);
  return rc;
}
#endif /* SQLITE_SHELL_HAVE_RECOVER */




































/*
 * zAutoColumn(zCol, &db, ?) => Maybe init db, add column zCol to it.
 * zAutoColumn(0, &db, ?) => (db!=0) Form columns spec for CREATE TABLE,
 *   close db and set it to 0, and return the columns spec, to later
 *   be sqlite3_free()'ed by the caller.
 * The return is 0 when either:







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







25635
25636
25637
25638
25639
25640
25641
25642
25643
25644
25645
25646
25647
25648
25649
25650
25651
25652
25653
25654
25655
25656
25657
25658
25659
25660
25661
25662
25663
25664
25665
25666
25667
25668
25669
25670
25671
25672
25673
25674
25675
25676
25677
25678
25679
25680
25681
25682
    eputf("sql error: %s (%d)\n", zErr, errCode);
  }
  rc = sqlite3_recover_finish(p);
  return rc;
}
#endif /* SQLITE_SHELL_HAVE_RECOVER */

/*
** Implementation of ".intck STEPS_PER_UNLOCK" command.
*/
static int intckDatabaseCmd(ShellState *pState, i64 nStepPerUnlock){
  sqlite3_intck *p = 0;
  int rc = SQLITE_OK;

  rc = sqlite3_intck_open(pState->db, "main", &p);
  if( rc==SQLITE_OK ){
    i64 nStep = 0;
    i64 nError = 0;
    const char *zErr = 0;
    while( SQLITE_OK==sqlite3_intck_step(p) ){
      const char *zMsg = sqlite3_intck_message(p);
      if( zMsg ){
        oputf("%s\n", zMsg);
        nError++;
      }
      nStep++;
      if( nStepPerUnlock && (nStep % nStepPerUnlock)==0 ){
        sqlite3_intck_unlock(p);
      }
    }
    rc = sqlite3_intck_error(p, &zErr);
    if( zErr ){
      eputf("%s\n", zErr);
    }
    sqlite3_intck_close(p);

    oputf("%lld steps, %lld errors\n", nStep, nError);
  }

  return rc;
}

/*
 * zAutoColumn(zCol, &db, ?) => Maybe init db, add column zCol to it.
 * zAutoColumn(0, &db, ?) => (db!=0) Form columns spec for CREATE TABLE,
 *   close db and set it to 0, and return the columns spec, to later
 *   be sqlite3_free()'ed by the caller.
 * The return is 0 when either:
26005
26006
26007
26008
26009
26010
26011















26012
26013
26014
26015
26016
26017
26018
    }else{
      eputf("SQLITE_TESTCTRL_IMPOSTER returns %d\n", rc);
      rc = 1;
    }
    sqlite3_free(zSql);
  }else
#endif /* !defined(SQLITE_OMIT_TEST_CONTROL) */
















#ifdef SQLITE_ENABLE_IOTRACE
  if( c=='i' && cli_strncmp(azArg[0], "iotrace", n)==0 ){
    SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...);
    if( iotrace && iotrace!=stdout ) fclose(iotrace);
    iotrace = 0;
    if( nArg<2 ){







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







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
    }else{
      eputf("SQLITE_TESTCTRL_IMPOSTER returns %d\n", rc);
      rc = 1;
    }
    sqlite3_free(zSql);
  }else
#endif /* !defined(SQLITE_OMIT_TEST_CONTROL) */

  if( c=='i' && cli_strncmp(azArg[0], "intck", n)==0 ){
    i64 iArg = 0;
    if( nArg==2 ){
      iArg = integerValue(azArg[1]);
      if( iArg==0 ) iArg = -1;
    }
    if( (nArg!=1 && nArg!=2) || iArg<0 ){
      eputf("%s","Usage: .intck STEPS_PER_UNLOCK\n");
      rc = 1;
      goto meta_command_exit;
    }
    open_db(p, 0);
    rc = intckDatabaseCmd(p, iArg);
  }else

#ifdef SQLITE_ENABLE_IOTRACE
  if( c=='i' && cli_strncmp(azArg[0], "iotrace", n)==0 ){
    SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...);
    if( iotrace && iotrace!=stdout ) fclose(iotrace);
    iotrace = 0;
    if( nArg<2 ){
29585
29586
29587
29588
29589
29590
29591





29592
29593
29594
29595
29596
29597
29598
      data.in = stdin;
      rc = process_input(&data);
    }
  }
#ifndef SQLITE_SHELL_FIDDLE
  /* In WASM mode we have to leave the db state in place so that
  ** client code can "push" SQL into it after this call returns. */





  free(azCmd);
  set_table_name(&data, 0);
  if( data.db ){
    session_close_all(&data, -1);
    close_db(data.db);
  }
  for(i=0; i<ArraySize(data.aAuxDb); i++){







>
>
>
>
>







30753
30754
30755
30756
30757
30758
30759
30760
30761
30762
30763
30764
30765
30766
30767
30768
30769
30770
30771
      data.in = stdin;
      rc = process_input(&data);
    }
  }
#ifndef SQLITE_SHELL_FIDDLE
  /* In WASM mode we have to leave the db state in place so that
  ** client code can "push" SQL into it after this call returns. */
#ifndef SQLITE_OMIT_VIRTUALTABLE
  if( data.expert.pExpert ){
    expertFinish(&data, 1, 0);
  }
#endif
  free(azCmd);
  set_table_name(&data, 0);
  if( data.db ){
    session_close_all(&data, -1);
    close_db(data.db);
  }
  for(i=0; i<ArraySize(data.aAuxDb); i++){
29651
29652
29653
29654
29655
29656
29657
29658
29659
29660
29661
29662
29663
29664
29665
                         SQLITE_FCNTL_VFS_POINTER, &pVfs);
  }
  return pVfs;
}

/* Only for emcc experimentation purposes. */
sqlite3 * fiddle_db_arg(sqlite3 *arg){
    printf("fiddle_db_arg(%p)\n", (const void*)arg);
    return arg;
}

/*
** Intended to be called via a SharedWorker() while a separate
** SharedWorker() (which manages the wasm module) is performing work
** which should be interrupted. Unfortunately, SharedWorker is not







|







30824
30825
30826
30827
30828
30829
30830
30831
30832
30833
30834
30835
30836
30837
30838
                         SQLITE_FCNTL_VFS_POINTER, &pVfs);
  }
  return pVfs;
}

/* Only for emcc experimentation purposes. */
sqlite3 * fiddle_db_arg(sqlite3 *arg){
    oputf("fiddle_db_arg(%p)\n", (const void*)arg);
    return arg;
}

/*
** Intended to be called via a SharedWorker() while a separate
** SharedWorker() (which manages the wasm module) is performing work
** which should be interrupted. Unfortunately, SharedWorker is not
29677
29678
29679
29680
29681
29682
29683
29684

29685
29686
29687









29688
29689
29690
29691
29692
29693
29694
29695
29696
    return globalDb
      ? sqlite3_db_filename(globalDb, zDbName ? zDbName : "main")
      : NULL;
}

/*
** Completely wipes out the contents of the currently-opened database
** but leaves its storage intact for reuse.

*/
void fiddle_reset_db(void){
  if( globalDb ){









    int rc = sqlite3_db_config(globalDb, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
    if( 0==rc ) rc = sqlite3_exec(globalDb, "VACUUM", 0, 0, 0);
    sqlite3_db_config(globalDb, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
  }
}

/*
** Uses the current database's VFS xRead to stream the db file's
** contents out to the given callback. The callback gets a single







|
>



>
>
>
>
>
>
>
>
>
|
|







30850
30851
30852
30853
30854
30855
30856
30857
30858
30859
30860
30861
30862
30863
30864
30865
30866
30867
30868
30869
30870
30871
30872
30873
30874
30875
30876
30877
30878
30879
    return globalDb
      ? sqlite3_db_filename(globalDb, zDbName ? zDbName : "main")
      : NULL;
}

/*
** Completely wipes out the contents of the currently-opened database
** but leaves its storage intact for reuse. If any transactions are
** active, they are forcibly rolled back.
*/
void fiddle_reset_db(void){
  if( globalDb ){
    int rc;
    while( sqlite3_txn_state(globalDb,0)>0 ){
      /*
      ** Resolve problem reported in
      ** https://sqlite.org/forum/forumpost/0b41a25d65
      */
      oputz("Rolling back in-progress transaction.\n");
      sqlite3_exec(globalDb,"ROLLBACK", 0, 0, 0);
    }
    rc = sqlite3_db_config(globalDb, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
    if( 0==rc ) sqlite3_exec(globalDb, "VACUUM", 0, 0, 0);
    sqlite3_db_config(globalDb, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
  }
}

/*
** Uses the current database's VFS xRead to stream the db file's
** contents out to the given callback. The callback gets a single
Changes to extsrc/sqlite3.c.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
** the text of this file.  Search for "Begin file sqlite3.h" to find the start
** of the embedded sqlite3.h header file.) Additional code files may be needed
** if you want a wrapper to interface SQLite with your choice of programming
** language. The code for the "sqlite3" command-line shell is also in a
** separate file. This file contains only code for the core SQLite library.
**
** The content in this amalgamation comes from Fossil check-in
** ce5df19dc4aff3fde03ef62261a5e095a16a.
*/
#define SQLITE_CORE 1
#define SQLITE_AMALGAMATION 1
#ifndef SQLITE_PRIVATE
# define SQLITE_PRIVATE static
#endif
/************** Begin file sqliteInt.h ***************************************/







|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
** the text of this file.  Search for "Begin file sqlite3.h" to find the start
** of the embedded sqlite3.h header file.) Additional code files may be needed
** if you want a wrapper to interface SQLite with your choice of programming
** language. The code for the "sqlite3" command-line shell is also in a
** separate file. This file contains only code for the core SQLite library.
**
** The content in this amalgamation comes from Fossil check-in
** 7ead022edaf7a0cd6a8976a1261246084975.
*/
#define SQLITE_CORE 1
#define SQLITE_AMALGAMATION 1
#ifndef SQLITE_PRIVATE
# define SQLITE_PRIVATE static
#endif
/************** Begin file sqliteInt.h ***************************************/
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION        "3.46.0"
#define SQLITE_VERSION_NUMBER 3046000
#define SQLITE_SOURCE_ID      "2024-02-22 00:50:54 ce5df19dc4aff3fde03ef62261a5e095a16a8f4e46e2924becea4fed56ce49e3"

/*
** 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







|







457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION        "3.46.0"
#define SQLITE_VERSION_NUMBER 3046000
#define SQLITE_SOURCE_ID      "2024-03-09 18:41:40 7ead022edaf7a0cd6a8976a1261246084975c9a5be5c893f6c751bb5f963ac0f"

/*
** 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
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
** <li> [SQLITE_LOCK_SHARED],
** <li> [SQLITE_LOCK_RESERVED],
** <li> [SQLITE_LOCK_PENDING], or
** <li> [SQLITE_LOCK_EXCLUSIVE].
** </ul>
** xLock() upgrades the database file lock.  In other words, xLock() moves the
** database file lock in the direction NONE toward EXCLUSIVE. The argument to
** xLock() is always on of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
** SQLITE_LOCK_NONE.  If the database file lock is already at or above the
** requested lock, then the call to xLock() is a no-op.
** xUnlock() downgrades the database file lock to either SHARED or NONE.
*  If the lock is already at or below the requested lock state, then the call
** to xUnlock() is a no-op.
** The xCheckReservedLock() method checks whether any database connection,
** either in this process or in some other process, is holding a RESERVED,
** PENDING, or EXCLUSIVE lock on the file.  It returns true
** if such a lock exists and false otherwise.
**
** The xFileControl() method is a generic interface that allows custom







|



|







1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
** <li> [SQLITE_LOCK_SHARED],
** <li> [SQLITE_LOCK_RESERVED],
** <li> [SQLITE_LOCK_PENDING], or
** <li> [SQLITE_LOCK_EXCLUSIVE].
** </ul>
** xLock() upgrades the database file lock.  In other words, xLock() moves the
** database file lock in the direction NONE toward EXCLUSIVE. The argument to
** xLock() is always one of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
** SQLITE_LOCK_NONE.  If the database file lock is already at or above the
** requested lock, then the call to xLock() is a no-op.
** xUnlock() downgrades the database file lock to either SHARED or NONE.
** If the lock is already at or below the requested lock state, then the call
** to xUnlock() is a no-op.
** The xCheckReservedLock() method checks whether any database connection,
** either in this process or in some other process, is holding a RESERVED,
** PENDING, or EXCLUSIVE lock on the file.  It returns true
** if such a lock exists and false otherwise.
**
** The xFileControl() method is a generic interface that allows custom
14293
14294
14295
14296
14297
14298
14299


14300
14301
14302
14303
14304
14305
14306
/*
** SQLITE_OMIT_VIRTUALTABLE implies SQLITE_OMIT_ALTERTABLE
*/
#if defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_ALTERTABLE)
# define SQLITE_OMIT_ALTERTABLE
#endif



/*
** Return true (non-zero) if the input is an integer that is too large
** to fit in 32-bits.  This macro is used inside of various testcase()
** macros to verify that we have tested SQLite for large-file support.
*/
#define IS_BIG_INT(X)  (((X)&~(i64)0xffffffff)!=0)








>
>







14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
/*
** SQLITE_OMIT_VIRTUALTABLE implies SQLITE_OMIT_ALTERTABLE
*/
#if defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_ALTERTABLE)
# define SQLITE_OMIT_ALTERTABLE
#endif

#define SQLITE_DIGIT_SEPARATOR '_'

/*
** Return true (non-zero) if the input is an integer that is too large
** to fit in 32-bits.  This macro is used inside of various testcase()
** macros to verify that we have tested SQLite for large-file support.
*/
#define IS_BIG_INT(X)  (((X)&~(i64)0xffffffff)!=0)

14595
14596
14597
14598
14599
14600
14601

14602
14603
14604
14605
14606
14607
14608
14609
14610
#define TK_REGISTER                       176
#define TK_VECTOR                         177
#define TK_SELECT_COLUMN                  178
#define TK_IF_NULL_ROW                    179
#define TK_ASTERISK                       180
#define TK_SPAN                           181
#define TK_ERROR                          182

#define TK_SPACE                          183
#define TK_ILLEGAL                        184

/************** End of parse.h ***********************************************/
/************** Continuing where we left off in sqliteInt.h ******************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>







>
|
|







14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
#define TK_REGISTER                       176
#define TK_VECTOR                         177
#define TK_SELECT_COLUMN                  178
#define TK_IF_NULL_ROW                    179
#define TK_ASTERISK                       180
#define TK_SPAN                           181
#define TK_ERROR                          182
#define TK_QNUMBER                        183
#define TK_SPACE                          184
#define TK_ILLEGAL                        185

/************** End of parse.h ***********************************************/
/************** Continuing where we left off in sqliteInt.h ******************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
15095
15096
15097
15098
15099
15100
15101

15102
15103
15104
15105
15106
15107
15108
**   0x00001000     LEFT JOIN simplifies to JOIN
**   0x00002000     Constant propagation
**   0x00004000     Push-down optimization
**   0x00008000     After all FROM-clause analysis
**   0x00010000     Beginning of DELETE/INSERT/UPDATE processing
**   0x00020000     Transform DISTINCT into GROUP BY
**   0x00040000     SELECT tree dump after all code has been generated

*/

/*
** Macros for "wheretrace"
*/
SQLITE_PRIVATE u32 sqlite3WhereTrace;
#if defined(SQLITE_DEBUG) \







>







15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
**   0x00001000     LEFT JOIN simplifies to JOIN
**   0x00002000     Constant propagation
**   0x00004000     Push-down optimization
**   0x00008000     After all FROM-clause analysis
**   0x00010000     Beginning of DELETE/INSERT/UPDATE processing
**   0x00020000     Transform DISTINCT into GROUP BY
**   0x00040000     SELECT tree dump after all code has been generated
**   0x00080000     NOT NULL strength reduction
*/

/*
** Macros for "wheretrace"
*/
SQLITE_PRIVATE u32 sqlite3WhereTrace;
#if defined(SQLITE_DEBUG) \
16274
16275
16276
16277
16278
16279
16280

16281
16282
16283
16284
16285
16286
16287
SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor*);

SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
  sqlite3 *db,  /* Database connection that is running the check */
  Btree *p,     /* The btree to be checked */
  Pgno *aRoot,  /* An array of root pages numbers for individual trees */

  int nRoot,    /* Number of entries in aRoot[] */
  int mxErr,    /* Stop reporting errors after this many */
  int *pnErr,   /* OUT: Write number of errors seen to this variable */
  char **pzOut  /* OUT: Write the error message string here */
);
SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*);







>







16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor*);

SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
  sqlite3 *db,  /* Database connection that is running the check */
  Btree *p,     /* The btree to be checked */
  Pgno *aRoot,  /* An array of root pages numbers for individual trees */
  sqlite3_value *aCnt,  /* OUT: entry counts for each btree in aRoot[] */
  int nRoot,    /* Number of entries in aRoot[] */
  int mxErr,    /* Stop reporting errors after this many */
  int *pnErr,   /* OUT: Write number of errors seen to this variable */
  char **pzOut  /* OUT: Write the error message string here */
);
SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*);
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
#define OP_AutoCommit      1
#define OP_Transaction     2
#define OP_Checkpoint      3
#define OP_JournalMode     4
#define OP_Vacuum          5
#define OP_VFilter         6 /* jump, synopsis: iplan=r[P3] zplan='P4'     */
#define OP_VUpdate         7 /* synopsis: data=r[P3@P2]                    */
#define OP_Init            8 /* jump, synopsis: Start at P2                */
#define OP_Goto            9 /* jump                                       */
#define OP_Gosub          10 /* jump                                       */
#define OP_InitCoroutine  11 /* jump                                       */
#define OP_Yield          12 /* jump                                       */
#define OP_MustBeInt      13 /* jump                                       */
#define OP_Jump           14 /* jump                                       */
#define OP_Once           15 /* jump                                       */
#define OP_If             16 /* jump                                       */
#define OP_IfNot          17 /* jump                                       */
#define OP_IsType         18 /* jump, synopsis: if typeof(P1.P3) in P5 goto P2 */
#define OP_Not            19 /* same as TK_NOT, synopsis: r[P2]= !r[P1]    */
#define OP_IfNullRow      20 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */
#define OP_SeekLT         21 /* jump, synopsis: key=r[P3@P4]               */
#define OP_SeekLE         22 /* jump, synopsis: key=r[P3@P4]               */
#define OP_SeekGE         23 /* jump, synopsis: key=r[P3@P4]               */
#define OP_SeekGT         24 /* jump, synopsis: key=r[P3@P4]               */
#define OP_IfNotOpen      25 /* jump, synopsis: if( !csr[P1] ) goto P2     */
#define OP_IfNoHope       26 /* jump, synopsis: key=r[P3@P4]               */
#define OP_NoConflict     27 /* jump, synopsis: key=r[P3@P4]               */
#define OP_NotFound       28 /* jump, synopsis: key=r[P3@P4]               */
#define OP_Found          29 /* jump, synopsis: key=r[P3@P4]               */
#define OP_SeekRowid      30 /* jump, synopsis: intkey=r[P3]               */
#define OP_NotExists      31 /* jump, synopsis: intkey=r[P3]               */
#define OP_Last           32 /* jump                                       */
#define OP_IfSizeBetween  33 /* jump                                       */
#define OP_SorterSort     34 /* jump                                       */
#define OP_Sort           35 /* jump                                       */
#define OP_Rewind         36 /* jump                                       */
#define OP_SorterNext     37 /* jump                                       */
#define OP_Prev           38 /* jump                                       */
#define OP_Next           39 /* jump                                       */
#define OP_IdxLE          40 /* jump, synopsis: key=r[P3@P4]               */
#define OP_IdxGT          41 /* jump, synopsis: key=r[P3@P4]               */
#define OP_IdxLT          42 /* jump, synopsis: key=r[P3@P4]               */
#define OP_Or             43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
#define OP_And            44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
#define OP_IdxGE          45 /* jump, synopsis: key=r[P3@P4]               */
#define OP_RowSetRead     46 /* jump, synopsis: r[P3]=rowset(P1)           */
#define OP_RowSetTest     47 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
#define OP_Program        48 /* jump                                       */
#define OP_FkIfZero       49 /* jump, synopsis: if fkctr[P1]==0 goto P2    */
#define OP_IsNull         50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
#define OP_NotNull        51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
#define OP_Ne             52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
#define OP_Eq             53 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */
#define OP_Gt             54 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */
#define OP_Le             55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */







|


|
|
|







|
|
|
|





|

|



|











|







16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
#define OP_AutoCommit      1
#define OP_Transaction     2
#define OP_Checkpoint      3
#define OP_JournalMode     4
#define OP_Vacuum          5
#define OP_VFilter         6 /* jump, synopsis: iplan=r[P3] zplan='P4'     */
#define OP_VUpdate         7 /* synopsis: data=r[P3@P2]                    */
#define OP_Init            8 /* jump0, synopsis: Start at P2               */
#define OP_Goto            9 /* jump                                       */
#define OP_Gosub          10 /* jump                                       */
#define OP_InitCoroutine  11 /* jump0                                      */
#define OP_Yield          12 /* jump0                                      */
#define OP_MustBeInt      13 /* jump0                                      */
#define OP_Jump           14 /* jump                                       */
#define OP_Once           15 /* jump                                       */
#define OP_If             16 /* jump                                       */
#define OP_IfNot          17 /* jump                                       */
#define OP_IsType         18 /* jump, synopsis: if typeof(P1.P3) in P5 goto P2 */
#define OP_Not            19 /* same as TK_NOT, synopsis: r[P2]= !r[P1]    */
#define OP_IfNullRow      20 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */
#define OP_SeekLT         21 /* jump0, synopsis: key=r[P3@P4]              */
#define OP_SeekLE         22 /* jump0, synopsis: key=r[P3@P4]              */
#define OP_SeekGE         23 /* jump0, synopsis: key=r[P3@P4]              */
#define OP_SeekGT         24 /* jump0, synopsis: key=r[P3@P4]              */
#define OP_IfNotOpen      25 /* jump, synopsis: if( !csr[P1] ) goto P2     */
#define OP_IfNoHope       26 /* jump, synopsis: key=r[P3@P4]               */
#define OP_NoConflict     27 /* jump, synopsis: key=r[P3@P4]               */
#define OP_NotFound       28 /* jump, synopsis: key=r[P3@P4]               */
#define OP_Found          29 /* jump, synopsis: key=r[P3@P4]               */
#define OP_SeekRowid      30 /* jump0, synopsis: intkey=r[P3]              */
#define OP_NotExists      31 /* jump, synopsis: intkey=r[P3]               */
#define OP_Last           32 /* jump0                                      */
#define OP_IfSizeBetween  33 /* jump                                       */
#define OP_SorterSort     34 /* jump                                       */
#define OP_Sort           35 /* jump                                       */
#define OP_Rewind         36 /* jump0                                      */
#define OP_SorterNext     37 /* jump                                       */
#define OP_Prev           38 /* jump                                       */
#define OP_Next           39 /* jump                                       */
#define OP_IdxLE          40 /* jump, synopsis: key=r[P3@P4]               */
#define OP_IdxGT          41 /* jump, synopsis: key=r[P3@P4]               */
#define OP_IdxLT          42 /* jump, synopsis: key=r[P3@P4]               */
#define OP_Or             43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
#define OP_And            44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
#define OP_IdxGE          45 /* jump, synopsis: key=r[P3@P4]               */
#define OP_RowSetRead     46 /* jump, synopsis: r[P3]=rowset(P1)           */
#define OP_RowSetTest     47 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
#define OP_Program        48 /* jump0                                      */
#define OP_FkIfZero       49 /* jump, synopsis: if fkctr[P1]==0 goto P2    */
#define OP_IsNull         50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
#define OP_NotNull        51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
#define OP_Ne             52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
#define OP_Eq             53 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */
#define OP_Gt             54 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */
#define OP_Le             55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
#define OP_Integer        71 /* synopsis: r[P2]=P1                         */
#define OP_Int64          72 /* synopsis: r[P2]=P4                         */
#define OP_String         73 /* synopsis: r[P2]='P4' (len=P1)              */
#define OP_BeginSubrtn    74 /* synopsis: r[P2]=NULL                       */
#define OP_Null           75 /* synopsis: r[P2..P3]=NULL                   */
#define OP_SoftNull       76 /* synopsis: r[P1]=NULL                       */
#define OP_Blob           77 /* synopsis: r[P2]=P4 (len=P1)                */
#define OP_Variable       78 /* synopsis: r[P2]=parameter(P1,P4)           */
#define OP_Move           79 /* synopsis: r[P2@P3]=r[P1@P3]                */
#define OP_Copy           80 /* synopsis: r[P2@P3+1]=r[P1@P3+1]            */
#define OP_SCopy          81 /* synopsis: r[P2]=r[P1]                      */
#define OP_IntCopy        82 /* synopsis: r[P2]=r[P1]                      */
#define OP_FkCheck        83
#define OP_ResultRow      84 /* synopsis: output=r[P1@P2]                  */
#define OP_CollSeq        85







|







16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
#define OP_Integer        71 /* synopsis: r[P2]=P1                         */
#define OP_Int64          72 /* synopsis: r[P2]=P4                         */
#define OP_String         73 /* synopsis: r[P2]='P4' (len=P1)              */
#define OP_BeginSubrtn    74 /* synopsis: r[P2]=NULL                       */
#define OP_Null           75 /* synopsis: r[P2..P3]=NULL                   */
#define OP_SoftNull       76 /* synopsis: r[P1]=NULL                       */
#define OP_Blob           77 /* synopsis: r[P2]=P4 (len=P1)                */
#define OP_Variable       78 /* synopsis: r[P2]=parameter(P1)              */
#define OP_Move           79 /* synopsis: r[P2@P3]=r[P1@P3]                */
#define OP_Copy           80 /* synopsis: r[P2@P3+1]=r[P1@P3+1]            */
#define OP_SCopy          81 /* synopsis: r[P2]=r[P1]                      */
#define OP_IntCopy        82 /* synopsis: r[P2]=r[P1]                      */
#define OP_FkCheck        83
#define OP_ResultRow      84 /* synopsis: output=r[P1@P2]                  */
#define OP_CollSeq        85
16738
16739
16740
16741
16742
16743
16744

16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
#define OPFLG_JUMP        0x01  /* jump:  P2 holds jmp target */
#define OPFLG_IN1         0x02  /* in1:   P1 is an input */
#define OPFLG_IN2         0x04  /* in2:   P2 is an input */
#define OPFLG_IN3         0x08  /* in3:   P3 is an input */
#define OPFLG_OUT2        0x10  /* out2:  P2 is an output */
#define OPFLG_OUT3        0x20  /* out3:  P3 is an output */
#define OPFLG_NCYCLE      0x40  /* ncycle:Cycles count against P1 */

#define OPFLG_INITIALIZER {\
/*   0 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x41, 0x00,\
/*   8 */ 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x01, 0x01,\
/*  16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x49, 0x49, 0x49,\
/*  24 */ 0x49, 0x01, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49,\
/*  32 */ 0x41, 0x01, 0x41, 0x41, 0x41, 0x01, 0x41, 0x41,\
/*  40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x23, 0x0b,\
/*  48 */ 0x01, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
/*  56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x03, 0x01, 0x41,\
/*  64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\
/*  72 */ 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10, 0x00,\
/*  80 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02,\
/*  88 */ 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x40, 0x00,\
/*  96 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x26, 0x26,\
/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\







>


|
|
|
|

|







16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
#define OPFLG_JUMP        0x01  /* jump:  P2 holds jmp target */
#define OPFLG_IN1         0x02  /* in1:   P1 is an input */
#define OPFLG_IN2         0x04  /* in2:   P2 is an input */
#define OPFLG_IN3         0x08  /* in3:   P3 is an input */
#define OPFLG_OUT2        0x10  /* out2:  P2 is an output */
#define OPFLG_OUT3        0x20  /* out3:  P3 is an output */
#define OPFLG_NCYCLE      0x40  /* ncycle:Cycles count against P1 */
#define OPFLG_JUMP0       0x80  /* jump0:  P2 might be zero */
#define OPFLG_INITIALIZER {\
/*   0 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x41, 0x00,\
/*   8 */ 0x81, 0x01, 0x01, 0x81, 0x83, 0x83, 0x01, 0x01,\
/*  16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0xc9, 0xc9, 0xc9,\
/*  24 */ 0xc9, 0x01, 0x49, 0x49, 0x49, 0x49, 0xc9, 0x49,\
/*  32 */ 0xc1, 0x01, 0x41, 0x41, 0xc1, 0x01, 0x41, 0x41,\
/*  40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x23, 0x0b,\
/*  48 */ 0x81, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
/*  56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x03, 0x01, 0x41,\
/*  64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\
/*  72 */ 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10, 0x00,\
/*  80 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02,\
/*  88 */ 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x40, 0x00,\
/*  96 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x26, 0x26,\
/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
16904
16905
16906
16907
16908
16909
16910


16911
16912
16913
16914
16915
16916
16917
SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*);

typedef int (*RecordCompare)(int,const void*,UnpackedRecord*);
SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);

SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe*);



SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*);
#ifdef SQLITE_ENABLE_BYTECODE_VTAB
SQLITE_PRIVATE int sqlite3VdbeBytecodeVtabInit(sqlite3*);
#endif

/* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on







>
>







16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*);

typedef int (*RecordCompare)(int,const void*,UnpackedRecord*);
SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);

SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe*);

SQLITE_PRIVATE void sqlite3MemSetArrayInt64(sqlite3_value *aMem, int iIdx, i64 val);

SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*);
#ifdef SQLITE_ENABLE_BYTECODE_VTAB
SQLITE_PRIVATE int sqlite3VdbeBytecodeVtabInit(sqlite3*);
#endif

/* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on
19347
19348
19349
19350
19351
19352
19353

19354
19355
19356
19357
19358
19359
19360
#define NC_Complex   0x002000 /* True if a function or subquery seen */
#define NC_AllowWin  0x004000 /* Window functions are allowed here */
#define NC_HasWin    0x008000 /* One or more window functions seen */
#define NC_IsDDL     0x010000 /* Resolving names in a CREATE statement */
#define NC_InAggFunc 0x020000 /* True if analyzing arguments to an agg func */
#define NC_FromDDL   0x040000 /* SQL text comes from sqlite_schema */
#define NC_NoSelect  0x080000 /* Do not descend into sub-selects */

#define NC_OrderAgg 0x8000000 /* Has an aggregate other than count/min/max */

/*
** 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







>







19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
#define NC_Complex   0x002000 /* True if a function or subquery seen */
#define NC_AllowWin  0x004000 /* Window functions are allowed here */
#define NC_HasWin    0x008000 /* One or more window functions seen */
#define NC_IsDDL     0x010000 /* Resolving names in a CREATE statement */
#define NC_InAggFunc 0x020000 /* True if analyzing arguments to an agg func */
#define NC_FromDDL   0x040000 /* SQL text comes from sqlite_schema */
#define NC_NoSelect  0x080000 /* Do not descend into sub-selects */
#define NC_Where     0x100000 /* Processing WHERE clause of a SELECT */
#define NC_OrderAgg 0x8000000 /* Has an aggregate other than count/min/max */

/*
** 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
19370
19371
19372
19373
19374
19375
19376

19377
19378
19379
19380
19381
19382
19383
struct Upsert {
  ExprList *pUpsertTarget;  /* Optional description of conflict target */
  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 */
  Upsert *pNextUpsert;      /* Next ON CONFLICT clause in the list */
  u8 isDoUpdate;            /* True for DO UPDATE.  False for DO NOTHING */

  /* Above this point is the parse tree for the ON CONFLICT clauses.
  ** The next group of fields stores intermediate data. */
  void *pToFree;            /* Free memory when deleting the Upsert object */
  /* All fields above are owned by the Upsert object and must be freed
  ** when the Upsert is destroyed.  The fields below are used to transfer
  ** information from the INSERT processing down into the UPDATE processing
  ** while generating code.  The fields below are owned by the INSERT







>







19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
struct Upsert {
  ExprList *pUpsertTarget;  /* Optional description of conflict target */
  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 */
  Upsert *pNextUpsert;      /* Next ON CONFLICT clause in the list */
  u8 isDoUpdate;            /* True for DO UPDATE.  False for DO NOTHING */
  u8 isDup;                 /* True if 2nd or later with same pUpsertIdx */
  /* Above this point is the parse tree for the ON CONFLICT clauses.
  ** The next group of fields stores intermediate data. */
  void *pToFree;            /* Free memory when deleting the Upsert object */
  /* All fields above are owned by the Upsert object and must be freed
  ** when the Upsert is destroyed.  The fields below are used to transfer
  ** information from the INSERT processing down into the UPDATE processing
  ** while generating code.  The fields below are owned by the INSERT
20691
20692
20693
20694
20695
20696
20697

20698
20699
20700
20701
20702
20703
20704
SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*);
SQLITE_PRIVATE void sqlite3ProgressCheck(Parse*);
SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...);
SQLITE_PRIVATE int sqlite3ErrorToParser(sqlite3*,int);
SQLITE_PRIVATE void sqlite3Dequote(char*);
SQLITE_PRIVATE void sqlite3DequoteExpr(Expr*);
SQLITE_PRIVATE void sqlite3DequoteToken(Token*);

SQLITE_PRIVATE void sqlite3TokenInit(Token*,char*);
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int);
SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*);
SQLITE_PRIVATE void sqlite3FinishCoding(Parse*);
SQLITE_PRIVATE int sqlite3GetTempReg(Parse*);
SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse*,int);
SQLITE_PRIVATE int sqlite3GetTempRange(Parse*,int);







>







20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
20714
20715
SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*);
SQLITE_PRIVATE void sqlite3ProgressCheck(Parse*);
SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...);
SQLITE_PRIVATE int sqlite3ErrorToParser(sqlite3*,int);
SQLITE_PRIVATE void sqlite3Dequote(char*);
SQLITE_PRIVATE void sqlite3DequoteExpr(Expr*);
SQLITE_PRIVATE void sqlite3DequoteToken(Token*);
SQLITE_PRIVATE void sqlite3DequoteNumber(Parse*, Expr*);
SQLITE_PRIVATE void sqlite3TokenInit(Token*,char*);
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int);
SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*);
SQLITE_PRIVATE void sqlite3FinishCoding(Parse*);
SQLITE_PRIVATE int sqlite3GetTempReg(Parse*);
SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse*,int);
SQLITE_PRIVATE int sqlite3GetTempRange(Parse*,int);
21445
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458
21459
# define sqlite3WithDelete(x,y)
# define sqlite3WithPush(x,y,z) ((void*)0)
#endif
#ifndef SQLITE_OMIT_UPSERT
SQLITE_PRIVATE   Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*,Upsert*);
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);
SQLITE_PRIVATE   Upsert *sqlite3UpsertOfIndex(Upsert*,Index*);
SQLITE_PRIVATE   int sqlite3UpsertNextIsIPK(Upsert*);
#else
#define sqlite3UpsertNew(u,v,w,x,y,z) ((Upsert*)0)
#define sqlite3UpsertDelete(x,y)
#define sqlite3UpsertDup(x,y)         ((Upsert*)0)







|







21456
21457
21458
21459
21460
21461
21462
21463
21464
21465
21466
21467
21468
21469
21470
# define sqlite3WithDelete(x,y)
# define sqlite3WithPush(x,y,z) ((void*)0)
#endif
#ifndef SQLITE_OMIT_UPSERT
SQLITE_PRIVATE   Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*,Upsert*);
SQLITE_PRIVATE   void sqlite3UpsertDelete(sqlite3*,Upsert*);
SQLITE_PRIVATE   Upsert *sqlite3UpsertDup(sqlite3*,Upsert*);
SQLITE_PRIVATE   int sqlite3UpsertAnalyzeTarget(Parse*,SrcList*,Upsert*,Upsert*);
SQLITE_PRIVATE   void sqlite3UpsertDoUpdate(Parse*,Upsert*,Table*,Index*,int);
SQLITE_PRIVATE   Upsert *sqlite3UpsertOfIndex(Upsert*,Index*);
SQLITE_PRIVATE   int sqlite3UpsertNextIsIPK(Upsert*);
#else
#define sqlite3UpsertNew(u,v,w,x,y,z) ((Upsert*)0)
#define sqlite3UpsertDelete(x,y)
#define sqlite3UpsertDup(x,y)         ((Upsert*)0)
24175
24176
24177
24178
24179
24180
24181
24182
24183
24184
24185
24186

24187
24188


24189
24190
24191
24192
24193
24194
24195
struct DateTime {
  sqlite3_int64 iJD;  /* The julian day number times 86400000 */
  int Y, M, D;        /* Year, month, and day */
  int h, m;           /* Hour and minutes */
  int tz;             /* Timezone offset in minutes */
  double s;           /* Seconds */
  char validJD;       /* True (1) if iJD is valid */
  char rawS;          /* Raw numeric value stored in s */
  char validYMD;      /* True (1) if Y,M,D are valid */
  char validHMS;      /* True (1) if h,m,s are valid */
  char validTZ;       /* True (1) if tz is valid */
  char tzSet;         /* Timezone was set explicitly */

  char isError;       /* An overflow has occurred */
  char useSubsec;     /* Display subsecond precision */


};


/*
** Convert zDate into one or more integers according to the conversion
** specifier zFormat.
**







<


<
|
>
|
|
>
>







24186
24187
24188
24189
24190
24191
24192

24193
24194

24195
24196
24197
24198
24199
24200
24201
24202
24203
24204
24205
24206
24207
struct DateTime {
  sqlite3_int64 iJD;  /* The julian day number times 86400000 */
  int Y, M, D;        /* Year, month, and day */
  int h, m;           /* Hour and minutes */
  int tz;             /* Timezone offset in minutes */
  double s;           /* Seconds */
  char validJD;       /* True (1) if iJD is valid */

  char validYMD;      /* True (1) if Y,M,D are valid */
  char validHMS;      /* True (1) if h,m,s are valid */

  char nFloor;            /* Days to implement "floor" */
  unsigned rawS      : 1; /* Raw numeric value stored in s */
  unsigned isError   : 1; /* An overflow has occurred */
  unsigned useSubsec : 1; /* Display subsecond precision */
  unsigned isUtc     : 1; /* Time is known to be UTC */
  unsigned isLocal   : 1; /* Time is known to be localtime */
};


/*
** Convert zDate into one or more integers according to the conversion
** specifier zFormat.
**
24279
24280
24281
24282
24283
24284
24285


24286
24287
24288
24289
24290
24291
24292
24293
24294
24295
24296
24297
24298
24299
24300
24301
24302
24303
24304
24305
  c = *zDate;
  if( c=='-' ){
    sgn = -1;
  }else if( c=='+' ){
    sgn = +1;
  }else if( c=='Z' || c=='z' ){
    zDate++;


    goto zulu_time;
  }else{
    return c!=0;
  }
  zDate++;
  if( getDigits(zDate, "20b:20e", &nHr, &nMn)!=2 ){
    return 1;
  }
  zDate += 5;
  p->tz = sgn*(nMn + nHr*60);
zulu_time:
  while( sqlite3Isspace(*zDate) ){ zDate++; }
  p->tzSet = 1;
  return *zDate!=0;
}

/*
** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF.
** The HH, MM, and SS must each be exactly 2 digits.  The
** fractional seconds FFFF can be one or more digits.







>
>












<







24291
24292
24293
24294
24295
24296
24297
24298
24299
24300
24301
24302
24303
24304
24305
24306
24307
24308
24309
24310
24311

24312
24313
24314
24315
24316
24317
24318
  c = *zDate;
  if( c=='-' ){
    sgn = -1;
  }else if( c=='+' ){
    sgn = +1;
  }else if( c=='Z' || c=='z' ){
    zDate++;
    p->isLocal = 0;
    p->isUtc = 1;
    goto zulu_time;
  }else{
    return c!=0;
  }
  zDate++;
  if( getDigits(zDate, "20b:20e", &nHr, &nMn)!=2 ){
    return 1;
  }
  zDate += 5;
  p->tz = sgn*(nMn + nHr*60);
zulu_time:
  while( sqlite3Isspace(*zDate) ){ zDate++; }

  return *zDate!=0;
}

/*
** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF.
** The HH, MM, and SS must each be exactly 2 digits.  The
** fractional seconds FFFF can be one or more digits.
24335
24336
24337
24338
24339
24340
24341
24342
24343
24344
24345
24346
24347
24348
24349
  p->validJD = 0;
  p->rawS = 0;
  p->validHMS = 1;
  p->h = h;
  p->m = m;
  p->s = s + ms;
  if( parseTimezone(zDate, p) ) return 1;
  p->validTZ = (p->tz!=0)?1:0;
  return 0;
}

/*
** Put the DateTime object into its error state.
*/
static void datetimeError(DateTime *p){







<







24348
24349
24350
24351
24352
24353
24354

24355
24356
24357
24358
24359
24360
24361
  p->validJD = 0;
  p->rawS = 0;
  p->validHMS = 1;
  p->h = h;
  p->m = m;
  p->s = s + ms;
  if( parseTimezone(zDate, p) ) return 1;

  return 0;
}

/*
** Put the DateTime object into its error state.
*/
static void datetimeError(DateTime *p){
24382
24383
24384
24385
24386
24387
24388
24389
24390
24391
24392
24393


24394
24395
24396























24397
24398
24399
24400
24401
24402
24403
  B = 2 - A + (A/4);
  X1 = 36525*(Y+4716)/100;
  X2 = 306001*(M+1)/10000;
  p->iJD = (sqlite3_int64)((X1 + X2 + D + B - 1524.5 ) * 86400000);
  p->validJD = 1;
  if( p->validHMS ){
    p->iJD += p->h*3600000 + p->m*60000 + (sqlite3_int64)(p->s*1000 + 0.5);
    if( p->validTZ ){
      p->iJD -= p->tz*60000;
      p->validYMD = 0;
      p->validHMS = 0;
      p->validTZ = 0;


    }
  }
}
























/*
** Parse dates of the form
**
**     YYYY-MM-DD HH:MM:SS.FFF
**     YYYY-MM-DD HH:MM:SS
**     YYYY-MM-DD HH:MM







|



|
>
>



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







24394
24395
24396
24397
24398
24399
24400
24401
24402
24403
24404
24405
24406
24407
24408
24409
24410
24411
24412
24413
24414
24415
24416
24417
24418
24419
24420
24421
24422
24423
24424
24425
24426
24427
24428
24429
24430
24431
24432
24433
24434
24435
24436
24437
24438
24439
24440
  B = 2 - A + (A/4);
  X1 = 36525*(Y+4716)/100;
  X2 = 306001*(M+1)/10000;
  p->iJD = (sqlite3_int64)((X1 + X2 + D + B - 1524.5 ) * 86400000);
  p->validJD = 1;
  if( p->validHMS ){
    p->iJD += p->h*3600000 + p->m*60000 + (sqlite3_int64)(p->s*1000 + 0.5);
    if( p->tz ){
      p->iJD -= p->tz*60000;
      p->validYMD = 0;
      p->validHMS = 0;
      p->tz = 0;
      p->isUtc = 1;
      p->isLocal = 0;
    }
  }
}

/*
** Given the YYYY-MM-DD information current in p, determine if there
** is day-of-month overflow and set nFloor to the number of days that
** would need to be subtracted from the date in order to bring the
** date back to the end of the month.
*/
static void computeFloor(DateTime *p){
  assert( p->validYMD || p->isError );
  assert( p->D>=0 && p->D<=31 );
  assert( p->M>=0 && p->M<=12 );
  if( p->D<=28 ){
    p->nFloor = 0;
  }else if( (1<<p->M) & 0x15aa ){
    p->nFloor = 0;
  }else if( p->M!=2 ){
    p->nFloor = (p->D==31);
  }else if( p->Y%4!=0 || (p->Y%100==0 && p->Y%400!=0) ){
    p->nFloor = p->D - 28;
  }else{
    p->nFloor = p->D - 29;
  }
}

/*
** Parse dates of the form
**
**     YYYY-MM-DD HH:MM:SS.FFF
**     YYYY-MM-DD HH:MM:SS
**     YYYY-MM-DD HH:MM
24429
24430
24431
24432
24433
24434
24435

24436
24437
24438
24439
24440
24441



24442
24443
24444
24445
24446
24447
24448
24449
24450



24451
24452
24453
24454
24455
24456
24457
    return 1;
  }
  p->validJD = 0;
  p->validYMD = 1;
  p->Y = neg ? -Y : Y;
  p->M = M;
  p->D = D;

  if( p->validTZ ){
    computeJD(p);
  }
  return 0;
}




/*
** Set the time to the current time reported by the VFS.
**
** Return the number of errors.
*/
static int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){
  p->iJD = sqlite3StmtCurrentTime(context);
  if( p->iJD>0 ){
    p->validJD = 1;



    return 0;
  }else{
    return 1;
  }
}

/*







>
|





>
>
>









>
>
>







24466
24467
24468
24469
24470
24471
24472
24473
24474
24475
24476
24477
24478
24479
24480
24481
24482
24483
24484
24485
24486
24487
24488
24489
24490
24491
24492
24493
24494
24495
24496
24497
24498
24499
24500
24501
    return 1;
  }
  p->validJD = 0;
  p->validYMD = 1;
  p->Y = neg ? -Y : Y;
  p->M = M;
  p->D = D;
  computeFloor(p);
  if( p->tz ){
    computeJD(p);
  }
  return 0;
}


static void clearYMD_HMS_TZ(DateTime *p);  /* Forward declaration */

/*
** Set the time to the current time reported by the VFS.
**
** Return the number of errors.
*/
static int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){
  p->iJD = sqlite3StmtCurrentTime(context);
  if( p->iJD>0 ){
    p->validJD = 1;
    p->isUtc = 1;
    p->isLocal = 0;
    clearYMD_HMS_TZ(p);
    return 0;
  }else{
    return 1;
  }
}

/*
24582
24583
24584
24585
24586
24587
24588
24589
24590
24591
24592
24593
24594
24595
24596

/*
** Clear the YMD and HMS and the TZ
*/
static void clearYMD_HMS_TZ(DateTime *p){
  p->validYMD = 0;
  p->validHMS = 0;
  p->validTZ = 0;
}

#ifndef SQLITE_OMIT_LOCALTIME
/*
** On recent Windows platforms, the localtime_s() function is available
** as part of the "Secure CRT". It is essentially equivalent to
** localtime_r() available under most POSIX platforms, except that the







|







24626
24627
24628
24629
24630
24631
24632
24633
24634
24635
24636
24637
24638
24639
24640

/*
** Clear the YMD and HMS and the TZ
*/
static void clearYMD_HMS_TZ(DateTime *p){
  p->validYMD = 0;
  p->validHMS = 0;
  p->tz = 0;
}

#ifndef SQLITE_OMIT_LOCALTIME
/*
** On recent Windows platforms, the localtime_s() function is available
** as part of the "Secure CRT". It is essentially equivalent to
** localtime_r() available under most POSIX platforms, except that the
24714
24715
24716
24717
24718
24719
24720
24721
24722
24723
24724
24725
24726
24727
24728
24729
24730
24731
24732
24733
24734
24735
24736
24737
24738
24739
24740
24741
24742
24743
24744
24745
24746
24747
24748
24749
24750
24751
24752
24753
  p->h = sLocal.tm_hour;
  p->m = sLocal.tm_min;
  p->s = sLocal.tm_sec + (p->iJD%1000)*0.001;
  p->validYMD = 1;
  p->validHMS = 1;
  p->validJD = 0;
  p->rawS = 0;
  p->validTZ = 0;
  p->isError = 0;
  return SQLITE_OK;
}
#endif /* SQLITE_OMIT_LOCALTIME */

/*
** The following table defines various date transformations of the form
**
**            'NNN days'
**
** Where NNN is an arbitrary floating-point number and "days" can be one
** of several units of time.
*/
static const struct {
  u8 nName;           /* Length of the name */
  char zName[7];      /* Name of the transformation */
  float rLimit;       /* Maximum NNN value for this transform */
  float rXform;       /* Constant used for this transform */
} aXformType[] = {
  { 6, "second", 4.6427e+14,       1.0  },
  { 6, "minute", 7.7379e+12,      60.0  },
  { 4, "hour",   1.2897e+11,    3600.0  },
  { 3, "day",    5373485.0,    86400.0  },
  { 5, "month",  176546.0,   2592000.0  },
  { 4, "year",   14713.0,   31536000.0  },
};

/*
** If the DateTime p is raw number, try to figure out if it is
** a julian day number of a unix timestamp.  Set the p value
** appropriately.
*/







|



















|
|
|
|
|
|







24758
24759
24760
24761
24762
24763
24764
24765
24766
24767
24768
24769
24770
24771
24772
24773
24774
24775
24776
24777
24778
24779
24780
24781
24782
24783
24784
24785
24786
24787
24788
24789
24790
24791
24792
24793
24794
24795
24796
24797
  p->h = sLocal.tm_hour;
  p->m = sLocal.tm_min;
  p->s = sLocal.tm_sec + (p->iJD%1000)*0.001;
  p->validYMD = 1;
  p->validHMS = 1;
  p->validJD = 0;
  p->rawS = 0;
  p->tz = 0;
  p->isError = 0;
  return SQLITE_OK;
}
#endif /* SQLITE_OMIT_LOCALTIME */

/*
** The following table defines various date transformations of the form
**
**            'NNN days'
**
** Where NNN is an arbitrary floating-point number and "days" can be one
** of several units of time.
*/
static const struct {
  u8 nName;           /* Length of the name */
  char zName[7];      /* Name of the transformation */
  float rLimit;       /* Maximum NNN value for this transform */
  float rXform;       /* Constant used for this transform */
} aXformType[] = {
  /* 0 */ { 6, "second",   4.6427e+14,         1.0  },
  /* 1 */ { 6, "minute",   7.7379e+12,        60.0  },
  /* 2 */ { 4, "hour",     1.2897e+11,      3600.0  },
  /* 3 */ { 3, "day",      5373485.0,      86400.0  },
  /* 4 */ { 5, "month",    176546.0,  30.0*86400.0  },
  /* 5 */ { 4, "year",     14713.0,  365.0*86400.0  },
};

/*
** If the DateTime p is raw number, try to figure out if it is
** a julian day number of a unix timestamp.  Set the p value
** appropriately.
*/
24771
24772
24773
24774
24775
24776
24777



24778
24779
24780
24781
24782
24783

24784
24785


24786
24787
24788
24789
24790
24791
24792
**
**     NNN days
**     NNN hours
**     NNN minutes
**     NNN.NNNN seconds
**     NNN months
**     NNN years



**     start of month
**     start of year
**     start of week
**     start of day
**     weekday N
**     unixepoch

**     localtime
**     utc


**
** Return 0 on success and 1 if there is any kind of error. If the error
** is in a system call (i.e. localtime()), then an error message is written
** to context pCtx. If the error is an unrecognized modifier, no error is
** written to pCtx.
*/
static int parseModifier(







>
>
>






>


>
>







24815
24816
24817
24818
24819
24820
24821
24822
24823
24824
24825
24826
24827
24828
24829
24830
24831
24832
24833
24834
24835
24836
24837
24838
24839
24840
24841
24842
**
**     NNN days
**     NNN hours
**     NNN minutes
**     NNN.NNNN seconds
**     NNN months
**     NNN years
**     +/-YYYY-MM-DD HH:MM:SS.SSS
**     ceiling
**     floor
**     start of month
**     start of year
**     start of week
**     start of day
**     weekday N
**     unixepoch
**     auto
**     localtime
**     utc
**     subsec
**     subsecond
**
** Return 0 on success and 1 if there is any kind of error. If the error
** is in a system call (i.e. localtime()), then an error message is written
** to context pCtx. If the error is an unrecognized modifier, no error is
** written to pCtx.
*/
static int parseModifier(
24808
24809
24810
24811
24812
24813
24814































24815
24816
24817
24818
24819
24820
24821
      */
      if( sqlite3_stricmp(z, "auto")==0 ){
        if( idx>1 ) return 1; /* IMP: R-33611-57934 */
        autoAdjustDate(p);
        rc = 0;
      }
      break;































    }
    case 'j': {
      /*
      **    julianday
      **
      ** Always interpret the prior number as a julian-day value.  If this
      ** is not the first modifier, or if the prior argument is not a numeric







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







24858
24859
24860
24861
24862
24863
24864
24865
24866
24867
24868
24869
24870
24871
24872
24873
24874
24875
24876
24877
24878
24879
24880
24881
24882
24883
24884
24885
24886
24887
24888
24889
24890
24891
24892
24893
24894
24895
24896
24897
24898
24899
24900
24901
24902
      */
      if( sqlite3_stricmp(z, "auto")==0 ){
        if( idx>1 ) return 1; /* IMP: R-33611-57934 */
        autoAdjustDate(p);
        rc = 0;
      }
      break;
    }
    case 'c': {
      /*
      **    ceiling
      **
      ** Resolve day-of-month overflow by rolling forward into the next
      ** month.  As this is the default action, this modifier is really
      ** a no-op that is only included for symmetry.  See "floor".
      */
      if( sqlite3_stricmp(z, "ceiling")==0 ){
        computeJD(p);
        clearYMD_HMS_TZ(p);
        rc = 0;
        p->nFloor = 0;
      }
      break;
    }
    case 'f': {
      /*
      **    floor
      **
      ** Resolve day-of-month overflow by rolling back to the end of the
      ** previous month.
      */
      if( sqlite3_stricmp(z, "floor")==0 ){
        computeJD(p);
        p->iJD -= p->nFloor*86400000;
        clearYMD_HMS_TZ(p);
        rc = 0;
      }
      break;
    }
    case 'j': {
      /*
      **    julianday
      **
      ** Always interpret the prior number as a julian-day value.  If this
      ** is not the first modifier, or if the prior argument is not a numeric
24835
24836
24837
24838
24839
24840
24841
24842


24843
24844
24845
24846
24847
24848
24849
    case 'l': {
      /*    localtime
      **
      ** Assuming the current time value is UTC (a.k.a. GMT), shift it to
      ** show local time.
      */
      if( sqlite3_stricmp(z, "localtime")==0 && sqlite3NotPureFunc(pCtx) ){
        rc = toLocaltime(p, pCtx);


      }
      break;
    }
#endif
    case 'u': {
      /*
      **    unixepoch







|
>
>







24916
24917
24918
24919
24920
24921
24922
24923
24924
24925
24926
24927
24928
24929
24930
24931
24932
    case 'l': {
      /*    localtime
      **
      ** Assuming the current time value is UTC (a.k.a. GMT), shift it to
      ** show local time.
      */
      if( sqlite3_stricmp(z, "localtime")==0 && sqlite3NotPureFunc(pCtx) ){
        rc = p->isLocal ? SQLITE_OK : toLocaltime(p, pCtx);
        p->isUtc = 0;
        p->isLocal = 1;
      }
      break;
    }
#endif
    case 'u': {
      /*
      **    unixepoch
24860
24861
24862
24863
24864
24865
24866
24867
24868
24869
24870
24871
24872
24873
24874
          p->validJD = 1;
          p->rawS = 0;
          rc = 0;
        }
      }
#ifndef SQLITE_OMIT_LOCALTIME
      else if( sqlite3_stricmp(z, "utc")==0 && sqlite3NotPureFunc(pCtx) ){
        if( p->tzSet==0 ){
          i64 iOrigJD;              /* Original localtime */
          i64 iGuess;               /* Guess at the corresponding utc time */
          int cnt = 0;              /* Safety to prevent infinite loop */
          i64 iErr;                 /* Guess is off by this much */

          computeJD(p);
          iGuess = iOrigJD = p->iJD;







|







24943
24944
24945
24946
24947
24948
24949
24950
24951
24952
24953
24954
24955
24956
24957
          p->validJD = 1;
          p->rawS = 0;
          rc = 0;
        }
      }
#ifndef SQLITE_OMIT_LOCALTIME
      else if( sqlite3_stricmp(z, "utc")==0 && sqlite3NotPureFunc(pCtx) ){
        if( p->isUtc==0 ){
          i64 iOrigJD;              /* Original localtime */
          i64 iGuess;               /* Guess at the corresponding utc time */
          int cnt = 0;              /* Safety to prevent infinite loop */
          i64 iErr;                 /* Guess is off by this much */

          computeJD(p);
          iGuess = iOrigJD = p->iJD;
24883
24884
24885
24886
24887
24888
24889
24890

24891
24892
24893
24894
24895
24896
24897
24898
24899
24900
24901
24902
24903
24904
24905
24906
24907
24908
24909
24910
24911
24912
24913
24914
24915
24916
24917
            if( rc ) return rc;
            computeJD(&new);
            iErr = new.iJD - iOrigJD;
          }while( iErr && cnt++<3 );
          memset(p, 0, sizeof(*p));
          p->iJD = iGuess;
          p->validJD = 1;
          p->tzSet = 1;

        }
        rc = SQLITE_OK;
      }
#endif
      break;
    }
    case 'w': {
      /*
      **    weekday N
      **
      ** Move the date to the same time on the next occurrence of
      ** weekday N where 0==Sunday, 1==Monday, and so forth.  If the
      ** date is already on the appropriate weekday, this is a no-op.
      */
      if( sqlite3_strnicmp(z, "weekday ", 8)==0
               && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), SQLITE_UTF8)>0
               && r>=0.0 && r<7.0 && (n=(int)r)==r ){
        sqlite3_int64 Z;
        computeYMD_HMS(p);
        p->validTZ = 0;
        p->validJD = 0;
        computeJD(p);
        Z = ((p->iJD + 129600000)/86400000) % 7;
        if( Z>n ) Z -= 7;
        p->iJD += (n - Z)*86400000;
        clearYMD_HMS_TZ(p);
        rc = 0;







|
>



















|







24966
24967
24968
24969
24970
24971
24972
24973
24974
24975
24976
24977
24978
24979
24980
24981
24982
24983
24984
24985
24986
24987
24988
24989
24990
24991
24992
24993
24994
24995
24996
24997
24998
24999
25000
25001
            if( rc ) return rc;
            computeJD(&new);
            iErr = new.iJD - iOrigJD;
          }while( iErr && cnt++<3 );
          memset(p, 0, sizeof(*p));
          p->iJD = iGuess;
          p->validJD = 1;
          p->isUtc = 1;
          p->isLocal = 0;
        }
        rc = SQLITE_OK;
      }
#endif
      break;
    }
    case 'w': {
      /*
      **    weekday N
      **
      ** Move the date to the same time on the next occurrence of
      ** weekday N where 0==Sunday, 1==Monday, and so forth.  If the
      ** date is already on the appropriate weekday, this is a no-op.
      */
      if( sqlite3_strnicmp(z, "weekday ", 8)==0
               && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), SQLITE_UTF8)>0
               && r>=0.0 && r<7.0 && (n=(int)r)==r ){
        sqlite3_int64 Z;
        computeYMD_HMS(p);
        p->tz = 0;
        p->validJD = 0;
        computeJD(p);
        Z = ((p->iJD + 129600000)/86400000) % 7;
        if( Z>n ) Z -= 7;
        p->iJD += (n - Z)*86400000;
        clearYMD_HMS_TZ(p);
        rc = 0;
24943
24944
24945
24946
24947
24948
24949
24950
24951
24952
24953
24954
24955
24956
24957
      if( !p->validJD && !p->validYMD && !p->validHMS ) break;
      z += 9;
      computeYMD(p);
      p->validHMS = 1;
      p->h = p->m = 0;
      p->s = 0.0;
      p->rawS = 0;
      p->validTZ = 0;
      p->validJD = 0;
      if( sqlite3_stricmp(z,"month")==0 ){
        p->D = 1;
        rc = 0;
      }else if( sqlite3_stricmp(z,"year")==0 ){
        p->M = 1;
        p->D = 1;







|







25027
25028
25029
25030
25031
25032
25033
25034
25035
25036
25037
25038
25039
25040
25041
      if( !p->validJD && !p->validYMD && !p->validHMS ) break;
      z += 9;
      computeYMD(p);
      p->validHMS = 1;
      p->h = p->m = 0;
      p->s = 0.0;
      p->rawS = 0;
      p->tz = 0;
      p->validJD = 0;
      if( sqlite3_stricmp(z,"month")==0 ){
        p->D = 1;
        rc = 0;
      }else if( sqlite3_stricmp(z,"year")==0 ){
        p->M = 1;
        p->D = 1;
25014
25015
25016
25017
25018
25019
25020

25021
25022
25023
25024
25025
25026
25027
        }else{
          p->Y += Y;
          p->M += M;
        }
        x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
        p->Y += x;
        p->M -= x*12;

        computeJD(p);
        p->validHMS = 0;
        p->validYMD = 0;
        p->iJD += (i64)D*86400000;
        if( z[11]==0 ){
          rc = 0;
          break;







>







25098
25099
25100
25101
25102
25103
25104
25105
25106
25107
25108
25109
25110
25111
25112
        }else{
          p->Y += Y;
          p->M += M;
        }
        x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
        p->Y += x;
        p->M -= x*12;
        computeFloor(p);
        computeJD(p);
        p->validHMS = 0;
        p->validYMD = 0;
        p->iJD += (i64)D*86400000;
        if( z[11]==0 ){
          rc = 0;
          break;
25060
25061
25062
25063
25064
25065
25066
25067
25068
25069
25070
25071

25072
25073
25074
25075
25076
25077
25078
25079
25080
25081
25082
25083
25084

25085
25086
25087
25088
25089
25090
25091
25092

25093

25094
25095
25096
25097
25098
25099
25100
      }

      /* If control reaches this point, it means the transformation is
      ** one of the forms like "+NNN days".  */
      z += n;
      while( sqlite3Isspace(*z) ) z++;
      n = sqlite3Strlen30(z);
      if( n>10 || n<3 ) break;
      if( sqlite3UpperToLower[(u8)z[n-1]]=='s' ) n--;
      computeJD(p);
      assert( rc==1 );
      rRounder = r<0 ? -0.5 : +0.5;

      for(i=0; i<ArraySize(aXformType); i++){
        if( aXformType[i].nName==n
         && sqlite3_strnicmp(aXformType[i].zName, z, n)==0
         && r>-aXformType[i].rLimit && r<aXformType[i].rLimit
        ){
          switch( i ){
            case 4: { /* Special processing to add months */
              assert( strcmp(aXformType[i].zName,"month")==0 );
              computeYMD_HMS(p);
              p->M += (int)r;
              x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
              p->Y += x;
              p->M -= x*12;

              p->validJD = 0;
              r -= (int)r;
              break;
            }
            case 5: { /* Special processing to add years */
              int y = (int)r;
              assert( strcmp(aXformType[i].zName,"year")==0 );
              computeYMD_HMS(p);

              p->Y += y;

              p->validJD = 0;
              r -= (int)r;
              break;
            }
          }
          computeJD(p);
          p->iJD += (sqlite3_int64)(r*1000.0*aXformType[i].rXform + rRounder);







|




>







|





>






|

>

>







25145
25146
25147
25148
25149
25150
25151
25152
25153
25154
25155
25156
25157
25158
25159
25160
25161
25162
25163
25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
25174
25175
25176
25177
25178
25179
25180
25181
25182
25183
25184
25185
25186
25187
25188
25189
      }

      /* If control reaches this point, it means the transformation is
      ** one of the forms like "+NNN days".  */
      z += n;
      while( sqlite3Isspace(*z) ) z++;
      n = sqlite3Strlen30(z);
      if( n<3 || n>10 ) break;
      if( sqlite3UpperToLower[(u8)z[n-1]]=='s' ) n--;
      computeJD(p);
      assert( rc==1 );
      rRounder = r<0 ? -0.5 : +0.5;
      p->nFloor = 0;
      for(i=0; i<ArraySize(aXformType); i++){
        if( aXformType[i].nName==n
         && sqlite3_strnicmp(aXformType[i].zName, z, n)==0
         && r>-aXformType[i].rLimit && r<aXformType[i].rLimit
        ){
          switch( i ){
            case 4: { /* Special processing to add months */
              assert( strcmp(aXformType[4].zName,"month")==0 );
              computeYMD_HMS(p);
              p->M += (int)r;
              x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
              p->Y += x;
              p->M -= x*12;
              computeFloor(p);
              p->validJD = 0;
              r -= (int)r;
              break;
            }
            case 5: { /* Special processing to add years */
              int y = (int)r;
              assert( strcmp(aXformType[5].zName,"year")==0 );
              computeYMD_HMS(p);
              assert( p->M>=0 && p->M<=12 );
              p->Y += y;
              computeFloor(p);
              p->validJD = 0;
              r -= (int)r;
              break;
            }
          }
          computeJD(p);
          p->iJD += (sqlite3_int64)(r*1000.0*aXformType[i].rXform + rRounder);
25711
25712
25713
25714
25715
25716
25717
25718
25719
25720
25721
25722
25723
25724
25725
25726
25727
      }
      d2.validJD = 0;
      computeJD(&d2);
    }
    d1.iJD = d2.iJD - d1.iJD;
    d1.iJD += (u64)1486995408 * (u64)100000;
  }
  d1.validYMD = 0;
  d1.validHMS = 0;
  d1.validTZ = 0;
  computeYMD_HMS(&d1);
  sqlite3StrAccumInit(&sRes, 0, 0, 0, 100);
  sqlite3_str_appendf(&sRes, "%c%04d-%02d-%02d %02d:%02d:%06.3f",
       sign, Y, M, d1.D-1, d1.h, d1.m, d1.s);
  sqlite3ResultStrAccum(context, &sRes);
}








|
<
<







25800
25801
25802
25803
25804
25805
25806
25807


25808
25809
25810
25811
25812
25813
25814
      }
      d2.validJD = 0;
      computeJD(&d2);
    }
    d1.iJD = d2.iJD - d1.iJD;
    d1.iJD += (u64)1486995408 * (u64)100000;
  }
  clearYMD_HMS_TZ(&d1);


  computeYMD_HMS(&d1);
  sqlite3StrAccumInit(&sRes, 0, 0, 0, 100);
  sqlite3_str_appendf(&sRes, "%c%04d-%02d-%02d %02d:%02d:%06.3f",
       sign, Y, M, d1.D-1, d1.h, d1.m, d1.s);
  sqlite3ResultStrAccum(context, &sRes);
}

25781
25782
25783
25784
25785
25786
25787






























25788
25789
25790
25791
25792
25793
25794
25795
25796
25797
25798
25799
25800
25801
25802
25803



25804
25805
25806
25807
25808
25809
25810
#endif
  if( pTm ){
    strftime(zBuf, 20, zFormat, &sNow);
    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
  }
}
#endif































/*
** This function registered all of the above C functions as SQL
** functions.  This should be the only routine in this file with
** external linkage.
*/
SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){
  static FuncDef aDateTimeFuncs[] = {
#ifndef SQLITE_OMIT_DATETIME_FUNCS
    PURE_DATE(julianday,        -1, 0, 0, juliandayFunc ),
    PURE_DATE(unixepoch,        -1, 0, 0, unixepochFunc ),
    PURE_DATE(date,             -1, 0, 0, dateFunc      ),
    PURE_DATE(time,             -1, 0, 0, timeFunc      ),
    PURE_DATE(datetime,         -1, 0, 0, datetimeFunc  ),
    PURE_DATE(strftime,         -1, 0, 0, strftimeFunc  ),
    PURE_DATE(timediff,          2, 0, 0, timediffFunc  ),



    DFUNCTION(current_time,      0, 0, 0, ctimeFunc     ),
    DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc),
    DFUNCTION(current_date,      0, 0, 0, cdateFunc     ),
#else
    STR_FUNCTION(current_time,      0, "%H:%M:%S",          0, currentTimeFunc),
    STR_FUNCTION(current_date,      0, "%Y-%m-%d",          0, currentTimeFunc),
    STR_FUNCTION(current_timestamp, 0, "%Y-%m-%d %H:%M:%S", 0, currentTimeFunc),







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
















>
>
>







25868
25869
25870
25871
25872
25873
25874
25875
25876
25877
25878
25879
25880
25881
25882
25883
25884
25885
25886
25887
25888
25889
25890
25891
25892
25893
25894
25895
25896
25897
25898
25899
25900
25901
25902
25903
25904
25905
25906
25907
25908
25909
25910
25911
25912
25913
25914
25915
25916
25917
25918
25919
25920
25921
25922
25923
25924
25925
25926
25927
25928
25929
25930
#endif
  if( pTm ){
    strftime(zBuf, 20, zFormat, &sNow);
    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
  }
}
#endif

#if !defined(SQLITE_OMIT_DATETIME_FUNCS) && defined(SQLITE_DEBUG)
/*
**   datedebug(...)
**
** This routine returns JSON that describes the internal DateTime object.
** Used for debugging and testing only.  Subject to change.
*/
static void datedebugFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  DateTime x;
  if( isDate(context, argc, argv, &x)==0 ){
    char *zJson;
    zJson = sqlite3_mprintf(
      "{iJD:%lld,Y:%d,M:%d,D:%d,h:%d,m:%d,tz:%d,"
      "s:%.3f,validJD:%d,validYMS:%d,validHMS:%d,"
      "nFloor:%d,rawS:%d,isError:%d,useSubsec:%d,"
      "isUtc:%d,isLocal:%d}",
      x.iJD, x.Y, x.M, x.D, x.h, x.m, x.tz,
      x.s, x.validJD, x.validYMD, x.validHMS,
      x.nFloor, x.rawS, x.isError, x.useSubsec,
      x.isUtc, x.isLocal);
    sqlite3_result_text(context, zJson, -1, sqlite3_free);
  }
}
#endif /* !SQLITE_OMIT_DATETIME_FUNCS && SQLITE_DEBUG */


/*
** This function registered all of the above C functions as SQL
** functions.  This should be the only routine in this file with
** external linkage.
*/
SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){
  static FuncDef aDateTimeFuncs[] = {
#ifndef SQLITE_OMIT_DATETIME_FUNCS
    PURE_DATE(julianday,        -1, 0, 0, juliandayFunc ),
    PURE_DATE(unixepoch,        -1, 0, 0, unixepochFunc ),
    PURE_DATE(date,             -1, 0, 0, dateFunc      ),
    PURE_DATE(time,             -1, 0, 0, timeFunc      ),
    PURE_DATE(datetime,         -1, 0, 0, datetimeFunc  ),
    PURE_DATE(strftime,         -1, 0, 0, strftimeFunc  ),
    PURE_DATE(timediff,          2, 0, 0, timediffFunc  ),
#ifdef SQLITE_DEBUG
    PURE_DATE(datedebug,        -1, 0, 0, datedebugFunc ),
#endif
    DFUNCTION(current_time,      0, 0, 0, ctimeFunc     ),
    DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc),
    DFUNCTION(current_date,      0, 0, 0, cdateFunc     ),
#else
    STR_FUNCTION(current_time,      0, "%H:%M:%S",          0, currentTimeFunc),
    STR_FUNCTION(current_date,      0, "%Y-%m-%d",          0, currentTimeFunc),
    STR_FUNCTION(current_timestamp, 0, "%Y-%m-%d %H:%M:%S", 0, currentTimeFunc),
34987
34988
34989
34990
34991
34992
34993






































34994
34995
34996
34997
34998
34999
35000
}
SQLITE_PRIVATE void sqlite3DequoteExpr(Expr *p){
  assert( !ExprHasProperty(p, EP_IntValue) );
  assert( sqlite3Isquote(p->u.zToken[0]) );
  p->flags |= p->u.zToken[0]=='"' ? EP_Quoted|EP_DblQuoted : EP_Quoted;
  sqlite3Dequote(p->u.zToken);
}







































/*
** If the input token p is quoted, try to adjust the token to remove
** the quotes.  This is not always possible:
**
**     "abc"     ->   abc
**     "ab""cd"  ->   (not possible because of the interior "")







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







35107
35108
35109
35110
35111
35112
35113
35114
35115
35116
35117
35118
35119
35120
35121
35122
35123
35124
35125
35126
35127
35128
35129
35130
35131
35132
35133
35134
35135
35136
35137
35138
35139
35140
35141
35142
35143
35144
35145
35146
35147
35148
35149
35150
35151
35152
35153
35154
35155
35156
35157
35158
}
SQLITE_PRIVATE void sqlite3DequoteExpr(Expr *p){
  assert( !ExprHasProperty(p, EP_IntValue) );
  assert( sqlite3Isquote(p->u.zToken[0]) );
  p->flags |= p->u.zToken[0]=='"' ? EP_Quoted|EP_DblQuoted : EP_Quoted;
  sqlite3Dequote(p->u.zToken);
}

/*
** Expression p is a QNUMBER (quoted number). Dequote the value in p->u.zToken
** and set the type to INTEGER or FLOAT. "Quoted" integers or floats are those
** that contain '_' characters that must be removed before further processing.
*/
SQLITE_PRIVATE void sqlite3DequoteNumber(Parse *pParse, Expr *p){
  assert( p!=0 || pParse->db->mallocFailed );
  if( p ){
    const char *pIn = p->u.zToken;
    char *pOut = p->u.zToken;
    int bHex = (pIn[0]=='0' && (pIn[1]=='x' || pIn[1]=='X'));
    int iValue;
    assert( p->op==TK_QNUMBER );
    p->op = TK_INTEGER;
    do {
      if( *pIn!=SQLITE_DIGIT_SEPARATOR ){
        *pOut++ = *pIn;
        if( *pIn=='e' || *pIn=='E' || *pIn=='.' ) p->op = TK_FLOAT;
      }else{
        if( (bHex==0 && (!sqlite3Isdigit(pIn[-1]) || !sqlite3Isdigit(pIn[1])))
         || (bHex==1 && (!sqlite3Isxdigit(pIn[-1]) || !sqlite3Isxdigit(pIn[1])))
        ){
          sqlite3ErrorMsg(pParse, "unrecognized token: \"%s\"", p->u.zToken);
        }
      }
    }while( *pIn++ );
    if( bHex ) p->op = TK_INTEGER;

    /* tag-20240227-a: If after dequoting, the number is an integer that
    ** fits in 32 bits, then it must be converted into EP_IntValue.  Other
    ** parts of the code expect this.  See also tag-20240227-b. */
    if( p->op==TK_INTEGER && sqlite3GetInt32(p->u.zToken, &iValue) ){
      p->u.iValue = iValue;
      p->flags |= EP_IntValue;
    }
  }
}

/*
** If the input token p is quoted, try to adjust the token to remove
** the quotes.  This is not always possible:
**
**     "abc"     ->   abc
**     "ab""cd"  ->   (not possible because of the interior "")
35304
35305
35306
35307
35308
35309
35310



35311
35312
35313
35314
35315
35316
35317
      *pResult = (double)r;
    }
  }else{
    double rr[2];
    u64 s2;
    rr[0] = (double)s;
    s2 = (u64)rr[0];



    rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s);
    if( e>0 ){
      while( e>=100  ){
        e -= 100;
        dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83);
      }
      while( e>=10   ){







>
>
>







35462
35463
35464
35465
35466
35467
35468
35469
35470
35471
35472
35473
35474
35475
35476
35477
35478
      *pResult = (double)r;
    }
  }else{
    double rr[2];
    u64 s2;
    rr[0] = (double)s;
    s2 = (u64)rr[0];
#if defined(_MSC_VER) && _MSC_VER<1700
    if( s2==0x8000000000000000LL ){ s2 = 2*(u64)(0.5*rr[0]); }
#endif
    rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s);
    if( e>0 ){
      while( e>=100  ){
        e -= 100;
        dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83);
      }
      while( e>=10   ){
36969
36970
36971
36972
36973
36974
36975
36976
36977
36978
36979
36980
36981
36982
36983
    /*  71 */ "Integer"          OpHelp("r[P2]=P1"),
    /*  72 */ "Int64"            OpHelp("r[P2]=P4"),
    /*  73 */ "String"           OpHelp("r[P2]='P4' (len=P1)"),
    /*  74 */ "BeginSubrtn"      OpHelp("r[P2]=NULL"),
    /*  75 */ "Null"             OpHelp("r[P2..P3]=NULL"),
    /*  76 */ "SoftNull"         OpHelp("r[P1]=NULL"),
    /*  77 */ "Blob"             OpHelp("r[P2]=P4 (len=P1)"),
    /*  78 */ "Variable"         OpHelp("r[P2]=parameter(P1,P4)"),
    /*  79 */ "Move"             OpHelp("r[P2@P3]=r[P1@P3]"),
    /*  80 */ "Copy"             OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
    /*  81 */ "SCopy"            OpHelp("r[P2]=r[P1]"),
    /*  82 */ "IntCopy"          OpHelp("r[P2]=r[P1]"),
    /*  83 */ "FkCheck"          OpHelp(""),
    /*  84 */ "ResultRow"        OpHelp("output=r[P1@P2]"),
    /*  85 */ "CollSeq"          OpHelp(""),







|







37130
37131
37132
37133
37134
37135
37136
37137
37138
37139
37140
37141
37142
37143
37144
    /*  71 */ "Integer"          OpHelp("r[P2]=P1"),
    /*  72 */ "Int64"            OpHelp("r[P2]=P4"),
    /*  73 */ "String"           OpHelp("r[P2]='P4' (len=P1)"),
    /*  74 */ "BeginSubrtn"      OpHelp("r[P2]=NULL"),
    /*  75 */ "Null"             OpHelp("r[P2..P3]=NULL"),
    /*  76 */ "SoftNull"         OpHelp("r[P1]=NULL"),
    /*  77 */ "Blob"             OpHelp("r[P2]=P4 (len=P1)"),
    /*  78 */ "Variable"         OpHelp("r[P2]=parameter(P1)"),
    /*  79 */ "Move"             OpHelp("r[P2@P3]=r[P1@P3]"),
    /*  80 */ "Copy"             OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
    /*  81 */ "SCopy"            OpHelp("r[P2]=r[P1]"),
    /*  82 */ "IntCopy"          OpHelp("r[P2]=r[P1]"),
    /*  83 */ "FkCheck"          OpHelp(""),
    /*  84 */ "ResultRow"        OpHelp("output=r[P1@P2]"),
    /*  85 */ "CollSeq"          OpHelp(""),
69926
69927
69928
69929
69930
69931
69932

69933
69934
69935
69936
69937
69938
69939
  const char *zPfx; /* Error message prefix */
  Pgno v0;          /* Value for first %u substitution in zPfx (root page) */
  Pgno v1;          /* Value for second %u substitution in zPfx (current pg) */
  int v2;           /* Value for third %d substitution in zPfx */
  StrAccum errMsg;  /* Accumulate the error message text here */
  u32 *heap;        /* Min-heap used for analyzing cell coverage */
  sqlite3 *db;      /* Database connection running the check */

};

/*
** Routines to read or write a two- and four-byte big-endian integer values.
*/
#define get2byte(x)   ((x)[0]<<8 | (x)[1])
#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v))







>







70087
70088
70089
70090
70091
70092
70093
70094
70095
70096
70097
70098
70099
70100
70101
  const char *zPfx; /* Error message prefix */
  Pgno v0;          /* Value for first %u substitution in zPfx (root page) */
  Pgno v1;          /* Value for second %u substitution in zPfx (current pg) */
  int v2;           /* Value for third %d substitution in zPfx */
  StrAccum errMsg;  /* Accumulate the error message text here */
  u32 *heap;        /* Min-heap used for analyzing cell coverage */
  sqlite3 *db;      /* Database connection running the check */
  i64 nRow;         /* Number of rows visited in current tree */
};

/*
** Routines to read or write a two- and four-byte big-endian integer values.
*/
#define get2byte(x)   ((x)[0]<<8 | (x)[1])
#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v))
77256
77257
77258
77259
77260
77261
77262
77263



77264
77265
77266
77267
77268
77269
77270
  pPayload = &pCell[nHeader];
  if( nPayload<=pPage->maxLocal ){
    /* This is the common case where everything fits on the btree page
    ** and no overflow pages are required. */
    n = nHeader + nPayload;
    testcase( n==3 );
    testcase( n==4 );
    if( n<4 ) n = 4;



    *pnSize = n;
    assert( nSrc<=nPayload );
    testcase( nSrc<nPayload );
    memcpy(pPayload, pSrc, nSrc);
    memset(pPayload+nSrc, 0, nPayload-nSrc);
    return SQLITE_OK;
  }







|
>
>
>







77418
77419
77420
77421
77422
77423
77424
77425
77426
77427
77428
77429
77430
77431
77432
77433
77434
77435
  pPayload = &pCell[nHeader];
  if( nPayload<=pPage->maxLocal ){
    /* This is the common case where everything fits on the btree page
    ** and no overflow pages are required. */
    n = nHeader + nPayload;
    testcase( n==3 );
    testcase( n==4 );
    if( n<4 ){
      n = 4;
      pPayload[nPayload] = 0;
    }
    *pnSize = n;
    assert( nSrc<=nPayload );
    testcase( nSrc<nPayload );
    memcpy(pPayload, pSrc, nSrc);
    memset(pPayload+nSrc, 0, nPayload-nSrc);
    return SQLITE_OK;
  }
79702
79703
79704
79705
79706
79707
79708
79709



79710
79711
79712
79713
79714
79715
79716
  assert( pPage->isInit || CORRUPT_DB );
  newCell = p->pBt->pTmpSpace;
  assert( newCell!=0 );
  assert( BTREE_PREFORMAT==OPFLAG_PREFORMAT );
  if( flags & BTREE_PREFORMAT ){
    rc = SQLITE_OK;
    szNew = p->pBt->nPreformatSize;
    if( szNew<4 ) szNew = 4;



    if( ISAUTOVACUUM(p->pBt) && szNew>pPage->maxLocal ){
      CellInfo info;
      pPage->xParseCell(pPage, newCell, &info);
      if( info.nPayload!=info.nLocal ){
        Pgno ovfl = get4byte(&newCell[szNew-4]);
        ptrmapPut(p->pBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, &rc);
        if( NEVER(rc) ) goto end_insert;







|
>
>
>







79867
79868
79869
79870
79871
79872
79873
79874
79875
79876
79877
79878
79879
79880
79881
79882
79883
79884
  assert( pPage->isInit || CORRUPT_DB );
  newCell = p->pBt->pTmpSpace;
  assert( newCell!=0 );
  assert( BTREE_PREFORMAT==OPFLAG_PREFORMAT );
  if( flags & BTREE_PREFORMAT ){
    rc = SQLITE_OK;
    szNew = p->pBt->nPreformatSize;
    if( szNew<4 ){
      szNew = 4;
      newCell[3] = 0;
    }
    if( ISAUTOVACUUM(p->pBt) && szNew>pPage->maxLocal ){
      CellInfo info;
      pPage->xParseCell(pPage, newCell, &info);
      if( info.nPayload!=info.nLocal ){
        Pgno ovfl = get4byte(&newCell[szNew-4]);
        ptrmapPut(p->pBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, &rc);
        if( NEVER(rc) ) goto end_insert;
81043
81044
81045
81046
81047
81048
81049



81050
81051
81052
81053
81054
81055
81056
  contentOffset = get2byteNotZero(&data[hdr+5]);
  assert( contentOffset<=usableSize );  /* Enforced by btreeInitPage() */

  /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
  ** number of cells on the page. */
  nCell = get2byte(&data[hdr+3]);
  assert( pPage->nCell==nCell );




  /* EVIDENCE-OF: R-23882-45353 The cell pointer array of a b-tree page
  ** immediately follows the b-tree page header. */
  cellStart = hdr + 12 - 4*pPage->leaf;
  assert( pPage->aCellIdx==&data[cellStart] );
  pCellIdx = &data[cellStart + 2*(nCell-1)];








>
>
>







81211
81212
81213
81214
81215
81216
81217
81218
81219
81220
81221
81222
81223
81224
81225
81226
81227
  contentOffset = get2byteNotZero(&data[hdr+5]);
  assert( contentOffset<=usableSize );  /* Enforced by btreeInitPage() */

  /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
  ** number of cells on the page. */
  nCell = get2byte(&data[hdr+3]);
  assert( pPage->nCell==nCell );
  if( pPage->leaf || pPage->intKey==0 ){
    pCheck->nRow += nCell;
  }

  /* EVIDENCE-OF: R-23882-45353 The cell pointer array of a b-tree page
  ** immediately follows the b-tree page header. */
  cellStart = hdr + 12 - 4*pPage->leaf;
  assert( pPage->aCellIdx==&data[cellStart] );
  pCellIdx = &data[cellStart + 2*(nCell-1)];

81154
81155
81156
81157
81158
81159
81160

81161
81162
81163
81164
81165
81166
81167
      for(i=nCell-1; i>=0; i--){
        u32 size;
        pc = get2byteAligned(&data[cellStart+i*2]);
        size = pPage->xCellSize(pPage, &data[pc]);
        btreeHeapInsert(heap, (pc<<16)|(pc+size-1));
      }
    }

    /* Add the freeblocks to the min-heap
    **
    ** EVIDENCE-OF: R-20690-50594 The second field of the b-tree page header
    ** is the offset of the first freeblock, or zero if there are no
    ** freeblocks on the page.
    */
    i = get2byte(&data[hdr+1]);







>







81325
81326
81327
81328
81329
81330
81331
81332
81333
81334
81335
81336
81337
81338
81339
      for(i=nCell-1; i>=0; i--){
        u32 size;
        pc = get2byteAligned(&data[cellStart+i*2]);
        size = pPage->xCellSize(pPage, &data[pc]);
        btreeHeapInsert(heap, (pc<<16)|(pc+size-1));
      }
    }
    assert( heap!=0 );
    /* Add the freeblocks to the min-heap
    **
    ** EVIDENCE-OF: R-20690-50594 The second field of the b-tree page header
    ** is the offset of the first freeblock, or zero if there are no
    ** freeblocks on the page.
    */
    i = get2byte(&data[hdr+1]);
81253
81254
81255
81256
81257
81258
81259

81260
81261
81262
81263
81264
81265
81266
81267
81268
81269
81270
81271
81272

81273

81274
81275
81276
81277
81278
81279
81280
** the unverified btrees.  Except, if aRoot[1] is 1, then the freelist
** checks are still performed.
*/
SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
  sqlite3 *db,  /* Database connection that is running the check */
  Btree *p,     /* The btree to be checked */
  Pgno *aRoot,  /* An array of root pages numbers for individual trees */

  int nRoot,    /* Number of entries in aRoot[] */
  int mxErr,    /* Stop reporting errors after this many */
  int *pnErr,   /* OUT: Write number of errors seen to this variable */
  char **pzOut  /* OUT: Write the error message string here */
){
  Pgno i;
  IntegrityCk sCheck;
  BtShared *pBt = p->pBt;
  u64 savedDbFlags = pBt->db->flags;
  char zErr[100];
  int bPartial = 0;            /* True if not checking all btrees */
  int bCkFreelist = 1;         /* True to scan the freelist */
  VVA_ONLY( int nRef );

  assert( nRoot>0 );


  /* aRoot[0]==0 means this is a partial check */
  if( aRoot[0]==0 ){
    assert( nRoot>1 );
    bPartial = 1;
    if( aRoot[1]!=1 ) bCkFreelist = 0;
  }







>













>

>







81425
81426
81427
81428
81429
81430
81431
81432
81433
81434
81435
81436
81437
81438
81439
81440
81441
81442
81443
81444
81445
81446
81447
81448
81449
81450
81451
81452
81453
81454
81455
** the unverified btrees.  Except, if aRoot[1] is 1, then the freelist
** checks are still performed.
*/
SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
  sqlite3 *db,  /* Database connection that is running the check */
  Btree *p,     /* The btree to be checked */
  Pgno *aRoot,  /* An array of root pages numbers for individual trees */
  Mem *aCnt,    /* Memory cells to write counts for each tree to */
  int nRoot,    /* Number of entries in aRoot[] */
  int mxErr,    /* Stop reporting errors after this many */
  int *pnErr,   /* OUT: Write number of errors seen to this variable */
  char **pzOut  /* OUT: Write the error message string here */
){
  Pgno i;
  IntegrityCk sCheck;
  BtShared *pBt = p->pBt;
  u64 savedDbFlags = pBt->db->flags;
  char zErr[100];
  int bPartial = 0;            /* True if not checking all btrees */
  int bCkFreelist = 1;         /* True to scan the freelist */
  VVA_ONLY( int nRef );

  assert( nRoot>0 );
  assert( aCnt!=0 );

  /* aRoot[0]==0 means this is a partial check */
  if( aRoot[0]==0 ){
    assert( nRoot>1 );
    bPartial = 1;
    if( aRoot[1]!=1 ) bCkFreelist = 0;
  }
81339
81340
81341
81342
81343
81344
81345


81346
81347
81348
81349
81350
81351
81352
81353
81354


81355
81356
81357
81358
81359
81360
81361
      );
    }
  }
#endif
  testcase( pBt->db->flags & SQLITE_CellSizeCk );
  pBt->db->flags &= ~(u64)SQLITE_CellSizeCk;
  for(i=0; (int)i<nRoot && sCheck.mxErr; i++){


    i64 notUsed;
    if( aRoot[i]==0 ) continue;
#ifndef SQLITE_OMIT_AUTOVACUUM
    if( pBt->autoVacuum && aRoot[i]>1 && !bPartial ){
      checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0);
    }
#endif
    sCheck.v0 = aRoot[i];
    checkTreePage(&sCheck, aRoot[i], &notUsed, LARGEST_INT64);


  }
  pBt->db->flags = savedDbFlags;

  /* Make sure every page in the file is referenced
  */
  if( !bPartial ){
    for(i=1; i<=sCheck.nCkPage && sCheck.mxErr; i++){







>
>
|
<

|
|
|

|
|
>
>







81514
81515
81516
81517
81518
81519
81520
81521
81522
81523

81524
81525
81526
81527
81528
81529
81530
81531
81532
81533
81534
81535
81536
81537
81538
81539
      );
    }
  }
#endif
  testcase( pBt->db->flags & SQLITE_CellSizeCk );
  pBt->db->flags &= ~(u64)SQLITE_CellSizeCk;
  for(i=0; (int)i<nRoot && sCheck.mxErr; i++){
    sCheck.nRow = 0;
    if( aRoot[i] ){
      i64 notUsed;

#ifndef SQLITE_OMIT_AUTOVACUUM
      if( pBt->autoVacuum && aRoot[i]>1 && !bPartial ){
        checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0);
      }
#endif
      sCheck.v0 = aRoot[i];
      checkTreePage(&sCheck, aRoot[i], &notUsed, LARGEST_INT64);
    }
    sqlite3MemSetArrayInt64(aCnt, i, sCheck.nRow);
  }
  pBt->db->flags = savedDbFlags;

  /* Make sure every page in the file is referenced
  */
  if( !bPartial ){
    for(i=1; i<=sCheck.nCkPage && sCheck.mxErr; i++){
83401
83402
83403
83404
83405
83406
83407







83408
83409
83410
83411
83412
83413
83414
  if( VdbeMemDynamic(pMem) ){
    vdbeReleaseAndSetInt64(pMem, val);
  }else{
    pMem->u.i = val;
    pMem->flags = MEM_Int;
  }
}








/* A no-op destructor */
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.







>
>
>
>
>
>
>







83579
83580
83581
83582
83583
83584
83585
83586
83587
83588
83589
83590
83591
83592
83593
83594
83595
83596
83597
83598
83599
  if( VdbeMemDynamic(pMem) ){
    vdbeReleaseAndSetInt64(pMem, val);
  }else{
    pMem->u.i = val;
    pMem->flags = MEM_Int;
  }
}

/*
** Set the iIdx'th entry of array aMem[] to contain integer value val.
*/
SQLITE_PRIVATE void sqlite3MemSetArrayInt64(sqlite3_value *aMem, int iIdx, i64 val){
  sqlite3VdbeMemSetInt64(&aMem[iIdx], val);
}

/* A no-op destructor */
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.
85446
85447
85448
85449
85450
85451
85452









85453
85454
85455
85456
85457
85458
85459
            ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to
            ** have non-negative values for P2. */
            assert( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 );
            assert( ADDR(pOp->p2)<-pParse->nLabel );
            assert( aLabel!=0 );  /* True because of tag-20230419-1 */
            pOp->p2 = aLabel[ADDR(pOp->p2)];
          }









          break;
        }
      }
      /* The mkopcodeh.tcl script has so arranged things that the only
      ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to
      ** have non-negative values for P2. */
      assert( (sqlite3OpcodeProperty[pOp->opcode]&OPFLG_JUMP)==0 || pOp->p2>=0);







>
>
>
>
>
>
>
>
>







85631
85632
85633
85634
85635
85636
85637
85638
85639
85640
85641
85642
85643
85644
85645
85646
85647
85648
85649
85650
85651
85652
85653
            ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to
            ** have non-negative values for P2. */
            assert( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 );
            assert( ADDR(pOp->p2)<-pParse->nLabel );
            assert( aLabel!=0 );  /* True because of tag-20230419-1 */
            pOp->p2 = aLabel[ADDR(pOp->p2)];
          }

          /* OPFLG_JUMP opcodes never have P2==0, though OPFLG_JUMP0 opcodes
          ** might */
          assert( pOp->p2>0
                  || (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP0)!=0 );

          /* Jumps never go off the end of the bytecode array */
          assert( pOp->p2<p->nOp
                  || (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)==0 );
          break;
        }
      }
      /* The mkopcodeh.tcl script has so arranged things that the only
      ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to
      ** have non-negative values for P2. */
      assert( (sqlite3OpcodeProperty[pOp->opcode]&OPFLG_JUMP)==0 || pOp->p2>=0);
88566
88567
88568
88569
88570
88571
88572

















88573
88574
88575
88576
88577
88578
88579
    assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );
#endif
    assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 );
    swapMixedEndianFloat(x);
    memcpy(&pMem->u.r, &x, sizeof(x));
    pMem->flags = IsNaN(x) ? MEM_Null : MEM_Real;
  }

















}
SQLITE_PRIVATE void sqlite3VdbeSerialGet(
  const unsigned char *buf,     /* Buffer to deserialize from */
  u32 serial_type,              /* Serial type to deserialize */
  Mem *pMem                     /* Memory cell to write value into */
){
  switch( serial_type ){







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







88760
88761
88762
88763
88764
88765
88766
88767
88768
88769
88770
88771
88772
88773
88774
88775
88776
88777
88778
88779
88780
88781
88782
88783
88784
88785
88786
88787
88788
88789
88790
    assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );
#endif
    assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 );
    swapMixedEndianFloat(x);
    memcpy(&pMem->u.r, &x, sizeof(x));
    pMem->flags = IsNaN(x) ? MEM_Null : MEM_Real;
  }
}
static int serialGet7(
  const unsigned char *buf,     /* Buffer to deserialize from */
  Mem *pMem                     /* Memory cell to write value into */
){
  u64 x = FOUR_BYTE_UINT(buf);
  u32 y = FOUR_BYTE_UINT(buf+4);
  x = (x<<32) + y;
  assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 );
  swapMixedEndianFloat(x);
  memcpy(&pMem->u.r, &x, sizeof(x));
  if( IsNaN(x) ){
    pMem->flags = MEM_Null;
    return 1;
  }
  pMem->flags = MEM_Real;
  return 0;
}
SQLITE_PRIVATE void sqlite3VdbeSerialGet(
  const unsigned char *buf,     /* Buffer to deserialize from */
  u32 serial_type,              /* Serial type to deserialize */
  Mem *pMem                     /* Memory cell to write value into */
){
  switch( serial_type ){
89006
89007
89008
89009
89010
89011
89012
89013
89014
89015
89016
89017
89018
89019
89020
89021
89022
89023
89024
89025
89026
89027
89028
89029
89030
    LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i;
    testcase( x<r );
    testcase( x>r );
    testcase( x==r );
    return (x<r) ? -1 : (x>r);
  }else{
    i64 y;
    double s;
    if( r<-9223372036854775808.0 ) return +1;
    if( r>=9223372036854775808.0 ) return -1;
    y = (i64)r;
    if( i<y ) return -1;
    if( i>y ) return +1;
    s = (double)i;
    testcase( doubleLt(s,r) );
    testcase( doubleLt(r,s) );
    testcase( doubleEq(r,s) );
    return (s<r) ? -1 : (s>r);
  }
}

/*
** Compare the values contained by the two memory cells, returning
** negative, zero or positive if pMem1 is less than, equal to, or greater
** than pMem2. Sorting order is NULL's first, followed by numbers (integers







<





<
|
|
|
|







89217
89218
89219
89220
89221
89222
89223

89224
89225
89226
89227
89228

89229
89230
89231
89232
89233
89234
89235
89236
89237
89238
89239
    LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i;
    testcase( x<r );
    testcase( x>r );
    testcase( x==r );
    return (x<r) ? -1 : (x>r);
  }else{
    i64 y;

    if( r<-9223372036854775808.0 ) return +1;
    if( r>=9223372036854775808.0 ) return -1;
    y = (i64)r;
    if( i<y ) return -1;
    if( i>y ) return +1;

    testcase( doubleLt(((double)i),r) );
    testcase( doubleLt(r,((double)i)) );
    testcase( doubleEq(r,((double)i)) );
    return (((double)i)<r) ? -1 : (((double)i)>r);
  }
}

/*
** Compare the values contained by the two memory cells, returning
** negative, zero or positive if pMem1 is less than, equal to, or greater
** than pMem2. Sorting order is NULL's first, followed by numbers (integers
89246
89247
89248
89249
89250
89251
89252
89253
89254
89255
89256
89257
89258
89259
89260
      serial_type = aKey1[idx1];
      testcase( serial_type==12 );
      if( serial_type>=10 ){
        rc = serial_type==10 ? -1 : +1;
      }else if( serial_type==0 ){
        rc = -1;
      }else if( serial_type==7 ){
        sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1);
        rc = -sqlite3IntFloatCompare(pRhs->u.i, mem1.u.r);
      }else{
        i64 lhs = vdbeRecordDecodeInt(serial_type, &aKey1[d1]);
        i64 rhs = pRhs->u.i;
        if( lhs<rhs ){
          rc = -1;
        }else if( lhs>rhs ){







|







89455
89456
89457
89458
89459
89460
89461
89462
89463
89464
89465
89466
89467
89468
89469
      serial_type = aKey1[idx1];
      testcase( serial_type==12 );
      if( serial_type>=10 ){
        rc = serial_type==10 ? -1 : +1;
      }else if( serial_type==0 ){
        rc = -1;
      }else if( serial_type==7 ){
        serialGet7(&aKey1[d1], &mem1);
        rc = -sqlite3IntFloatCompare(pRhs->u.i, mem1.u.r);
      }else{
        i64 lhs = vdbeRecordDecodeInt(serial_type, &aKey1[d1]);
        i64 rhs = pRhs->u.i;
        if( lhs<rhs ){
          rc = -1;
        }else if( lhs>rhs ){
89271
89272
89273
89274
89275
89276
89277
89278
89279


89280
89281
89282
89283


89284
89285

89286
89287
89288
89289
89290
89291
89292
        ** numbers). Types 10 and 11 are currently "reserved for future
        ** use", so it doesn't really matter what the results of comparing
        ** them to numeric values are.  */
        rc = serial_type==10 ? -1 : +1;
      }else if( serial_type==0 ){
        rc = -1;
      }else{
        sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1);
        if( serial_type==7 ){


          if( mem1.u.r<pRhs->u.r ){
            rc = -1;
          }else if( mem1.u.r>pRhs->u.r ){
            rc = +1;


          }
        }else{

          rc = sqlite3IntFloatCompare(mem1.u.i, pRhs->u.r);
        }
      }
    }

    /* RHS is a string */
    else if( pRhs->flags & MEM_Str ){







<

>
>
|



>
>


>







89480
89481
89482
89483
89484
89485
89486

89487
89488
89489
89490
89491
89492
89493
89494
89495
89496
89497
89498
89499
89500
89501
89502
89503
89504
89505
        ** numbers). Types 10 and 11 are currently "reserved for future
        ** use", so it doesn't really matter what the results of comparing
        ** them to numeric values are.  */
        rc = serial_type==10 ? -1 : +1;
      }else if( serial_type==0 ){
        rc = -1;
      }else{

        if( serial_type==7 ){
          if( serialGet7(&aKey1[d1], &mem1) ){
            rc = -1;  /* mem1 is a NaN */
          }else if( mem1.u.r<pRhs->u.r ){
            rc = -1;
          }else if( mem1.u.r>pRhs->u.r ){
            rc = +1;
          }else{
            assert( rc==0 );
          }
        }else{
          sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1);
          rc = sqlite3IntFloatCompare(mem1.u.i, pRhs->u.r);
        }
      }
    }

    /* RHS is a string */
    else if( pRhs->flags & MEM_Str ){
89348
89349
89350
89351
89352
89353
89354
89355







89356
89357
89358
89359
89360
89361
89362
        }
      }
    }

    /* RHS is null */
    else{
      serial_type = aKey1[idx1];
      rc = (serial_type!=0 && serial_type!=10);







    }

    if( rc!=0 ){
      int sortFlags = pPKey2->pKeyInfo->aSortFlags[i];
      if( sortFlags ){
        if( (sortFlags & KEYINFO_ORDER_BIGNULL)==0
         || ((sortFlags & KEYINFO_ORDER_DESC)







|
>
>
>
>
>
>
>







89561
89562
89563
89564
89565
89566
89567
89568
89569
89570
89571
89572
89573
89574
89575
89576
89577
89578
89579
89580
89581
89582
        }
      }
    }

    /* RHS is null */
    else{
      serial_type = aKey1[idx1];
      if( serial_type==0
       || serial_type==10
       || (serial_type==7 && serialGet7(&aKey1[d1], &mem1)!=0)
      ){
        assert( rc==0 );
      }else{
        rc = 1;
      }
    }

    if( rc!=0 ){
      int sortFlags = pPKey2->pKeyInfo->aSortFlags[i];
      if( sortFlags ){
        if( (sortFlags & KEYINFO_ORDER_BIGNULL)==0
         || ((sortFlags & KEYINFO_ORDER_DESC)
93874
93875
93876
93877
93878
93879
93880
93881
93882
93883
93884
93885
93886
93887
93888
**
** If P2!=0 then the coroutine implementation immediately follows
** this opcode.  So jump over the coroutine implementation to
** address P2.
**
** See also: EndCoroutine
*/
case OP_InitCoroutine: {     /* jump */
  assert( pOp->p1>0 &&  pOp->p1<=(p->nMem+1 - p->nCursor) );
  assert( pOp->p2>=0 && pOp->p2<p->nOp );
  assert( pOp->p3>=0 && pOp->p3<p->nOp );
  pOut = &aMem[pOp->p1];
  assert( !VdbeMemDynamic(pOut) );
  pOut->u.i = pOp->p3 - 1;
  pOut->flags = MEM_Int;







|







94094
94095
94096
94097
94098
94099
94100
94101
94102
94103
94104
94105
94106
94107
94108
**
** If P2!=0 then the coroutine implementation immediately follows
** this opcode.  So jump over the coroutine implementation to
** address P2.
**
** See also: EndCoroutine
*/
case OP_InitCoroutine: {     /* jump0 */
  assert( pOp->p1>0 &&  pOp->p1<=(p->nMem+1 - p->nCursor) );
  assert( pOp->p2>=0 && pOp->p2<p->nOp );
  assert( pOp->p3>=0 && pOp->p3<p->nOp );
  pOut = &aMem[pOp->p1];
  assert( !VdbeMemDynamic(pOut) );
  pOut->u.i = pOp->p3 - 1;
  pOut->flags = MEM_Int;
93927
93928
93929
93930
93931
93932
93933
93934
93935
93936
93937
93938
93939
93940
93941
** Yield or Return then continue to the next instruction.  But if
** the coroutine launched by this instruction ends with
** EndCoroutine, then jump to P2 rather than continuing with the
** next instruction.
**
** See also: InitCoroutine
*/
case OP_Yield: {            /* in1, jump */
  int pcDest;
  pIn1 = &aMem[pOp->p1];
  assert( VdbeMemDynamic(pIn1)==0 );
  pIn1->flags = MEM_Int;
  pcDest = (int)pIn1->u.i;
  pIn1->u.i = (int)(pOp - aOp);
  REGISTER_TRACE(pOp->p1, pIn1);







|







94147
94148
94149
94150
94151
94152
94153
94154
94155
94156
94157
94158
94159
94160
94161
** Yield or Return then continue to the next instruction.  But if
** the coroutine launched by this instruction ends with
** EndCoroutine, then jump to P2 rather than continuing with the
** next instruction.
**
** See also: InitCoroutine
*/
case OP_Yield: {            /* in1, jump0 */
  int pcDest;
  pIn1 = &aMem[pOp->p1];
  assert( VdbeMemDynamic(pIn1)==0 );
  pIn1->flags = MEM_Int;
  pcDest = (int)pIn1->u.i;
  pIn1->u.i = (int)(pOp - aOp);
  REGISTER_TRACE(pOp->p1, pIn1);
94257
94258
94259
94260
94261
94262
94263
94264
94265
94266
94267
94268
94269
94270
94271
94272
94273
94274
94275
94276
94277
94278
94279
94280
94281
94282
94283
    sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);
  }
  pOut->enc = encoding;
  UPDATE_MAX_BLOBSIZE(pOut);
  break;
}

/* Opcode: Variable P1 P2 * P4 *
** Synopsis: r[P2]=parameter(P1,P4)
**
** Transfer the values of bound parameter P1 into register P2
**
** If the parameter is named, then its name appears in P4.
** The P4 value is used by sqlite3_bind_parameter_name().
*/
case OP_Variable: {            /* out2 */
  Mem *pVar;       /* Value being transferred */

  assert( pOp->p1>0 && pOp->p1<=p->nVar );
  assert( pOp->p4.z==0 || pOp->p4.z==sqlite3VListNumToName(p->pVList,pOp->p1) );
  pVar = &p->aVar[pOp->p1 - 1];
  if( sqlite3VdbeMemTooBig(pVar) ){
    goto too_big;
  }
  pOut = &aMem[pOp->p2];
  if( VdbeMemDynamic(pOut) ) sqlite3VdbeMemSetNull(pOut);
  memcpy(pOut, pVar, MEMCELLSIZE);







|
|


<
<
<





<







94477
94478
94479
94480
94481
94482
94483
94484
94485
94486
94487



94488
94489
94490
94491
94492

94493
94494
94495
94496
94497
94498
94499
    sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);
  }
  pOut->enc = encoding;
  UPDATE_MAX_BLOBSIZE(pOut);
  break;
}

/* Opcode: Variable P1 P2 * * *
** Synopsis: r[P2]=parameter(P1)
**
** Transfer the values of bound parameter P1 into register P2



*/
case OP_Variable: {            /* out2 */
  Mem *pVar;       /* Value being transferred */

  assert( pOp->p1>0 && pOp->p1<=p->nVar );

  pVar = &p->aVar[pOp->p1 - 1];
  if( sqlite3VdbeMemTooBig(pVar) ){
    goto too_big;
  }
  pOut = &aMem[pOp->p2];
  if( VdbeMemDynamic(pOut) ) sqlite3VdbeMemSetNull(pOut);
  memcpy(pOut, pVar, MEMCELLSIZE);
94790
94791
94792
94793
94794
94795
94796
94797
94798
94799
94800
94801
94802
94803
94804
/* Opcode: MustBeInt P1 P2 * * *
**
** Force the value in register P1 to be an integer.  If the value
** in P1 is not an integer and cannot be converted into an integer
** without data loss, then jump immediately to P2, or if P2==0
** raise an SQLITE_MISMATCH exception.
*/
case OP_MustBeInt: {            /* jump, in1 */
  pIn1 = &aMem[pOp->p1];
  if( (pIn1->flags & MEM_Int)==0 ){
    applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding);
    if( (pIn1->flags & MEM_Int)==0 ){
      VdbeBranchTaken(1, 2);
      if( pOp->p2==0 ){
        rc = SQLITE_MISMATCH;







|







95006
95007
95008
95009
95010
95011
95012
95013
95014
95015
95016
95017
95018
95019
95020
/* Opcode: MustBeInt P1 P2 * * *
**
** Force the value in register P1 to be an integer.  If the value
** in P1 is not an integer and cannot be converted into an integer
** without data loss, then jump immediately to P2, or if P2==0
** raise an SQLITE_MISMATCH exception.
*/
case OP_MustBeInt: {            /* jump0, in1 */
  pIn1 = &aMem[pOp->p1];
  if( (pIn1->flags & MEM_Int)==0 ){
    applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding);
    if( (pIn1->flags & MEM_Int)==0 ){
      VdbeBranchTaken(1, 2);
      if( pOp->p2==0 ){
        rc = SQLITE_MISMATCH;
97474
97475
97476
97477
97478
97479
97480
97481
97482
97483
97484
97485
97486
97487
97488
97489
97490
97491
** The IdxGE opcode will be skipped if this opcode succeeds, but the
** IdxGE opcode will be used on subsequent loop iterations.  The
** OPFLAG_SEEKEQ flags is a hint to the btree layer to say that this
** is an equality search.
**
** See also: Found, NotFound, SeekGt, SeekGe, SeekLt
*/
case OP_SeekLT:         /* jump, in3, group, ncycle */
case OP_SeekLE:         /* jump, in3, group, ncycle */
case OP_SeekGE:         /* jump, in3, group, ncycle */
case OP_SeekGT: {       /* jump, in3, group, ncycle */
  int res;           /* Comparison result */
  int oc;            /* Opcode */
  VdbeCursor *pC;    /* The cursor to seek */
  UnpackedRecord r;  /* The key to seek for */
  int nField;        /* Number of columns or fields in the key */
  i64 iKey;          /* The rowid we are to seek to */
  int eqOnly;        /* Only interested in == results */







|
|
|
|







97690
97691
97692
97693
97694
97695
97696
97697
97698
97699
97700
97701
97702
97703
97704
97705
97706
97707
** The IdxGE opcode will be skipped if this opcode succeeds, but the
** IdxGE opcode will be used on subsequent loop iterations.  The
** OPFLAG_SEEKEQ flags is a hint to the btree layer to say that this
** is an equality search.
**
** See also: Found, NotFound, SeekGt, SeekGe, SeekLt
*/
case OP_SeekLT:         /* jump0, in3, group, ncycle */
case OP_SeekLE:         /* jump0, in3, group, ncycle */
case OP_SeekGE:         /* jump0, in3, group, ncycle */
case OP_SeekGT: {       /* jump0, in3, group, ncycle */
  int res;           /* Comparison result */
  int oc;            /* Opcode */
  VdbeCursor *pC;    /* The cursor to seek */
  UnpackedRecord r;  /* The key to seek for */
  int nField;        /* Number of columns or fields in the key */
  i64 iKey;          /* The rowid we are to seek to */
  int eqOnly;        /* Only interested in == results */
98144
98145
98146
98147
98148
98149
98150
98151
98152
98153
98154
98155
98156
98157
98158
**
** This opcode leaves the cursor in a state where it cannot be advanced
** in either direction.  In other words, the Next and Prev opcodes will
** not work following this opcode.
**
** See also: Found, NotFound, NoConflict, SeekRowid
*/
case OP_SeekRowid: {        /* jump, in3, ncycle */
  VdbeCursor *pC;
  BtCursor *pCrsr;
  int res;
  u64 iKey;

  pIn3 = &aMem[pOp->p3];
  testcase( pIn3->flags & MEM_Int );







|







98360
98361
98362
98363
98364
98365
98366
98367
98368
98369
98370
98371
98372
98373
98374
**
** This opcode leaves the cursor in a state where it cannot be advanced
** in either direction.  In other words, the Next and Prev opcodes will
** not work following this opcode.
**
** See also: Found, NotFound, NoConflict, SeekRowid
*/
case OP_SeekRowid: {        /* jump0, in3, ncycle */
  VdbeCursor *pC;
  BtCursor *pCrsr;
  int res;
  u64 iKey;

  pIn3 = &aMem[pOp->p3];
  testcase( pIn3->flags & MEM_Int );
98903
98904
98905
98906
98907
98908
98909
98910
98911
98912
98913
98914
98915
98916
98917
** to the following instruction.
**
** This opcode leaves the cursor configured to move in reverse order,
** from the end toward the beginning.  In other words, the cursor is
** configured to use Prev, not Next.
*/
case OP_SeekEnd:             /* ncycle */
case OP_Last: {              /* jump, ncycle */
  VdbeCursor *pC;
  BtCursor *pCrsr;
  int res;

  assert( pOp->p1>=0 && pOp->p1<p->nCursor );
  pC = p->apCsr[pOp->p1];
  assert( pC!=0 );







|







99119
99120
99121
99122
99123
99124
99125
99126
99127
99128
99129
99130
99131
99132
99133
** to the following instruction.
**
** This opcode leaves the cursor configured to move in reverse order,
** from the end toward the beginning.  In other words, the cursor is
** configured to use Prev, not Next.
*/
case OP_SeekEnd:             /* ncycle */
case OP_Last: {              /* jump0, ncycle */
  VdbeCursor *pC;
  BtCursor *pCrsr;
  int res;

  assert( pOp->p1>=0 && pOp->p1<p->nCursor );
  pC = p->apCsr[pOp->p1];
  assert( pC!=0 );
99020
99021
99022
99023
99024
99025
99026
99027
99028
99029
99030
99031
99032
99033
99034
** If P2 is zero, that is an assertion that the P1 table is never
** empty and hence the jump will never be taken.
**
** This opcode leaves the cursor configured to move in forward order,
** from the beginning toward the end.  In other words, the cursor is
** configured to use Next, not Prev.
*/
case OP_Rewind: {        /* jump, ncycle */
  VdbeCursor *pC;
  BtCursor *pCrsr;
  int res;

  assert( pOp->p1>=0 && pOp->p1<p->nCursor );
  assert( pOp->p5==0 );
  assert( pOp->p2>=0 && pOp->p2<p->nOp );







|







99236
99237
99238
99239
99240
99241
99242
99243
99244
99245
99246
99247
99248
99249
99250
** If P2 is zero, that is an assertion that the P1 table is never
** empty and hence the jump will never be taken.
**
** This opcode leaves the cursor configured to move in forward order,
** from the beginning toward the end.  In other words, the cursor is
** configured to use Next, not Prev.
*/
case OP_Rewind: {        /* jump0, ncycle */
  VdbeCursor *pC;
  BtCursor *pCrsr;
  int res;

  assert( pOp->p1>=0 && pOp->p1<p->nCursor );
  assert( pOp->p5==0 );
  assert( pOp->p2>=0 && pOp->p2<p->nOp );
99863
99864
99865
99866
99867
99868
99869
99870
99871
99872
99873
99874
99875
99876
99877
99878
99879
99880
99881
99882
99883
99884
99885
99886
99887
99888
99889
99890
99891
99892
99893

99894
99895
99896

99897
99898
99899
99900
99901
99902
99903
99904
99905
99906
99907
99908
99909
99910
99911
99912
99913
}


#ifndef SQLITE_OMIT_INTEGRITY_CHECK
/* Opcode: IntegrityCk P1 P2 P3 P4 P5
**
** Do an analysis of the currently open database.  Store in
** register P1 the text of an error message describing any problems.
** If no problems are found, store a NULL in register P1.
**
** The register P3 contains one less than the maximum number of allowed errors.
** At most reg(P3) errors will be reported.
** In other words, the analysis stops as soon as reg(P3) errors are
** seen.  Reg(P3) is updated with the number of errors remaining.
**
** The root page numbers of all tables in the database are integers
** stored in P4_INTARRAY argument.
**
** If P5 is not zero, the check is done on the auxiliary database
** file, not the main database file.
**
** This opcode is used to implement the integrity_check pragma.
*/
case OP_IntegrityCk: {
  int nRoot;      /* Number of tables to check.  (Number of root pages.) */
  Pgno *aRoot;    /* Array of rootpage numbers for tables to be checked */
  int nErr;       /* Number of errors reported */
  char *z;        /* Text of the error report */
  Mem *pnErr;     /* Register keeping track of errors remaining */

  assert( p->bIsReader );

  nRoot = pOp->p2;
  aRoot = pOp->p4.ai;
  assert( nRoot>0 );

  assert( aRoot[0]==(Pgno)nRoot );
  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
  pnErr = &aMem[pOp->p3];
  assert( (pnErr->flags & MEM_Int)!=0 );
  assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );
  pIn1 = &aMem[pOp->p1];
  assert( pOp->p5<db->nDb );
  assert( DbMaskTest(p->btreeMask, pOp->p5) );
  rc = sqlite3BtreeIntegrityCheck(db, db->aDb[pOp->p5].pBt, &aRoot[1], nRoot,
                                 (int)pnErr->u.i+1, &nErr, &z);
  sqlite3VdbeMemSetNull(pIn1);
  if( nErr==0 ){
    assert( z==0 );
  }else if( rc ){
    sqlite3_free(z);
    goto abort_due_to_error;
  }else{







|
|

|
|
|
|

















>



>

|
|


|


|
|







100079
100080
100081
100082
100083
100084
100085
100086
100087
100088
100089
100090
100091
100092
100093
100094
100095
100096
100097
100098
100099
100100
100101
100102
100103
100104
100105
100106
100107
100108
100109
100110
100111
100112
100113
100114
100115
100116
100117
100118
100119
100120
100121
100122
100123
100124
100125
100126
100127
100128
100129
100130
100131
}


#ifndef SQLITE_OMIT_INTEGRITY_CHECK
/* Opcode: IntegrityCk P1 P2 P3 P4 P5
**
** Do an analysis of the currently open database.  Store in
** register (P1+1) the text of an error message describing any problems.
** If no problems are found, store a NULL in register (P1+1).
**
** The register (P1) contains one less than the maximum number of allowed
** errors.  At most reg(P1) errors will be reported.
** In other words, the analysis stops as soon as reg(P1) errors are
** seen.  Reg(P1) is updated with the number of errors remaining.
**
** The root page numbers of all tables in the database are integers
** stored in P4_INTARRAY argument.
**
** If P5 is not zero, the check is done on the auxiliary database
** file, not the main database file.
**
** This opcode is used to implement the integrity_check pragma.
*/
case OP_IntegrityCk: {
  int nRoot;      /* Number of tables to check.  (Number of root pages.) */
  Pgno *aRoot;    /* Array of rootpage numbers for tables to be checked */
  int nErr;       /* Number of errors reported */
  char *z;        /* Text of the error report */
  Mem *pnErr;     /* Register keeping track of errors remaining */

  assert( p->bIsReader );
  assert( pOp->p4type==P4_INTARRAY );
  nRoot = pOp->p2;
  aRoot = pOp->p4.ai;
  assert( nRoot>0 );
  assert( aRoot!=0 );
  assert( aRoot[0]==(Pgno)nRoot );
  assert( pOp->p1>0 && (pOp->p1+1)<=(p->nMem+1 - p->nCursor) );
  pnErr = &aMem[pOp->p1];
  assert( (pnErr->flags & MEM_Int)!=0 );
  assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );
  pIn1 = &aMem[pOp->p1+1];
  assert( pOp->p5<db->nDb );
  assert( DbMaskTest(p->btreeMask, pOp->p5) );
  rc = sqlite3BtreeIntegrityCheck(db, db->aDb[pOp->p5].pBt, &aRoot[1],
      &aMem[pOp->p3], nRoot, (int)pnErr->u.i+1, &nErr, &z);
  sqlite3VdbeMemSetNull(pIn1);
  if( nErr==0 ){
    assert( z==0 );
  }else if( rc ){
    sqlite3_free(z);
    goto abort_due_to_error;
  }else{
100026
100027
100028
100029
100030
100031
100032
100033


100034
100035
100036
100037
100038
100039
100040
100041
100042
100043
100044
100045
100046
100047
100048
/* Opcode: Program P1 P2 P3 P4 P5
**
** Execute the trigger program passed as P4 (type P4_SUBPROGRAM).
**
** P1 contains the address of the memory cell that contains the first memory
** cell in an array of values used as arguments to the sub-program. P2
** contains the address to jump to if the sub-program throws an IGNORE
** exception using the RAISE() function. Register P3 contains the address


** of a memory cell in this (the parent) VM that is used to allocate the
** memory required by the sub-vdbe at runtime.
**
** P4 is a pointer to the VM containing the trigger program.
**
** If P5 is non-zero, then recursive program invocation is enabled.
*/
case OP_Program: {        /* jump */
  int nMem;               /* Number of memory registers for sub-program */
  int nByte;              /* Bytes of runtime space required for sub-program */
  Mem *pRt;               /* Register to allocate runtime space */
  Mem *pMem;              /* Used to iterate through memory cells */
  Mem *pEnd;              /* Last memory cell in new array */
  VdbeFrame *pFrame;      /* New vdbe frame to execute in */
  SubProgram *pProgram;   /* Sub-program to execute */







|
>
>







|







100244
100245
100246
100247
100248
100249
100250
100251
100252
100253
100254
100255
100256
100257
100258
100259
100260
100261
100262
100263
100264
100265
100266
100267
100268
/* Opcode: Program P1 P2 P3 P4 P5
**
** Execute the trigger program passed as P4 (type P4_SUBPROGRAM).
**
** P1 contains the address of the memory cell that contains the first memory
** cell in an array of values used as arguments to the sub-program. P2
** contains the address to jump to if the sub-program throws an IGNORE
** exception using the RAISE() function. P2 might be zero, if there is
** no possibility that an IGNORE exception will be raised.
** Register P3 contains the address
** of a memory cell in this (the parent) VM that is used to allocate the
** memory required by the sub-vdbe at runtime.
**
** P4 is a pointer to the VM containing the trigger program.
**
** If P5 is non-zero, then recursive program invocation is enabled.
*/
case OP_Program: {        /* jump0 */
  int nMem;               /* Number of memory registers for sub-program */
  int nByte;              /* Bytes of runtime space required for sub-program */
  Mem *pRt;               /* Register to allocate runtime space */
  Mem *pMem;              /* Used to iterate through memory cells */
  Mem *pEnd;              /* Last memory cell in new array */
  VdbeFrame *pFrame;      /* New vdbe frame to execute in */
  SubProgram *pProgram;   /* Sub-program to execute */
101583
101584
101585
101586
101587
101588
101589
101590
101591
101592
101593
101594
101595
101596
101597
** Increment the value of P1 so that OP_Once opcodes will jump the
** first time they are evaluated for this run.
**
** If P3 is not zero, then it is an address to jump to if an SQLITE_CORRUPT
** error is encountered.
*/
case OP_Trace:
case OP_Init: {          /* jump */
  int i;
#ifndef SQLITE_OMIT_TRACE
  char *zTrace;
#endif

  /* If the P4 argument is not NULL, then it must be an SQL comment string.
  ** The "--" string is broken up to prevent false-positives with srcck1.c.







|







101803
101804
101805
101806
101807
101808
101809
101810
101811
101812
101813
101814
101815
101816
101817
** Increment the value of P1 so that OP_Once opcodes will jump the
** first time they are evaluated for this run.
**
** If P3 is not zero, then it is an address to jump to if an SQLITE_CORRUPT
** error is encountered.
*/
case OP_Trace:
case OP_Init: {          /* jump0 */
  int i;
#ifndef SQLITE_OMIT_TRACE
  char *zTrace;
#endif

  /* If the P4 argument is not NULL, then it must be an SQL comment string.
  ** The "--" string is broken up to prevent false-positives with srcck1.c.
107323
107324
107325
107326
107327
107328
107329













107330
107331
107332
107333
107334
107335
107336
107337
107338
107339

107340









107341
107342









107343
107344
107345
107346
107347
107348
107349
107350
107351
107352
107353
107354
107355
107356
107357
107358
107359
    ** "NOT NULL strength reduction optimization".
    **
    ** If this optimization occurs, also restore the NameContext ref-counts
    ** to the state they where in before the "column" LHS expression was
    ** resolved.  This prevents "column" from being counted as having been
    ** referenced, which might prevent a SELECT from being erroneously
    ** marked as correlated.













    */
    case TK_NOTNULL:
    case TK_ISNULL: {
      int anRef[8];
      NameContext *p;
      int i;
      for(i=0, p=pNC; p && i<ArraySize(anRef); p=p->pNext, i++){
        anRef[i] = p->nRef;
      }
      sqlite3WalkExpr(pWalker, pExpr->pLeft);

      if( 0==sqlite3ExprCanBeNull(pExpr->pLeft) && !IN_RENAME_OBJECT ){









        testcase( ExprHasProperty(pExpr, EP_OuterON) );
        assert( !ExprHasProperty(pExpr, EP_IntValue) );









        pExpr->u.iValue = (pExpr->op==TK_NOTNULL);
        pExpr->flags |= EP_IntValue;
        pExpr->op = TK_INTEGER;

        for(i=0, p=pNC; p && i<ArraySize(anRef); p=p->pNext, i++){
          p->nRef = anRef[i];
        }
        sqlite3ExprDelete(pParse->db, pExpr->pLeft);
        pExpr->pLeft = 0;
      }
      return WRC_Prune;
    }

    /* A column name:                    ID
    ** Or table name and column name:    ID.ID
    ** Or a database, table and column:  ID.ID.ID
    **







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










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







107543
107544
107545
107546
107547
107548
107549
107550
107551
107552
107553
107554
107555
107556
107557
107558
107559
107560
107561
107562
107563
107564
107565
107566
107567
107568
107569
107570
107571
107572
107573
107574
107575
107576
107577
107578
107579
107580
107581
107582
107583
107584
107585
107586
107587
107588
107589
107590
107591
107592
107593
107594
107595
107596
107597

107598
107599
107600
107601
107602

107603
107604
107605
107606
107607
107608
107609
    ** "NOT NULL strength reduction optimization".
    **
    ** If this optimization occurs, also restore the NameContext ref-counts
    ** to the state they where in before the "column" LHS expression was
    ** resolved.  This prevents "column" from being counted as having been
    ** referenced, which might prevent a SELECT from being erroneously
    ** marked as correlated.
    **
    ** 2024-03-28: Beware of aggregates.  A bare column of aggregated table
    ** can still evaluate to NULL even though it is marked as NOT NULL.
    ** Example:
    **
    **       CREATE TABLE t1(a INT NOT NULL);
    **       SELECT a, a IS NULL, a IS NOT NULL, count(*) FROM t1;
    **
    ** The "a IS NULL" and "a IS NOT NULL" expressions cannot be optimized
    ** here because at the time this case is hit, we do not yet know whether
    ** or not t1 is being aggregated.  We have to assume the worst and omit
    ** the optimization.  The only time it is safe to apply this optimization
    ** is within the WHERE clause.
    */
    case TK_NOTNULL:
    case TK_ISNULL: {
      int anRef[8];
      NameContext *p;
      int i;
      for(i=0, p=pNC; p && i<ArraySize(anRef); p=p->pNext, i++){
        anRef[i] = p->nRef;
      }
      sqlite3WalkExpr(pWalker, pExpr->pLeft);
      if( IN_RENAME_OBJECT ) return WRC_Prune;
      if( sqlite3ExprCanBeNull(pExpr->pLeft) ){
        /* The expression can be NULL.  So the optimization does not apply */
        return WRC_Prune;
      }

      for(i=0, p=pNC; p; p=p->pNext, i++){
        if( (p->ncFlags & NC_Where)==0 ){
          return WRC_Prune;  /* Not in a WHERE clause.  Unsafe to optimize. */
        }
      }
      testcase( ExprHasProperty(pExpr, EP_OuterON) );
      assert( !ExprHasProperty(pExpr, EP_IntValue) );
#if TREETRACE_ENABLED
      if( sqlite3TreeTrace & 0x80000 ){
        sqlite3DebugPrintf(
           "NOT NULL strength reduction converts the following to %d:\n",
           pExpr->op==TK_NOTNULL
        );
        sqlite3ShowExpr(pExpr);
      }
#endif /* TREETRACE_ENABLED */
      pExpr->u.iValue = (pExpr->op==TK_NOTNULL);
      pExpr->flags |= EP_IntValue;
      pExpr->op = TK_INTEGER;

      for(i=0, p=pNC; p && i<ArraySize(anRef); p=p->pNext, i++){
        p->nRef = anRef[i];
      }
      sqlite3ExprDelete(pParse->db, pExpr->pLeft);
      pExpr->pLeft = 0;

      return WRC_Prune;
    }

    /* A column name:                    ID
    ** Or table name and column name:    ID.ID
    ** Or a database, table and column:  ID.ID.ID
    **
108243
108244
108245
108246
108247
108248
108249

108250

108251
108252
108253
108254
108255
108256
108257
    if( p->pHaving ){
      if( (p->selFlags & SF_Aggregate)==0 ){
        sqlite3ErrorMsg(pParse, "HAVING clause on a non-aggregate query");
        return WRC_Abort;
      }
      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++){
      SrcItem *pItem = &p->pSrc->a[i];
      if( pItem->fg.isTabFunc
       && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg)
      ){







>

>







108493
108494
108495
108496
108497
108498
108499
108500
108501
108502
108503
108504
108505
108506
108507
108508
108509
    if( p->pHaving ){
      if( (p->selFlags & SF_Aggregate)==0 ){
        sqlite3ErrorMsg(pParse, "HAVING clause on a non-aggregate query");
        return WRC_Abort;
      }
      if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
    }
    sNC.ncFlags |= NC_Where;
    if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;
    sNC.ncFlags &= ~NC_Where;

    /* Resolve names in table-valued-function arguments */
    for(i=0; i<p->pSrc->nSrc; i++){
      SrcItem *pItem = &p->pSrc->a[i];
      if( pItem->fg.isTabFunc
       && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg)
      ){
109478
109479
109480
109481
109482
109483
109484
109485
109486
109487
109488
109489

109490
109491
109492
109493
109494
109495
109496
109497
109498
109499
109500
109501
109502
109503
109504
109505
109506
109507
109508
109509
109510
109511
109512
**
** If dequote is true, then the token (if it exists) is dequoted.
** If dequote is false, no dequoting is performed.  The deQuote
** parameter is ignored if pToken is NULL or if the token does not
** appear to be quoted.  If the quotes were of the form "..." (double-quotes)
** then the EP_DblQuoted flag is set on the expression node.
**
** Special case:  If op==TK_INTEGER and pToken points to a string that
** can be translated into a 32-bit integer, then the token is not
** stored in u.zToken.  Instead, the integer values is written
** into u.iValue and the EP_IntValue flag is set.  No extra storage
** is allocated to hold the integer text and the dequote flag is ignored.

*/
SQLITE_PRIVATE Expr *sqlite3ExprAlloc(
  sqlite3 *db,            /* Handle for sqlite3DbMallocRawNN() */
  int op,                 /* Expression opcode */
  const Token *pToken,    /* Token argument.  Might be NULL */
  int dequote             /* True to dequote */
){
  Expr *pNew;
  int nExtra = 0;
  int iValue = 0;

  assert( db!=0 );
  if( pToken ){
    if( op!=TK_INTEGER || pToken->z==0
          || sqlite3GetInt32(pToken->z, &iValue)==0 ){
      nExtra = pToken->n+1;
      assert( iValue>=0 );
    }
  }
  pNew = sqlite3DbMallocRawNN(db, sizeof(Expr)+nExtra);
  if( pNew ){
    memset(pNew, 0, sizeof(Expr));
    pNew->op = (u8)op;







|
|
|
|

>















|







109730
109731
109732
109733
109734
109735
109736
109737
109738
109739
109740
109741
109742
109743
109744
109745
109746
109747
109748
109749
109750
109751
109752
109753
109754
109755
109756
109757
109758
109759
109760
109761
109762
109763
109764
109765
**
** If dequote is true, then the token (if it exists) is dequoted.
** If dequote is false, no dequoting is performed.  The deQuote
** parameter is ignored if pToken is NULL or if the token does not
** appear to be quoted.  If the quotes were of the form "..." (double-quotes)
** then the EP_DblQuoted flag is set on the expression node.
**
** Special case (tag-20240227-a):  If op==TK_INTEGER and pToken points to
** a string that can be translated into a 32-bit integer, then the token is
** not stored in u.zToken.  Instead, the integer values is written
** into u.iValue and the EP_IntValue flag is set. No extra storage
** is allocated to hold the integer text and the dequote flag is ignored.
** See also tag-20240227-b.
*/
SQLITE_PRIVATE Expr *sqlite3ExprAlloc(
  sqlite3 *db,            /* Handle for sqlite3DbMallocRawNN() */
  int op,                 /* Expression opcode */
  const Token *pToken,    /* Token argument.  Might be NULL */
  int dequote             /* True to dequote */
){
  Expr *pNew;
  int nExtra = 0;
  int iValue = 0;

  assert( db!=0 );
  if( pToken ){
    if( op!=TK_INTEGER || pToken->z==0
          || sqlite3GetInt32(pToken->z, &iValue)==0 ){
      nExtra = pToken->n+1;  /* tag-20240227-a */
      assert( iValue>=0 );
    }
  }
  pNew = sqlite3DbMallocRawNN(db, sizeof(Expr)+nExtra);
  if( pNew ){
    memset(pNew, 0, sizeof(Expr));
    pNew->op = (u8)op;
113180
113181
113182
113183
113184
113185
113186
113187
113188
113189
113190
113191
113192
113193
113194
113195
113196
113197
113198
113199
    }
#endif
    case TK_VARIABLE: {
      assert( !ExprHasProperty(pExpr, EP_IntValue) );
      assert( pExpr->u.zToken!=0 );
      assert( pExpr->u.zToken[0]!=0 );
      sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);
      if( pExpr->u.zToken[1]!=0 ){
        const char *z = sqlite3VListNumToName(pParse->pVList, pExpr->iColumn);
        assert( pExpr->u.zToken[0]=='?' || (z && !strcmp(pExpr->u.zToken, z)) );
        pParse->pVList[0] = 0; /* Indicate VList may no longer be enlarged */
        sqlite3VdbeAppendP4(v, (char*)z, P4_STATIC);
      }
      return target;
    }
    case TK_REGISTER: {
      return pExpr->iTable;
    }
#ifndef SQLITE_OMIT_CAST
    case TK_CAST: {







<
<
<
<
<
<







113433
113434
113435
113436
113437
113438
113439






113440
113441
113442
113443
113444
113445
113446
    }
#endif
    case TK_VARIABLE: {
      assert( !ExprHasProperty(pExpr, EP_IntValue) );
      assert( pExpr->u.zToken!=0 );
      assert( pExpr->u.zToken[0]!=0 );
      sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);






      return target;
    }
    case TK_REGISTER: {
      return pExpr->iTable;
    }
#ifndef SQLITE_OMIT_CAST
    case TK_CAST: {
119188
119189
119190
119191
119192
119193
119194

119195
119196
119197
119198
119199
119200
119201
      int addrIsNull;
      u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound;

      /* No STAT4 data is generated if the number of rows is zero */
      if( addrGotoEnd==0 ){
        sqlite3VdbeAddOp2(v, OP_Cast, regStat1, SQLITE_AFF_INTEGER);
        addrGotoEnd = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1);

      }

      if( doOnce ){
        int mxCol = nCol;
        Index *pX;

        /* Compute the maximum number of columns in any index */







>







119435
119436
119437
119438
119439
119440
119441
119442
119443
119444
119445
119446
119447
119448
119449
      int addrIsNull;
      u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound;

      /* No STAT4 data is generated if the number of rows is zero */
      if( addrGotoEnd==0 ){
        sqlite3VdbeAddOp2(v, OP_Cast, regStat1, SQLITE_AFF_INTEGER);
        addrGotoEnd = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1);
        VdbeCoverage(v);
      }

      if( doOnce ){
        int mxCol = nCol;
        Index *pX;

        /* Compute the maximum number of columns in any index */
129183
129184
129185
129186
129187
129188
129189
129190
129191
129192
129193
129194
129195
129196
129197
129198
129199
129200
129201
129202
129203
  assert( pStr!=0 && pStr->nChar==0 );

  switch( sqlite3_value_type(pValue) ){
    case SQLITE_FLOAT: {
      double r1, r2;
      const char *zVal;
      r1 = sqlite3_value_double(pValue);
      sqlite3_str_appendf(pStr, "%!.15g", r1);
      zVal = sqlite3_str_value(pStr);
      if( zVal ){
        sqlite3AtoF(zVal, &r2, pStr->nChar, SQLITE_UTF8);
        if( r1!=r2 ){
          sqlite3_str_reset(pStr);
          sqlite3_str_appendf(pStr, "%!.20e", r1);
        }
      }
      break;
    }
    case SQLITE_INTEGER: {
      sqlite3_str_appendf(pStr, "%lld", sqlite3_value_int64(pValue));
      break;







|





|







129431
129432
129433
129434
129435
129436
129437
129438
129439
129440
129441
129442
129443
129444
129445
129446
129447
129448
129449
129450
129451
  assert( pStr!=0 && pStr->nChar==0 );

  switch( sqlite3_value_type(pValue) ){
    case SQLITE_FLOAT: {
      double r1, r2;
      const char *zVal;
      r1 = sqlite3_value_double(pValue);
      sqlite3_str_appendf(pStr, "%!0.15g", r1);
      zVal = sqlite3_str_value(pStr);
      if( zVal ){
        sqlite3AtoF(zVal, &r2, pStr->nChar, SQLITE_UTF8);
        if( r1!=r2 ){
          sqlite3_str_reset(pStr);
          sqlite3_str_appendf(pStr, "%!0.20e", r1);
        }
      }
      break;
    }
    case SQLITE_INTEGER: {
      sqlite3_str_appendf(pStr, "%lld", sqlite3_value_int64(pValue));
      break;
133411
133412
133413
133414
133415
133416
133417
133418
133419
133420
133421
133422
133423
133424
133425
    pNx = pUpsert;
    do{
      pNx->pUpsertSrc = pTabList;
      pNx->regData = regData;
      pNx->iDataCur = iDataCur;
      pNx->iIdxCur = iIdxCur;
      if( pNx->pUpsertTarget ){
        if( sqlite3UpsertAnalyzeTarget(pParse, pTabList, pNx) ){
          goto insert_cleanup;
        }
      }
      pNx = pNx->pNextUpsert;
    }while( pNx!=0 );
  }
#endif







|







133659
133660
133661
133662
133663
133664
133665
133666
133667
133668
133669
133670
133671
133672
133673
    pNx = pUpsert;
    do{
      pNx->pUpsertSrc = pTabList;
      pNx->regData = regData;
      pNx->iDataCur = iDataCur;
      pNx->iIdxCur = iIdxCur;
      if( pNx->pUpsertTarget ){
        if( sqlite3UpsertAnalyzeTarget(pParse, pTabList, pNx, pUpsert) ){
          goto insert_cleanup;
        }
      }
      pNx = pNx->pNextUpsert;
    }while( pNx!=0 );
  }
#endif
139668
139669
139670
139671
139672
139673
139674
139675
139676
139677
139678
139679
139680
139681
139682

    /* Do an integrity check on each database file */
    for(i=0; i<db->nDb; i++){
      HashElem *x;     /* For looping over tables in the schema */
      Hash *pTbls;     /* Set of all tables in the schema */
      int *aRoot;      /* Array of root page numbers of all btrees */
      int cnt = 0;     /* Number of entries in aRoot[] */
      int mxIdx = 0;   /* Maximum number of indexes for any table */

      if( OMIT_TEMPDB && i==1 ) continue;
      if( iDb>=0 && i!=iDb ) continue;

      sqlite3CodeVerifySchema(pParse, i);
      pParse->okConstFactor = 0;  /* tag-20230327-1 */








<







139916
139917
139918
139919
139920
139921
139922

139923
139924
139925
139926
139927
139928
139929

    /* Do an integrity check on each database file */
    for(i=0; i<db->nDb; i++){
      HashElem *x;     /* For looping over tables in the schema */
      Hash *pTbls;     /* Set of all tables in the schema */
      int *aRoot;      /* Array of root page numbers of all btrees */
      int cnt = 0;     /* Number of entries in aRoot[] */


      if( OMIT_TEMPDB && i==1 ) continue;
      if( iDb>=0 && i!=iDb ) continue;

      sqlite3CodeVerifySchema(pParse, i);
      pParse->okConstFactor = 0;  /* tag-20230327-1 */

139690
139691
139692
139693
139694
139695
139696
139697
139698
139699
139700
139701
139702
139703
139704
139705
139706
139707
139708
139709
139710
139711
139712
139713
139714
139715
139716
139717
139718
139719
139720
139721
139722
139723
139724
139725
139726
139727
139728
139729






























139730
139731
139732
139733
139734
139735
139736
      for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
        Table *pTab = sqliteHashData(x);  /* Current table */
        Index *pIdx;                      /* An index on pTab */
        int nIdx;                         /* Number of indexes on pTab */
        if( pObjTab && pObjTab!=pTab ) continue;
        if( HasRowid(pTab) ) cnt++;
        for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ cnt++; }
        if( nIdx>mxIdx ) mxIdx = nIdx;
      }
      if( cnt==0 ) continue;
      if( pObjTab ) cnt++;
      aRoot = sqlite3DbMallocRawNN(db, sizeof(int)*(cnt+1));
      if( aRoot==0 ) break;
      cnt = 0;
      if( pObjTab ) aRoot[++cnt] = 0;
      for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
        Table *pTab = sqliteHashData(x);
        Index *pIdx;
        if( pObjTab && pObjTab!=pTab ) continue;
        if( HasRowid(pTab) ) aRoot[++cnt] = pTab->tnum;
        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
          aRoot[++cnt] = pIdx->tnum;
        }
      }
      aRoot[0] = cnt;

      /* Make sure sufficient number of registers have been allocated */
      sqlite3TouchRegister(pParse, 8+mxIdx);
      sqlite3ClearTempRegCache(pParse);

      /* Do the b-tree integrity checks */
      sqlite3VdbeAddOp4(v, OP_IntegrityCk, 2, cnt, 1, (char*)aRoot,P4_INTARRAY);
      sqlite3VdbeChangeP5(v, (u8)i);
      addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);
      sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
         sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zDbSName),
         P4_DYNAMIC);
      sqlite3VdbeAddOp3(v, OP_Concat, 2, 3, 3);
      integrityCheckResultRow(v);
      sqlite3VdbeJumpHere(v, addr);































      /* Make sure all the indices are constructed correctly.
      */
      for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
        Table *pTab = sqliteHashData(x);
        Index *pIdx, *pPk;
        Index *pPrior = 0;      /* Previous index */







<



















|



|








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







139937
139938
139939
139940
139941
139942
139943

139944
139945
139946
139947
139948
139949
139950
139951
139952
139953
139954
139955
139956
139957
139958
139959
139960
139961
139962
139963
139964
139965
139966
139967
139968
139969
139970
139971
139972
139973
139974
139975
139976
139977
139978
139979
139980
139981
139982
139983
139984
139985
139986
139987
139988
139989
139990
139991
139992
139993
139994
139995
139996
139997
139998
139999
140000
140001
140002
140003
140004
140005
140006
140007
140008
140009
140010
140011
140012
      for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
        Table *pTab = sqliteHashData(x);  /* Current table */
        Index *pIdx;                      /* An index on pTab */
        int nIdx;                         /* Number of indexes on pTab */
        if( pObjTab && pObjTab!=pTab ) continue;
        if( HasRowid(pTab) ) cnt++;
        for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ cnt++; }

      }
      if( cnt==0 ) continue;
      if( pObjTab ) cnt++;
      aRoot = sqlite3DbMallocRawNN(db, sizeof(int)*(cnt+1));
      if( aRoot==0 ) break;
      cnt = 0;
      if( pObjTab ) aRoot[++cnt] = 0;
      for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
        Table *pTab = sqliteHashData(x);
        Index *pIdx;
        if( pObjTab && pObjTab!=pTab ) continue;
        if( HasRowid(pTab) ) aRoot[++cnt] = pTab->tnum;
        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
          aRoot[++cnt] = pIdx->tnum;
        }
      }
      aRoot[0] = cnt;

      /* Make sure sufficient number of registers have been allocated */
      sqlite3TouchRegister(pParse, 8+cnt);
      sqlite3ClearTempRegCache(pParse);

      /* Do the b-tree integrity checks */
      sqlite3VdbeAddOp4(v, OP_IntegrityCk, 1, cnt, 8, (char*)aRoot,P4_INTARRAY);
      sqlite3VdbeChangeP5(v, (u8)i);
      addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);
      sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
         sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zDbSName),
         P4_DYNAMIC);
      sqlite3VdbeAddOp3(v, OP_Concat, 2, 3, 3);
      integrityCheckResultRow(v);
      sqlite3VdbeJumpHere(v, addr);

      /* Check that the indexes all have the right number of rows */
      cnt = pObjTab ? 1 : 0;
      sqlite3VdbeLoadString(v, 2, "wrong # of entries in index ");
      for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
        int iTab = 0;
        Table *pTab = sqliteHashData(x);
        Index *pIdx;
        if( pObjTab && pObjTab!=pTab ) continue;
        if( HasRowid(pTab) ){
          iTab = cnt++;
        }else{
          iTab = cnt;
          for(pIdx=pTab->pIndex; ALWAYS(pIdx); pIdx=pIdx->pNext){
            if( IsPrimaryKeyIndex(pIdx) ) break;
            iTab++;
          }
        }
        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
          if( pIdx->pPartIdxWhere==0 ){
            addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+cnt, 0, 8+iTab);
            VdbeCoverageNeverNull(v);
            sqlite3VdbeLoadString(v, 4, pIdx->zName);
            sqlite3VdbeAddOp3(v, OP_Concat, 4, 2, 3);
            integrityCheckResultRow(v);
            sqlite3VdbeJumpHere(v, addr);
          }
          cnt++;
        }
      }

      /* Make sure all the indices are constructed correctly.
      */
      for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
        Table *pTab = sqliteHashData(x);
        Index *pIdx, *pPk;
        Index *pPrior = 0;      /* Previous index */
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
            }
            sqlite3VdbeJumpHere(v, jmp4);
            sqlite3ResolvePartIdxLabel(pParse, jmp3);
          }
        }
        sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); VdbeCoverage(v);
        sqlite3VdbeJumpHere(v, loopTop-1);
        if( !isQuick ){
          sqlite3VdbeLoadString(v, 2, "wrong # of entries in index ");
          for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
            if( pPk==pIdx ) continue;
            sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3);
            addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+j, 0, 3); VdbeCoverage(v);
            sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
            sqlite3VdbeLoadString(v, 4, pIdx->zName);
            sqlite3VdbeAddOp3(v, OP_Concat, 4, 2, 3);
            integrityCheckResultRow(v);
            sqlite3VdbeJumpHere(v, addr);
          }
          if( pPk ){

            sqlite3ReleaseTempRange(pParse, r2, pPk->nKeyCol);
          }
        }
      }

#ifndef SQLITE_OMIT_VIRTUALTABLE
      /* Second pass to invoke the xIntegrity method on all virtual
      ** tables.
      */







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







140323
140324
140325
140326
140327
140328
140329












140330
140331
140332

140333
140334
140335
140336
140337
140338
140339
            }
            sqlite3VdbeJumpHere(v, jmp4);
            sqlite3ResolvePartIdxLabel(pParse, jmp3);
          }
        }
        sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); VdbeCoverage(v);
        sqlite3VdbeJumpHere(v, loopTop-1);












        if( pPk ){
          assert( !isQuick );
          sqlite3ReleaseTempRange(pParse, r2, pPk->nKeyCol);

        }
      }

#ifndef SQLITE_OMIT_VIRTUALTABLE
      /* Second pass to invoke the xIntegrity method on all virtual
      ** tables.
      */
153826
153827
153828
153829
153830
153831
153832
153833

153834
153835
153836
153837
153838
153839
153840
**
** 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 */







|
>







154090
154091
154092
154093
154094
154095
154096
154097
154098
154099
154100
154101
154102
154103
154104
154105
**
** 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 */
  Upsert *pAll       /* Complete list of all 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 */
153929
153930
153931
153932
153933
153934
153935








153936
153937
153938
153939
153940
153941
153942
      }
      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;








      break;
    }
    if( pUpsert->pUpsertIdx==0 ){
      char zWhich[16];
      if( nClause==0 && pUpsert->pNextUpsert==0 ){
        zWhich[0] = 0;
      }else{







>
>
>
>
>
>
>
>







154194
154195
154196
154197
154198
154199
154200
154201
154202
154203
154204
154205
154206
154207
154208
154209
154210
154211
154212
154213
154214
154215
      }
      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;
      if( sqlite3UpsertOfIndex(pAll,pIdx)!=pUpsert ){
        /* Really this should be an error.  The isDup ON CONFLICT clause will
        ** never fire.  But this problem was not discovered until three years
        ** after multi-CONFLICT upsert was added, and so we silently ignore
        ** the problem to prevent breaking applications that might actually
        ** have redundant ON CONFLICT clauses. */
        pUpsert->isDup = 1;
      }
      break;
    }
    if( pUpsert->pUpsertIdx==0 ){
      char zWhich[16];
      if( nClause==0 && pUpsert->pNextUpsert==0 ){
        zWhich[0] = 0;
      }else{
153955
153956
153957
153958
153959
153960
153961

153962
153963
153964



153965
153966
153967
153968
153969
153970
153971
** conflict target, or if pUpsert is followed by another ON CONFLICT
** clause that targets the INTEGER PRIMARY KEY.
*/
SQLITE_PRIVATE int sqlite3UpsertNextIsIPK(Upsert *pUpsert){
  Upsert *pNext;
  if( NEVER(pUpsert==0) ) return 0;
  pNext = pUpsert->pNextUpsert;

  if( pNext==0 ) return 1;
  if( pNext->pUpsertTarget==0 ) return 1;
  if( pNext->pUpsertIdx==0 ) return 1;



  return 0;
}

/*
** Given the list of ON CONFLICT clauses described by pUpsert, and
** a particular index pIdx, return a pointer to the particular ON CONFLICT
** clause that applies to the index.  Or, if the index is not subject to







>
|
|
|
>
>
>







154228
154229
154230
154231
154232
154233
154234
154235
154236
154237
154238
154239
154240
154241
154242
154243
154244
154245
154246
154247
154248
** conflict target, or if pUpsert is followed by another ON CONFLICT
** clause that targets the INTEGER PRIMARY KEY.
*/
SQLITE_PRIVATE int sqlite3UpsertNextIsIPK(Upsert *pUpsert){
  Upsert *pNext;
  if( NEVER(pUpsert==0) ) return 0;
  pNext = pUpsert->pNextUpsert;
  while( 1 /*exit-by-return*/ ){
    if( pNext==0 ) return 1;
    if( pNext->pUpsertTarget==0 ) return 1;
    if( pNext->pUpsertIdx==0 ) return 1;
    if( !pNext->isDup ) return 0;
    pNext = pNext->pNextUpsert;
  }
  return 0;
}

/*
** Given the list of ON CONFLICT clauses described by pUpsert, and
** a particular index pIdx, return a pointer to the particular ON CONFLICT
** clause that applies to the index.  Or, if the index is not subject to
160253
160254
160255
160256
160257
160258
160259
160260
160261
160262
160263
160264
160265
160266
160267
    iCur = pFrom->a[j].iCursor;
    for(pIdx=pFrom->a[j].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
      if( pIdx->aColExpr==0 ) continue;
      for(i=0; i<pIdx->nKeyCol; i++){
        if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
        assert( pIdx->bHasExpr );
        if( sqlite3ExprCompareSkip(pExpr,pIdx->aColExpr->a[i].pExpr,iCur)==0
          && pExpr->op!=TK_STRING
        ){
          aiCurCol[0] = iCur;
          aiCurCol[1] = XN_EXPR;
          return 1;
        }
      }
    }







|







160530
160531
160532
160533
160534
160535
160536
160537
160538
160539
160540
160541
160542
160543
160544
    iCur = pFrom->a[j].iCursor;
    for(pIdx=pFrom->a[j].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
      if( pIdx->aColExpr==0 ) continue;
      for(i=0; i<pIdx->nKeyCol; i++){
        if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
        assert( pIdx->bHasExpr );
        if( sqlite3ExprCompareSkip(pExpr,pIdx->aColExpr->a[i].pExpr,iCur)==0
         && !sqlite3ExprIsConstant(pIdx->aColExpr->a[i].pExpr)
        ){
          aiCurCol[0] = iCur;
          aiCurCol[1] = XN_EXPR;
          return 1;
        }
      }
    }
164112
164113
164114
164115
164116
164117
164118

164119

164120
164121
164122
164123
164124
164125
164126
    opMask = WO_LT|WO_LE;
  }else{
    assert( pNew->u.btree.nBtm==0 );
    opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
  }
  if( pProbe->bUnordered || pProbe->bLowQual ){
    if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);

    if( pProbe->bLowQual )   opMask &= ~(WO_EQ|WO_IN|WO_IS);

  }

  assert( pNew->u.btree.nEq<pProbe->nColumn );
  assert( pNew->u.btree.nEq<pProbe->nKeyCol
       || pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY );

  saved_nEq = pNew->u.btree.nEq;







>
|
>







164389
164390
164391
164392
164393
164394
164395
164396
164397
164398
164399
164400
164401
164402
164403
164404
164405
    opMask = WO_LT|WO_LE;
  }else{
    assert( pNew->u.btree.nBtm==0 );
    opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
  }
  if( pProbe->bUnordered || pProbe->bLowQual ){
    if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
    if( pProbe->bLowQual && pSrc->fg.isIndexedBy==0 ){
      opMask &= ~(WO_EQ|WO_IN|WO_IS);
    }
  }

  assert( pNew->u.btree.nEq<pProbe->nColumn );
  assert( pNew->u.btree.nEq<pProbe->nKeyCol
       || pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY );

  saved_nEq = pNew->u.btree.nEq;
171694
171695
171696
171697
171698
171699
171700

171701
171702
171703
171704
171705
171706
171707
171708
171709
#define TK_REGISTER                       176
#define TK_VECTOR                         177
#define TK_SELECT_COLUMN                  178
#define TK_IF_NULL_ROW                    179
#define TK_ASTERISK                       180
#define TK_SPAN                           181
#define TK_ERROR                          182

#define TK_SPACE                          183
#define TK_ILLEGAL                        184
#endif
/**************** End token definitions ***************************************/

/* The next sections is a series of control #defines.
** various aspects of the generated parser.
**    YYCODETYPE         is the data type used to store the integer codes
**                       that represent terminal and non-terminal symbols.







>
|
|







171973
171974
171975
171976
171977
171978
171979
171980
171981
171982
171983
171984
171985
171986
171987
171988
171989
#define TK_REGISTER                       176
#define TK_VECTOR                         177
#define TK_SELECT_COLUMN                  178
#define TK_IF_NULL_ROW                    179
#define TK_ASTERISK                       180
#define TK_SPAN                           181
#define TK_ERROR                          182
#define TK_QNUMBER                        183
#define TK_SPACE                          184
#define TK_ILLEGAL                        185
#endif
/**************** End token definitions ***************************************/

/* The next sections is a series of control #defines.
** various aspects of the generated parser.
**    YYCODETYPE         is the data type used to store the integer codes
**                       that represent terminal and non-terminal symbols.
171760
171761
171762
171763
171764
171765
171766
171767
171768
171769
171770
171771
171772
171773
171774
171775
171776

171777
171778





171779

171780
171781
171782
171783
171784
171785
171786
171787
171788
171789
171790
171791
171792
171793
171794
171795
171796
171797
171798
171799
171800
171801
171802
171803
171804
171805
171806
171807
171808
171809
171810
171811
171812
171813
171814
171815
171816
171817
171818
171819
171820
171821
171822
171823
171824
171825
171826
171827
171828
171829
171830
**    YY_MAX_DSTRCTR     Maximum symbol value that has a destructor
*/
#ifndef INTERFACE
# define INTERFACE 1
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned short int
#define YYNOCODE 319
#define YYACTIONTYPE unsigned short int
#define YYWILDCARD 101
#define sqlite3ParserTOKENTYPE Token
typedef union {
  int yyinit;
  sqlite3ParserTOKENTYPE yy0;
  TriggerStep* yy33;
  Window* yy41;
  Select* yy47;

  SrcList* yy131;
  struct TrigEvent yy180;





  struct {int value; int mask;} yy231;

  IdList* yy254;
  u32 yy285;
  ExprList* yy322;
  Cte* yy385;
  int yy394;
  Upsert* yy444;
  u8 yy516;
  With* yy521;
  const char* yy522;
  Expr* yy528;
  OnOrUsing yy561;
  struct FrameBound yy595;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
#endif
#define sqlite3ParserARG_SDECL
#define sqlite3ParserARG_PDECL
#define sqlite3ParserARG_PARAM
#define sqlite3ParserARG_FETCH
#define sqlite3ParserARG_STORE
#define YYREALLOC parserStackRealloc
#define YYFREE sqlite3_free
#define YYDYNSTACK 1
#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             579
#define YYNRULE              405
#define YYNRULE_WITH_ACTION  340
#define YYNTOKEN             185
#define YY_MAX_SHIFT         578
#define YY_MIN_SHIFTREDUCE   838
#define YY_MAX_SHIFTREDUCE   1242
#define YY_ERROR_ACTION      1243
#define YY_ACCEPT_ACTION     1244
#define YY_NO_ACTION         1245
#define YY_MIN_REDUCE        1246
#define YY_MAX_REDUCE        1650
#define YY_MIN_DSTRCTR       204
#define YY_MAX_DSTRCTR       316
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))

/* 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







|






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



















|
|
|

|
|
|
|
|
|
|
|
|







172040
172041
172042
172043
172044
172045
172046
172047
172048
172049
172050
172051
172052
172053
172054
172055
172056
172057
172058
172059
172060
172061
172062
172063
172064
172065
172066
172067

172068



172069
172070
172071



172072
172073
172074
172075
172076
172077
172078
172079
172080
172081
172082
172083
172084
172085
172086
172087
172088
172089
172090
172091
172092
172093
172094
172095
172096
172097
172098
172099
172100
172101
172102
172103
172104
172105
172106
172107
172108
172109
172110
**    YY_MAX_DSTRCTR     Maximum symbol value that has a destructor
*/
#ifndef INTERFACE
# define INTERFACE 1
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned short int
#define YYNOCODE 320
#define YYACTIONTYPE unsigned short int
#define YYWILDCARD 101
#define sqlite3ParserTOKENTYPE Token
typedef union {
  int yyinit;
  sqlite3ParserTOKENTYPE yy0;
  Expr* yy2;
  Window* yy3;
  Cte* yy79;
  int yy92;
  With* yy131;
  struct TrigEvent yy210;
  Upsert* yy258;
  Select* yy299;
  OnOrUsing yy305;
  struct FrameBound yy337;
  TriggerStep* yy347;
  struct {int value; int mask;} yy367;
  SrcList* yy387;
  IdList* yy400;

  ExprList* yy402;



  u8 yy498;
  u32 yy527;
  const char* yy616;



} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
#endif
#define sqlite3ParserARG_SDECL
#define sqlite3ParserARG_PDECL
#define sqlite3ParserARG_PARAM
#define sqlite3ParserARG_FETCH
#define sqlite3ParserARG_STORE
#define YYREALLOC parserStackRealloc
#define YYFREE sqlite3_free
#define YYDYNSTACK 1
#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             579
#define YYNRULE              406
#define YYNRULE_WITH_ACTION  341
#define YYNTOKEN             186
#define YY_MAX_SHIFT         578
#define YY_MIN_SHIFTREDUCE   839
#define YY_MAX_SHIFTREDUCE   1244
#define YY_ERROR_ACTION      1245
#define YY_ACCEPT_ACTION     1246
#define YY_NO_ACTION         1247
#define YY_MIN_REDUCE        1248
#define YY_MAX_REDUCE        1653
#define YY_MIN_DSTRCTR       205
#define YY_MAX_DSTRCTR       317
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))

/* 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
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
171969
171970
171971
171972
171973
171974
171975
171976
171977
171978
171979
171980
171981
171982
171983
171984
171985
171986
171987
171988
171989
171990
171991
171992
171993
171994
171995
171996
171997
171998
171999
172000
172001
172002
172003
172004
172005
172006
172007
172008
172009
172010
172011
172012
172013
172014
172015
172016
172017
172018
172019
172020
172021
172022
172023
172024
172025
172026
172027
172028
172029
172030
172031
172032
172033
172034
172035
172036
172037
172038
172039
172040
172041
172042
172043
172044
172045
172046
172047
172048
172049
172050
172051
172052
172053
172054
172055
172056
172057
172058
172059
172060
172061
172062
172063
172064
172065
172066
172067
172068
172069
172070
172071
172072
172073
172074
172075
172076
172077
172078
172079
172080
172081
172082
172083
172084
172085
172086
172087
172088
172089
172090
172091
172092
172093
172094
172095
172096
172097
172098
172099
172100
172101
172102
172103
172104
172105
172106
172107
172108
172109
172110
172111
172112
172113
172114
172115
172116
172117


172118
172119
172120
172121
172122
172123
172124
172125
172126
172127
172128
172129
172130
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
172177
172178
172179
172180
172181
172182
172183
172184
172185
172186
172187
172188
172189
172190
172191
172192
172193
172194
172195
172196
172197
172198
172199
172200
172201
172202
172203
172204
172205
172206
172207
172208
172209
172210
172211
172212
172213
172214
172215
172216
172217
172218
172219
172220
172221
172222
172223
172224
172225
172226
172227
172228
172229
172230
172231
172232
172233
172234
172235
172236
172237
172238
172239
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
172265
172266
172267
172268
172269
172270
172271
172272
172273
172274
172275
172276
172277
172278
172279
172280
172281
172282
172283
172284
172285
172286
172287
172288
172289
172290
172291
172292
172293
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
172383
172384
172385
172386
172387
172388
172389
172390
172391
172392
172393
172394
172395
172396
172397
172398
172399
172400
172401
172402
172403
172404
172405
172406
172407
172408
172409
172410
172411
172412
172413
172414
172415
172416
172417
172418
172419
172420
172421
172422
172423
172424
172425
172426
172427
172428
172429
172430
172431
172432
172433
172434
172435
172436
172437
172438
172439
172440
172441
172442
172443
172444
172445
172446
172447
172448
172449
172450
172451
172452
172453
172454
172455
172456
172457
172458
172459
172460
172461
172462
172463
172464
172465
172466
172467
172468
172469
172470
172471
172472
172473
172474
172475
172476
172477
172478
172479
172480
172481
172482
172483
172484
172485
172486
172487
172488
172489
172490
172491
172492
172493
172494
172495
172496
172497
172498
172499
172500
172501
172502
172503
172504
172505
172506
172507
172508
172509
172510
172511
172512
172513
172514
172515
172516
172517
172518
172519
172520
172521
172522
172523
172524
172525
**  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 (2100)
static const YYACTIONTYPE yy_action[] = {
 /*     0 */   572,  210,  572,  119,  116,  231,  572,  119,  116,  231,
 /*    10 */   572, 1317,  379, 1296,  410,  566,  566,  566,  572,  411,
 /*    20 */   380, 1317, 1279,   42,   42,   42,   42,  210, 1529,   72,
 /*    30 */    72,  974,  421,   42,   42,  495,  305,  281,  305,  975,
 /*    40 */   399,   72,   72,  126,  127,   81, 1217, 1217, 1054, 1057,
 /*    50 */  1044, 1044,  124,  124,  125,  125,  125,  125,  480,  411,
 /*    60 */  1244,    1,    1,  578,    2, 1248,  554,  119,  116,  231,
 /*    70 */   319,  484,  147,  484,  528,  119,  116,  231,  533, 1330,
 /*    80 */   419,  527,  143,  126,  127,   81, 1217, 1217, 1054, 1057,
 /*    90 */  1044, 1044,  124,  124,  125,  125,  125,  125,  119,  116,
 /*   100 */   231,  329,  123,  123,  123,  123,  122,  122,  121,  121,
 /*   110 */   121,  120,  117,  448,  286,  286,  286,  286,  446,  446,
 /*   120 */   446, 1568,  378, 1570, 1193,  377, 1164,  569, 1164,  569,
 /*   130 */   411, 1568,  541,  261,  228,  448,  102,  146,  453,  318,
 /*   140 */   563,  242,  123,  123,  123,  123,  122,  122,  121,  121,
 /*   150 */   121,  120,  117,  448,  126,  127,   81, 1217, 1217, 1054,
 /*   160 */  1057, 1044, 1044,  124,  124,  125,  125,  125,  125,  143,
 /*   170 */   296, 1193,  341,  452,  121,  121,  121,  120,  117,  448,
 /*   180 */   128, 1193, 1194, 1193,  149,  445,  444,  572,  120,  117,
 /*   190 */   448,  125,  125,  125,  125,  118,  123,  123,  123,  123,
 /*   200 */   122,  122,  121,  121,  121,  120,  117,  448,  458,  114,
 /*   210 */    13,   13,  550,  123,  123,  123,  123,  122,  122,  121,
 /*   220 */   121,  121,  120,  117,  448,  424,  318,  563, 1193, 1194,
 /*   230 */  1193,  150, 1225,  411, 1225,  125,  125,  125,  125,  123,
 /*   240 */   123,  123,  123,  122,  122,  121,  121,  121,  120,  117,
 /*   250 */   448,  469,  344, 1041, 1041, 1055, 1058,  126,  127,   81,
 /*   260 */  1217, 1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,
 /*   270 */   125,  125, 1282,  526,  224, 1193,  572,  411,  226,  519,
 /*   280 */   177,   83,   84,  123,  123,  123,  123,  122,  122,  121,
 /*   290 */   121,  121,  120,  117,  448, 1010,   16,   16, 1193,  134,
 /*   300 */   134,  126,  127,   81, 1217, 1217, 1054, 1057, 1044, 1044,
 /*   310 */   124,  124,  125,  125,  125,  125,  123,  123,  123,  123,
 /*   320 */   122,  122,  121,  121,  121,  120,  117,  448, 1045,  550,
 /*   330 */  1193,  375, 1193, 1194, 1193,  254, 1438,  401,  508,  505,
 /*   340 */   504,  112,  564,  570,    4,  929,  929,  435,  503,  342,
 /*   350 */   464,  330,  362,  396, 1238, 1193, 1194, 1193,  567,  572,
 /*   360 */   123,  123,  123,  123,  122,  122,  121,  121,  121,  120,
 /*   370 */   117,  448,  286,  286,  371, 1581, 1607,  445,  444,  155,
 /*   380 */   411,  449,   72,   72, 1289,  569, 1222, 1193, 1194, 1193,
 /*   390 */    86, 1224,  273,  561,  547,  520,  520,  572,   99, 1223,
 /*   400 */     6, 1281,  476,  143,  126,  127,   81, 1217, 1217, 1054,
 /*   410 */  1057, 1044, 1044,  124,  124,  125,  125,  125,  125,  554,
 /*   420 */    13,   13, 1031,  511, 1225, 1193, 1225,  553,  110,  110,
 /*   430 */   224,  572, 1239,  177,  572,  429,  111,  199,  449,  573,
 /*   440 */   449,  432, 1555, 1019,  327,  555, 1193,  272,  289,  370,
 /*   450 */   514,  365,  513,  259,   72,   72,  547,   72,   72,  361,
 /*   460 */   318,  563, 1613,  123,  123,  123,  123,  122,  122,  121,
 /*   470 */   121,  121,  120,  117,  448, 1019, 1019, 1021, 1022,   28,
 /*   480 */   286,  286, 1193, 1194, 1193, 1159,  572, 1612,  411,  904,
 /*   490 */   192,  554,  358,  569,  554,  940,  537,  521, 1159,  437,
 /*   500 */   415, 1159,  556, 1193, 1194, 1193,  572,  548,  548,   52,
 /*   510 */    52,  216,  126,  127,   81, 1217, 1217, 1054, 1057, 1044,
 /*   520 */  1044,  124,  124,  125,  125,  125,  125, 1193,  478,  136,
 /*   530 */   136,  411,  286,  286, 1493,  509,  122,  122,  121,  121,
 /*   540 */   121,  120,  117,  448, 1010,  569,  522,  219,  545,  545,
 /*   550 */   318,  563,  143,    6,  536,  126,  127,   81, 1217, 1217,
 /*   560 */  1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,  125,
 /*   570 */  1557,  123,  123,  123,  123,  122,  122,  121,  121,  121,
 /*   580 */   120,  117,  448,  489, 1193, 1194, 1193,  486,  283, 1270,
 /*   590 */   960,  254, 1193,  375,  508,  505,  504, 1193,  342,  574,
 /*   600 */  1193,  574,  411,  294,  503,  960,  879,  193,  484,  318,
 /*   610 */   563,  386,  292,  382,  123,  123,  123,  123,  122,  122,
 /*   620 */   121,  121,  121,  120,  117,  448,  126,  127,   81, 1217,
 /*   630 */  1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,
 /*   640 */   125,  411,  396, 1139, 1193,  872,  101,  286,  286, 1193,
 /*   650 */  1194, 1193,  375, 1096, 1193, 1194, 1193, 1193, 1194, 1193,
 /*   660 */   569,  459,   33,  375,  235,  126,  127,   81, 1217, 1217,
 /*   670 */  1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,  125,
 /*   680 */  1437,  962,  572,  230,  961,  123,  123,  123,  123,  122,
 /*   690 */   122,  121,  121,  121,  120,  117,  448, 1159,  230, 1193,
 /*   700 */   158, 1193, 1194, 1193, 1556,   13,   13,  303,  960, 1233,
 /*   710 */  1159,  154,  411, 1159,  375, 1584, 1177,    5,  371, 1581,
 /*   720 */   431, 1239,    3,  960,  123,  123,  123,  123,  122,  122,
 /*   730 */   121,  121,  121,  120,  117,  448,  126,  127,   81, 1217,
 /*   740 */  1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,
 /*   750 */   125,  411,  210,  571, 1193, 1032, 1193, 1194, 1193, 1193,
 /*   760 */   390,  855,  156, 1555,  376,  404, 1101, 1101,  492,  572,
 /*   770 */   469,  344, 1322, 1322, 1555,  126,  127,   81, 1217, 1217,
 /*   780 */  1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,  125,
 /*   790 */   130,  572,   13,   13,  532,  123,  123,  123,  123,  122,
 /*   800 */   122,  121,  121,  121,  120,  117,  448,  304,  572,  457,
 /*   810 */   229, 1193, 1194, 1193,   13,   13, 1193, 1194, 1193, 1300,
 /*   820 */   467, 1270,  411, 1320, 1320, 1555, 1015,  457,  456,  436,
 /*   830 */   301,   72,   72, 1268,  123,  123,  123,  123,  122,  122,
 /*   840 */   121,  121,  121,  120,  117,  448,  126,  127,   81, 1217,
 /*   850 */  1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,
 /*   860 */   125,  411,  384, 1076, 1159,  286,  286,  421,  314,  280,
 /*   870 */   280,  287,  287,  461,  408,  407, 1539, 1159,  569,  572,
 /*   880 */  1159, 1196,  569,  409,  569,  126,  127,   81, 1217, 1217,
 /*   890 */  1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,  125,
 /*   900 */   457, 1485,   13,   13, 1541,  123,  123,  123,  123,  122,
 /*   910 */   122,  121,  121,  121,  120,  117,  448,  202,  572,  462,
 /*   920 */  1587,  578,    2, 1248,  843,  844,  845, 1563,  319,  409,
 /*   930 */   147,    6,  411,  257,  256,  255,  208, 1330,    9, 1196,
 /*   940 */   264,   72,   72, 1436,  123,  123,  123,  123,  122,  122,
 /*   950 */   121,  121,  121,  120,  117,  448,  126,  127,   81, 1217,
 /*   960 */  1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,
 /*   970 */   125,  572,  286,  286,  572, 1213,  411,  577,  315, 1248,
 /*   980 */   421,  371, 1581,  356,  319,  569,  147,  495,  529, 1644,
 /*   990 */   397,  935,  495, 1330,   71,   71,  934,   72,   72,  242,
 /*  1000 */  1328,  105,   81, 1217, 1217, 1054, 1057, 1044, 1044,  124,
 /*  1010 */   124,  125,  125,  125,  125,  123,  123,  123,  123,  122,
 /*  1020 */   122,  121,  121,  121,  120,  117,  448, 1117,  286,  286,
 /*  1030 */  1422,  452, 1528, 1213,  443,  286,  286, 1492, 1355,  313,
 /*  1040 */   478,  569, 1118,  454,  351,  495,  354, 1266,  569,  209,
 /*  1050 */   572,  418,  179,  572, 1031,  242,  385, 1119,  523,  123,
 /*  1060 */   123,  123,  123,  122,  122,  121,  121,  121,  120,  117,
 /*  1070 */   448, 1020,  108,   72,   72, 1019,   13,   13,  915,  572,
 /*  1080 */  1498,  572,  286,  286,   98,  530, 1537,  452,  916, 1334,
 /*  1090 */  1329,  203,  411,  286,  286,  569,  152,  211, 1498, 1500,
 /*  1100 */   426,  569,   56,   56,   57,   57,  569, 1019, 1019, 1021,
 /*  1110 */   447,  572,  411,  531,   12,  297,  126,  127,   81, 1217,
 /*  1120 */  1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,
 /*  1130 */   125,  572,  411,  867,   15,   15,  126,  127,   81, 1217,
 /*  1140 */  1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,
 /*  1150 */   125,  373,  529,  264,   44,   44,  126,  115,   81, 1217,
 /*  1160 */  1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,
 /*  1170 */   125, 1498,  478, 1271,  417,  123,  123,  123,  123,  122,
 /*  1180 */   122,  121,  121,  121,  120,  117,  448,  205, 1213,  495,
 /*  1190 */   430,  867,  468,  322,  495,  123,  123,  123,  123,  122,
 /*  1200 */   122,  121,  121,  121,  120,  117,  448,  572,  557, 1140,
 /*  1210 */  1642, 1422, 1642,  543,  572,  123,  123,  123,  123,  122,
 /*  1220 */   122,  121,  121,  121,  120,  117,  448,  572, 1422,  572,
 /*  1230 */    13,   13,  542,  323, 1325,  411,  334,   58,   58,  349,
 /*  1240 */  1422, 1170,  326,  286,  286,  549, 1213,  300,  895,  530,
 /*  1250 */    45,   45,   59,   59, 1140, 1643,  569, 1643,  565,  417,
 /*  1260 */   127,   81, 1217, 1217, 1054, 1057, 1044, 1044,  124,  124,
 /*  1270 */   125,  125,  125,  125, 1367,  373,  500,  290, 1193,  512,
 /*  1280 */  1366,  427,  394,  394,  393,  275,  391,  896, 1138,  852,
 /*  1290 */   478,  258, 1422, 1170,  463, 1159,   12,  331,  428,  333,
 /*  1300 */  1117,  460,  236,  258,  325,  460,  544, 1544, 1159, 1098,
 /*  1310 */   491, 1159,  324, 1098,  440, 1118,  335,  516,  123,  123,
 /*  1320 */   123,  123,  122,  122,  121,  121,  121,  120,  117,  448,
 /*  1330 */  1119,  318,  563, 1138,  572, 1193, 1194, 1193,  112,  564,
 /*  1340 */   201,    4,  238,  433,  935,  490,  285,  228, 1517,  934,
 /*  1350 */   170,  560,  572,  142, 1516,  567,  572,   60,   60,  572,
 /*  1360 */   416,  572,  441,  572,  535,  302,  875,    8,  487,  572,
 /*  1370 */   237,  572,  416,  572,  485,   61,   61,  572,  449,   62,
 /*  1380 */    62,  332,   63,   63,   46,   46,   47,   47,  361,  572,
 /*  1390 */   561,  572,   48,   48,   50,   50,   51,   51,  572,  295,
 /*  1400 */    64,   64,  482,  295,  539,  412,  471, 1031,  572,  538,
 /*  1410 */   318,  563,   65,   65,   66,   66,  409,  475,  572, 1031,
 /*  1420 */   572,   14,   14,  875, 1020,  110,  110,  409, 1019,  572,
 /*  1430 */   474,   67,   67,  111,  455,  449,  573,  449,   98,  317,
 /*  1440 */  1019,  132,  132,  133,  133,  572, 1561,  572,  974,  409,
 /*  1450 */     6, 1562,   68,   68, 1560,    6,  975,  572,    6, 1559,
 /*  1460 */  1019, 1019, 1021,    6,  346,  218,  101,  531,   53,   53,
 /*  1470 */    69,   69, 1019, 1019, 1021, 1022,   28, 1586, 1181,  451,
 /*  1480 */    70,   70,  290,   87,  215,   31, 1363,  394,  394,  393,
 /*  1490 */   275,  391,  350,  109,  852,  107,  572,  112,  564,  483,
 /*  1500 */     4, 1212,  572,  239,  153,  572,   39,  236, 1299,  325,
 /*  1510 */   112,  564, 1298,    4,  567,  572,   32,  324,  572,   54,
 /*  1520 */    54,  572, 1135,  353,  398,  165,  165,  567,  166,  166,
 /*  1530 */   572,  291,  355,  572,   17,  357,  572,  449,   77,   77,
 /*  1540 */  1313,   55,   55, 1297,   73,   73,  572,  238,  470,  561,
 /*  1550 */   449,  472,  364,  135,  135,  170,   74,   74,  142,  163,
 /*  1560 */   163,  374,  561,  539,  572,  321,  572,  886,  540,  137,
 /*  1570 */   137,  339, 1353,  422,  298,  237,  539,  572, 1031,  572,
 /*  1580 */   340,  538,  101,  369,  110,  110,  162,  131,  131,  164,
 /*  1590 */   164, 1031,  111,  368,  449,  573,  449,  110,  110, 1019,
 /*  1600 */   157,  157,  141,  141,  572,  111,  572,  449,  573,  449,
 /*  1610 */   412,  288, 1019,  572,  882,  318,  563,  572,  219,  572,
 /*  1620 */   241, 1012,  477,  263,  263,  894,  893,  140,  140,  138,
 /*  1630 */   138, 1019, 1019, 1021, 1022,   28,  139,  139,  525,  455,
 /*  1640 */    76,   76,   78,   78, 1019, 1019, 1021, 1022,   28, 1181,
 /*  1650 */   451,  572, 1083,  290,  112,  564, 1575,    4,  394,  394,
 /*  1660 */   393,  275,  391,  572, 1023,  852,  572,  479,  345,  263,
 /*  1670 */   101,  567,  882, 1376,   75,   75, 1421,  501,  236,  260,
 /*  1680 */   325,  112,  564,  359,    4,  101,   43,   43,  324,   49,
 /*  1690 */    49,  901,  902,  161,  449,  101,  977,  978,  567, 1079,
 /*  1700 */  1349,  260,  965,  932,  263,  114,  561, 1095,  517, 1095,
 /*  1710 */  1083, 1094,  865, 1094,  151,  933, 1144,  114,  238, 1361,
 /*  1720 */   558,  449, 1023,  559, 1426, 1278,  170, 1269, 1257,  142,
 /*  1730 */  1601, 1256, 1258,  561, 1594, 1031,  496,  278,  213, 1346,
 /*  1740 */   310,  110,  110,  939,  311,  312,  237,   11,  234,  111,
 /*  1750 */   221,  449,  573,  449,  293,  395, 1019, 1408,  337, 1403,
 /*  1760 */  1396,  338, 1031,  299,  343, 1413, 1412,  481,  110,  110,
 /*  1770 */   506,  402,  225, 1296,  206,  367,  111, 1358,  449,  573,
 /*  1780 */   449,  412, 1359, 1019, 1489, 1488,  318,  563, 1019, 1019,
 /*  1790 */  1021, 1022,   28,  562,  207,  220,   80,  564,  389,    4,
 /*  1800 */  1597, 1357,  552, 1356, 1233,  181,  267,  232, 1536, 1534,
 /*  1810 */   455, 1230,  420,  567,   82, 1019, 1019, 1021, 1022,   28,
 /*  1820 */    86,  217,   85, 1494,  190,  175,  183,  465,  185,  466,
 /*  1830 */    36, 1409,  186,  187,  188,  499,  449,  244,   37,   99,
 /*  1840 */   400, 1415, 1414,  488, 1417,  194,  473,  403,  561, 1483,
 /*  1850 */   248,   92, 1505,  494,  198,  279,  112,  564,  250,    4,
 /*  1860 */   348,  497,  405,  352, 1259,  251,  252,  515, 1316,  434,
 /*  1870 */  1315, 1314,   94,  567, 1307,  886, 1306, 1031,  226,  406,
 /*  1880 */  1611, 1610,  438,  110,  110, 1580, 1286,  524,  439,  308,
 /*  1890 */   266,  111, 1285,  449,  573,  449,  449,  309, 1019,  366,
 /*  1900 */  1284, 1609,  265, 1566, 1565,  442,  372, 1381,  561,  129,
 /*  1910 */   550, 1380,   10, 1470,  383,  106,  316,  551,  100,   35,
 /*  1920 */   534,  575,  212, 1339,  381,  387, 1187, 1338,  274,  276,
 /*  1930 */  1019, 1019, 1021, 1022,   28,  277,  413, 1031,  576, 1254,
 /*  1940 */   388, 1521, 1249,  110,  110,  167, 1522,  168,  148, 1520,
 /*  1950 */  1519,  111,  306,  449,  573,  449,  222,  223, 1019,  839,
 /*  1960 */   169,   79,  450,  214,  414,  233,  320,  145, 1093, 1091,
 /*  1970 */   328,  182,  171, 1212,  918,  184,  240,  336,  243, 1107,
 /*  1980 */   189,  172,  173,  423,  425,   88,  180,  191,   89,   90,
 /*  1990 */  1019, 1019, 1021, 1022,   28,   91,  174, 1110,  245, 1106,
 /*  2000 */   246,  159,   18,  247,  347, 1099,  263,  195, 1227,  493,
 /*  2010 */   249,  196,   38,  854,  498,  368,  253,  360,  897,  197,
 /*  2020 */   502,   93,   19,   20,  507,  884,  363,  510,   95,  307,
 /*  2030 */   160,   96,  518,   97, 1175, 1060, 1146,   40,   21,  227,
 /*  2040 */   176, 1145,  282,  284,  969,  200,  963,  114,  262, 1165,
 /*  2050 */    22,   23,   24, 1161, 1169,   25, 1163, 1150,   34,   26,
 /*  2060 */  1168,  546,   27,  204,  101,  103,  104, 1074,    7, 1061,
 /*  2070 */  1059, 1063, 1116, 1064, 1115,  268,  269,   29,   41,  270,
 /*  2080 */  1024,  866,  113,   30,  568,  392, 1183,  144,  178, 1182,
 /*  2090 */   271,  928, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1602,


};
static const YYCODETYPE yy_lookahead[] = {
 /*     0 */   193,  193,  193,  274,  275,  276,  193,  274,  275,  276,
 /*    10 */   193,  223,  219,  225,  206,  210,  211,  212,  193,   19,
 /*    20 */   219,  233,  216,  216,  217,  216,  217,  193,  295,  216,
 /*    30 */   217,   31,  193,  216,  217,  193,  228,  213,  230,   39,
 /*    40 */   206,  216,  217,   43,   44,   45,   46,   47,   48,   49,
 /*    50 */    50,   51,   52,   53,   54,   55,   56,   57,  193,   19,
 /*    60 */   185,  186,  187,  188,  189,  190,  253,  274,  275,  276,
 /*    70 */   195,  193,  197,  193,  261,  274,  275,  276,  253,  204,
 /*    80 */   238,  204,   81,   43,   44,   45,   46,   47,   48,   49,
 /*    90 */    50,   51,   52,   53,   54,   55,   56,   57,  274,  275,
 /*   100 */   276,  262,  102,  103,  104,  105,  106,  107,  108,  109,
 /*   110 */   110,  111,  112,  113,  239,  240,  239,  240,  210,  211,
 /*   120 */   212,  314,  315,  314,   59,  316,   86,  252,   88,  252,
 /*   130 */    19,  314,  315,  256,  257,  113,   25,   72,  296,  138,
 /*   140 */   139,  266,  102,  103,  104,  105,  106,  107,  108,  109,
 /*   150 */   110,  111,  112,  113,   43,   44,   45,   46,   47,   48,
 /*   160 */    49,   50,   51,   52,   53,   54,   55,   56,   57,   81,
 /*   170 */   292,   59,  292,  298,  108,  109,  110,  111,  112,  113,
 /*   180 */    69,  116,  117,  118,   72,  106,  107,  193,  111,  112,
 /*   190 */   113,   54,   55,   56,   57,   58,  102,  103,  104,  105,
 /*   200 */   106,  107,  108,  109,  110,  111,  112,  113,  120,   25,
 /*   210 */   216,  217,  145,  102,  103,  104,  105,  106,  107,  108,
 /*   220 */   109,  110,  111,  112,  113,  231,  138,  139,  116,  117,
 /*   230 */   118,  164,  153,   19,  155,   54,   55,   56,   57,  102,
 /*   240 */   103,  104,  105,  106,  107,  108,  109,  110,  111,  112,
 /*   250 */   113,  128,  129,   46,   47,   48,   49,   43,   44,   45,
 /*   260 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
 /*   270 */    56,   57,  216,  193,   25,   59,  193,   19,  165,  166,
 /*   280 */   193,   67,   24,  102,  103,  104,  105,  106,  107,  108,
 /*   290 */   109,  110,  111,  112,  113,   73,  216,  217,   59,  216,
 /*   300 */   217,   43,   44,   45,   46,   47,   48,   49,   50,   51,
 /*   310 */    52,   53,   54,   55,   56,   57,  102,  103,  104,  105,
 /*   320 */   106,  107,  108,  109,  110,  111,  112,  113,  121,  145,
 /*   330 */    59,  193,  116,  117,  118,  119,  273,  204,  122,  123,
 /*   340 */   124,   19,   20,  134,   22,  136,  137,   19,  132,  127,
 /*   350 */   128,  129,   24,   22,   23,  116,  117,  118,   36,  193,
 /*   360 */   102,  103,  104,  105,  106,  107,  108,  109,  110,  111,
 /*   370 */   112,  113,  239,  240,  311,  312,  215,  106,  107,  241,
 /*   380 */    19,   59,  216,  217,  223,  252,  115,  116,  117,  118,
 /*   390 */   151,  120,   26,   71,  193,  308,  309,  193,  149,  128,
 /*   400 */   313,  216,  269,   81,   43,   44,   45,   46,   47,   48,
 /*   410 */    49,   50,   51,   52,   53,   54,   55,   56,   57,  253,
 /*   420 */   216,  217,  100,   95,  153,   59,  155,  261,  106,  107,
 /*   430 */    25,  193,  101,  193,  193,  231,  114,   25,  116,  117,
 /*   440 */   118,  113,  304,  121,  193,  204,   59,  119,  120,  121,
 /*   450 */   122,  123,  124,  125,  216,  217,  193,  216,  217,  131,
 /*   460 */   138,  139,  230,  102,  103,  104,  105,  106,  107,  108,
 /*   470 */   109,  110,  111,  112,  113,  153,  154,  155,  156,  157,
 /*   480 */   239,  240,  116,  117,  118,   76,  193,   23,   19,   25,
 /*   490 */    22,  253,   23,  252,  253,  108,   87,  204,   89,  261,
 /*   500 */   198,   92,  261,  116,  117,  118,  193,  306,  307,  216,
 /*   510 */   217,  150,   43,   44,   45,   46,   47,   48,   49,   50,
 /*   520 */    51,   52,   53,   54,   55,   56,   57,   59,  193,  216,
 /*   530 */   217,   19,  239,  240,  283,   23,  106,  107,  108,  109,
 /*   540 */   110,  111,  112,  113,   73,  252,  253,  142,  308,  309,
 /*   550 */   138,  139,   81,  313,  145,   43,   44,   45,   46,   47,
 /*   560 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   570 */   307,  102,  103,  104,  105,  106,  107,  108,  109,  110,
 /*   580 */   111,  112,  113,  281,  116,  117,  118,  285,   23,  193,
 /*   590 */    25,  119,   59,  193,  122,  123,  124,   59,  127,  203,
 /*   600 */    59,  205,   19,  268,  132,   25,   23,   22,  193,  138,
 /*   610 */   139,  249,  204,  251,  102,  103,  104,  105,  106,  107,
 /*   620 */   108,  109,  110,  111,  112,  113,   43,   44,   45,   46,
 /*   630 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   640 */    57,   19,   22,   23,   59,   23,   25,  239,  240,  116,
 /*   650 */   117,  118,  193,   11,  116,  117,  118,  116,  117,  118,
 /*   660 */   252,  269,   22,  193,   15,   43,   44,   45,   46,   47,
 /*   670 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   680 */   273,  143,  193,  118,  143,  102,  103,  104,  105,  106,
 /*   690 */   107,  108,  109,  110,  111,  112,  113,   76,  118,   59,
 /*   700 */   241,  116,  117,  118,  304,  216,  217,  292,  143,   60,
 /*   710 */    89,  241,   19,   92,  193,  193,   23,   22,  311,  312,
 /*   720 */   231,  101,   22,  143,  102,  103,  104,  105,  106,  107,
 /*   730 */   108,  109,  110,  111,  112,  113,   43,   44,   45,   46,
 /*   740 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   750 */    57,   19,  193,  193,   59,   23,  116,  117,  118,   59,
 /*   760 */   201,   21,  241,  304,  193,  206,  127,  128,  129,  193,
 /*   770 */   128,  129,  235,  236,  304,   43,   44,   45,   46,   47,
 /*   780 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   790 */    22,  193,  216,  217,  193,  102,  103,  104,  105,  106,
 /*   800 */   107,  108,  109,  110,  111,  112,  113,  231,  193,  193,
 /*   810 */   193,  116,  117,  118,  216,  217,  116,  117,  118,  226,
 /*   820 */    80,  193,   19,  235,  236,  304,   23,  211,  212,  231,
 /*   830 */   204,  216,  217,  205,  102,  103,  104,  105,  106,  107,
 /*   840 */   108,  109,  110,  111,  112,  113,   43,   44,   45,   46,
 /*   850 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   860 */    57,   19,  193,  123,   76,  239,  240,  193,  253,  239,
 /*   870 */   240,  239,  240,  244,  106,  107,  193,   89,  252,  193,
 /*   880 */    92,   59,  252,  254,  252,   43,   44,   45,   46,   47,
 /*   890 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   900 */   284,  161,  216,  217,  193,  102,  103,  104,  105,  106,
 /*   910 */   107,  108,  109,  110,  111,  112,  113,  231,  193,  244,
 /*   920 */   187,  188,  189,  190,    7,    8,    9,  309,  195,  254,
 /*   930 */   197,  313,   19,  127,  128,  129,  262,  204,   22,  117,
 /*   940 */    24,  216,  217,  273,  102,  103,  104,  105,  106,  107,
 /*   950 */   108,  109,  110,  111,  112,  113,   43,   44,   45,   46,
 /*   960 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   970 */    57,  193,  239,  240,  193,   59,   19,  188,  253,  190,
 /*   980 */   193,  311,  312,   16,  195,  252,  197,  193,   19,  301,
 /*   990 */   302,  135,  193,  204,  216,  217,  140,  216,  217,  266,
 /*  1000 */   204,  159,   45,   46,   47,   48,   49,   50,   51,   52,
 /*  1010 */    53,   54,   55,   56,   57,  102,  103,  104,  105,  106,
 /*  1020 */   107,  108,  109,  110,  111,  112,  113,   12,  239,  240,
 /*  1030 */   193,  298,  238,  117,  253,  239,  240,  238,  259,  260,
 /*  1040 */   193,  252,   27,  193,   77,  193,   79,  204,  252,  262,
 /*  1050 */   193,  299,  300,  193,  100,  266,  278,   42,  204,  102,
 /*  1060 */   103,  104,  105,  106,  107,  108,  109,  110,  111,  112,
 /*  1070 */   113,  117,  159,  216,  217,  121,  216,  217,   63,  193,
 /*  1080 */   193,  193,  239,  240,  115,  116,  193,  298,   73,  240,
 /*  1090 */   238,  231,   19,  239,  240,  252,   22,   24,  211,  212,
 /*  1100 */   263,  252,  216,  217,  216,  217,  252,  153,  154,  155,
 /*  1110 */   253,  193,   19,  144,  213,  268,   43,   44,   45,   46,
 /*  1120 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*  1130 */    57,  193,   19,   59,  216,  217,   43,   44,   45,   46,
 /*  1140 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*  1150 */    57,  193,   19,   24,  216,  217,   43,   44,   45,   46,
 /*  1160 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*  1170 */    57,  284,  193,  208,  209,  102,  103,  104,  105,  106,
 /*  1180 */   107,  108,  109,  110,  111,  112,  113,  286,   59,  193,
 /*  1190 */   232,  117,  291,  193,  193,  102,  103,  104,  105,  106,
 /*  1200 */   107,  108,  109,  110,  111,  112,  113,  193,  204,   22,
 /*  1210 */    23,  193,   25,   66,  193,  102,  103,  104,  105,  106,
 /*  1220 */   107,  108,  109,  110,  111,  112,  113,  193,  193,  193,
 /*  1230 */   216,  217,   85,  193,  238,   19,   16,  216,  217,  238,
 /*  1240 */   193,   94,  193,  239,  240,  231,  117,  268,   35,  116,
 /*  1250 */   216,  217,  216,  217,   22,   23,  252,   25,  208,  209,
 /*  1260 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
 /*  1270 */    54,   55,   56,   57,  193,  193,   19,    5,   59,   66,
 /*  1280 */   193,  263,   10,   11,   12,   13,   14,   74,  101,   17,
 /*  1290 */   193,   46,  193,  146,  193,   76,  213,   77,  263,   79,
 /*  1300 */    12,  260,   30,   46,   32,  264,   87,  193,   89,   29,
 /*  1310 */   263,   92,   40,   33,  232,   27,  193,  108,  102,  103,
 /*  1320 */   104,  105,  106,  107,  108,  109,  110,  111,  112,  113,
 /*  1330 */    42,  138,  139,  101,  193,  116,  117,  118,   19,   20,
 /*  1340 */   255,   22,   70,  130,  135,   65,  256,  257,  193,  140,
 /*  1350 */    78,   63,  193,   81,  193,   36,  193,  216,  217,  193,
 /*  1360 */   115,  193,  263,  193,  145,  268,   59,   48,  193,  193,
 /*  1370 */    98,  193,  115,  193,  291,  216,  217,  193,   59,  216,
 /*  1380 */   217,  161,  216,  217,  216,  217,  216,  217,  131,  193,
 /*  1390 */    71,  193,  216,  217,  216,  217,  216,  217,  193,  260,
 /*  1400 */   216,  217,   19,  264,   85,  133,  244,  100,  193,   90,
 /*  1410 */   138,  139,  216,  217,  216,  217,  254,  244,  193,  100,
 /*  1420 */   193,  216,  217,  116,  117,  106,  107,  254,  121,  193,
 /*  1430 */   115,  216,  217,  114,  162,  116,  117,  118,  115,  244,
 /*  1440 */   121,  216,  217,  216,  217,  193,  309,  193,   31,  254,
 /*  1450 */   313,  309,  216,  217,  309,  313,   39,  193,  313,  309,
 /*  1460 */   153,  154,  155,  313,  193,  150,   25,  144,  216,  217,
 /*  1470 */   216,  217,  153,  154,  155,  156,  157,    0,    1,    2,
 /*  1480 */   216,  217,    5,  149,  150,   22,  193,   10,   11,   12,
 /*  1490 */    13,   14,  193,  158,   17,  160,  193,   19,   20,  116,
 /*  1500 */    22,   25,  193,   24,   22,  193,   24,   30,  226,   32,
 /*  1510 */    19,   20,  226,   22,   36,  193,   53,   40,  193,  216,
 /*  1520 */   217,  193,   23,  193,   25,  216,  217,   36,  216,  217,
 /*  1530 */   193,   99,  193,  193,   22,  193,  193,   59,  216,  217,
 /*  1540 */   193,  216,  217,  193,  216,  217,  193,   70,  129,   71,
 /*  1550 */    59,  129,  193,  216,  217,   78,  216,  217,   81,  216,
 /*  1560 */   217,  193,   71,   85,  193,  133,  193,  126,   90,  216,
 /*  1570 */   217,  152,  258,   61,  152,   98,   85,  193,  100,  193,
 /*  1580 */    23,   90,   25,  121,  106,  107,   23,  216,  217,  216,
 /*  1590 */   217,  100,  114,  131,  116,  117,  118,  106,  107,  121,
 /*  1600 */   216,  217,  216,  217,  193,  114,  193,  116,  117,  118,
 /*  1610 */   133,   22,  121,  193,   59,  138,  139,  193,  142,  193,
 /*  1620 */   141,   23,   23,   25,   25,  120,  121,  216,  217,  216,
 /*  1630 */   217,  153,  154,  155,  156,  157,  216,  217,   19,  162,
 /*  1640 */   216,  217,  216,  217,  153,  154,  155,  156,  157,    1,
 /*  1650 */     2,  193,   59,    5,   19,   20,  318,   22,   10,   11,
 /*  1660 */    12,   13,   14,  193,   59,   17,  193,   23,   23,   25,
 /*  1670 */    25,   36,  117,  193,  216,  217,  193,   23,   30,   25,
 /*  1680 */    32,   19,   20,   23,   22,   25,  216,  217,   40,  216,
 /*  1690 */   217,    7,    8,   23,   59,   25,   83,   84,   36,   23,
 /*  1700 */   193,   25,   23,   23,   25,   25,   71,  153,  145,  155,
 /*  1710 */   117,  153,   23,  155,   25,   23,   97,   25,   70,  193,
 /*  1720 */   193,   59,  117,  236,  193,  193,   78,  193,  193,   81,
 /*  1730 */   141,  193,  193,   71,  193,  100,  288,  287,  242,  255,
 /*  1740 */   255,  106,  107,  108,  255,  255,   98,  243,  297,  114,
 /*  1750 */   214,  116,  117,  118,  245,  191,  121,  271,  293,  267,
 /*  1760 */   267,  246,  100,  246,  245,  271,  271,  293,  106,  107,
 /*  1770 */   220,  271,  229,  225,  249,  219,  114,  259,  116,  117,
 /*  1780 */   118,  133,  259,  121,  219,  219,  138,  139,  153,  154,
 /*  1790 */   155,  156,  157,  280,  249,  243,   19,   20,  245,   22,
 /*  1800 */   196,  259,  140,  259,   60,  297,  141,  297,  200,  200,
 /*  1810 */   162,   38,  200,   36,  294,  153,  154,  155,  156,  157,
 /*  1820 */   151,  150,  294,  283,   22,   43,  234,   18,  237,  200,
 /*  1830 */   270,  272,  237,  237,  237,   18,   59,  199,  270,  149,
 /*  1840 */   246,  272,  272,  200,  234,  234,  246,  246,   71,  246,
 /*  1850 */   199,  158,  290,   62,   22,  200,   19,   20,  199,   22,
 /*  1860 */   289,  221,  221,  200,  200,  199,  199,  115,  218,   64,
 /*  1870 */   218,  218,   22,   36,  227,  126,  227,  100,  165,  221,
 /*  1880 */   224,  224,   24,  106,  107,  312,  218,  305,  113,  282,
 /*  1890 */    91,  114,  220,  116,  117,  118,   59,  282,  121,  218,
 /*  1900 */   218,  218,  200,  317,  317,   82,  221,  265,   71,  148,
 /*  1910 */   145,  265,   22,  277,  200,  158,  279,  140,  147,   25,
 /*  1920 */   146,  202,  248,  250,  249,  247,   13,  250,  194,  194,
 /*  1930 */   153,  154,  155,  156,  157,    6,  303,  100,  192,  192,
 /*  1940 */   246,  213,  192,  106,  107,  207,  213,  207,  222,  213,
 /*  1950 */   213,  114,  222,  116,  117,  118,  214,  214,  121,    4,
 /*  1960 */   207,  213,    3,   22,  303,   15,  163,   16,   23,   23,
 /*  1970 */   139,  151,  130,   25,   20,  142,   24,   16,  144,    1,
 /*  1980 */   142,  130,  130,   61,   37,   53,  300,  151,   53,   53,
 /*  1990 */   153,  154,  155,  156,  157,   53,  130,  116,   34,    1,

 /*  2000 */   141,    5,   22,  115,  161,   68,   25,   68,   75,   41,
 /*  2010 */   141,  115,   24,   20,   19,  131,  125,   23,   28,   22,
 /*  2020 */    67,   22,   22,   22,   67,   59,   24,   96,   22,   67,
 /*  2030 */    23,  149,   22,   25,   23,   23,   23,   22,   34,  141,

 /*  2040 */    37,   97,   23,   23,  116,   22,  143,   25,   34,   75,
 /*  2050 */    34,   34,   34,   88,   75,   34,   86,   23,   22,   34,
 /*  2060 */    93,   24,   34,   25,   25,  142,  142,   23,   44,   23,
 /*  2070 */    23,   23,   23,   11,   23,   25,   22,   22,   22,  141,
 /*  2080 */    23,   23,   22,   22,   25,   15,    1,   23,   25,    1,
 /*  2090 */   141,  135,  319,  319,  319,  319,  319,  319,  319,  141,
 /*  2100 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2110 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2120 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2130 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2140 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2150 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2160 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2170 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2180 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2190 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2200 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2210 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2220 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2230 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2240 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2250 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2260 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2270 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
 /*  2280 */   319,  319,  319,  319,  319,

};
#define YY_SHIFT_COUNT    (578)
#define YY_SHIFT_MIN      (0)
#define YY_SHIFT_MAX      (2088)
static const unsigned short int yy_shift_ofst[] = {
 /*     0 */  1648, 1477, 1272,  322,  322,    1, 1319, 1478, 1491, 1837,
 /*    10 */  1837, 1837,  471,    0,    0,  214, 1093, 1837, 1837, 1837,
 /*    20 */  1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
 /*    30 */  1837,  271,  271, 1219, 1219,  216,   88,    1,    1,    1,
 /*    40 */     1,    1,   40,  111,  258,  361,  469,  512,  583,  622,
 /*    50 */   693,  732,  803,  842,  913, 1073, 1093, 1093, 1093, 1093,
 /*    60 */  1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093,
 /*    70 */  1093, 1093, 1093, 1093, 1113, 1093, 1216,  957,  957, 1635,
 /*    80 */  1662, 1777, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
 /*    90 */  1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
 /*   100 */  1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
 /*   110 */  1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
 /*   120 */  1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
 /*   130 */  1837,  137,  181,  181,  181,  181,  181,  181,  181,   94,
 /*   140 */   430,   66,   65,  112,  366,  533,  533,  740, 1257,  533,
 /*   150 */   533,   79,   79,  533,  412,  412,  412,   77,  412,  123,
 /*   160 */   113,  113,  113,   22,   22, 2100, 2100,  328,  328,  328,
 /*   170 */   239,  468,  468,  468,  468, 1015, 1015,  409,  366, 1187,
 /*   180 */  1232,  533,  533,  533,  533,  533,  533,  533,  533,  533,
 /*   190 */   533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
 /*   200 */   533,  969,  621,  621,  533,  642,  788,  788, 1133, 1133,
 /*   210 */   822,  822,   67, 1193, 2100, 2100, 2100, 2100, 2100, 2100,
 /*   220 */  2100, 1307,  954,  954,  585,  472,  640,  387,  695,  538,
 /*   230 */   541,  700,  533,  533,  533,  533,  533,  533,  533,  533,
 /*   240 */   533,  533,  222,  533,  533,  533,  533,  533,  533,  533,
 /*   250 */   533,  533,  533,  533,  533, 1213, 1213, 1213,  533,  533,
 /*   260 */   533,  565,  533,  533,  533,  916, 1147,  533,  533, 1288,
 /*   270 */   533,  533,  533,  533,  533,  533,  533,  533,  639, 1280,
 /*   280 */   209, 1129, 1129, 1129, 1129,  580,  209,  209, 1209,  768,
 /*   290 */   917,  649, 1315, 1334,  405, 1334, 1383,  249, 1315, 1315,
 /*   300 */   249, 1315,  405, 1383, 1441,  464, 1245, 1417, 1417, 1417,
 /*   310 */  1323, 1323, 1323, 1323,  184,  184, 1335, 1476,  856, 1482,
 /*   320 */  1744, 1744, 1665, 1665, 1773, 1773, 1665, 1669, 1671, 1802,
 /*   330 */  1782, 1809, 1809, 1809, 1809, 1665, 1817, 1690, 1671, 1671,
 /*   340 */  1690, 1802, 1782, 1690, 1782, 1690, 1665, 1817, 1693, 1791,
 /*   350 */  1665, 1817, 1832, 1665, 1817, 1665, 1817, 1832, 1752, 1752,
 /*   360 */  1752, 1805, 1850, 1850, 1832, 1752, 1749, 1752, 1805, 1752,
 /*   370 */  1752, 1713, 1858, 1775, 1775, 1832, 1665, 1799, 1799, 1823,
 /*   380 */  1823, 1761, 1765, 1890, 1665, 1757, 1761, 1771, 1774, 1690,
 /*   390 */  1894, 1913, 1913, 1929, 1929, 1929, 2100, 2100, 2100, 2100,
 /*   400 */  2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100,
 /*   410 */  2100,  207, 1220,  331,  620,  967,  806, 1074, 1499, 1432,
 /*   420 */  1463, 1479, 1419, 1422, 1557, 1512, 1598, 1599, 1644, 1645,
 /*   430 */  1654, 1660, 1555, 1505, 1684, 1462, 1670, 1563, 1619, 1593,
 /*   440 */  1676, 1679, 1613, 1680, 1554, 1558, 1689, 1692, 1605, 1589,
 /*   450 */  1955, 1959, 1941, 1803, 1950, 1951, 1945, 1946, 1831, 1820,
 /*   460 */  1842, 1948, 1948, 1952, 1833, 1954, 1834, 1961, 1978, 1838,
 /*   470 */  1851, 1948, 1852, 1922, 1947, 1948, 1836, 1932, 1935, 1936,
 /*   480 */  1942, 1866, 1881, 1964, 1859, 1998, 1996, 1980, 1888, 1843,
 /*   490 */  1937, 1981, 1939, 1933, 1968, 1869, 1896, 1988, 1993, 1995,
 /*   500 */  1884, 1891, 1997, 1953, 1999, 2000, 1994, 2001, 1957, 1966,
 /*   510 */  2002, 1931, 1990, 2006, 1962, 2003, 2007, 2004, 1882, 2010,
 /*   520 */  2011, 2012, 2008, 2013, 2015, 1944, 1898, 2019, 2020, 1928,
 /*   530 */  2014, 2023, 1903, 2022, 2016, 2017, 2018, 2021, 1965, 1974,
 /*   540 */  1970, 2024, 1979, 1967, 2025, 2034, 2036, 2037, 2038, 2039,
 /*   550 */  2028, 1923, 1924, 2044, 2022, 2046, 2047, 2048, 2049, 2050,
 /*   560 */  2051, 2054, 2062, 2055, 2056, 2057, 2058, 2060, 2061, 2059,
 /*   570 */  1956, 1938, 1949, 1958, 2063, 2064, 2070, 2085, 2088,
};
#define YY_REDUCE_COUNT (410)
#define YY_REDUCE_MIN   (-271)
#define YY_REDUCE_MAX   (1753)
static const short yy_reduce_ofst[] = {
 /*     0 */  -125,  733,  789,  241,  293, -123, -193, -191, -183, -187,
 /*    10 */   166,  238,  133, -207, -199, -267, -176,   -6,  204,  489,
 /*    20 */   576,  598, -175,  686,  860,  615,  725, 1014,  778,  781,
 /*    30 */   857,  616,  887,   87,  240, -192,  408,  626,  796,  843,
 /*    40 */   854, 1004, -271, -271, -271, -271, -271, -271, -271, -271,
 /*    50 */  -271, -271, -271, -271, -271, -271, -271, -271, -271, -271,
 /*    60 */  -271, -271, -271, -271, -271, -271, -271, -271, -271, -271,
 /*    70 */  -271, -271, -271, -271, -271, -271, -271, -271, -271,   80,
 /*    80 */    83,  313,  886,  888,  918,  938, 1021, 1034, 1036, 1141,
 /*    90 */  1159, 1163, 1166, 1168, 1170, 1176, 1178, 1180, 1184, 1196,
 /*   100 */  1198, 1205, 1215, 1225, 1227, 1236, 1252, 1254, 1264, 1303,
 /*   110 */  1309, 1312, 1322, 1325, 1328, 1337, 1340, 1343, 1353, 1371,
 /*   120 */  1373, 1384, 1386, 1411, 1413, 1420, 1424, 1426, 1458, 1470,
 /*   130 */  1473, -271, -271, -271, -271, -271, -271, -271, -271, -271,
 /*   140 */  -271, -271,  138,  459,  396, -158,  470,  302, -212,  521,
 /*   150 */   201, -195,  -92,  559,  630,  632,  630, -271,  632,  901,
 /*   160 */    63,  407,  670, -271, -271, -271, -271,  161,  161,  161,
 /*   170 */   251,  335,  847,  979, 1097,  537,  588,  618,  628,  688,
 /*   180 */   688, -166, -161,  674,  787,  794,  799,  852,  996, -122,
 /*   190 */   837, -120, 1018, 1035,  415, 1047, 1001,  958, 1082,  400,
 /*   200 */  1099,  779, 1137, 1142,  263, 1083, 1145, 1150, 1041, 1139,
 /*   210 */   965, 1050,  362,  849,  752,  629,  675, 1162, 1173, 1090,
 /*   220 */  1195, -194,   56,  185, -135,  232,  522,  560,  571,  601,
 /*   230 */   617,  669,  683,  711,  850,  893, 1000, 1040, 1049, 1081,
 /*   240 */  1087, 1101,  392, 1114, 1123, 1155, 1161, 1175, 1271, 1293,
 /*   250 */  1299, 1330, 1339, 1342, 1347,  593, 1282, 1286, 1350, 1359,
 /*   260 */  1368, 1314, 1480, 1483, 1507, 1085, 1338, 1526, 1527, 1487,
 /*   270 */  1531,  560, 1532, 1534, 1535, 1538, 1539, 1541, 1448, 1450,
 /*   280 */  1496, 1484, 1485, 1489, 1490, 1314, 1496, 1496, 1504, 1536,
 /*   290 */  1564, 1451, 1486, 1492, 1509, 1493, 1465, 1515, 1494, 1495,
 /*   300 */  1517, 1500, 1519, 1474, 1550, 1543, 1548, 1556, 1565, 1566,
 /*   310 */  1518, 1523, 1542, 1544, 1525, 1545, 1513, 1553, 1552, 1604,
 /*   320 */  1508, 1510, 1608, 1609, 1520, 1528, 1612, 1540, 1559, 1560,
 /*   330 */  1592, 1591, 1595, 1596, 1597, 1629, 1638, 1594, 1569, 1570,
 /*   340 */  1600, 1568, 1610, 1601, 1611, 1603, 1643, 1651, 1562, 1571,
 /*   350 */  1655, 1659, 1640, 1663, 1666, 1664, 1667, 1641, 1650, 1652,
 /*   360 */  1653, 1647, 1656, 1657, 1658, 1668, 1672, 1681, 1649, 1682,
 /*   370 */  1683, 1573, 1582, 1607, 1615, 1685, 1702, 1586, 1587, 1642,
 /*   380 */  1646, 1673, 1675, 1636, 1714, 1637, 1677, 1674, 1678, 1694,
 /*   390 */  1719, 1734, 1735, 1746, 1747, 1750, 1633, 1661, 1686, 1738,
 /*   400 */  1728, 1733, 1736, 1737, 1740, 1726, 1730, 1742, 1743, 1748,
 /*   410 */  1753,
};
static const YYACTIONTYPE yy_default[] = {
 /*     0 */  1648, 1648, 1648, 1478, 1243, 1354, 1243, 1243, 1243, 1478,
 /*    10 */  1478, 1478, 1243, 1384, 1384, 1531, 1276, 1243, 1243, 1243,
 /*    20 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1477, 1243,
 /*    30 */  1243, 1243, 1243, 1564, 1564, 1243, 1243, 1243, 1243, 1243,
 /*    40 */  1243, 1243, 1243, 1393, 1243, 1400, 1243, 1243, 1243, 1243,
 /*    50 */  1243, 1479, 1480, 1243, 1243, 1243, 1530, 1532, 1495, 1407,
 /*    60 */  1406, 1405, 1404, 1513, 1372, 1398, 1391, 1395, 1474, 1475,
 /*    70 */  1473, 1626, 1480, 1479, 1243, 1394, 1442, 1458, 1441, 1243,
 /*    80 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
 /*    90 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   100 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   110 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   120 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   130 */  1243, 1450, 1457, 1456, 1455, 1464, 1454, 1451, 1444, 1443,
 /*   140 */  1445, 1446, 1243, 1243, 1267, 1243, 1243, 1264, 1318, 1243,
 /*   150 */  1243, 1243, 1243, 1243, 1550, 1549, 1243, 1447, 1243, 1276,
 /*   160 */  1435, 1434, 1433, 1461, 1448, 1460, 1459, 1538, 1600, 1599,
 /*   170 */  1496, 1243, 1243, 1243, 1243, 1243, 1243, 1564, 1243, 1243,
 /*   180 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   190 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   200 */  1243, 1374, 1564, 1564, 1243, 1276, 1564, 1564, 1375, 1375,
 /*   210 */  1272, 1272, 1378, 1243, 1545, 1345, 1345, 1345, 1345, 1354,
 /*   220 */  1345, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   230 */  1243, 1243, 1243, 1243, 1243, 1243, 1535, 1533, 1243, 1243,
 /*   240 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   250 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   260 */  1243, 1243, 1243, 1243, 1243, 1350, 1243, 1243, 1243, 1243,
 /*   270 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1593, 1243, 1508,
 /*   280 */  1332, 1350, 1350, 1350, 1350, 1352, 1333, 1331, 1344, 1277,
 /*   290 */  1250, 1640, 1410, 1399, 1351, 1399, 1637, 1397, 1410, 1410,
 /*   300 */  1397, 1410, 1351, 1637, 1293, 1615, 1288, 1384, 1384, 1384,
 /*   310 */  1374, 1374, 1374, 1374, 1378, 1378, 1476, 1351, 1344, 1243,
 /*   320 */  1640, 1640, 1360, 1360, 1639, 1639, 1360, 1496, 1623, 1419,
 /*   330 */  1321, 1327, 1327, 1327, 1327, 1360, 1261, 1397, 1623, 1623,
 /*   340 */  1397, 1419, 1321, 1397, 1321, 1397, 1360, 1261, 1512, 1634,
 /*   350 */  1360, 1261, 1486, 1360, 1261, 1360, 1261, 1486, 1319, 1319,
 /*   360 */  1319, 1308, 1243, 1243, 1486, 1319, 1293, 1319, 1308, 1319,
 /*   370 */  1319, 1582, 1243, 1490, 1490, 1486, 1360, 1574, 1574, 1387,
 /*   380 */  1387, 1392, 1378, 1481, 1360, 1243, 1392, 1390, 1388, 1397,
 /*   390 */  1311, 1596, 1596, 1592, 1592, 1592, 1645, 1645, 1545, 1608,
 /*   400 */  1276, 1276, 1276, 1276, 1608, 1295, 1295, 1277, 1277, 1276,
 /*   410 */  1608, 1243, 1243, 1243, 1243, 1243, 1243, 1603, 1243, 1540,
 /*   420 */  1497, 1364, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   430 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1551, 1243,
 /*   440 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1424,
 /*   450 */  1243, 1246, 1542, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   460 */  1243, 1401, 1402, 1365, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   470 */  1243, 1416, 1243, 1243, 1243, 1411, 1243, 1243, 1243, 1243,
 /*   480 */  1243, 1243, 1243, 1243, 1636, 1243, 1243, 1243, 1243, 1243,
 /*   490 */  1243, 1511, 1510, 1243, 1243, 1362, 1243, 1243, 1243, 1243,
 /*   500 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1291,
 /*   510 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   520 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   530 */  1243, 1243, 1243, 1389, 1243, 1243, 1243, 1243, 1243, 1243,
 /*   540 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1579, 1379,
 /*   550 */  1243, 1243, 1243, 1243, 1627, 1243, 1243, 1243, 1243, 1243,
 /*   560 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1619,
 /*   570 */  1335, 1425, 1243, 1428, 1265, 1243, 1255, 1243, 1243,
};
/********** 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.







|


|
|
|
|
|
|
|
|
|


|
|

|
|
|
|

|
|
|
|

|
|
|

|
|

|
|
|
|

|
|
|
|
|
|
|
|

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

|
|
|
|

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

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


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


|
|

|
|
|
|



|
|
|
|

|
|

|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|

|
|
|
|
|


|
|
|

|
|
|
|
|


|
|
|

|
|
|
|
|


|
|
|

|
|
|
|
|


|
|
|
|

|
|
|
|

|
|
|
|
|

|

|

|
|
|
|
|
|
|
|
|

|
|
|
|
|

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



|

|
|
|
|



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


|
|

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


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







172179
172180
172181
172182
172183
172184
172185
172186
172187
172188
172189
172190
172191
172192
172193
172194
172195
172196
172197
172198
172199
172200
172201
172202
172203
172204
172205
172206
172207
172208
172209
172210
172211
172212
172213
172214
172215
172216
172217
172218
172219
172220
172221
172222
172223
172224
172225
172226
172227
172228
172229
172230
172231
172232
172233
172234
172235
172236
172237
172238
172239
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
172265
172266
172267
172268
172269
172270
172271
172272
172273
172274
172275
172276
172277
172278
172279
172280
172281
172282
172283
172284
172285
172286
172287
172288
172289
172290
172291
172292
172293
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
172383
172384
172385
172386
172387
172388
172389
172390
172391
172392
172393
172394
172395
172396
172397
172398
172399
172400
172401
172402
172403
172404
172405
172406
172407
172408
172409
172410
172411
172412
172413
172414
172415
172416
172417
172418
172419
172420
172421
172422
172423
172424
172425
172426
172427
172428
172429
172430
172431
172432
172433
172434
172435
172436
172437
172438
172439
172440
172441
172442
172443
172444
172445
172446
172447
172448
172449
172450
172451
172452
172453
172454
172455
172456
172457
172458
172459
172460
172461
172462
172463
172464
172465
172466
172467
172468
172469
172470
172471
172472
172473
172474
172475
172476
172477
172478
172479
172480
172481
172482
172483
172484
172485
172486
172487
172488
172489
172490
172491
172492
172493
172494
172495
172496
172497
172498
172499
172500
172501
172502
172503
172504
172505
172506
172507
172508
172509
172510
172511
172512
172513
172514
172515
172516
172517
172518
172519
172520
172521
172522
172523
172524
172525
172526
172527
172528
172529
172530
172531
172532
172533
172534
172535
172536
172537
172538
172539
172540
172541
172542
172543
172544
172545
172546
172547
172548
172549
172550
172551
172552
172553
172554
172555
172556
172557
172558
172559
172560
172561
172562
172563
172564
172565
172566
172567
172568
172569
172570
172571
172572
172573
172574
172575
172576
172577
172578
172579
172580
172581
172582
172583
172584
172585
172586
172587
172588
172589
172590
172591
172592
172593
172594
172595
172596
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
172628
172629
172630
172631
172632
172633
172634
172635
172636
172637
172638
172639
172640
172641
172642
172643
172644
172645
172646
172647
172648
172649
172650
172651
172652
172653
172654
172655
172656
172657
172658
172659
172660
172661
172662
172663
172664
172665
172666
172667
172668
172669
172670
172671
172672
172673
172674
172675
172676
172677
172678
172679
172680
172681
172682
172683
172684
172685
172686
172687
172688
172689
172690
172691
172692
172693
172694
172695
172696
172697
172698
172699
172700
172701
172702
172703
172704
172705
172706
172707
172708
172709
172710
172711
172712
172713
172714
172715
172716
172717
172718
172719
172720
172721
172722
172723
172724
172725
172726
172727
172728
172729
172730
172731
172732
172733
172734
172735
172736
172737
172738
172739
172740
172741
172742
172743
172744
172745
172746
172747
172748
172749
172750
172751
172752
172753
172754
172755
172756
172757
172758
172759
172760
172761
172762
172763
172764
172765
172766
172767
172768
172769
172770
172771
172772
172773
172774
172775
172776
172777
172778
172779
172780
172781
172782
172783
172784
172785
172786
172787
172788
172789
172790
172791
172792
172793
172794
172795
172796
172797
172798
172799
172800
172801
172802
172803
172804
172805
172806
172807
172808
**  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 (2114)
static const YYACTIONTYPE yy_action[] = {
 /*     0 */   572,  210,  572,  119,  116,  231,  572,  119,  116,  231,
 /*    10 */   572, 1319,  379, 1298,  410,  566,  566,  566,  572,  411,
 /*    20 */   380, 1319, 1281,   42,   42,   42,   42,  210, 1531,   72,
 /*    30 */    72,  975,  421,   42,   42,  495,  305,  281,  305,  976,
 /*    40 */   399,   72,   72,  126,  127,   81, 1219, 1219, 1055, 1058,
 /*    50 */  1045, 1045,  124,  124,  125,  125,  125,  125,  480,  411,
 /*    60 */  1246,    1,    1,  578,    2, 1250,  554,  119,  116,  231,
 /*    70 */   319,  484,  147,  484,  528,  119,  116,  231,  533, 1332,
 /*    80 */   419,  527,  143,  126,  127,   81, 1219, 1219, 1055, 1058,
 /*    90 */  1045, 1045,  124,  124,  125,  125,  125,  125,  119,  116,
 /*   100 */   231,  329,  123,  123,  123,  123,  122,  122,  121,  121,
 /*   110 */   121,  120,  117,  448,  286,  286,  286,  286,  446,  446,
 /*   120 */   446, 1570,  378, 1572, 1195,  377, 1165,  569, 1165,  569,
 /*   130 */   411, 1570,  541,  261,  228,  448,  102,  146,  453,  318,
 /*   140 */   563,  242,  123,  123,  123,  123,  122,  122,  121,  121,
 /*   150 */   121,  120,  117,  448,  126,  127,   81, 1219, 1219, 1055,
 /*   160 */  1058, 1045, 1045,  124,  124,  125,  125,  125,  125,  143,
 /*   170 */   296, 1195,  341,  452,  121,  121,  121,  120,  117,  448,
 /*   180 */   128, 1195, 1196, 1195,  149,  445,  444,  572,  120,  117,
 /*   190 */   448,  125,  125,  125,  125,  118,  123,  123,  123,  123,
 /*   200 */   122,  122,  121,  121,  121,  120,  117,  448,  458, 1284,
 /*   210 */    13,   13,  130,  123,  123,  123,  123,  122,  122,  121,
 /*   220 */   121,  121,  120,  117,  448,  424,  318,  563, 1195, 1196,
 /*   230 */  1195,  162, 1227,  411, 1227,  125,  125,  125,  125,  123,
 /*   240 */   123,  123,  123,  122,  122,  121,  121,  121,  120,  117,
 /*   250 */   448,  469,  344, 1042, 1042, 1056, 1059,  126,  127,   81,
 /*   260 */  1219, 1219, 1055, 1058, 1045, 1045,  124,  124,  125,  125,
 /*   270 */   125,  125, 1102, 1102,  492, 1195,  572,  411,  226,  519,
 /*   280 */   177,   83,   84,  123,  123,  123,  123,  122,  122,  121,
 /*   290 */   121,  121,  120,  117,  448, 1011,  408,  407, 1195,   72,
 /*   300 */    72,  126,  127,   81, 1219, 1219, 1055, 1058, 1045, 1045,
 /*   310 */   124,  124,  125,  125,  125,  125,  123,  123,  123,  123,
 /*   320 */   122,  122,  121,  121,  121,  120,  117,  448, 1046, 1615,
 /*   330 */  1195,  905, 1195, 1196, 1195,  254,  314,  401,  508,  505,
 /*   340 */   504,  112,  564,  570,    4,  930,  930,  435,  503,  342,
 /*   350 */   464,  330,  362,  517,  327, 1195, 1196, 1195,  567,  572,
 /*   360 */   123,  123,  123,  123,  122,  122,  121,  121,  121,  120,
 /*   370 */   117,  448,  286,  286,  844,  845,  846,  445,  444, 1198,
 /*   380 */   411,  449,   72,   72,   12,  569, 1224, 1195, 1196, 1195,
 /*   390 */    86, 1226,  273,  561, 1440,  520,  520,  572,  375, 1225,
 /*   400 */     6, 1283,  476,  143,  126,  127,   81, 1219, 1219, 1055,
 /*   410 */  1058, 1045, 1045,  124,  124,  125,  125,  125,  125,  554,
 /*   420 */    13,   13, 1032,  511, 1227, 1195, 1227,  553,  110,  110,
 /*   430 */   224,  572,  371, 1583,  572,  429,  111, 1198,  449,  573,
 /*   440 */   449,  432,  375, 1020, 1495,  555,  155,  272,  289,  370,
 /*   450 */   514,  365,  513,  259,   72,   72,  547,   72,   72,  361,
 /*   460 */   318,  563,  485,  123,  123,  123,  123,  122,  122,  121,
 /*   470 */   121,  121,  120,  117,  448, 1020, 1020, 1022, 1023,   28,
 /*   480 */   286,  286, 1195, 1196, 1195, 1160, 1616,  210,  411, 1610,
 /*   490 */   158,  554,  358,  569,  554,  390,  537, 1291, 1160,  437,
 /*   500 */   404, 1160,  556, 1565,  572, 1179,  572,    6,    9, 1557,
 /*   510 */   264,  216,  126,  127,   81, 1219, 1219, 1055, 1058, 1045,
 /*   520 */  1045,  124,  124,  125,  125,  125,  125,   13,   13,   13,
 /*   530 */    13,  411,  577,  254, 1250,  509,  508,  505,  504,  319,
 /*   540 */   224,  147,  431, 1011,  304, 1215,  503,  219, 1332, 1324,
 /*   550 */  1324,  143,  375, 1557,  536,  126,  127,   81, 1219, 1219,
 /*   560 */  1055, 1058, 1045, 1045,  124,  124,  125,  125,  125,  125,
 /*   570 */  1559,  123,  123,  123,  123,  122,  122,  121,  121,  121,
 /*   580 */   120,  117,  448,  286,  286,  122,  122,  121,  121,  121,
 /*   590 */   120,  117,  448, 1586, 1195,  177,  569,  342, 1195,  386,
 /*   600 */   154,  382,  411, 1215,  571,  547,  880,  192,  318,  563,
 /*   610 */   242,  193, 1322, 1322,  123,  123,  123,  123,  122,  122,
 /*   620 */   121,  121,  121,  120,  117,  448,  126,  127,   81, 1219,
 /*   630 */  1219, 1055, 1058, 1045, 1045,  124,  124,  125,  125,  125,
 /*   640 */   125,  411,  452,  941, 1195,  873, 1272,  376, 1195, 1272,
 /*   650 */   856, 1195, 1196, 1195,  421, 1195, 1196, 1195, 1270,  574,
 /*   660 */   572,  574,   33, 1557,   99,  126,  127,   81, 1219, 1219,
 /*   670 */  1055, 1058, 1045, 1045,  124,  124,  125,  125,  125,  125,
 /*   680 */  1355,  415,  963,   13,   13,  123,  123,  123,  123,  122,
 /*   690 */   122,  121,  121,  121,  120,  117,  448,  526,  436, 1195,
 /*   700 */   421, 1195, 1196, 1195, 1195, 1195, 1196, 1195, 1195,  467,
 /*   710 */   545,  545,  411,  375,  373,    6, 1178,    5,  548,  548,
 /*   720 */    16,   16,    3,  208,  123,  123,  123,  123,  122,  122,
 /*   730 */   121,  121,  121,  120,  117,  448,  126,  127,   81, 1219,
 /*   740 */  1219, 1055, 1058, 1045, 1045,  124,  124,  125,  125,  125,
 /*   750 */   125,  411, 1077,  430, 1195, 1033, 1195, 1196, 1195, 1195,
 /*   760 */   532, 1195, 1196, 1195,  489, 1195, 1196, 1195,  486,  209,
 /*   770 */   572,  375,  229, 1647,  397,  126,  127,   81, 1219, 1219,
 /*   780 */  1055, 1058, 1045, 1045,  124,  124,  125,  125,  125,  125,
 /*   790 */  1487,  572,  962,   13,   13,  123,  123,  123,  123,  122,
 /*   800 */   122,  121,  121,  121,  120,  117,  448, 1424,  202,  572,
 /*   810 */   384, 1195, 1196, 1195,   13,   13, 1195, 1196, 1195,  156,
 /*   820 */   199,  459,  411,  283, 1558,  961, 1016, 1541,  292,  203,
 /*   830 */   301,  896,   72,   72,  123,  123,  123,  123,  122,  122,
 /*   840 */   121,  121,  121,  120,  117,  448,  126,  127,   81, 1219,
 /*   850 */  1219, 1055, 1058, 1045, 1045,  124,  124,  125,  125,  125,
 /*   860 */   125,  411,  512,  286,  286,  286,  286,  280,  280,  315,
 /*   870 */   897,  287,  287,  461,  101,   98,  569,  426,  569,  572,
 /*   880 */   569,  288, 1557,  409,  569,  126,  127,   81, 1219, 1219,
 /*   890 */  1055, 1058, 1045, 1045,  124,  124,  125,  125,  125,  125,
 /*   900 */   572,   12,   13,   13,  531,  123,  123,  123,  123,  122,
 /*   910 */   122,  121,  121,  121,  120,  117,  448,  549,  230, 1590,
 /*   920 */   578,    2, 1250,   71,   71, 1160,  433,  319,  356,  147,
 /*   930 */   495, 1563,  411,  318,  563,    6, 1332, 1543, 1160, 1357,
 /*   940 */   313, 1160, 1330,  961,  123,  123,  123,  123,  122,  122,
 /*   950 */   121,  121,  121,  120,  117,  448,  126,  127,   81, 1219,
 /*   960 */  1219, 1055, 1058, 1045, 1045,  124,  124,  125,  125,  125,
 /*   970 */   125,  286,  286,  572,  205, 1530,  411,  286,  286,  468,
 /*   980 */   257,  256,  255, 1097,  569,  385,  495,  876,  529,  351,
 /*   990 */   569,  354, 1141, 1645, 1302, 1645,   72,   72,  242, 1268,
 /*  1000 */  1604,  105,   81, 1219, 1219, 1055, 1058, 1045, 1045,  124,
 /*  1010 */   124,  125,  125,  125,  125,  123,  123,  123,  123,  122,
 /*  1020 */   122,  121,  121,  121,  120,  117,  448,  572, 1032,  572,
 /*  1030 */   452, 1494,  572,  443,  286,  286, 1141, 1646, 1424, 1646,
 /*  1040 */   521,  495,  523, 1118,  876, 1021,  334,  569,  495, 1020,
 /*  1050 */    72,   72,   52,   52,  101,  134,  134, 1439, 1119,  123,
 /*  1060 */   123,  123,  123,  122,  122,  121,  121,  121,  120,  117,
 /*  1070 */   448, 1139,  108, 1120,  936,  286,  286,  286,  286,  935,
 /*  1080 */   457, 1020, 1020, 1022,   98,  530, 1331,  447,  569,  522,
 /*  1090 */   569,  484,  411, 1327,  916,  371, 1583,  211,  457,  456,
 /*  1100 */   469,  344,  460,  109,  917,  107,  460,  331,  427,  333,
 /*  1110 */   572, 1179,  411,  531, 1438, 1139,  126,  127,   81, 1219,
 /*  1120 */  1219, 1055, 1058, 1045, 1045,  124,  124,  125,  125,  125,
 /*  1130 */   125, 1564,  411,  136,  136,    6,  126,  127,   81, 1219,
 /*  1140 */  1219, 1055, 1058, 1045, 1045,  124,  124,  125,  125,  125,
 /*  1150 */   125,  152,  371, 1583, 1500,  887,  126,  115,   81, 1219,
 /*  1160 */  1219, 1055, 1058, 1045, 1045,  124,  124,  125,  125,  125,
 /*  1170 */   125,  457, 1500, 1502,  478,  123,  123,  123,  123,  122,
 /*  1180 */   122,  121,  121,  121,  120,  117,  448,  500,  868, 1214,
 /*  1190 */   303,  332,  454,  557, 1160,  123,  123,  123,  123,  122,
 /*  1200 */   122,  121,  121,  121,  120,  117,  448, 1160, 1562,  572,
 /*  1210 */  1160,  543,    6,  572,  258,  123,  123,  123,  123,  122,
 /*  1220 */   122,  121,  121,  121,  120,  117,  448, 1032,  286,  286,
 /*  1230 */   542,  572,   56,   56, 1561,  411,   57,   57,    6, 1171,
 /*  1240 */   474,  569,  478,  295, 1021, 1500,  868,  295, 1020,  294,
 /*  1250 */   495,  264, 1099,  572,   15,   15, 1099, 1195,  396, 1240,
 /*  1260 */   127,   81, 1219, 1219, 1055, 1058, 1045, 1045,  124,  124,
 /*  1270 */   125,  125,  125,  125, 1160,  218,   44,   44,  572, 1118,
 /*  1280 */  1020, 1020, 1022,  416,  572,  544, 1215, 1160,  490,  572,
 /*  1290 */  1160, 1171, 1424,  373, 1119,  349,  478, 1539,  529,  361,
 /*  1300 */   322,   58,   58,  235,  516,  478,  219,   45,   45, 1120,
 /*  1310 */  1179,  572,   59,   59, 1195, 1196, 1195,  297,  123,  123,
 /*  1320 */   123,  123,  122,  122,  121,  121,  121,  120,  117,  448,
 /*  1330 */   560,  936,  440,  572,   60,   60,  935, 1241,  112,  564,
 /*  1340 */   572,    4,  572,  535, 1215,  572, 1424, 1424, 1235,  572,
 /*  1350 */   961,  396, 1140,  572,   31,  567,   61,   61,  112,  564,
 /*  1360 */   572,    4,  428,   62,   62,   63,   63,    8,   46,   46,
 /*  1370 */   572,  300,   47,   47,   17,  567,   48,   48,  449,  572,
 /*  1380 */   302,  975,  572,   50,   50,   32, 1273,  417,  572,  976,
 /*  1390 */   561,  572,  258,   51,   51,  530,  883,  572,  449,  572,
 /*  1400 */   565,  417,   64,   64,  539,   65,   65,  323,  572,  538,
 /*  1410 */   561,   66,   66,  422,   14,   14,  491,  441,  572, 1032,
 /*  1420 */    67,   67,  132,  132,  539,  110,  110,  326,  550,  540,
 /*  1430 */  1241,  133,  133,  111,  462,  449,  573,  449,  482, 1032,
 /*  1440 */  1020,   68,   68,  230,  409,  110,  110,  150,  114,  112,
 /*  1450 */   564, 1336,    4,  111,  883,  449,  573,  449,  572,  239,
 /*  1460 */  1020,  416,  572,  569,  572, 1369,  567,  572,  961,  318,
 /*  1470 */   563,  525, 1020, 1020, 1022, 1023,   28, 1301,  418,  179,
 /*  1480 */  1368,   53,   53,  285,  228,   69,   69,   70,   70,  449,
 /*  1490 */    54,   54, 1020, 1020, 1022, 1023,   28,   87,  215,  290,
 /*  1500 */   471,  561, 1179,  475,  394,  394,  393,  275,  391,  572,
 /*  1510 */   409,  853,  153,  409,   39,  539,  572,  317,  470, 1136,
 /*  1520 */   538,  398, 1179,  291,  236, 1300,  325,  409,  463,  572,
 /*  1530 */  1032,  201,  165,  165,  324,  483,  110,  110,  572,  166,
 /*  1540 */   166,  339,  112,  564,  111,    4,  449,  573,  449, 1145,
 /*  1550 */   572, 1020,   77,   77,  572, 1546,  572,  321,  472,  567,
 /*  1560 */   335,   55,   55,  340,  238,  101, 1519, 1013,  550,  263,
 /*  1570 */   895,  894,  170,   73,   73,  142,  241,  135,  135,   74,
 /*  1580 */    74,  298,  449, 1020, 1020, 1022, 1023,   28, 1589, 1183,
 /*  1590 */   451, 1518,  237,  290,  561,  161, 1084,  101,  394,  394,
 /*  1600 */   393,  275,  391,  487,  477,  853,  263,  479,  345,  263,
 /*  1610 */   101,  346,  501, 1179,  260,  902,  903,  559,  236,  572,
 /*  1620 */   325,  112,  564, 1032,    4,  369,  572,  412,  324,  110,
 /*  1630 */   110,  940,  318,  563, 1024,  368,  572,  111,  567,  449,
 /*  1640 */   573,  449,  163,  163, 1020, 1365,  359,  572,  101,  137,
 /*  1650 */   137,  572,  350, 1080, 1084,  260,  455,  353,  238,  131,
 /*  1660 */   131,  449,  966,  933,  263,  114,  170,  572,  355,  142,
 /*  1670 */   164,  164, 1299,  561,  157,  157, 1020, 1020, 1022, 1023,
 /*  1680 */    28,  572,  978,  979, 1577,  866,  237,  151,  496,  572,
 /*  1690 */   141,  141, 1024,   80,  564, 1096,    4, 1096, 1095,  357,
 /*  1700 */  1095,  572, 1032, 1315,  140,  140, 1179,  364,  110,  110,
 /*  1710 */   567,  572,  138,  138,  374,  572,  111, 1348,  449,  573,
 /*  1720 */   449,  412, 1378, 1020,  139,  139,  318,  563,  572,  934,
 /*  1730 */  1423,  114, 1351,  449,   76,   76,  278,  572,   78,   78,
 /*  1740 */   572, 1363,  552,  558, 1428,  561, 1280, 1271, 1259, 1258,
 /*  1750 */   455,   75,   75, 1260, 1597, 1020, 1020, 1022, 1023,   28,
 /*  1760 */    43,   43,  213,   49,   49,  395,  310,  311,  312,   11,
 /*  1770 */   234,  221, 1410,  293, 1032,  337, 1405,  338, 1415,  299,
 /*  1780 */   110,  110, 1398,  481,  506, 1179,  367, 1414,  111, 1491,
 /*  1790 */   449,  573,  449, 1183,  451, 1020,  402,  290,  225, 1490,
 /*  1800 */  1298, 1360,  394,  394,  393,  275,  391,  343, 1361,  853,
 /*  1810 */   562, 1359,  206,  389,  551,  207, 1600, 1358, 1235,  267,
 /*  1820 */   220, 1538,  236, 1536,  325, 1232,   82, 1020, 1020, 1022,
 /*  1830 */  1023,   28,  324,  181,  420,   86,  217,  232,  190,  175,
 /*  1840 */   183,  465,  185,  466, 1411,  186,  244,  112,  564,   36,
 /*  1850 */     4,  187,  188,   85, 1496,  499,   99, 1179,  400, 1417,
 /*  1860 */  1416,   37,  238,  473,  567,  403, 1419,  194, 1485,  488,
 /*  1870 */   170,  248,   92,  142, 1507,  494,  279,  250,  198,  497,
 /*  1880 */   352,  348,  251,  405, 1261,  252,  515,  449, 1318, 1317,
 /*  1890 */   237, 1316, 1309,  434,   94,  887,  226,  438, 1614,  561,
 /*  1900 */  1288, 1613,  406,  524,  439, 1582,  265,  366, 1287, 1286,
 /*  1910 */  1612,  308,  309,  266,  372,  442, 1568, 1308, 1567, 1383,
 /*  1920 */  1382,  129,  550,   10,  383,  412, 1472,  316, 1032,  100,
 /*  1930 */   318,  563,  106,   35,  110,  110,  534,  575, 1189,  274,
 /*  1940 */   276,  388,  111,  381,  449,  573,  449, 1341, 1340, 1020,
 /*  1950 */   212,  387,  277,  576,  455, 1256, 1251,  167,  148,  413,
 /*  1960 */   414,  180, 1523,  168, 1524, 1522, 1521,  840,  222,  306,
 /*  1970 */   450,  223,  169,   79,  214,  320,  233, 1094,  145, 1092,
 /*  1980 */   328, 1020, 1020, 1022, 1023,   28,  182,  171,  184, 1214,
 /*  1990 */   240,  919,  243,  336, 1108,  189,  172,  173,  423,  174,
 /*  2000 */   191,   88,  425,   89,   90, 1111,   91,  245, 1107,  246,
 /*  2010 */   159, 1179,   18,  247,  263,  347, 1229, 1100,  249,  493,
 /*  2020 */   196,   38,  855,  195,  368,  498,  197,  253,  510,  885,
 /*  2030 */    93,   19,  176,  360,   20,  502,  507,  363,   95,  898,
 /*  2040 */   160,  307,  518,   96, 1176, 1061, 1147,   40,   21,   97,
 /*  2050 */   227,  282,  284,  262, 1146,  970,  200,  964,  114, 1166,
 /*  2060 */    22,   23, 1164, 1162,   24,   25, 1170, 1151,   34,   26,
 /*  2070 */   204,  546, 1169,  101,   27,  103,    7,  104, 1075, 1062,
 /*  2080 */  1060, 1064, 1117, 1065, 1116,  268,  269,   29,   41, 1185,
 /*  2090 */  1025,  867,  113,   30,  568,  929,  392,  144,  178,  270,
 /*  2100 */   271, 1184, 1247, 1247, 1247, 1247, 1247, 1247, 1247, 1247,
 /*  2110 */  1247, 1247, 1247, 1605,
};
static const YYCODETYPE yy_lookahead[] = {
 /*     0 */   194,  194,  194,  275,  276,  277,  194,  275,  276,  277,
 /*    10 */   194,  224,  220,  226,  207,  211,  212,  213,  194,   19,
 /*    20 */   220,  234,  217,  217,  218,  217,  218,  194,  296,  217,
 /*    30 */   218,   31,  194,  217,  218,  194,  229,  214,  231,   39,
 /*    40 */   207,  217,  218,   43,   44,   45,   46,   47,   48,   49,
 /*    50 */    50,   51,   52,   53,   54,   55,   56,   57,  194,   19,
 /*    60 */   186,  187,  188,  189,  190,  191,  254,  275,  276,  277,
 /*    70 */   196,  194,  198,  194,  262,  275,  276,  277,  254,  205,
 /*    80 */   239,  205,   81,   43,   44,   45,   46,   47,   48,   49,
 /*    90 */    50,   51,   52,   53,   54,   55,   56,   57,  275,  276,
 /*   100 */   277,  263,  102,  103,  104,  105,  106,  107,  108,  109,
 /*   110 */   110,  111,  112,  113,  240,  241,  240,  241,  211,  212,
 /*   120 */   213,  315,  316,  315,   59,  317,   86,  253,   88,  253,
 /*   130 */    19,  315,  316,  257,  258,  113,   25,   72,  297,  138,
 /*   140 */   139,  267,  102,  103,  104,  105,  106,  107,  108,  109,
 /*   150 */   110,  111,  112,  113,   43,   44,   45,   46,   47,   48,
 /*   160 */    49,   50,   51,   52,   53,   54,   55,   56,   57,   81,
 /*   170 */   293,   59,  293,  299,  108,  109,  110,  111,  112,  113,
 /*   180 */    69,  116,  117,  118,   72,  106,  107,  194,  111,  112,
 /*   190 */   113,   54,   55,   56,   57,   58,  102,  103,  104,  105,
 /*   200 */   106,  107,  108,  109,  110,  111,  112,  113,  120,  217,
 /*   210 */   217,  218,   22,  102,  103,  104,  105,  106,  107,  108,
 /*   220 */   109,  110,  111,  112,  113,  232,  138,  139,  116,  117,
 /*   230 */   118,   23,  153,   19,  155,   54,   55,   56,   57,  102,
 /*   240 */   103,  104,  105,  106,  107,  108,  109,  110,  111,  112,
 /*   250 */   113,  128,  129,   46,   47,   48,   49,   43,   44,   45,
 /*   260 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
 /*   270 */    56,   57,  127,  128,  129,   59,  194,   19,  165,  166,
 /*   280 */   194,   67,   24,  102,  103,  104,  105,  106,  107,  108,
 /*   290 */   109,  110,  111,  112,  113,   73,  106,  107,   59,  217,
 /*   300 */   218,   43,   44,   45,   46,   47,   48,   49,   50,   51,
 /*   310 */    52,   53,   54,   55,   56,   57,  102,  103,  104,  105,
 /*   320 */   106,  107,  108,  109,  110,  111,  112,  113,  121,   23,
 /*   330 */    59,   25,  116,  117,  118,  119,  254,  205,  122,  123,
 /*   340 */   124,   19,   20,  134,   22,  136,  137,   19,  132,  127,
 /*   350 */   128,  129,   24,  145,  194,  116,  117,  118,   36,  194,
 /*   360 */   102,  103,  104,  105,  106,  107,  108,  109,  110,  111,
 /*   370 */   112,  113,  240,  241,    7,    8,    9,  106,  107,   59,
 /*   380 */    19,   59,  217,  218,  214,  253,  115,  116,  117,  118,
 /*   390 */   151,  120,   26,   71,  274,  309,  310,  194,  194,  128,
 /*   400 */   314,  217,  270,   81,   43,   44,   45,   46,   47,   48,
 /*   410 */    49,   50,   51,   52,   53,   54,   55,   56,   57,  254,
 /*   420 */   217,  218,  100,   95,  153,   59,  155,  262,  106,  107,
 /*   430 */    25,  194,  312,  313,  194,  232,  114,  117,  116,  117,
 /*   440 */   118,  113,  194,  121,  284,  205,  242,  119,  120,  121,
 /*   450 */   122,  123,  124,  125,  217,  218,  194,  217,  218,  131,
 /*   460 */   138,  139,  292,  102,  103,  104,  105,  106,  107,  108,
 /*   470 */   109,  110,  111,  112,  113,  153,  154,  155,  156,  157,
 /*   480 */   240,  241,  116,  117,  118,   76,  231,  194,   19,  216,
 /*   490 */   242,  254,   23,  253,  254,  202,   87,  224,   89,  262,
 /*   500 */   207,   92,  262,  310,  194,  183,  194,  314,   22,  305,
 /*   510 */    24,  150,   43,   44,   45,   46,   47,   48,   49,   50,
 /*   520 */    51,   52,   53,   54,   55,   56,   57,  217,  218,  217,
 /*   530 */   218,   19,  189,  119,  191,   23,  122,  123,  124,  196,
 /*   540 */    25,  198,  232,   73,  232,   59,  132,  142,  205,  236,
 /*   550 */   237,   81,  194,  305,  145,   43,   44,   45,   46,   47,
 /*   560 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   570 */   308,  102,  103,  104,  105,  106,  107,  108,  109,  110,
 /*   580 */   111,  112,  113,  240,  241,  106,  107,  108,  109,  110,
 /*   590 */   111,  112,  113,  194,   59,  194,  253,  127,   59,  250,
 /*   600 */   242,  252,   19,  117,  194,  194,   23,   22,  138,  139,
 /*   610 */   267,   22,  236,  237,  102,  103,  104,  105,  106,  107,
 /*   620 */   108,  109,  110,  111,  112,  113,   43,   44,   45,   46,
 /*   630 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   640 */    57,   19,  299,  108,   59,   23,  194,  194,   59,  194,
 /*   650 */    21,  116,  117,  118,  194,  116,  117,  118,  206,  204,
 /*   660 */   194,  206,   22,  305,  149,   43,   44,   45,   46,   47,
 /*   670 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   680 */   259,  199,  143,  217,  218,  102,  103,  104,  105,  106,
 /*   690 */   107,  108,  109,  110,  111,  112,  113,  194,  232,   59,
 /*   700 */   194,  116,  117,  118,   59,  116,  117,  118,   59,   80,
 /*   710 */   309,  310,   19,  194,  194,  314,   23,   22,  307,  308,
 /*   720 */   217,  218,   22,  263,  102,  103,  104,  105,  106,  107,
 /*   730 */   108,  109,  110,  111,  112,  113,   43,   44,   45,   46,
 /*   740 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   750 */    57,   19,  123,  233,   59,   23,  116,  117,  118,   59,
 /*   760 */   194,  116,  117,  118,  282,  116,  117,  118,  286,  263,
 /*   770 */   194,  194,  194,  302,  303,   43,   44,   45,   46,   47,
 /*   780 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   790 */   161,  194,  143,  217,  218,  102,  103,  104,  105,  106,
 /*   800 */   107,  108,  109,  110,  111,  112,  113,  194,  232,  194,
 /*   810 */   194,  116,  117,  118,  217,  218,  116,  117,  118,  242,
 /*   820 */    25,  270,   19,   23,  305,   25,   23,  194,  205,  232,
 /*   830 */   205,   35,  217,  218,  102,  103,  104,  105,  106,  107,
 /*   840 */   108,  109,  110,  111,  112,  113,   43,   44,   45,   46,
 /*   850 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   860 */    57,   19,   66,  240,  241,  240,  241,  240,  241,  254,
 /*   870 */    74,  240,  241,  245,   25,  115,  253,  264,  253,  194,
 /*   880 */   253,   22,  305,  255,  253,   43,   44,   45,   46,   47,
 /*   890 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   900 */   194,  214,  217,  218,  144,  102,  103,  104,  105,  106,
 /*   910 */   107,  108,  109,  110,  111,  112,  113,  232,  118,  188,
 /*   920 */   189,  190,  191,  217,  218,   76,  130,  196,   16,  198,
 /*   930 */   194,  310,   19,  138,  139,  314,  205,  194,   89,  260,
 /*   940 */   261,   92,  205,  143,  102,  103,  104,  105,  106,  107,
 /*   950 */   108,  109,  110,  111,  112,  113,   43,   44,   45,   46,
 /*   960 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   970 */    57,  240,  241,  194,  287,  239,   19,  240,  241,  292,
 /*   980 */   127,  128,  129,   11,  253,  279,  194,   59,   19,   77,
 /*   990 */   253,   79,   22,   23,  227,   25,  217,  218,  267,  205,
 /*  1000 */   141,  159,   45,   46,   47,   48,   49,   50,   51,   52,
 /*  1010 */    53,   54,   55,   56,   57,  102,  103,  104,  105,  106,
 /*  1020 */   107,  108,  109,  110,  111,  112,  113,  194,  100,  194,
 /*  1030 */   299,  239,  194,  254,  240,  241,   22,   23,  194,   25,
 /*  1040 */   205,  194,  205,   12,  116,  117,   16,  253,  194,  121,
 /*  1050 */   217,  218,  217,  218,   25,  217,  218,  274,   27,  102,
 /*  1060 */   103,  104,  105,  106,  107,  108,  109,  110,  111,  112,
 /*  1070 */   113,  101,  159,   42,  135,  240,  241,  240,  241,  140,
 /*  1080 */   194,  153,  154,  155,  115,  116,  239,  254,  253,  254,
 /*  1090 */   253,  194,   19,  239,   63,  312,  313,   24,  212,  213,
 /*  1100 */   128,  129,  261,  158,   73,  160,  265,   77,  264,   79,
 /*  1110 */   194,  183,   19,  144,  274,  101,   43,   44,   45,   46,
 /*  1120 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*  1130 */    57,  310,   19,  217,  218,  314,   43,   44,   45,   46,
 /*  1140 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*  1150 */    57,   22,  312,  313,  194,  126,   43,   44,   45,   46,
 /*  1160 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*  1170 */    57,  285,  212,  213,  194,  102,  103,  104,  105,  106,
 /*  1180 */   107,  108,  109,  110,  111,  112,  113,   19,   59,   25,
 /*  1190 */   293,  161,  194,  205,   76,  102,  103,  104,  105,  106,
 /*  1200 */   107,  108,  109,  110,  111,  112,  113,   89,  310,  194,
 /*  1210 */    92,   66,  314,  194,   46,  102,  103,  104,  105,  106,
 /*  1220 */   107,  108,  109,  110,  111,  112,  113,  100,  240,  241,
 /*  1230 */    85,  194,  217,  218,  310,   19,  217,  218,  314,   94,
 /*  1240 */   115,  253,  194,  261,  117,  285,  117,  265,  121,  269,
 /*  1250 */   194,   24,   29,  194,  217,  218,   33,   59,   22,   23,
 /*  1260 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
 /*  1270 */    54,   55,   56,   57,   76,  150,  217,  218,  194,   12,
 /*  1280 */   153,  154,  155,  115,  194,   87,   59,   89,   65,  194,
 /*  1290 */    92,  146,  194,  194,   27,  239,  194,  194,   19,  131,
 /*  1300 */   194,  217,  218,   15,  108,  194,  142,  217,  218,   42,
 /*  1310 */   183,  194,  217,  218,  116,  117,  118,  269,  102,  103,
 /*  1320 */   104,  105,  106,  107,  108,  109,  110,  111,  112,  113,
 /*  1330 */    63,  135,  233,  194,  217,  218,  140,  101,   19,   20,
 /*  1340 */   194,   22,  194,  145,  117,  194,  194,  194,   60,  194,
 /*  1350 */    25,   22,   23,  194,   22,   36,  217,  218,   19,   20,
 /*  1360 */   194,   22,  264,  217,  218,  217,  218,   48,  217,  218,
 /*  1370 */   194,  269,  217,  218,   22,   36,  217,  218,   59,  194,
 /*  1380 */   269,   31,  194,  217,  218,   53,  209,  210,  194,   39,
 /*  1390 */    71,  194,   46,  217,  218,  116,   59,  194,   59,  194,
 /*  1400 */   209,  210,  217,  218,   85,  217,  218,  194,  194,   90,
 /*  1410 */    71,  217,  218,   61,  217,  218,  264,  264,  194,  100,
 /*  1420 */   217,  218,  217,  218,   85,  106,  107,  194,  145,   90,
 /*  1430 */   101,  217,  218,  114,  245,  116,  117,  118,   19,  100,
 /*  1440 */   121,  217,  218,  118,  255,  106,  107,  164,   25,   19,
 /*  1450 */    20,  241,   22,  114,  117,  116,  117,  118,  194,   24,
 /*  1460 */   121,  115,  194,  253,  194,  194,   36,  194,  143,  138,
 /*  1470 */   139,   19,  153,  154,  155,  156,  157,  227,  300,  301,
 /*  1480 */   194,  217,  218,  257,  258,  217,  218,  217,  218,   59,
 /*  1490 */   217,  218,  153,  154,  155,  156,  157,  149,  150,    5,
 /*  1500 */   245,   71,  183,  245,   10,   11,   12,   13,   14,  194,
 /*  1510 */   255,   17,   22,  255,   24,   85,  194,  245,  129,   23,
 /*  1520 */    90,   25,  183,   99,   30,  227,   32,  255,  194,  194,
 /*  1530 */   100,  256,  217,  218,   40,  116,  106,  107,  194,  217,
 /*  1540 */   218,  152,   19,   20,  114,   22,  116,  117,  118,   97,
 /*  1550 */   194,  121,  217,  218,  194,  194,  194,  133,  129,   36,
 /*  1560 */   194,  217,  218,   23,   70,   25,  194,   23,  145,   25,
 /*  1570 */   120,  121,   78,  217,  218,   81,  141,  217,  218,  217,
 /*  1580 */   218,  152,   59,  153,  154,  155,  156,  157,    0,    1,
 /*  1590 */     2,  194,   98,    5,   71,   23,   59,   25,   10,   11,
 /*  1600 */    12,   13,   14,  194,   23,   17,   25,   23,   23,   25,
 /*  1610 */    25,  194,   23,  183,   25,    7,    8,  237,   30,  194,
 /*  1620 */    32,   19,   20,  100,   22,  121,  194,  133,   40,  106,
 /*  1630 */   107,  108,  138,  139,   59,  131,  194,  114,   36,  116,
 /*  1640 */   117,  118,  217,  218,  121,  194,   23,  194,   25,  217,
 /*  1650 */   218,  194,  194,   23,  117,   25,  162,  194,   70,  217,
 /*  1660 */   218,   59,   23,   23,   25,   25,   78,  194,  194,   81,
 /*  1670 */   217,  218,  194,   71,  217,  218,  153,  154,  155,  156,
 /*  1680 */   157,  194,   83,   84,  319,   23,   98,   25,  289,  194,
 /*  1690 */   217,  218,  117,   19,   20,  153,   22,  155,  153,  194,
 /*  1700 */   155,  194,  100,  194,  217,  218,  183,  194,  106,  107,
 /*  1710 */    36,  194,  217,  218,  194,  194,  114,  256,  116,  117,
 /*  1720 */   118,  133,  194,  121,  217,  218,  138,  139,  194,   23,
 /*  1730 */   194,   25,  194,   59,  217,  218,  288,  194,  217,  218,
 /*  1740 */   194,  194,  140,  194,  194,   71,  194,  194,  194,  194,
 /*  1750 */   162,  217,  218,  194,  194,  153,  154,  155,  156,  157,
 /*  1760 */   217,  218,  243,  217,  218,  192,  256,  256,  256,  244,
 /*  1770 */   298,  215,  272,  246,  100,  294,  268,  247,  272,  247,
 /*  1780 */   106,  107,  268,  294,  221,  183,  220,  272,  114,  220,
 /*  1790 */   116,  117,  118,    1,    2,  121,  272,    5,  230,  220,
 /*  1800 */   226,  260,   10,   11,   12,   13,   14,  246,  260,   17,
 /*  1810 */   281,  260,  250,  246,  140,  250,  197,  260,   60,  141,
 /*  1820 */   244,  201,   30,  201,   32,   38,  295,  153,  154,  155,
 /*  1830 */   156,  157,   40,  298,  201,  151,  150,  298,   22,   43,
 /*  1840 */   235,   18,  238,  201,  273,  238,  200,   19,   20,  271,
 /*  1850 */    22,  238,  238,  295,  284,   18,  149,  183,  247,  273,
 /*  1860 */   273,  271,   70,  247,   36,  247,  235,  235,  247,  201,
 /*  1870 */    78,  200,  158,   81,  291,   62,  201,  200,   22,  222,
 /*  1880 */   201,  290,  200,  222,  201,  200,  115,   59,  219,  219,
 /*  1890 */    98,  219,  228,   64,   22,  126,  165,   24,  225,   71,
 /*  1900 */   219,  225,  222,  306,  113,  313,  201,  219,  221,  219,
 /*  1910 */   219,  283,  283,   91,  222,   82,  318,  228,  318,  266,
 /*  1920 */   266,  148,  145,   22,  201,  133,  278,  280,  100,  147,
 /*  1930 */   138,  139,  158,   25,  106,  107,  146,  203,   13,  195,
 /*  1940 */   195,  247,  114,  250,  116,  117,  118,  251,  251,  121,
 /*  1950 */   249,  248,    6,  193,  162,  193,  193,  208,  223,  304,
 /*  1960 */   304,  301,  214,  208,  214,  214,  214,    4,  215,  223,
 /*  1970 */     3,  215,  208,  214,   22,  163,   15,   23,   16,   23,

 /*  1980 */   139,  153,  154,  155,  156,  157,  151,  130,  142,   25,
 /*  1990 */    24,   20,  144,   16,    1,  142,  130,  130,   61,  130,
 /*  2000 */   151,   53,   37,   53,   53,  116,   53,   34,    1,  141,
 /*  2010 */     5,  183,   22,  115,   25,  161,   75,   68,  141,   41,
 /*  2020 */   115,   24,   20,   68,  131,   19,   22,  125,   96,   59,
 /*  2030 */    22,   22,   37,   23,   22,   67,   67,   24,   22,   28,
 /*  2040 */    23,   67,   22,  149,   23,   23,   23,   22,   34,   25,
 /*  2050 */   141,   23,   23,   34,   97,  116,   22,  143,   25,   75,
 /*  2060 */    34,   34,   86,   88,   34,   34,   75,   23,   22,   34,
 /*  2070 */    25,   24,   93,   25,   34,  142,   44,  142,   23,   23,
 /*  2080 */    23,   23,   23,   11,   23,   25,   22,   22,   22,    1,
 /*  2090 */    23,   23,   22,   22,   25,  135,   15,   23,   25,  141,

 /*  2100 */   141,    1,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2110 */   320,  320,  320,  141,  320,  320,  320,  320,  320,  320,
 /*  2120 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2130 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2140 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2150 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2160 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2170 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2180 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2190 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2200 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2210 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2220 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2230 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2240 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2250 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2260 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2270 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2280 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
 /*  2290 */   320,  320,  320,  320,  320,  320,  320,  320,  320,  320,
};
#define YY_SHIFT_COUNT    (578)
#define YY_SHIFT_MIN      (0)
#define YY_SHIFT_MAX      (2100)
static const unsigned short int yy_shift_ofst[] = {
 /*     0 */  1792, 1588, 1494,  322,  322,    1, 1319, 1339, 1430, 1828,
 /*    10 */  1828, 1828,  470,    0,    0,  214, 1093, 1828, 1828, 1828,
 /*    20 */  1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
 /*    30 */  1828,  271,  271, 1198, 1198,  216,   88,    1,    1,    1,
 /*    40 */     1,    1,   40,  111,  258,  361,  469,  512,  583,  622,
 /*    50 */   693,  732,  803,  842,  913, 1073, 1093, 1093, 1093, 1093,
 /*    60 */  1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093,
 /*    70 */  1093, 1093, 1093, 1093, 1113, 1093, 1216,  957,  957, 1523,
 /*    80 */  1602, 1674, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
 /*    90 */  1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
 /*   100 */  1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
 /*   110 */  1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
 /*   120 */  1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
 /*   130 */  1828,  137,  181,  181,  181,  181,  181,  181,  181,   94,
 /*   140 */   479,   66,   65,  112,  366,  645,  645,  629, 1168,  645,
 /*   150 */   645,   79,   79,  645,  795,  795,  795,   77,  795,  123,
 /*   160 */   113,  113,  113,   22,   22, 2114, 2114,  328,  328,  328,
 /*   170 */   239,  585,  585,  585,  585, 1031, 1031,  409,  366,  970,
 /*   180 */  1014,  645,  645,  645,  645,  645,  645,  645,  645,  645,
 /*   190 */   645,  645,  645,  645,  645,  645,  645,  645,  645,  645,
 /*   200 */   645,  969,  849,  849,  645,  972, 1118, 1118, 1279, 1279,
 /*   210 */   320,  320, 1283, 1331, 2114, 2114, 2114, 2114, 2114, 2114,
 /*   220 */  2114,  928, 1127, 1127,  589,  414,  640,  535,  695,  539,
 /*   230 */   649,  700,  645,  645,  645,  645,  645,  645,  645,  645,
 /*   240 */   645,  645,  222,  645,  645,  645,  645,  645,  645,  645,
 /*   250 */   645,  645,  645,  645,  645,  796,  796,  796,  645,  645,
 /*   260 */   645,  800,  645,  645,  645,  486, 1145,  645,  645, 1267,
 /*   270 */   645,  645,  645,  645,  645,  645,  645,  645,  145, 1223,
 /*   280 */   209, 1227, 1227, 1227, 1227, 1325,  209,  209, 1196,  190,
 /*   290 */   367, 1288, 1125, 1348,  405, 1348, 1419,  515, 1125, 1125,
 /*   300 */   515, 1125,  405, 1419, 1029,  306, 1346, 1350, 1350, 1350,
 /*   310 */   760,  760,  760,  760, 1423, 1423,  945, 1164,  939, 1490,
 /*   320 */  1758, 1758, 1678, 1678, 1787, 1787, 1678, 1684, 1686, 1816,
 /*   330 */  1796, 1823, 1823, 1823, 1823, 1678, 1837, 1707, 1686, 1686,
 /*   340 */  1707, 1816, 1796, 1707, 1796, 1707, 1678, 1837, 1714, 1813,
 /*   350 */  1678, 1837, 1856, 1678, 1837, 1678, 1837, 1856, 1771, 1771,
 /*   360 */  1771, 1829, 1872, 1872, 1856, 1771, 1769, 1771, 1829, 1771,
 /*   370 */  1771, 1731, 1873, 1791, 1791, 1856, 1678, 1822, 1822, 1833,
 /*   380 */  1833, 1773, 1777, 1901, 1678, 1774, 1773, 1782, 1790, 1707,
 /*   390 */  1908, 1925, 1925, 1946, 1946, 1946, 2114, 2114, 2114, 2114,
 /*   400 */  2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114,
 /*   410 */  2114,  207, 1030, 1236, 1329,  912,  853, 1129, 1496, 1424,
 /*   420 */  1332, 1435, 1389, 1429, 1540, 1352, 1544, 1581, 1584, 1585,
 /*   430 */  1589, 1623, 1337, 1450, 1608, 1504, 1572,  208, 1452, 1537,
 /*   440 */  1630, 1639, 1599, 1640, 1542, 1545, 1662, 1706, 1575,  859,
 /*   450 */  1963, 1967, 1952, 1812, 1961, 1962, 1954, 1956, 1841, 1835,
 /*   460 */  1857, 1964, 1964, 1966, 1846, 1971, 1848, 1977, 1993, 1853,
 /*   470 */  1866, 1964, 1867, 1937, 1965, 1964, 1849, 1948, 1950, 1951,
 /*   480 */  1953, 1869, 1889, 1973, 1868, 2007, 2005, 1990, 1898, 1854,
 /*   490 */  1949, 1989, 1955, 1941, 1978, 1877, 1905, 1997, 2002, 2006,
 /*   500 */  1893, 1902, 2004, 1968, 2008, 2009, 2010, 2012, 1969, 1970,
 /*   510 */  2013, 1932, 2011, 2016, 1974, 1995, 2017, 2014, 1894, 2020,
 /*   520 */  2021, 2022, 2024, 2023, 2025, 1957, 1909, 2028, 2029, 1939,
 /*   530 */  2019, 2034, 1914, 2033, 2026, 2027, 2030, 2031, 1975, 1984,
 /*   540 */  1976, 2032, 1991, 1979, 2035, 2044, 2046, 2047, 2045, 2048,
 /*   550 */  2040, 1933, 1935, 2055, 2033, 2056, 2057, 2058, 2059, 2060,
 /*   560 */  2061, 2064, 2072, 2065, 2066, 2067, 2068, 2070, 2071, 2069,
 /*   570 */  1960, 1958, 1959, 1972, 2073, 2074, 2081, 2088, 2100,
};
#define YY_REDUCE_COUNT (410)
#define YY_REDUCE_MIN   (-272)
#define YY_REDUCE_MAX   (1764)
static const short yy_reduce_ofst[] = {
 /*     0 */  -126,  731,  343,  240,  835, -124, -194, -192, -184, -188,
 /*    10 */   165,  237,  132, -208, -200, -268, -177,   -7,  203,  310,
 /*    20 */   312,  466, -176,  576,  597,   82,  615,  685,  706,  779,
 /*    30 */   833,  886,  960,   86,  401, -193,  623,  625,  737,  794,
 /*    40 */   837,  988, -272, -272, -272, -272, -272, -272, -272, -272,
 /*    50 */  -272, -272, -272, -272, -272, -272, -272, -272, -272, -272,
 /*    60 */  -272, -272, -272, -272, -272, -272, -272, -272, -272, -272,
 /*    70 */  -272, -272, -272, -272, -272, -272, -272, -272, -272,  503,
 /*    80 */   838,  916, 1015, 1019, 1037, 1059, 1084, 1090, 1095, 1117,
 /*    90 */  1139, 1146, 1148, 1151, 1155, 1159, 1166, 1176, 1185, 1188,
 /*   100 */  1194, 1197, 1203, 1205, 1214, 1224, 1264, 1268, 1270, 1273,
 /*   110 */  1315, 1322, 1335, 1344, 1356, 1360, 1362, 1425, 1432, 1442,
 /*   120 */  1453, 1457, 1473, 1487, 1495, 1507, 1517, 1521, 1534, 1543,
 /*   130 */  1546, -272, -272, -272, -272, -272, -272, -272, -272, -272,
 /*   140 */  -272, -272,  204,  248,  455, -159,  358,  482, -213,  577,
 /*   150 */   411, -196,  -93,  293,  627,  631,  627, -272,  631,  687,
 /*   160 */   120,  783,  840, -272, -272, -272, -272,  273,  273,  273,
 /*   170 */   160,  980, 1048, 1102, 1111,  313,  376,  193,  452,  471,
 /*   180 */   471, -167, -162,  460,  506,  736,  792,  847,  854, -123,
 /*   190 */   613, -121,  844, 1098,  897, 1152, 1056,  520, 1099,  519,
 /*   200 */  1153,  679,  621,  821,  262,  170,  898,  924,  841,  982,
 /*   210 */  1177, 1191,  349, 1210, 1178,  628, 1189, 1255, 1258, 1226,
 /*   220 */  1272, -195,   -8,  184, -136,  255,  399,  410,  453,  566,
 /*   230 */   578,  616,  633,  743,  998, 1103, 1106, 1213, 1233, 1271,
 /*   240 */  1286, 1334,  551, 1361, 1366, 1372, 1397, 1409, 1417, 1451,
 /*   250 */  1458, 1463, 1474, 1505, 1509,  767, 1250, 1298, 1478, 1513,
 /*   260 */  1520,  421, 1528, 1536, 1538, 1275, 1365, 1547, 1549, 1380,
 /*   270 */  1550,  410, 1552, 1553, 1554, 1555, 1559, 1560, 1399, 1448,
 /*   280 */  1519, 1461, 1510, 1511, 1512,  421, 1519, 1519, 1525, 1556,
 /*   290 */  1573, 1472, 1500, 1508, 1527, 1514, 1481, 1530, 1506, 1515,
 /*   300 */  1532, 1524, 1561, 1489, 1563, 1568, 1574, 1566, 1569, 1579,
 /*   310 */  1541, 1548, 1551, 1557, 1562, 1565, 1529, 1567, 1576, 1619,
 /*   320 */  1535, 1539, 1620, 1622, 1531, 1558, 1633, 1570, 1571, 1578,
 /*   330 */  1605, 1604, 1607, 1613, 1614, 1642, 1646, 1611, 1586, 1587,
 /*   340 */  1616, 1590, 1631, 1618, 1632, 1621, 1668, 1671, 1583, 1591,
 /*   350 */  1675, 1677, 1657, 1679, 1682, 1683, 1685, 1661, 1669, 1670,
 /*   360 */  1672, 1664, 1673, 1676, 1680, 1681, 1687, 1688, 1689, 1690,
 /*   370 */  1691, 1592, 1597, 1628, 1629, 1692, 1705, 1598, 1600, 1653,
 /*   380 */  1654, 1696, 1693, 1648, 1723, 1647, 1697, 1701, 1703, 1694,
 /*   390 */  1734, 1744, 1745, 1760, 1762, 1763, 1655, 1656, 1660, 1749,
 /*   400 */  1748, 1750, 1751, 1752, 1755, 1735, 1746, 1753, 1756, 1759,
 /*   410 */  1764,
};
static const YYACTIONTYPE yy_default[] = {
 /*     0 */  1651, 1651, 1651, 1480, 1245, 1356, 1245, 1245, 1245, 1480,
 /*    10 */  1480, 1480, 1245, 1386, 1386, 1533, 1278, 1245, 1245, 1245,
 /*    20 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1479, 1245,
 /*    30 */  1245, 1245, 1245, 1566, 1566, 1245, 1245, 1245, 1245, 1245,
 /*    40 */  1245, 1245, 1245, 1395, 1245, 1402, 1245, 1245, 1245, 1245,
 /*    50 */  1245, 1481, 1482, 1245, 1245, 1245, 1532, 1534, 1497, 1409,
 /*    60 */  1408, 1407, 1406, 1515, 1374, 1400, 1393, 1397, 1476, 1477,
 /*    70 */  1475, 1629, 1482, 1481, 1245, 1396, 1444, 1460, 1443, 1245,
 /*    80 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245,
 /*    90 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   100 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   110 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   120 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   130 */  1245, 1452, 1459, 1458, 1457, 1466, 1456, 1453, 1446, 1445,
 /*   140 */  1447, 1448, 1245, 1245, 1269, 1245, 1245, 1266, 1320, 1245,
 /*   150 */  1245, 1245, 1245, 1245, 1552, 1551, 1245, 1449, 1245, 1278,
 /*   160 */  1437, 1436, 1435, 1463, 1450, 1462, 1461, 1540, 1603, 1602,
 /*   170 */  1498, 1245, 1245, 1245, 1245, 1245, 1245, 1566, 1245, 1245,
 /*   180 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   190 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   200 */  1245, 1376, 1566, 1566, 1245, 1278, 1566, 1566, 1377, 1377,
 /*   210 */  1274, 1274, 1380, 1245, 1547, 1347, 1347, 1347, 1347, 1356,
 /*   220 */  1347, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   230 */  1245, 1245, 1245, 1245, 1245, 1245, 1537, 1535, 1245, 1245,
 /*   240 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   250 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   260 */  1245, 1245, 1245, 1245, 1245, 1352, 1245, 1245, 1245, 1245,
 /*   270 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1596, 1245, 1510,
 /*   280 */  1334, 1352, 1352, 1352, 1352, 1354, 1335, 1333, 1346, 1279,
 /*   290 */  1252, 1643, 1412, 1401, 1353, 1401, 1640, 1399, 1412, 1412,
 /*   300 */  1399, 1412, 1353, 1640, 1295, 1618, 1290, 1386, 1386, 1386,
 /*   310 */  1376, 1376, 1376, 1376, 1380, 1380, 1478, 1353, 1346, 1245,
 /*   320 */  1643, 1643, 1362, 1362, 1642, 1642, 1362, 1498, 1626, 1421,
 /*   330 */  1323, 1329, 1329, 1329, 1329, 1362, 1263, 1399, 1626, 1626,
 /*   340 */  1399, 1421, 1323, 1399, 1323, 1399, 1362, 1263, 1514, 1637,
 /*   350 */  1362, 1263, 1488, 1362, 1263, 1362, 1263, 1488, 1321, 1321,
 /*   360 */  1321, 1310, 1245, 1245, 1488, 1321, 1295, 1321, 1310, 1321,
 /*   370 */  1321, 1584, 1245, 1492, 1492, 1488, 1362, 1576, 1576, 1389,
 /*   380 */  1389, 1394, 1380, 1483, 1362, 1245, 1394, 1392, 1390, 1399,
 /*   390 */  1313, 1599, 1599, 1595, 1595, 1595, 1648, 1648, 1547, 1611,
 /*   400 */  1278, 1278, 1278, 1278, 1611, 1297, 1297, 1279, 1279, 1278,
 /*   410 */  1611, 1245, 1245, 1245, 1245, 1245, 1245, 1606, 1245, 1542,
 /*   420 */  1499, 1366, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   430 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1553, 1245,
 /*   440 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1426,
 /*   450 */  1245, 1248, 1544, 1245, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   460 */  1245, 1403, 1404, 1367, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   470 */  1245, 1418, 1245, 1245, 1245, 1413, 1245, 1245, 1245, 1245,
 /*   480 */  1245, 1245, 1245, 1245, 1639, 1245, 1245, 1245, 1245, 1245,
 /*   490 */  1245, 1513, 1512, 1245, 1245, 1364, 1245, 1245, 1245, 1245,
 /*   500 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1293,
 /*   510 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   520 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   530 */  1245, 1245, 1245, 1391, 1245, 1245, 1245, 1245, 1245, 1245,
 /*   540 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1581, 1381,
 /*   550 */  1245, 1245, 1245, 1245, 1630, 1245, 1245, 1245, 1245, 1245,
 /*   560 */  1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1622,
 /*   570 */  1337, 1427, 1245, 1430, 1267, 1245, 1257, 1245, 1245,
};
/********** 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.
172714
172715
172716
172717
172718
172719
172720

172721
172722
172723
172724
172725
172726
172727
    0,  /*   REGISTER => nothing */
    0,  /*     VECTOR => nothing */
    0,  /* SELECT_COLUMN => nothing */
    0,  /* IF_NULL_ROW => nothing */
    0,  /*   ASTERISK => nothing */
    0,  /*       SPAN => nothing */
    0,  /*      ERROR => nothing */

    0,  /*      SPACE => nothing */
    0,  /*    ILLEGAL => nothing */
};
#endif /* YYFALLBACK */

/* The following structure represents a single element of the
** parser's stack.  Information stored includes:







>







172997
172998
172999
173000
173001
173002
173003
173004
173005
173006
173007
173008
173009
173010
173011
    0,  /*   REGISTER => nothing */
    0,  /*     VECTOR => nothing */
    0,  /* SELECT_COLUMN => nothing */
    0,  /* IF_NULL_ROW => nothing */
    0,  /*   ASTERISK => nothing */
    0,  /*       SPAN => nothing */
    0,  /*      ERROR => nothing */
    0,  /*    QNUMBER => nothing */
    0,  /*      SPACE => nothing */
    0,  /*    ILLEGAL => nothing */
};
#endif /* YYFALLBACK */

/* The following structure represents a single element of the
** parser's stack.  Information stored includes:
172982
172983
172984
172985
172986
172987
172988
172989
172990
172991
172992
172993
172994
172995
172996
172997
172998
172999
173000
173001
173002
173003
173004
173005
173006
173007
173008
173009
173010
173011
173012
173013
173014
173015
173016
173017
173018
173019
173020
173021
173022
173023
173024
173025
173026
173027
173028
173029
173030
173031
173032
173033
173034
173035
173036
173037
173038
173039
173040
173041
173042
173043
173044
173045
173046
173047
173048
173049
173050
173051
173052
173053
173054
173055
173056
173057
173058
173059
173060
173061
173062
173063
173064
173065
173066
173067
173068
173069
173070
173071
173072
173073
173074
173075
173076
173077
173078
173079
173080
173081
173082
173083
173084
173085
173086
173087
173088
173089
173090
173091
173092
173093
173094
173095
173096
173097
173098
173099
173100
173101
173102
173103
173104
173105
173106
173107
173108
173109
173110
173111
173112
173113
173114
173115
173116
173117
173118
173119
173120
173121
173122
173123
173124

173125
173126
173127
173128
173129
173130
173131
  /*  176 */ "REGISTER",
  /*  177 */ "VECTOR",
  /*  178 */ "SELECT_COLUMN",
  /*  179 */ "IF_NULL_ROW",
  /*  180 */ "ASTERISK",
  /*  181 */ "SPAN",
  /*  182 */ "ERROR",
  /*  183 */ "SPACE",
  /*  184 */ "ILLEGAL",
  /*  185 */ "input",
  /*  186 */ "cmdlist",
  /*  187 */ "ecmd",
  /*  188 */ "cmdx",
  /*  189 */ "explain",
  /*  190 */ "cmd",
  /*  191 */ "transtype",
  /*  192 */ "trans_opt",
  /*  193 */ "nm",
  /*  194 */ "savepoint_opt",
  /*  195 */ "create_table",
  /*  196 */ "create_table_args",
  /*  197 */ "createkw",
  /*  198 */ "temp",
  /*  199 */ "ifnotexists",
  /*  200 */ "dbnm",
  /*  201 */ "columnlist",
  /*  202 */ "conslist_opt",
  /*  203 */ "table_option_set",
  /*  204 */ "select",
  /*  205 */ "table_option",
  /*  206 */ "columnname",
  /*  207 */ "carglist",
  /*  208 */ "typetoken",
  /*  209 */ "typename",
  /*  210 */ "signed",
  /*  211 */ "plus_num",
  /*  212 */ "minus_num",
  /*  213 */ "scanpt",
  /*  214 */ "scantok",
  /*  215 */ "ccons",
  /*  216 */ "term",
  /*  217 */ "expr",
  /*  218 */ "onconf",
  /*  219 */ "sortorder",
  /*  220 */ "autoinc",
  /*  221 */ "eidlist_opt",
  /*  222 */ "refargs",
  /*  223 */ "defer_subclause",
  /*  224 */ "generated",
  /*  225 */ "refarg",
  /*  226 */ "refact",
  /*  227 */ "init_deferred_pred_opt",
  /*  228 */ "conslist",
  /*  229 */ "tconscomma",
  /*  230 */ "tcons",
  /*  231 */ "sortlist",
  /*  232 */ "eidlist",
  /*  233 */ "defer_subclause_opt",
  /*  234 */ "orconf",
  /*  235 */ "resolvetype",
  /*  236 */ "raisetype",
  /*  237 */ "ifexists",
  /*  238 */ "fullname",
  /*  239 */ "selectnowith",
  /*  240 */ "oneselect",
  /*  241 */ "wqlist",
  /*  242 */ "multiselect_op",
  /*  243 */ "distinct",
  /*  244 */ "selcollist",
  /*  245 */ "from",
  /*  246 */ "where_opt",
  /*  247 */ "groupby_opt",
  /*  248 */ "having_opt",
  /*  249 */ "orderby_opt",
  /*  250 */ "limit_opt",
  /*  251 */ "window_clause",
  /*  252 */ "values",
  /*  253 */ "nexprlist",
  /*  254 */ "sclp",
  /*  255 */ "as",
  /*  256 */ "seltablist",
  /*  257 */ "stl_prefix",
  /*  258 */ "joinop",
  /*  259 */ "on_using",
  /*  260 */ "indexed_by",
  /*  261 */ "exprlist",
  /*  262 */ "xfullname",
  /*  263 */ "idlist",
  /*  264 */ "indexed_opt",
  /*  265 */ "nulls",
  /*  266 */ "with",
  /*  267 */ "where_opt_ret",
  /*  268 */ "setlist",
  /*  269 */ "insert_cmd",
  /*  270 */ "idlist_opt",
  /*  271 */ "upsert",
  /*  272 */ "returning",
  /*  273 */ "filter_over",
  /*  274 */ "likeop",
  /*  275 */ "between_op",
  /*  276 */ "in_op",
  /*  277 */ "paren_exprlist",
  /*  278 */ "case_operand",
  /*  279 */ "case_exprlist",
  /*  280 */ "case_else",
  /*  281 */ "uniqueflag",
  /*  282 */ "collate",
  /*  283 */ "vinto",
  /*  284 */ "nmnum",
  /*  285 */ "trigger_decl",
  /*  286 */ "trigger_cmd_list",
  /*  287 */ "trigger_time",
  /*  288 */ "trigger_event",
  /*  289 */ "foreach_clause",
  /*  290 */ "when_clause",
  /*  291 */ "trigger_cmd",
  /*  292 */ "trnm",
  /*  293 */ "tridxby",
  /*  294 */ "database_kw_opt",
  /*  295 */ "key_opt",
  /*  296 */ "add_column_fullname",
  /*  297 */ "kwcolumn_opt",
  /*  298 */ "create_vtab",
  /*  299 */ "vtabarglist",
  /*  300 */ "vtabarg",
  /*  301 */ "vtabargtoken",
  /*  302 */ "lp",
  /*  303 */ "anylist",
  /*  304 */ "wqitem",
  /*  305 */ "wqas",
  /*  306 */ "windowdefn_list",
  /*  307 */ "windowdefn",
  /*  308 */ "window",
  /*  309 */ "frame_opt",
  /*  310 */ "part_opt",
  /*  311 */ "filter_clause",
  /*  312 */ "over_clause",
  /*  313 */ "range_or_rows",
  /*  314 */ "frame_bound",
  /*  315 */ "frame_bound_s",
  /*  316 */ "frame_bound_e",
  /*  317 */ "frame_exclude_opt",
  /*  318 */ "frame_exclude",

};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */

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







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







173266
173267
173268
173269
173270
173271
173272
173273
173274
173275
173276
173277
173278
173279
173280
173281
173282
173283
173284
173285
173286
173287
173288
173289
173290
173291
173292
173293
173294
173295
173296
173297
173298
173299
173300
173301
173302
173303
173304
173305
173306
173307
173308
173309
173310
173311
173312
173313
173314
173315
173316
173317
173318
173319
173320
173321
173322
173323
173324
173325
173326
173327
173328
173329
173330
173331
173332
173333
173334
173335
173336
173337
173338
173339
173340
173341
173342
173343
173344
173345
173346
173347
173348
173349
173350
173351
173352
173353
173354
173355
173356
173357
173358
173359
173360
173361
173362
173363
173364
173365
173366
173367
173368
173369
173370
173371
173372
173373
173374
173375
173376
173377
173378
173379
173380
173381
173382
173383
173384
173385
173386
173387
173388
173389
173390
173391
173392
173393
173394
173395
173396
173397
173398
173399
173400
173401
173402
173403
173404
173405
173406
173407
173408
173409
173410
173411
173412
173413
173414
173415
173416
  /*  176 */ "REGISTER",
  /*  177 */ "VECTOR",
  /*  178 */ "SELECT_COLUMN",
  /*  179 */ "IF_NULL_ROW",
  /*  180 */ "ASTERISK",
  /*  181 */ "SPAN",
  /*  182 */ "ERROR",
  /*  183 */ "QNUMBER",
  /*  184 */ "SPACE",
  /*  185 */ "ILLEGAL",
  /*  186 */ "input",
  /*  187 */ "cmdlist",
  /*  188 */ "ecmd",
  /*  189 */ "cmdx",
  /*  190 */ "explain",
  /*  191 */ "cmd",
  /*  192 */ "transtype",
  /*  193 */ "trans_opt",
  /*  194 */ "nm",
  /*  195 */ "savepoint_opt",
  /*  196 */ "create_table",
  /*  197 */ "create_table_args",
  /*  198 */ "createkw",
  /*  199 */ "temp",
  /*  200 */ "ifnotexists",
  /*  201 */ "dbnm",
  /*  202 */ "columnlist",
  /*  203 */ "conslist_opt",
  /*  204 */ "table_option_set",
  /*  205 */ "select",
  /*  206 */ "table_option",
  /*  207 */ "columnname",
  /*  208 */ "carglist",
  /*  209 */ "typetoken",
  /*  210 */ "typename",
  /*  211 */ "signed",
  /*  212 */ "plus_num",
  /*  213 */ "minus_num",
  /*  214 */ "scanpt",
  /*  215 */ "scantok",
  /*  216 */ "ccons",
  /*  217 */ "term",
  /*  218 */ "expr",
  /*  219 */ "onconf",
  /*  220 */ "sortorder",
  /*  221 */ "autoinc",
  /*  222 */ "eidlist_opt",
  /*  223 */ "refargs",
  /*  224 */ "defer_subclause",
  /*  225 */ "generated",
  /*  226 */ "refarg",
  /*  227 */ "refact",
  /*  228 */ "init_deferred_pred_opt",
  /*  229 */ "conslist",
  /*  230 */ "tconscomma",
  /*  231 */ "tcons",
  /*  232 */ "sortlist",
  /*  233 */ "eidlist",
  /*  234 */ "defer_subclause_opt",
  /*  235 */ "orconf",
  /*  236 */ "resolvetype",
  /*  237 */ "raisetype",
  /*  238 */ "ifexists",
  /*  239 */ "fullname",
  /*  240 */ "selectnowith",
  /*  241 */ "oneselect",
  /*  242 */ "wqlist",
  /*  243 */ "multiselect_op",
  /*  244 */ "distinct",
  /*  245 */ "selcollist",
  /*  246 */ "from",
  /*  247 */ "where_opt",
  /*  248 */ "groupby_opt",
  /*  249 */ "having_opt",
  /*  250 */ "orderby_opt",
  /*  251 */ "limit_opt",
  /*  252 */ "window_clause",
  /*  253 */ "values",
  /*  254 */ "nexprlist",
  /*  255 */ "sclp",
  /*  256 */ "as",
  /*  257 */ "seltablist",
  /*  258 */ "stl_prefix",
  /*  259 */ "joinop",
  /*  260 */ "on_using",
  /*  261 */ "indexed_by",
  /*  262 */ "exprlist",
  /*  263 */ "xfullname",
  /*  264 */ "idlist",
  /*  265 */ "indexed_opt",
  /*  266 */ "nulls",
  /*  267 */ "with",
  /*  268 */ "where_opt_ret",
  /*  269 */ "setlist",
  /*  270 */ "insert_cmd",
  /*  271 */ "idlist_opt",
  /*  272 */ "upsert",
  /*  273 */ "returning",
  /*  274 */ "filter_over",
  /*  275 */ "likeop",
  /*  276 */ "between_op",
  /*  277 */ "in_op",
  /*  278 */ "paren_exprlist",
  /*  279 */ "case_operand",
  /*  280 */ "case_exprlist",
  /*  281 */ "case_else",
  /*  282 */ "uniqueflag",
  /*  283 */ "collate",
  /*  284 */ "vinto",
  /*  285 */ "nmnum",
  /*  286 */ "trigger_decl",
  /*  287 */ "trigger_cmd_list",
  /*  288 */ "trigger_time",
  /*  289 */ "trigger_event",
  /*  290 */ "foreach_clause",
  /*  291 */ "when_clause",
  /*  292 */ "trigger_cmd",
  /*  293 */ "trnm",
  /*  294 */ "tridxby",
  /*  295 */ "database_kw_opt",
  /*  296 */ "key_opt",
  /*  297 */ "add_column_fullname",
  /*  298 */ "kwcolumn_opt",
  /*  299 */ "create_vtab",
  /*  300 */ "vtabarglist",
  /*  301 */ "vtabarg",
  /*  302 */ "vtabargtoken",
  /*  303 */ "lp",
  /*  304 */ "anylist",
  /*  305 */ "wqitem",
  /*  306 */ "wqas",
  /*  307 */ "windowdefn_list",
  /*  308 */ "windowdefn",
  /*  309 */ "window",
  /*  310 */ "frame_opt",
  /*  311 */ "part_opt",
  /*  312 */ "filter_clause",
  /*  313 */ "over_clause",
  /*  314 */ "range_or_rows",
  /*  315 */ "frame_bound",
  /*  316 */ "frame_bound_s",
  /*  317 */ "frame_bound_e",
  /*  318 */ "frame_exclude_opt",
  /*  319 */ "frame_exclude",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */

#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
*/
static const char *const yyRuleName[] = {
173465
173466
173467
173468
173469
173470
173471

173472
173473
173474
173475
173476
173477
173478
173479
173480
173481
173482
173483
173484
173485
173486
173487
173488
173489
173490
173491
173492
173493
173494
173495
173496
173497
173498
173499
173500
173501
173502
173503
173504
173505
173506
173507
173508
173509
173510
173511
173512
173513
173514
173515
173516
173517
173518

173519
173520
173521
173522
173523
173524
173525
173526
173527
173528
173529
173530
173531
173532
173533
173534
173535
173536
173537
173538
173539
173540
173541
173542
173543
 /* 333 */ "window_clause ::= WINDOW windowdefn_list",
 /* 334 */ "filter_over ::= filter_clause over_clause",
 /* 335 */ "filter_over ::= over_clause",
 /* 336 */ "filter_over ::= filter_clause",
 /* 337 */ "over_clause ::= OVER LP window RP",
 /* 338 */ "over_clause ::= OVER nm",
 /* 339 */ "filter_clause ::= FILTER LP WHERE expr RP",

 /* 340 */ "input ::= cmdlist",
 /* 341 */ "cmdlist ::= cmdlist ecmd",
 /* 342 */ "cmdlist ::= ecmd",
 /* 343 */ "ecmd ::= SEMI",
 /* 344 */ "ecmd ::= cmdx SEMI",
 /* 345 */ "ecmd ::= explain cmdx SEMI",
 /* 346 */ "trans_opt ::=",
 /* 347 */ "trans_opt ::= TRANSACTION",
 /* 348 */ "trans_opt ::= TRANSACTION nm",
 /* 349 */ "savepoint_opt ::= SAVEPOINT",
 /* 350 */ "savepoint_opt ::=",
 /* 351 */ "cmd ::= create_table create_table_args",
 /* 352 */ "table_option_set ::= table_option",
 /* 353 */ "columnlist ::= columnlist COMMA columnname carglist",
 /* 354 */ "columnlist ::= columnname carglist",
 /* 355 */ "nm ::= ID|INDEXED|JOIN_KW",
 /* 356 */ "nm ::= STRING",
 /* 357 */ "typetoken ::= typename",
 /* 358 */ "typename ::= ID|STRING",
 /* 359 */ "signed ::= plus_num",
 /* 360 */ "signed ::= minus_num",
 /* 361 */ "carglist ::= carglist ccons",
 /* 362 */ "carglist ::=",
 /* 363 */ "ccons ::= NULL onconf",
 /* 364 */ "ccons ::= GENERATED ALWAYS AS generated",
 /* 365 */ "ccons ::= AS generated",
 /* 366 */ "conslist_opt ::= COMMA conslist",
 /* 367 */ "conslist ::= conslist tconscomma tcons",
 /* 368 */ "conslist ::= tcons",
 /* 369 */ "tconscomma ::=",
 /* 370 */ "defer_subclause_opt ::= defer_subclause",
 /* 371 */ "resolvetype ::= raisetype",
 /* 372 */ "selectnowith ::= oneselect",
 /* 373 */ "oneselect ::= values",
 /* 374 */ "sclp ::= selcollist COMMA",
 /* 375 */ "as ::= ID|STRING",
 /* 376 */ "indexed_opt ::= indexed_by",
 /* 377 */ "returning ::=",
 /* 378 */ "expr ::= term",
 /* 379 */ "likeop ::= LIKE_KW|MATCH",
 /* 380 */ "case_operand ::= expr",
 /* 381 */ "exprlist ::= nexprlist",
 /* 382 */ "nmnum ::= plus_num",
 /* 383 */ "nmnum ::= nm",
 /* 384 */ "nmnum ::= ON",
 /* 385 */ "nmnum ::= DELETE",
 /* 386 */ "nmnum ::= DEFAULT",

 /* 387 */ "plus_num ::= INTEGER|FLOAT",
 /* 388 */ "foreach_clause ::=",
 /* 389 */ "foreach_clause ::= FOR EACH ROW",
 /* 390 */ "trnm ::= nm",
 /* 391 */ "tridxby ::=",
 /* 392 */ "database_kw_opt ::= DATABASE",
 /* 393 */ "database_kw_opt ::=",
 /* 394 */ "kwcolumn_opt ::=",
 /* 395 */ "kwcolumn_opt ::= COLUMNKW",
 /* 396 */ "vtabarglist ::= vtabarg",
 /* 397 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
 /* 398 */ "vtabarg ::= vtabarg vtabargtoken",
 /* 399 */ "anylist ::=",
 /* 400 */ "anylist ::= anylist LP anylist RP",
 /* 401 */ "anylist ::= anylist ANY",
 /* 402 */ "with ::=",
 /* 403 */ "windowdefn_list ::= windowdefn",
 /* 404 */ "window ::= frame_opt",
};
#endif /* NDEBUG */


#if YYGROWABLESTACK
/*
** Try to increase the size of the parser stack.  Return the number







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







173750
173751
173752
173753
173754
173755
173756
173757
173758
173759
173760
173761
173762
173763
173764
173765
173766
173767
173768
173769
173770
173771
173772
173773
173774
173775
173776
173777
173778
173779
173780
173781
173782
173783
173784
173785
173786
173787
173788
173789
173790
173791
173792
173793
173794
173795
173796
173797
173798
173799

173800
173801
173802
173803
173804
173805
173806
173807
173808
173809
173810
173811
173812
173813
173814
173815
173816
173817
173818
173819
173820
173821
173822
173823
173824
173825
173826
173827
173828
173829
 /* 333 */ "window_clause ::= WINDOW windowdefn_list",
 /* 334 */ "filter_over ::= filter_clause over_clause",
 /* 335 */ "filter_over ::= over_clause",
 /* 336 */ "filter_over ::= filter_clause",
 /* 337 */ "over_clause ::= OVER LP window RP",
 /* 338 */ "over_clause ::= OVER nm",
 /* 339 */ "filter_clause ::= FILTER LP WHERE expr RP",
 /* 340 */ "term ::= QNUMBER",
 /* 341 */ "input ::= cmdlist",
 /* 342 */ "cmdlist ::= cmdlist ecmd",
 /* 343 */ "cmdlist ::= ecmd",
 /* 344 */ "ecmd ::= SEMI",
 /* 345 */ "ecmd ::= cmdx SEMI",
 /* 346 */ "ecmd ::= explain cmdx SEMI",
 /* 347 */ "trans_opt ::=",
 /* 348 */ "trans_opt ::= TRANSACTION",
 /* 349 */ "trans_opt ::= TRANSACTION nm",
 /* 350 */ "savepoint_opt ::= SAVEPOINT",
 /* 351 */ "savepoint_opt ::=",
 /* 352 */ "cmd ::= create_table create_table_args",
 /* 353 */ "table_option_set ::= table_option",
 /* 354 */ "columnlist ::= columnlist COMMA columnname carglist",
 /* 355 */ "columnlist ::= columnname carglist",
 /* 356 */ "nm ::= ID|INDEXED|JOIN_KW",
 /* 357 */ "nm ::= STRING",
 /* 358 */ "typetoken ::= typename",
 /* 359 */ "typename ::= ID|STRING",
 /* 360 */ "signed ::= plus_num",
 /* 361 */ "signed ::= minus_num",
 /* 362 */ "carglist ::= carglist ccons",
 /* 363 */ "carglist ::=",
 /* 364 */ "ccons ::= NULL onconf",
 /* 365 */ "ccons ::= GENERATED ALWAYS AS generated",
 /* 366 */ "ccons ::= AS generated",
 /* 367 */ "conslist_opt ::= COMMA conslist",
 /* 368 */ "conslist ::= conslist tconscomma tcons",
 /* 369 */ "conslist ::= tcons",
 /* 370 */ "tconscomma ::=",
 /* 371 */ "defer_subclause_opt ::= defer_subclause",
 /* 372 */ "resolvetype ::= raisetype",
 /* 373 */ "selectnowith ::= oneselect",
 /* 374 */ "oneselect ::= values",
 /* 375 */ "sclp ::= selcollist COMMA",
 /* 376 */ "as ::= ID|STRING",
 /* 377 */ "indexed_opt ::= indexed_by",
 /* 378 */ "returning ::=",
 /* 379 */ "expr ::= term",
 /* 380 */ "likeop ::= LIKE_KW|MATCH",
 /* 381 */ "case_operand ::= expr",
 /* 382 */ "exprlist ::= nexprlist",

 /* 383 */ "nmnum ::= plus_num",
 /* 384 */ "nmnum ::= nm",
 /* 385 */ "nmnum ::= ON",
 /* 386 */ "nmnum ::= DELETE",
 /* 387 */ "nmnum ::= DEFAULT",
 /* 388 */ "plus_num ::= INTEGER|FLOAT",
 /* 389 */ "foreach_clause ::=",
 /* 390 */ "foreach_clause ::= FOR EACH ROW",
 /* 391 */ "trnm ::= nm",
 /* 392 */ "tridxby ::=",
 /* 393 */ "database_kw_opt ::= DATABASE",
 /* 394 */ "database_kw_opt ::=",
 /* 395 */ "kwcolumn_opt ::=",
 /* 396 */ "kwcolumn_opt ::= COLUMNKW",
 /* 397 */ "vtabarglist ::= vtabarg",
 /* 398 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
 /* 399 */ "vtabarg ::= vtabarg vtabargtoken",
 /* 400 */ "anylist ::=",
 /* 401 */ "anylist ::= anylist LP anylist RP",
 /* 402 */ "anylist ::= anylist ANY",
 /* 403 */ "with ::=",
 /* 404 */ "windowdefn_list ::= windowdefn",
 /* 405 */ "window ::= frame_opt",
};
#endif /* NDEBUG */


#if YYGROWABLESTACK
/*
** Try to increase the size of the parser stack.  Return the number
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
173695
173696
173697
173698
173699
173700
173701
173702
173703
173704
173705
173706
173707
173708
173709
173710
173711
173712
173713
173714
173715
173716
173717
173718
173719
173720
173721
173722
173723
173724
173725
173726
173727
173728
173729

173730
173731
173732
173733
173734
173735
173736
173737
173738
173739
173740
173741
173742
173743
173744
173745
173746
173747
173748
173749
173750
173751
173752
173753
173754
173755
173756
173757
    ** 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 204: /* select */
    case 239: /* selectnowith */
    case 240: /* oneselect */
    case 252: /* values */
{
sqlite3SelectDelete(pParse->db, (yypminor->yy47));
}
      break;
    case 216: /* term */
    case 217: /* expr */
    case 246: /* where_opt */
    case 248: /* having_opt */
    case 267: /* where_opt_ret */
    case 278: /* case_operand */
    case 280: /* case_else */
    case 283: /* vinto */
    case 290: /* when_clause */
    case 295: /* key_opt */
    case 311: /* filter_clause */
{
sqlite3ExprDelete(pParse->db, (yypminor->yy528));
}
      break;
    case 221: /* eidlist_opt */
    case 231: /* sortlist */
    case 232: /* eidlist */
    case 244: /* selcollist */
    case 247: /* groupby_opt */
    case 249: /* orderby_opt */
    case 253: /* nexprlist */
    case 254: /* sclp */
    case 261: /* exprlist */
    case 268: /* setlist */
    case 277: /* paren_exprlist */
    case 279: /* case_exprlist */
    case 310: /* part_opt */
{
sqlite3ExprListDelete(pParse->db, (yypminor->yy322));
}
      break;
    case 238: /* fullname */
    case 245: /* from */
    case 256: /* seltablist */
    case 257: /* stl_prefix */
    case 262: /* xfullname */
{
sqlite3SrcListDelete(pParse->db, (yypminor->yy131));
}
      break;
    case 241: /* wqlist */
{
sqlite3WithDelete(pParse->db, (yypminor->yy521));
}
      break;
    case 251: /* window_clause */
    case 306: /* windowdefn_list */
{
sqlite3WindowListDelete(pParse->db, (yypminor->yy41));
}
      break;
    case 263: /* idlist */
    case 270: /* idlist_opt */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy254));
}
      break;
    case 273: /* filter_over */
    case 307: /* windowdefn */
    case 308: /* window */
    case 309: /* frame_opt */

    case 312: /* over_clause */
{
sqlite3WindowDelete(pParse->db, (yypminor->yy41));
}
      break;
    case 286: /* trigger_cmd_list */
    case 291: /* trigger_cmd */
{
sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy33));
}
      break;
    case 288: /* trigger_event */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy180).b);
}
      break;
    case 314: /* frame_bound */
    case 315: /* frame_bound_s */
    case 316: /* frame_bound_e */
{
sqlite3ExprDelete(pParse->db, (yypminor->yy595).pExpr);
}
      break;
/********* End destructor definitions *****************************************/
    default:  break;   /* If no destructor action specified: do nothing */
  }
}








|
|
|
|

|


|
|
|
|
|
|
|
|
|
|
|

|


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

|


|
|
|
|
|

|


|

|


|
|

|


|
|

|


|
<
|
|
>
|

|


|
|

|


|

|


|
|
|

|







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
173988
173989
173990
173991
173992
173993
173994
173995
173996
173997
173998
173999
174000
174001
174002
174003
174004
174005
174006
174007
174008
174009
174010
174011
174012

174013
174014
174015
174016
174017
174018
174019
174020
174021
174022
174023
174024
174025
174026
174027
174028
174029
174030
174031
174032
174033
174034
174035
174036
174037
174038
174039
174040
174041
174042
174043
    ** 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 205: /* select */
    case 240: /* selectnowith */
    case 241: /* oneselect */
    case 253: /* values */
{
sqlite3SelectDelete(pParse->db, (yypminor->yy299));
}
      break;
    case 217: /* term */
    case 218: /* expr */
    case 247: /* where_opt */
    case 249: /* having_opt */
    case 268: /* where_opt_ret */
    case 279: /* case_operand */
    case 281: /* case_else */
    case 284: /* vinto */
    case 291: /* when_clause */
    case 296: /* key_opt */
    case 312: /* filter_clause */
{
sqlite3ExprDelete(pParse->db, (yypminor->yy2));
}
      break;
    case 222: /* eidlist_opt */
    case 232: /* sortlist */
    case 233: /* eidlist */
    case 245: /* selcollist */
    case 248: /* groupby_opt */
    case 250: /* orderby_opt */
    case 254: /* nexprlist */
    case 255: /* sclp */
    case 262: /* exprlist */
    case 269: /* setlist */
    case 278: /* paren_exprlist */
    case 280: /* case_exprlist */
    case 311: /* part_opt */
{
sqlite3ExprListDelete(pParse->db, (yypminor->yy402));
}
      break;
    case 239: /* fullname */
    case 246: /* from */
    case 257: /* seltablist */
    case 258: /* stl_prefix */
    case 263: /* xfullname */
{
sqlite3SrcListDelete(pParse->db, (yypminor->yy387));
}
      break;
    case 242: /* wqlist */
{
sqlite3WithDelete(pParse->db, (yypminor->yy131));
}
      break;
    case 252: /* window_clause */
    case 307: /* windowdefn_list */
{
sqlite3WindowListDelete(pParse->db, (yypminor->yy3));
}
      break;
    case 264: /* idlist */
    case 271: /* idlist_opt */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy400));
}
      break;
    case 274: /* filter_over */

    case 308: /* windowdefn */
    case 309: /* window */
    case 310: /* frame_opt */
    case 313: /* over_clause */
{
sqlite3WindowDelete(pParse->db, (yypminor->yy3));
}
      break;
    case 287: /* trigger_cmd_list */
    case 292: /* trigger_cmd */
{
sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy347));
}
      break;
    case 289: /* trigger_event */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy210).b);
}
      break;
    case 315: /* frame_bound */
    case 316: /* frame_bound_s */
    case 317: /* frame_bound_e */
{
sqlite3ExprDelete(pParse->db, (yypminor->yy337).pExpr);
}
      break;
/********* End destructor definitions *****************************************/
    default:  break;   /* If no destructor action specified: do nothing */
  }
}

174045
174046
174047
174048
174049
174050
174051
174052
174053
174054
174055
174056
174057
174058
174059
174060
174061
174062
174063
174064
174065
174066
174067
174068
174069
174070
174071
174072
174073
174074
174075
174076
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
174191
174192
174193
174194
174195
174196
174197
174198
174199
174200
174201
174202
174203
174204
174205
174206
174207
174208
174209
174210
174211
174212
174213
174214
174215
174216
174217
174218
174219
174220
174221
174222
174223
174224
174225
174226
174227
174228
174229
174230
174231
174232
174233
174234
174235
174236
174237
174238
174239
174240
174241
174242
174243
174244
174245
174246
174247
174248
174249
174250
174251
174252
174253
174254
174255
174256
174257
174258
174259
174260
174261
174262
174263
174264
174265
174266
174267
174268
174269
174270
174271
174272
174273
174274
174275
174276
174277
174278
174279
174280
174281
174282
174283
174284
174285
174286
174287
174288
174289
174290
174291
174292
174293
174294
174295
174296
174297
174298
174299
174300
174301
174302
174303
174304
174305
174306
174307
174308
174309
174310
174311
174312
174313
174314
174315
174316
174317
174318
174319
174320
174321
174322
174323
174324
174325
174326
174327
174328
174329
174330
174331
174332
174333
174334
174335
174336
174337
174338
174339
174340
174341
174342
174343
174344
174345
174346
174347
174348
174349
174350
174351
174352
174353
174354
174355
174356
174357
174358
174359
174360
174361
174362
174363
174364
174365
174366
174367
174368
174369
174370
174371
174372
174373
174374
174375
174376
174377
174378
174379
174380
174381
174382
174383
174384
174385
174386
174387
174388
174389
174390
174391

174392
174393
174394
174395
174396
174397
174398
174399
174400
174401
174402
174403
174404
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
174436
174437
174438
174439
174440
174441
174442
174443
174444
174445
174446
174447
174448
174449
174450
174451
174452
174453
174454
174455
174456
174457
174458
174459
174460
174461
174462
174463
  yytos->minor.yy0 = yyMinor;
  yyTraceShift(yypParser, yyNewState, "Shift");
}

/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
** of that rule */
static const YYCODETYPE yyRuleInfoLhs[] = {
   189,  /* (0) explain ::= EXPLAIN */
   189,  /* (1) explain ::= EXPLAIN QUERY PLAN */
   188,  /* (2) cmdx ::= cmd */
   190,  /* (3) cmd ::= BEGIN transtype trans_opt */
   191,  /* (4) transtype ::= */
   191,  /* (5) transtype ::= DEFERRED */
   191,  /* (6) transtype ::= IMMEDIATE */
   191,  /* (7) transtype ::= EXCLUSIVE */
   190,  /* (8) cmd ::= COMMIT|END trans_opt */
   190,  /* (9) cmd ::= ROLLBACK trans_opt */
   190,  /* (10) cmd ::= SAVEPOINT nm */
   190,  /* (11) cmd ::= RELEASE savepoint_opt nm */
   190,  /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
   195,  /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
   197,  /* (14) createkw ::= CREATE */
   199,  /* (15) ifnotexists ::= */
   199,  /* (16) ifnotexists ::= IF NOT EXISTS */
   198,  /* (17) temp ::= TEMP */
   198,  /* (18) temp ::= */
   196,  /* (19) create_table_args ::= LP columnlist conslist_opt RP table_option_set */
   196,  /* (20) create_table_args ::= AS select */
   203,  /* (21) table_option_set ::= */
   203,  /* (22) table_option_set ::= table_option_set COMMA table_option */
   205,  /* (23) table_option ::= WITHOUT nm */
   205,  /* (24) table_option ::= nm */
   206,  /* (25) columnname ::= nm typetoken */
   208,  /* (26) typetoken ::= */
   208,  /* (27) typetoken ::= typename LP signed RP */
   208,  /* (28) typetoken ::= typename LP signed COMMA signed RP */
   209,  /* (29) typename ::= typename ID|STRING */
   213,  /* (30) scanpt ::= */
   214,  /* (31) scantok ::= */
   215,  /* (32) ccons ::= CONSTRAINT nm */
   215,  /* (33) ccons ::= DEFAULT scantok term */
   215,  /* (34) ccons ::= DEFAULT LP expr RP */
   215,  /* (35) ccons ::= DEFAULT PLUS scantok term */
   215,  /* (36) ccons ::= DEFAULT MINUS scantok term */
   215,  /* (37) ccons ::= DEFAULT scantok ID|INDEXED */
   215,  /* (38) ccons ::= NOT NULL onconf */
   215,  /* (39) ccons ::= PRIMARY KEY sortorder onconf autoinc */
   215,  /* (40) ccons ::= UNIQUE onconf */
   215,  /* (41) ccons ::= CHECK LP expr RP */
   215,  /* (42) ccons ::= REFERENCES nm eidlist_opt refargs */
   215,  /* (43) ccons ::= defer_subclause */
   215,  /* (44) ccons ::= COLLATE ID|STRING */
   224,  /* (45) generated ::= LP expr RP */
   224,  /* (46) generated ::= LP expr RP ID */
   220,  /* (47) autoinc ::= */
   220,  /* (48) autoinc ::= AUTOINCR */
   222,  /* (49) refargs ::= */
   222,  /* (50) refargs ::= refargs refarg */
   225,  /* (51) refarg ::= MATCH nm */
   225,  /* (52) refarg ::= ON INSERT refact */
   225,  /* (53) refarg ::= ON DELETE refact */
   225,  /* (54) refarg ::= ON UPDATE refact */
   226,  /* (55) refact ::= SET NULL */
   226,  /* (56) refact ::= SET DEFAULT */
   226,  /* (57) refact ::= CASCADE */
   226,  /* (58) refact ::= RESTRICT */
   226,  /* (59) refact ::= NO ACTION */
   223,  /* (60) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
   223,  /* (61) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
   227,  /* (62) init_deferred_pred_opt ::= */
   227,  /* (63) init_deferred_pred_opt ::= INITIALLY DEFERRED */
   227,  /* (64) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
   202,  /* (65) conslist_opt ::= */
   229,  /* (66) tconscomma ::= COMMA */
   230,  /* (67) tcons ::= CONSTRAINT nm */
   230,  /* (68) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
   230,  /* (69) tcons ::= UNIQUE LP sortlist RP onconf */
   230,  /* (70) tcons ::= CHECK LP expr RP onconf */
   230,  /* (71) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
   233,  /* (72) defer_subclause_opt ::= */
   218,  /* (73) onconf ::= */
   218,  /* (74) onconf ::= ON CONFLICT resolvetype */
   234,  /* (75) orconf ::= */
   234,  /* (76) orconf ::= OR resolvetype */
   235,  /* (77) resolvetype ::= IGNORE */
   235,  /* (78) resolvetype ::= REPLACE */
   190,  /* (79) cmd ::= DROP TABLE ifexists fullname */
   237,  /* (80) ifexists ::= IF EXISTS */
   237,  /* (81) ifexists ::= */
   190,  /* (82) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
   190,  /* (83) cmd ::= DROP VIEW ifexists fullname */
   190,  /* (84) cmd ::= select */
   204,  /* (85) select ::= WITH wqlist selectnowith */
   204,  /* (86) select ::= WITH RECURSIVE wqlist selectnowith */
   204,  /* (87) select ::= selectnowith */
   239,  /* (88) selectnowith ::= selectnowith multiselect_op oneselect */
   242,  /* (89) multiselect_op ::= UNION */
   242,  /* (90) multiselect_op ::= UNION ALL */
   242,  /* (91) multiselect_op ::= EXCEPT|INTERSECT */
   240,  /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
   240,  /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
   252,  /* (94) values ::= VALUES LP nexprlist RP */
   252,  /* (95) values ::= values COMMA LP nexprlist RP */
   243,  /* (96) distinct ::= DISTINCT */
   243,  /* (97) distinct ::= ALL */
   243,  /* (98) distinct ::= */
   254,  /* (99) sclp ::= */
   244,  /* (100) selcollist ::= sclp scanpt expr scanpt as */
   244,  /* (101) selcollist ::= sclp scanpt STAR */
   244,  /* (102) selcollist ::= sclp scanpt nm DOT STAR */
   255,  /* (103) as ::= AS nm */
   255,  /* (104) as ::= */
   245,  /* (105) from ::= */
   245,  /* (106) from ::= FROM seltablist */
   257,  /* (107) stl_prefix ::= seltablist joinop */
   257,  /* (108) stl_prefix ::= */
   256,  /* (109) seltablist ::= stl_prefix nm dbnm as on_using */
   256,  /* (110) seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
   256,  /* (111) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
   256,  /* (112) seltablist ::= stl_prefix LP select RP as on_using */
   256,  /* (113) seltablist ::= stl_prefix LP seltablist RP as on_using */
   200,  /* (114) dbnm ::= */
   200,  /* (115) dbnm ::= DOT nm */
   238,  /* (116) fullname ::= nm */
   238,  /* (117) fullname ::= nm DOT nm */
   262,  /* (118) xfullname ::= nm */
   262,  /* (119) xfullname ::= nm DOT nm */
   262,  /* (120) xfullname ::= nm DOT nm AS nm */
   262,  /* (121) xfullname ::= nm AS nm */
   258,  /* (122) joinop ::= COMMA|JOIN */
   258,  /* (123) joinop ::= JOIN_KW JOIN */
   258,  /* (124) joinop ::= JOIN_KW nm JOIN */
   258,  /* (125) joinop ::= JOIN_KW nm nm JOIN */
   259,  /* (126) on_using ::= ON expr */
   259,  /* (127) on_using ::= USING LP idlist RP */
   259,  /* (128) on_using ::= */
   264,  /* (129) indexed_opt ::= */
   260,  /* (130) indexed_by ::= INDEXED BY nm */
   260,  /* (131) indexed_by ::= NOT INDEXED */
   249,  /* (132) orderby_opt ::= */
   249,  /* (133) orderby_opt ::= ORDER BY sortlist */
   231,  /* (134) sortlist ::= sortlist COMMA expr sortorder nulls */
   231,  /* (135) sortlist ::= expr sortorder nulls */
   219,  /* (136) sortorder ::= ASC */
   219,  /* (137) sortorder ::= DESC */
   219,  /* (138) sortorder ::= */
   265,  /* (139) nulls ::= NULLS FIRST */
   265,  /* (140) nulls ::= NULLS LAST */
   265,  /* (141) nulls ::= */
   247,  /* (142) groupby_opt ::= */
   247,  /* (143) groupby_opt ::= GROUP BY nexprlist */
   248,  /* (144) having_opt ::= */
   248,  /* (145) having_opt ::= HAVING expr */
   250,  /* (146) limit_opt ::= */
   250,  /* (147) limit_opt ::= LIMIT expr */
   250,  /* (148) limit_opt ::= LIMIT expr OFFSET expr */
   250,  /* (149) limit_opt ::= LIMIT expr COMMA expr */
   190,  /* (150) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
   246,  /* (151) where_opt ::= */
   246,  /* (152) where_opt ::= WHERE expr */
   267,  /* (153) where_opt_ret ::= */
   267,  /* (154) where_opt_ret ::= WHERE expr */
   267,  /* (155) where_opt_ret ::= RETURNING selcollist */
   267,  /* (156) where_opt_ret ::= WHERE expr RETURNING selcollist */
   190,  /* (157) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
   268,  /* (158) setlist ::= setlist COMMA nm EQ expr */
   268,  /* (159) setlist ::= setlist COMMA LP idlist RP EQ expr */
   268,  /* (160) setlist ::= nm EQ expr */
   268,  /* (161) setlist ::= LP idlist RP EQ expr */
   190,  /* (162) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
   190,  /* (163) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
   271,  /* (164) upsert ::= */
   271,  /* (165) upsert ::= RETURNING selcollist */
   271,  /* (166) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
   271,  /* (167) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
   271,  /* (168) upsert ::= ON CONFLICT DO NOTHING returning */
   271,  /* (169) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
   272,  /* (170) returning ::= RETURNING selcollist */
   269,  /* (171) insert_cmd ::= INSERT orconf */
   269,  /* (172) insert_cmd ::= REPLACE */
   270,  /* (173) idlist_opt ::= */
   270,  /* (174) idlist_opt ::= LP idlist RP */
   263,  /* (175) idlist ::= idlist COMMA nm */
   263,  /* (176) idlist ::= nm */
   217,  /* (177) expr ::= LP expr RP */
   217,  /* (178) expr ::= ID|INDEXED|JOIN_KW */
   217,  /* (179) expr ::= nm DOT nm */
   217,  /* (180) expr ::= nm DOT nm DOT nm */
   216,  /* (181) term ::= NULL|FLOAT|BLOB */
   216,  /* (182) term ::= STRING */
   216,  /* (183) term ::= INTEGER */
   217,  /* (184) expr ::= VARIABLE */
   217,  /* (185) expr ::= expr COLLATE ID|STRING */
   217,  /* (186) expr ::= CAST LP expr AS typetoken RP */
   217,  /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
   217,  /* (188) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
   217,  /* (189) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
   217,  /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
   217,  /* (191) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
   217,  /* (192) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
   216,  /* (193) term ::= CTIME_KW */
   217,  /* (194) expr ::= LP nexprlist COMMA expr RP */
   217,  /* (195) expr ::= expr AND expr */
   217,  /* (196) expr ::= expr OR expr */
   217,  /* (197) expr ::= expr LT|GT|GE|LE expr */
   217,  /* (198) expr ::= expr EQ|NE expr */
   217,  /* (199) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
   217,  /* (200) expr ::= expr PLUS|MINUS expr */
   217,  /* (201) expr ::= expr STAR|SLASH|REM expr */
   217,  /* (202) expr ::= expr CONCAT expr */
   274,  /* (203) likeop ::= NOT LIKE_KW|MATCH */
   217,  /* (204) expr ::= expr likeop expr */
   217,  /* (205) expr ::= expr likeop expr ESCAPE expr */
   217,  /* (206) expr ::= expr ISNULL|NOTNULL */
   217,  /* (207) expr ::= expr NOT NULL */
   217,  /* (208) expr ::= expr IS expr */
   217,  /* (209) expr ::= expr IS NOT expr */
   217,  /* (210) expr ::= expr IS NOT DISTINCT FROM expr */
   217,  /* (211) expr ::= expr IS DISTINCT FROM expr */
   217,  /* (212) expr ::= NOT expr */
   217,  /* (213) expr ::= BITNOT expr */
   217,  /* (214) expr ::= PLUS|MINUS expr */
   217,  /* (215) expr ::= expr PTR expr */
   275,  /* (216) between_op ::= BETWEEN */
   275,  /* (217) between_op ::= NOT BETWEEN */
   217,  /* (218) expr ::= expr between_op expr AND expr */
   276,  /* (219) in_op ::= IN */
   276,  /* (220) in_op ::= NOT IN */
   217,  /* (221) expr ::= expr in_op LP exprlist RP */
   217,  /* (222) expr ::= LP select RP */
   217,  /* (223) expr ::= expr in_op LP select RP */
   217,  /* (224) expr ::= expr in_op nm dbnm paren_exprlist */
   217,  /* (225) expr ::= EXISTS LP select RP */
   217,  /* (226) expr ::= CASE case_operand case_exprlist case_else END */
   279,  /* (227) case_exprlist ::= case_exprlist WHEN expr THEN expr */
   279,  /* (228) case_exprlist ::= WHEN expr THEN expr */
   280,  /* (229) case_else ::= ELSE expr */
   280,  /* (230) case_else ::= */
   278,  /* (231) case_operand ::= */
   261,  /* (232) exprlist ::= */
   253,  /* (233) nexprlist ::= nexprlist COMMA expr */
   253,  /* (234) nexprlist ::= expr */
   277,  /* (235) paren_exprlist ::= */
   277,  /* (236) paren_exprlist ::= LP exprlist RP */
   190,  /* (237) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
   281,  /* (238) uniqueflag ::= UNIQUE */
   281,  /* (239) uniqueflag ::= */
   221,  /* (240) eidlist_opt ::= */
   221,  /* (241) eidlist_opt ::= LP eidlist RP */
   232,  /* (242) eidlist ::= eidlist COMMA nm collate sortorder */
   232,  /* (243) eidlist ::= nm collate sortorder */
   282,  /* (244) collate ::= */
   282,  /* (245) collate ::= COLLATE ID|STRING */
   190,  /* (246) cmd ::= DROP INDEX ifexists fullname */
   190,  /* (247) cmd ::= VACUUM vinto */
   190,  /* (248) cmd ::= VACUUM nm vinto */
   283,  /* (249) vinto ::= INTO expr */
   283,  /* (250) vinto ::= */
   190,  /* (251) cmd ::= PRAGMA nm dbnm */
   190,  /* (252) cmd ::= PRAGMA nm dbnm EQ nmnum */
   190,  /* (253) cmd ::= PRAGMA nm dbnm LP nmnum RP */
   190,  /* (254) cmd ::= PRAGMA nm dbnm EQ minus_num */
   190,  /* (255) cmd ::= PRAGMA nm dbnm LP minus_num RP */
   211,  /* (256) plus_num ::= PLUS INTEGER|FLOAT */
   212,  /* (257) minus_num ::= MINUS INTEGER|FLOAT */
   190,  /* (258) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
   285,  /* (259) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
   287,  /* (260) trigger_time ::= BEFORE|AFTER */
   287,  /* (261) trigger_time ::= INSTEAD OF */
   287,  /* (262) trigger_time ::= */
   288,  /* (263) trigger_event ::= DELETE|INSERT */
   288,  /* (264) trigger_event ::= UPDATE */
   288,  /* (265) trigger_event ::= UPDATE OF idlist */
   290,  /* (266) when_clause ::= */
   290,  /* (267) when_clause ::= WHEN expr */
   286,  /* (268) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
   286,  /* (269) trigger_cmd_list ::= trigger_cmd SEMI */
   292,  /* (270) trnm ::= nm DOT nm */
   293,  /* (271) tridxby ::= INDEXED BY nm */
   293,  /* (272) tridxby ::= NOT INDEXED */
   291,  /* (273) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
   291,  /* (274) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
   291,  /* (275) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
   291,  /* (276) trigger_cmd ::= scanpt select scanpt */
   217,  /* (277) expr ::= RAISE LP IGNORE RP */
   217,  /* (278) expr ::= RAISE LP raisetype COMMA nm RP */
   236,  /* (279) raisetype ::= ROLLBACK */
   236,  /* (280) raisetype ::= ABORT */
   236,  /* (281) raisetype ::= FAIL */
   190,  /* (282) cmd ::= DROP TRIGGER ifexists fullname */
   190,  /* (283) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
   190,  /* (284) cmd ::= DETACH database_kw_opt expr */
   295,  /* (285) key_opt ::= */
   295,  /* (286) key_opt ::= KEY expr */
   190,  /* (287) cmd ::= REINDEX */
   190,  /* (288) cmd ::= REINDEX nm dbnm */
   190,  /* (289) cmd ::= ANALYZE */
   190,  /* (290) cmd ::= ANALYZE nm dbnm */
   190,  /* (291) cmd ::= ALTER TABLE fullname RENAME TO nm */
   190,  /* (292) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
   190,  /* (293) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
   296,  /* (294) add_column_fullname ::= fullname */
   190,  /* (295) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
   190,  /* (296) cmd ::= create_vtab */
   190,  /* (297) cmd ::= create_vtab LP vtabarglist RP */
   298,  /* (298) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
   300,  /* (299) vtabarg ::= */
   301,  /* (300) vtabargtoken ::= ANY */
   301,  /* (301) vtabargtoken ::= lp anylist RP */
   302,  /* (302) lp ::= LP */
   266,  /* (303) with ::= WITH wqlist */
   266,  /* (304) with ::= WITH RECURSIVE wqlist */
   305,  /* (305) wqas ::= AS */
   305,  /* (306) wqas ::= AS MATERIALIZED */
   305,  /* (307) wqas ::= AS NOT MATERIALIZED */
   304,  /* (308) wqitem ::= nm eidlist_opt wqas LP select RP */
   241,  /* (309) wqlist ::= wqitem */
   241,  /* (310) wqlist ::= wqlist COMMA wqitem */
   306,  /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */
   307,  /* (312) windowdefn ::= nm AS LP window RP */
   308,  /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
   308,  /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
   308,  /* (315) window ::= ORDER BY sortlist frame_opt */
   308,  /* (316) window ::= nm ORDER BY sortlist frame_opt */
   308,  /* (317) window ::= nm frame_opt */
   309,  /* (318) frame_opt ::= */
   309,  /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
   309,  /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
   313,  /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */
   315,  /* (322) frame_bound_s ::= frame_bound */
   315,  /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */
   316,  /* (324) frame_bound_e ::= frame_bound */
   316,  /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */
   314,  /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */
   314,  /* (327) frame_bound ::= CURRENT ROW */
   317,  /* (328) frame_exclude_opt ::= */
   317,  /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */
   318,  /* (330) frame_exclude ::= NO OTHERS */
   318,  /* (331) frame_exclude ::= CURRENT ROW */
   318,  /* (332) frame_exclude ::= GROUP|TIES */
   251,  /* (333) window_clause ::= WINDOW windowdefn_list */
   273,  /* (334) filter_over ::= filter_clause over_clause */
   273,  /* (335) filter_over ::= over_clause */
   273,  /* (336) filter_over ::= filter_clause */
   312,  /* (337) over_clause ::= OVER LP window RP */
   312,  /* (338) over_clause ::= OVER nm */
   311,  /* (339) filter_clause ::= FILTER LP WHERE expr RP */

   185,  /* (340) input ::= cmdlist */
   186,  /* (341) cmdlist ::= cmdlist ecmd */
   186,  /* (342) cmdlist ::= ecmd */
   187,  /* (343) ecmd ::= SEMI */
   187,  /* (344) ecmd ::= cmdx SEMI */
   187,  /* (345) ecmd ::= explain cmdx SEMI */
   192,  /* (346) trans_opt ::= */
   192,  /* (347) trans_opt ::= TRANSACTION */
   192,  /* (348) trans_opt ::= TRANSACTION nm */
   194,  /* (349) savepoint_opt ::= SAVEPOINT */
   194,  /* (350) savepoint_opt ::= */
   190,  /* (351) cmd ::= create_table create_table_args */
   203,  /* (352) table_option_set ::= table_option */
   201,  /* (353) columnlist ::= columnlist COMMA columnname carglist */
   201,  /* (354) columnlist ::= columnname carglist */
   193,  /* (355) nm ::= ID|INDEXED|JOIN_KW */
   193,  /* (356) nm ::= STRING */
   208,  /* (357) typetoken ::= typename */
   209,  /* (358) typename ::= ID|STRING */
   210,  /* (359) signed ::= plus_num */
   210,  /* (360) signed ::= minus_num */
   207,  /* (361) carglist ::= carglist ccons */
   207,  /* (362) carglist ::= */
   215,  /* (363) ccons ::= NULL onconf */
   215,  /* (364) ccons ::= GENERATED ALWAYS AS generated */
   215,  /* (365) ccons ::= AS generated */
   202,  /* (366) conslist_opt ::= COMMA conslist */
   228,  /* (367) conslist ::= conslist tconscomma tcons */
   228,  /* (368) conslist ::= tcons */
   229,  /* (369) tconscomma ::= */
   233,  /* (370) defer_subclause_opt ::= defer_subclause */
   235,  /* (371) resolvetype ::= raisetype */
   239,  /* (372) selectnowith ::= oneselect */
   240,  /* (373) oneselect ::= values */
   254,  /* (374) sclp ::= selcollist COMMA */
   255,  /* (375) as ::= ID|STRING */
   264,  /* (376) indexed_opt ::= indexed_by */
   272,  /* (377) returning ::= */
   217,  /* (378) expr ::= term */
   274,  /* (379) likeop ::= LIKE_KW|MATCH */
   278,  /* (380) case_operand ::= expr */
   261,  /* (381) exprlist ::= nexprlist */
   284,  /* (382) nmnum ::= plus_num */
   284,  /* (383) nmnum ::= nm */
   284,  /* (384) nmnum ::= ON */
   284,  /* (385) nmnum ::= DELETE */
   284,  /* (386) nmnum ::= DEFAULT */
   211,  /* (387) plus_num ::= INTEGER|FLOAT */
   289,  /* (388) foreach_clause ::= */
   289,  /* (389) foreach_clause ::= FOR EACH ROW */
   292,  /* (390) trnm ::= nm */
   293,  /* (391) tridxby ::= */
   294,  /* (392) database_kw_opt ::= DATABASE */
   294,  /* (393) database_kw_opt ::= */
   297,  /* (394) kwcolumn_opt ::= */
   297,  /* (395) kwcolumn_opt ::= COLUMNKW */
   299,  /* (396) vtabarglist ::= vtabarg */
   299,  /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */
   300,  /* (398) vtabarg ::= vtabarg vtabargtoken */
   303,  /* (399) anylist ::= */
   303,  /* (400) anylist ::= anylist LP anylist RP */
   303,  /* (401) anylist ::= anylist ANY */
   266,  /* (402) with ::= */
   306,  /* (403) windowdefn_list ::= windowdefn */
   308,  /* (404) window ::= frame_opt */
};

/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
** of symbols on the right-hand side of that rule. */
static const signed char yyRuleInfoNRhs[] = {
   -1,  /* (0) explain ::= EXPLAIN */
   -3,  /* (1) explain ::= EXPLAIN QUERY PLAN */







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







174331
174332
174333
174334
174335
174336
174337
174338
174339
174340
174341
174342
174343
174344
174345
174346
174347
174348
174349
174350
174351
174352
174353
174354
174355
174356
174357
174358
174359
174360
174361
174362
174363
174364
174365
174366
174367
174368
174369
174370
174371
174372
174373
174374
174375
174376
174377
174378
174379
174380
174381
174382
174383
174384
174385
174386
174387
174388
174389
174390
174391
174392
174393
174394
174395
174396
174397
174398
174399
174400
174401
174402
174403
174404
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
174436
174437
174438
174439
174440
174441
174442
174443
174444
174445
174446
174447
174448
174449
174450
174451
174452
174453
174454
174455
174456
174457
174458
174459
174460
174461
174462
174463
174464
174465
174466
174467
174468
174469
174470
174471
174472
174473
174474
174475
174476
174477
174478
174479
174480
174481
174482
174483
174484
174485
174486
174487
174488
174489
174490
174491
174492
174493
174494
174495
174496
174497
174498
174499
174500
174501
174502
174503
174504
174505
174506
174507
174508
174509
174510
174511
174512
174513
174514
174515
174516
174517
174518
174519
174520
174521
174522
174523
174524
174525
174526
174527
174528
174529
174530
174531
174532
174533
174534
174535
174536
174537
174538
174539
174540
174541
174542
174543
174544
174545
174546
174547
174548
174549
174550
174551
174552
174553
174554
174555
174556
174557
174558
174559
174560
174561
174562
174563
174564
174565
174566
174567
174568
174569
174570
174571
174572
174573
174574
174575
174576
174577
174578
174579
174580
174581
174582
174583
174584
174585
174586
174587
174588
174589
174590
174591
174592
174593
174594
174595
174596
174597
174598
174599
174600
174601
174602
174603
174604
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
174650
174651
174652
174653
174654
174655
174656
174657
174658
174659
174660
174661
174662
174663
174664
174665
174666
174667
174668
174669
174670
174671
174672
174673
174674
174675
174676
174677
174678
174679
174680
174681
174682
174683
174684
174685
174686
174687
174688
174689
174690
174691
174692
174693
174694
174695
174696
174697
174698
174699
174700
174701
174702
174703
174704
174705
174706
174707
174708
174709
174710
174711
174712
174713
174714
174715
174716
174717
174718
174719
174720
174721
174722
174723
174724
174725
174726
174727
174728
174729
174730
174731
174732
174733
174734
174735
174736
174737
174738
174739
174740
174741
174742
174743
174744
174745
174746
174747
174748
174749
174750
  yytos->minor.yy0 = yyMinor;
  yyTraceShift(yypParser, yyNewState, "Shift");
}

/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
** of that rule */
static const YYCODETYPE yyRuleInfoLhs[] = {
   190,  /* (0) explain ::= EXPLAIN */
   190,  /* (1) explain ::= EXPLAIN QUERY PLAN */
   189,  /* (2) cmdx ::= cmd */
   191,  /* (3) cmd ::= BEGIN transtype trans_opt */
   192,  /* (4) transtype ::= */
   192,  /* (5) transtype ::= DEFERRED */
   192,  /* (6) transtype ::= IMMEDIATE */
   192,  /* (7) transtype ::= EXCLUSIVE */
   191,  /* (8) cmd ::= COMMIT|END trans_opt */
   191,  /* (9) cmd ::= ROLLBACK trans_opt */
   191,  /* (10) cmd ::= SAVEPOINT nm */
   191,  /* (11) cmd ::= RELEASE savepoint_opt nm */
   191,  /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
   196,  /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
   198,  /* (14) createkw ::= CREATE */
   200,  /* (15) ifnotexists ::= */
   200,  /* (16) ifnotexists ::= IF NOT EXISTS */
   199,  /* (17) temp ::= TEMP */
   199,  /* (18) temp ::= */
   197,  /* (19) create_table_args ::= LP columnlist conslist_opt RP table_option_set */
   197,  /* (20) create_table_args ::= AS select */
   204,  /* (21) table_option_set ::= */
   204,  /* (22) table_option_set ::= table_option_set COMMA table_option */
   206,  /* (23) table_option ::= WITHOUT nm */
   206,  /* (24) table_option ::= nm */
   207,  /* (25) columnname ::= nm typetoken */
   209,  /* (26) typetoken ::= */
   209,  /* (27) typetoken ::= typename LP signed RP */
   209,  /* (28) typetoken ::= typename LP signed COMMA signed RP */
   210,  /* (29) typename ::= typename ID|STRING */
   214,  /* (30) scanpt ::= */
   215,  /* (31) scantok ::= */
   216,  /* (32) ccons ::= CONSTRAINT nm */
   216,  /* (33) ccons ::= DEFAULT scantok term */
   216,  /* (34) ccons ::= DEFAULT LP expr RP */
   216,  /* (35) ccons ::= DEFAULT PLUS scantok term */
   216,  /* (36) ccons ::= DEFAULT MINUS scantok term */
   216,  /* (37) ccons ::= DEFAULT scantok ID|INDEXED */
   216,  /* (38) ccons ::= NOT NULL onconf */
   216,  /* (39) ccons ::= PRIMARY KEY sortorder onconf autoinc */
   216,  /* (40) ccons ::= UNIQUE onconf */
   216,  /* (41) ccons ::= CHECK LP expr RP */
   216,  /* (42) ccons ::= REFERENCES nm eidlist_opt refargs */
   216,  /* (43) ccons ::= defer_subclause */
   216,  /* (44) ccons ::= COLLATE ID|STRING */
   225,  /* (45) generated ::= LP expr RP */
   225,  /* (46) generated ::= LP expr RP ID */
   221,  /* (47) autoinc ::= */
   221,  /* (48) autoinc ::= AUTOINCR */
   223,  /* (49) refargs ::= */
   223,  /* (50) refargs ::= refargs refarg */
   226,  /* (51) refarg ::= MATCH nm */
   226,  /* (52) refarg ::= ON INSERT refact */
   226,  /* (53) refarg ::= ON DELETE refact */
   226,  /* (54) refarg ::= ON UPDATE refact */
   227,  /* (55) refact ::= SET NULL */
   227,  /* (56) refact ::= SET DEFAULT */
   227,  /* (57) refact ::= CASCADE */
   227,  /* (58) refact ::= RESTRICT */
   227,  /* (59) refact ::= NO ACTION */
   224,  /* (60) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
   224,  /* (61) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
   228,  /* (62) init_deferred_pred_opt ::= */
   228,  /* (63) init_deferred_pred_opt ::= INITIALLY DEFERRED */
   228,  /* (64) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
   203,  /* (65) conslist_opt ::= */
   230,  /* (66) tconscomma ::= COMMA */
   231,  /* (67) tcons ::= CONSTRAINT nm */
   231,  /* (68) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
   231,  /* (69) tcons ::= UNIQUE LP sortlist RP onconf */
   231,  /* (70) tcons ::= CHECK LP expr RP onconf */
   231,  /* (71) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
   234,  /* (72) defer_subclause_opt ::= */
   219,  /* (73) onconf ::= */
   219,  /* (74) onconf ::= ON CONFLICT resolvetype */
   235,  /* (75) orconf ::= */
   235,  /* (76) orconf ::= OR resolvetype */
   236,  /* (77) resolvetype ::= IGNORE */
   236,  /* (78) resolvetype ::= REPLACE */
   191,  /* (79) cmd ::= DROP TABLE ifexists fullname */
   238,  /* (80) ifexists ::= IF EXISTS */
   238,  /* (81) ifexists ::= */
   191,  /* (82) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
   191,  /* (83) cmd ::= DROP VIEW ifexists fullname */
   191,  /* (84) cmd ::= select */
   205,  /* (85) select ::= WITH wqlist selectnowith */
   205,  /* (86) select ::= WITH RECURSIVE wqlist selectnowith */
   205,  /* (87) select ::= selectnowith */
   240,  /* (88) selectnowith ::= selectnowith multiselect_op oneselect */
   243,  /* (89) multiselect_op ::= UNION */
   243,  /* (90) multiselect_op ::= UNION ALL */
   243,  /* (91) multiselect_op ::= EXCEPT|INTERSECT */
   241,  /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
   241,  /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
   253,  /* (94) values ::= VALUES LP nexprlist RP */
   253,  /* (95) values ::= values COMMA LP nexprlist RP */
   244,  /* (96) distinct ::= DISTINCT */
   244,  /* (97) distinct ::= ALL */
   244,  /* (98) distinct ::= */
   255,  /* (99) sclp ::= */
   245,  /* (100) selcollist ::= sclp scanpt expr scanpt as */
   245,  /* (101) selcollist ::= sclp scanpt STAR */
   245,  /* (102) selcollist ::= sclp scanpt nm DOT STAR */
   256,  /* (103) as ::= AS nm */
   256,  /* (104) as ::= */
   246,  /* (105) from ::= */
   246,  /* (106) from ::= FROM seltablist */
   258,  /* (107) stl_prefix ::= seltablist joinop */
   258,  /* (108) stl_prefix ::= */
   257,  /* (109) seltablist ::= stl_prefix nm dbnm as on_using */
   257,  /* (110) seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
   257,  /* (111) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
   257,  /* (112) seltablist ::= stl_prefix LP select RP as on_using */
   257,  /* (113) seltablist ::= stl_prefix LP seltablist RP as on_using */
   201,  /* (114) dbnm ::= */
   201,  /* (115) dbnm ::= DOT nm */
   239,  /* (116) fullname ::= nm */
   239,  /* (117) fullname ::= nm DOT nm */
   263,  /* (118) xfullname ::= nm */
   263,  /* (119) xfullname ::= nm DOT nm */
   263,  /* (120) xfullname ::= nm DOT nm AS nm */
   263,  /* (121) xfullname ::= nm AS nm */
   259,  /* (122) joinop ::= COMMA|JOIN */
   259,  /* (123) joinop ::= JOIN_KW JOIN */
   259,  /* (124) joinop ::= JOIN_KW nm JOIN */
   259,  /* (125) joinop ::= JOIN_KW nm nm JOIN */
   260,  /* (126) on_using ::= ON expr */
   260,  /* (127) on_using ::= USING LP idlist RP */
   260,  /* (128) on_using ::= */
   265,  /* (129) indexed_opt ::= */
   261,  /* (130) indexed_by ::= INDEXED BY nm */
   261,  /* (131) indexed_by ::= NOT INDEXED */
   250,  /* (132) orderby_opt ::= */
   250,  /* (133) orderby_opt ::= ORDER BY sortlist */
   232,  /* (134) sortlist ::= sortlist COMMA expr sortorder nulls */
   232,  /* (135) sortlist ::= expr sortorder nulls */
   220,  /* (136) sortorder ::= ASC */
   220,  /* (137) sortorder ::= DESC */
   220,  /* (138) sortorder ::= */
   266,  /* (139) nulls ::= NULLS FIRST */
   266,  /* (140) nulls ::= NULLS LAST */
   266,  /* (141) nulls ::= */
   248,  /* (142) groupby_opt ::= */
   248,  /* (143) groupby_opt ::= GROUP BY nexprlist */
   249,  /* (144) having_opt ::= */
   249,  /* (145) having_opt ::= HAVING expr */
   251,  /* (146) limit_opt ::= */
   251,  /* (147) limit_opt ::= LIMIT expr */
   251,  /* (148) limit_opt ::= LIMIT expr OFFSET expr */
   251,  /* (149) limit_opt ::= LIMIT expr COMMA expr */
   191,  /* (150) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
   247,  /* (151) where_opt ::= */
   247,  /* (152) where_opt ::= WHERE expr */
   268,  /* (153) where_opt_ret ::= */
   268,  /* (154) where_opt_ret ::= WHERE expr */
   268,  /* (155) where_opt_ret ::= RETURNING selcollist */
   268,  /* (156) where_opt_ret ::= WHERE expr RETURNING selcollist */
   191,  /* (157) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
   269,  /* (158) setlist ::= setlist COMMA nm EQ expr */
   269,  /* (159) setlist ::= setlist COMMA LP idlist RP EQ expr */
   269,  /* (160) setlist ::= nm EQ expr */
   269,  /* (161) setlist ::= LP idlist RP EQ expr */
   191,  /* (162) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
   191,  /* (163) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
   272,  /* (164) upsert ::= */
   272,  /* (165) upsert ::= RETURNING selcollist */
   272,  /* (166) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
   272,  /* (167) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
   272,  /* (168) upsert ::= ON CONFLICT DO NOTHING returning */
   272,  /* (169) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
   273,  /* (170) returning ::= RETURNING selcollist */
   270,  /* (171) insert_cmd ::= INSERT orconf */
   270,  /* (172) insert_cmd ::= REPLACE */
   271,  /* (173) idlist_opt ::= */
   271,  /* (174) idlist_opt ::= LP idlist RP */
   264,  /* (175) idlist ::= idlist COMMA nm */
   264,  /* (176) idlist ::= nm */
   218,  /* (177) expr ::= LP expr RP */
   218,  /* (178) expr ::= ID|INDEXED|JOIN_KW */
   218,  /* (179) expr ::= nm DOT nm */
   218,  /* (180) expr ::= nm DOT nm DOT nm */
   217,  /* (181) term ::= NULL|FLOAT|BLOB */
   217,  /* (182) term ::= STRING */
   217,  /* (183) term ::= INTEGER */
   218,  /* (184) expr ::= VARIABLE */
   218,  /* (185) expr ::= expr COLLATE ID|STRING */
   218,  /* (186) expr ::= CAST LP expr AS typetoken RP */
   218,  /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
   218,  /* (188) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
   218,  /* (189) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
   218,  /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
   218,  /* (191) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
   218,  /* (192) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
   217,  /* (193) term ::= CTIME_KW */
   218,  /* (194) expr ::= LP nexprlist COMMA expr RP */
   218,  /* (195) expr ::= expr AND expr */
   218,  /* (196) expr ::= expr OR expr */
   218,  /* (197) expr ::= expr LT|GT|GE|LE expr */
   218,  /* (198) expr ::= expr EQ|NE expr */
   218,  /* (199) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
   218,  /* (200) expr ::= expr PLUS|MINUS expr */
   218,  /* (201) expr ::= expr STAR|SLASH|REM expr */
   218,  /* (202) expr ::= expr CONCAT expr */
   275,  /* (203) likeop ::= NOT LIKE_KW|MATCH */
   218,  /* (204) expr ::= expr likeop expr */
   218,  /* (205) expr ::= expr likeop expr ESCAPE expr */
   218,  /* (206) expr ::= expr ISNULL|NOTNULL */
   218,  /* (207) expr ::= expr NOT NULL */
   218,  /* (208) expr ::= expr IS expr */
   218,  /* (209) expr ::= expr IS NOT expr */
   218,  /* (210) expr ::= expr IS NOT DISTINCT FROM expr */
   218,  /* (211) expr ::= expr IS DISTINCT FROM expr */
   218,  /* (212) expr ::= NOT expr */
   218,  /* (213) expr ::= BITNOT expr */
   218,  /* (214) expr ::= PLUS|MINUS expr */
   218,  /* (215) expr ::= expr PTR expr */
   276,  /* (216) between_op ::= BETWEEN */
   276,  /* (217) between_op ::= NOT BETWEEN */
   218,  /* (218) expr ::= expr between_op expr AND expr */
   277,  /* (219) in_op ::= IN */
   277,  /* (220) in_op ::= NOT IN */
   218,  /* (221) expr ::= expr in_op LP exprlist RP */
   218,  /* (222) expr ::= LP select RP */
   218,  /* (223) expr ::= expr in_op LP select RP */
   218,  /* (224) expr ::= expr in_op nm dbnm paren_exprlist */
   218,  /* (225) expr ::= EXISTS LP select RP */
   218,  /* (226) expr ::= CASE case_operand case_exprlist case_else END */
   280,  /* (227) case_exprlist ::= case_exprlist WHEN expr THEN expr */
   280,  /* (228) case_exprlist ::= WHEN expr THEN expr */
   281,  /* (229) case_else ::= ELSE expr */
   281,  /* (230) case_else ::= */
   279,  /* (231) case_operand ::= */
   262,  /* (232) exprlist ::= */
   254,  /* (233) nexprlist ::= nexprlist COMMA expr */
   254,  /* (234) nexprlist ::= expr */
   278,  /* (235) paren_exprlist ::= */
   278,  /* (236) paren_exprlist ::= LP exprlist RP */
   191,  /* (237) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
   282,  /* (238) uniqueflag ::= UNIQUE */
   282,  /* (239) uniqueflag ::= */
   222,  /* (240) eidlist_opt ::= */
   222,  /* (241) eidlist_opt ::= LP eidlist RP */
   233,  /* (242) eidlist ::= eidlist COMMA nm collate sortorder */
   233,  /* (243) eidlist ::= nm collate sortorder */
   283,  /* (244) collate ::= */
   283,  /* (245) collate ::= COLLATE ID|STRING */
   191,  /* (246) cmd ::= DROP INDEX ifexists fullname */
   191,  /* (247) cmd ::= VACUUM vinto */
   191,  /* (248) cmd ::= VACUUM nm vinto */
   284,  /* (249) vinto ::= INTO expr */
   284,  /* (250) vinto ::= */
   191,  /* (251) cmd ::= PRAGMA nm dbnm */
   191,  /* (252) cmd ::= PRAGMA nm dbnm EQ nmnum */
   191,  /* (253) cmd ::= PRAGMA nm dbnm LP nmnum RP */
   191,  /* (254) cmd ::= PRAGMA nm dbnm EQ minus_num */
   191,  /* (255) cmd ::= PRAGMA nm dbnm LP minus_num RP */
   212,  /* (256) plus_num ::= PLUS INTEGER|FLOAT */
   213,  /* (257) minus_num ::= MINUS INTEGER|FLOAT */
   191,  /* (258) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
   286,  /* (259) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
   288,  /* (260) trigger_time ::= BEFORE|AFTER */
   288,  /* (261) trigger_time ::= INSTEAD OF */
   288,  /* (262) trigger_time ::= */
   289,  /* (263) trigger_event ::= DELETE|INSERT */
   289,  /* (264) trigger_event ::= UPDATE */
   289,  /* (265) trigger_event ::= UPDATE OF idlist */
   291,  /* (266) when_clause ::= */
   291,  /* (267) when_clause ::= WHEN expr */
   287,  /* (268) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
   287,  /* (269) trigger_cmd_list ::= trigger_cmd SEMI */
   293,  /* (270) trnm ::= nm DOT nm */
   294,  /* (271) tridxby ::= INDEXED BY nm */
   294,  /* (272) tridxby ::= NOT INDEXED */
   292,  /* (273) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
   292,  /* (274) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
   292,  /* (275) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
   292,  /* (276) trigger_cmd ::= scanpt select scanpt */
   218,  /* (277) expr ::= RAISE LP IGNORE RP */
   218,  /* (278) expr ::= RAISE LP raisetype COMMA nm RP */
   237,  /* (279) raisetype ::= ROLLBACK */
   237,  /* (280) raisetype ::= ABORT */
   237,  /* (281) raisetype ::= FAIL */
   191,  /* (282) cmd ::= DROP TRIGGER ifexists fullname */
   191,  /* (283) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
   191,  /* (284) cmd ::= DETACH database_kw_opt expr */
   296,  /* (285) key_opt ::= */
   296,  /* (286) key_opt ::= KEY expr */
   191,  /* (287) cmd ::= REINDEX */
   191,  /* (288) cmd ::= REINDEX nm dbnm */
   191,  /* (289) cmd ::= ANALYZE */
   191,  /* (290) cmd ::= ANALYZE nm dbnm */
   191,  /* (291) cmd ::= ALTER TABLE fullname RENAME TO nm */
   191,  /* (292) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
   191,  /* (293) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
   297,  /* (294) add_column_fullname ::= fullname */
   191,  /* (295) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
   191,  /* (296) cmd ::= create_vtab */
   191,  /* (297) cmd ::= create_vtab LP vtabarglist RP */
   299,  /* (298) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
   301,  /* (299) vtabarg ::= */
   302,  /* (300) vtabargtoken ::= ANY */
   302,  /* (301) vtabargtoken ::= lp anylist RP */
   303,  /* (302) lp ::= LP */
   267,  /* (303) with ::= WITH wqlist */
   267,  /* (304) with ::= WITH RECURSIVE wqlist */
   306,  /* (305) wqas ::= AS */
   306,  /* (306) wqas ::= AS MATERIALIZED */
   306,  /* (307) wqas ::= AS NOT MATERIALIZED */
   305,  /* (308) wqitem ::= nm eidlist_opt wqas LP select RP */
   242,  /* (309) wqlist ::= wqitem */
   242,  /* (310) wqlist ::= wqlist COMMA wqitem */
   307,  /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */
   308,  /* (312) windowdefn ::= nm AS LP window RP */
   309,  /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
   309,  /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
   309,  /* (315) window ::= ORDER BY sortlist frame_opt */
   309,  /* (316) window ::= nm ORDER BY sortlist frame_opt */
   309,  /* (317) window ::= nm frame_opt */
   310,  /* (318) frame_opt ::= */
   310,  /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
   310,  /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
   314,  /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */
   316,  /* (322) frame_bound_s ::= frame_bound */
   316,  /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */
   317,  /* (324) frame_bound_e ::= frame_bound */
   317,  /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */
   315,  /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */
   315,  /* (327) frame_bound ::= CURRENT ROW */
   318,  /* (328) frame_exclude_opt ::= */
   318,  /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */
   319,  /* (330) frame_exclude ::= NO OTHERS */
   319,  /* (331) frame_exclude ::= CURRENT ROW */
   319,  /* (332) frame_exclude ::= GROUP|TIES */
   252,  /* (333) window_clause ::= WINDOW windowdefn_list */
   274,  /* (334) filter_over ::= filter_clause over_clause */
   274,  /* (335) filter_over ::= over_clause */
   274,  /* (336) filter_over ::= filter_clause */
   313,  /* (337) over_clause ::= OVER LP window RP */
   313,  /* (338) over_clause ::= OVER nm */
   312,  /* (339) filter_clause ::= FILTER LP WHERE expr RP */
   217,  /* (340) term ::= QNUMBER */
   186,  /* (341) input ::= cmdlist */
   187,  /* (342) cmdlist ::= cmdlist ecmd */
   187,  /* (343) cmdlist ::= ecmd */
   188,  /* (344) ecmd ::= SEMI */
   188,  /* (345) ecmd ::= cmdx SEMI */
   188,  /* (346) ecmd ::= explain cmdx SEMI */
   193,  /* (347) trans_opt ::= */
   193,  /* (348) trans_opt ::= TRANSACTION */
   193,  /* (349) trans_opt ::= TRANSACTION nm */
   195,  /* (350) savepoint_opt ::= SAVEPOINT */
   195,  /* (351) savepoint_opt ::= */
   191,  /* (352) cmd ::= create_table create_table_args */
   204,  /* (353) table_option_set ::= table_option */
   202,  /* (354) columnlist ::= columnlist COMMA columnname carglist */
   202,  /* (355) columnlist ::= columnname carglist */
   194,  /* (356) nm ::= ID|INDEXED|JOIN_KW */
   194,  /* (357) nm ::= STRING */
   209,  /* (358) typetoken ::= typename */
   210,  /* (359) typename ::= ID|STRING */
   211,  /* (360) signed ::= plus_num */
   211,  /* (361) signed ::= minus_num */
   208,  /* (362) carglist ::= carglist ccons */
   208,  /* (363) carglist ::= */
   216,  /* (364) ccons ::= NULL onconf */
   216,  /* (365) ccons ::= GENERATED ALWAYS AS generated */
   216,  /* (366) ccons ::= AS generated */
   203,  /* (367) conslist_opt ::= COMMA conslist */
   229,  /* (368) conslist ::= conslist tconscomma tcons */
   229,  /* (369) conslist ::= tcons */
   230,  /* (370) tconscomma ::= */
   234,  /* (371) defer_subclause_opt ::= defer_subclause */
   236,  /* (372) resolvetype ::= raisetype */
   240,  /* (373) selectnowith ::= oneselect */
   241,  /* (374) oneselect ::= values */
   255,  /* (375) sclp ::= selcollist COMMA */
   256,  /* (376) as ::= ID|STRING */
   265,  /* (377) indexed_opt ::= indexed_by */
   273,  /* (378) returning ::= */
   218,  /* (379) expr ::= term */
   275,  /* (380) likeop ::= LIKE_KW|MATCH */
   279,  /* (381) case_operand ::= expr */
   262,  /* (382) exprlist ::= nexprlist */
   285,  /* (383) nmnum ::= plus_num */
   285,  /* (384) nmnum ::= nm */
   285,  /* (385) nmnum ::= ON */
   285,  /* (386) nmnum ::= DELETE */
   285,  /* (387) nmnum ::= DEFAULT */
   212,  /* (388) plus_num ::= INTEGER|FLOAT */
   290,  /* (389) foreach_clause ::= */
   290,  /* (390) foreach_clause ::= FOR EACH ROW */
   293,  /* (391) trnm ::= nm */
   294,  /* (392) tridxby ::= */
   295,  /* (393) database_kw_opt ::= DATABASE */
   295,  /* (394) database_kw_opt ::= */
   298,  /* (395) kwcolumn_opt ::= */
   298,  /* (396) kwcolumn_opt ::= COLUMNKW */
   300,  /* (397) vtabarglist ::= vtabarg */
   300,  /* (398) vtabarglist ::= vtabarglist COMMA vtabarg */
   301,  /* (399) vtabarg ::= vtabarg vtabargtoken */
   304,  /* (400) anylist ::= */
   304,  /* (401) anylist ::= anylist LP anylist RP */
   304,  /* (402) anylist ::= anylist ANY */
   267,  /* (403) with ::= */
   307,  /* (404) windowdefn_list ::= windowdefn */
   309,  /* (405) window ::= frame_opt */
};

/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
** of symbols on the right-hand side of that rule. */
static const signed char yyRuleInfoNRhs[] = {
   -1,  /* (0) explain ::= EXPLAIN */
   -3,  /* (1) explain ::= EXPLAIN QUERY PLAN */
174795
174796
174797
174798
174799
174800
174801

174802
174803
174804
174805
174806
174807
174808
174809
174810
174811
174812
174813
174814
174815
174816
174817
174818
174819
174820
174821
174822
174823
174824
174825
174826
174827
174828
174829
174830
174831
174832
174833
174834
174835
174836
174837
174838
174839
174840
174841
174842
174843
174844
174845
174846
174847
174848

174849
174850
174851
174852
174853
174854
174855
174856
174857
174858
174859
174860
174861
174862
174863
174864
174865
174866
174867
174868
174869
174870
174871
174872
174873
   -2,  /* (333) window_clause ::= WINDOW windowdefn_list */
   -2,  /* (334) filter_over ::= filter_clause over_clause */
   -1,  /* (335) filter_over ::= over_clause */
   -1,  /* (336) filter_over ::= filter_clause */
   -4,  /* (337) over_clause ::= OVER LP window RP */
   -2,  /* (338) over_clause ::= OVER nm */
   -5,  /* (339) filter_clause ::= FILTER LP WHERE expr RP */

   -1,  /* (340) input ::= cmdlist */
   -2,  /* (341) cmdlist ::= cmdlist ecmd */
   -1,  /* (342) cmdlist ::= ecmd */
   -1,  /* (343) ecmd ::= SEMI */
   -2,  /* (344) ecmd ::= cmdx SEMI */
   -3,  /* (345) ecmd ::= explain cmdx SEMI */
    0,  /* (346) trans_opt ::= */
   -1,  /* (347) trans_opt ::= TRANSACTION */
   -2,  /* (348) trans_opt ::= TRANSACTION nm */
   -1,  /* (349) savepoint_opt ::= SAVEPOINT */
    0,  /* (350) savepoint_opt ::= */
   -2,  /* (351) cmd ::= create_table create_table_args */
   -1,  /* (352) table_option_set ::= table_option */
   -4,  /* (353) columnlist ::= columnlist COMMA columnname carglist */
   -2,  /* (354) columnlist ::= columnname carglist */
   -1,  /* (355) nm ::= ID|INDEXED|JOIN_KW */
   -1,  /* (356) nm ::= STRING */
   -1,  /* (357) typetoken ::= typename */
   -1,  /* (358) typename ::= ID|STRING */
   -1,  /* (359) signed ::= plus_num */
   -1,  /* (360) signed ::= minus_num */
   -2,  /* (361) carglist ::= carglist ccons */
    0,  /* (362) carglist ::= */
   -2,  /* (363) ccons ::= NULL onconf */
   -4,  /* (364) ccons ::= GENERATED ALWAYS AS generated */
   -2,  /* (365) ccons ::= AS generated */
   -2,  /* (366) conslist_opt ::= COMMA conslist */
   -3,  /* (367) conslist ::= conslist tconscomma tcons */
   -1,  /* (368) conslist ::= tcons */
    0,  /* (369) tconscomma ::= */
   -1,  /* (370) defer_subclause_opt ::= defer_subclause */
   -1,  /* (371) resolvetype ::= raisetype */
   -1,  /* (372) selectnowith ::= oneselect */
   -1,  /* (373) oneselect ::= values */
   -2,  /* (374) sclp ::= selcollist COMMA */
   -1,  /* (375) as ::= ID|STRING */
   -1,  /* (376) indexed_opt ::= indexed_by */
    0,  /* (377) returning ::= */
   -1,  /* (378) expr ::= term */
   -1,  /* (379) likeop ::= LIKE_KW|MATCH */
   -1,  /* (380) case_operand ::= expr */
   -1,  /* (381) exprlist ::= nexprlist */
   -1,  /* (382) nmnum ::= plus_num */
   -1,  /* (383) nmnum ::= nm */
   -1,  /* (384) nmnum ::= ON */
   -1,  /* (385) nmnum ::= DELETE */
   -1,  /* (386) nmnum ::= DEFAULT */

   -1,  /* (387) plus_num ::= INTEGER|FLOAT */
    0,  /* (388) foreach_clause ::= */
   -3,  /* (389) foreach_clause ::= FOR EACH ROW */
   -1,  /* (390) trnm ::= nm */
    0,  /* (391) tridxby ::= */
   -1,  /* (392) database_kw_opt ::= DATABASE */
    0,  /* (393) database_kw_opt ::= */
    0,  /* (394) kwcolumn_opt ::= */
   -1,  /* (395) kwcolumn_opt ::= COLUMNKW */
   -1,  /* (396) vtabarglist ::= vtabarg */
   -3,  /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */
   -2,  /* (398) vtabarg ::= vtabarg vtabargtoken */
    0,  /* (399) anylist ::= */
   -4,  /* (400) anylist ::= anylist LP anylist RP */
   -2,  /* (401) anylist ::= anylist ANY */
    0,  /* (402) with ::= */
   -1,  /* (403) windowdefn_list ::= windowdefn */
   -1,  /* (404) window ::= frame_opt */
};

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

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







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







175082
175083
175084
175085
175086
175087
175088
175089
175090
175091
175092
175093
175094
175095
175096
175097
175098
175099
175100
175101
175102
175103
175104
175105
175106
175107
175108
175109
175110
175111
175112
175113
175114
175115
175116
175117
175118
175119
175120
175121
175122
175123
175124
175125
175126
175127
175128
175129
175130
175131

175132
175133
175134
175135
175136
175137
175138
175139
175140
175141
175142
175143
175144
175145
175146
175147
175148
175149
175150
175151
175152
175153
175154
175155
175156
175157
175158
175159
175160
175161
   -2,  /* (333) window_clause ::= WINDOW windowdefn_list */
   -2,  /* (334) filter_over ::= filter_clause over_clause */
   -1,  /* (335) filter_over ::= over_clause */
   -1,  /* (336) filter_over ::= filter_clause */
   -4,  /* (337) over_clause ::= OVER LP window RP */
   -2,  /* (338) over_clause ::= OVER nm */
   -5,  /* (339) filter_clause ::= FILTER LP WHERE expr RP */
   -1,  /* (340) term ::= QNUMBER */
   -1,  /* (341) input ::= cmdlist */
   -2,  /* (342) cmdlist ::= cmdlist ecmd */
   -1,  /* (343) cmdlist ::= ecmd */
   -1,  /* (344) ecmd ::= SEMI */
   -2,  /* (345) ecmd ::= cmdx SEMI */
   -3,  /* (346) ecmd ::= explain cmdx SEMI */
    0,  /* (347) trans_opt ::= */
   -1,  /* (348) trans_opt ::= TRANSACTION */
   -2,  /* (349) trans_opt ::= TRANSACTION nm */
   -1,  /* (350) savepoint_opt ::= SAVEPOINT */
    0,  /* (351) savepoint_opt ::= */
   -2,  /* (352) cmd ::= create_table create_table_args */
   -1,  /* (353) table_option_set ::= table_option */
   -4,  /* (354) columnlist ::= columnlist COMMA columnname carglist */
   -2,  /* (355) columnlist ::= columnname carglist */
   -1,  /* (356) nm ::= ID|INDEXED|JOIN_KW */
   -1,  /* (357) nm ::= STRING */
   -1,  /* (358) typetoken ::= typename */
   -1,  /* (359) typename ::= ID|STRING */
   -1,  /* (360) signed ::= plus_num */
   -1,  /* (361) signed ::= minus_num */
   -2,  /* (362) carglist ::= carglist ccons */
    0,  /* (363) carglist ::= */
   -2,  /* (364) ccons ::= NULL onconf */
   -4,  /* (365) ccons ::= GENERATED ALWAYS AS generated */
   -2,  /* (366) ccons ::= AS generated */
   -2,  /* (367) conslist_opt ::= COMMA conslist */
   -3,  /* (368) conslist ::= conslist tconscomma tcons */
   -1,  /* (369) conslist ::= tcons */
    0,  /* (370) tconscomma ::= */
   -1,  /* (371) defer_subclause_opt ::= defer_subclause */
   -1,  /* (372) resolvetype ::= raisetype */
   -1,  /* (373) selectnowith ::= oneselect */
   -1,  /* (374) oneselect ::= values */
   -2,  /* (375) sclp ::= selcollist COMMA */
   -1,  /* (376) as ::= ID|STRING */
   -1,  /* (377) indexed_opt ::= indexed_by */
    0,  /* (378) returning ::= */
   -1,  /* (379) expr ::= term */
   -1,  /* (380) likeop ::= LIKE_KW|MATCH */
   -1,  /* (381) case_operand ::= expr */
   -1,  /* (382) exprlist ::= nexprlist */

   -1,  /* (383) nmnum ::= plus_num */
   -1,  /* (384) nmnum ::= nm */
   -1,  /* (385) nmnum ::= ON */
   -1,  /* (386) nmnum ::= DELETE */
   -1,  /* (387) nmnum ::= DEFAULT */
   -1,  /* (388) plus_num ::= INTEGER|FLOAT */
    0,  /* (389) foreach_clause ::= */
   -3,  /* (390) foreach_clause ::= FOR EACH ROW */
   -1,  /* (391) trnm ::= nm */
    0,  /* (392) tridxby ::= */
   -1,  /* (393) database_kw_opt ::= DATABASE */
    0,  /* (394) database_kw_opt ::= */
    0,  /* (395) kwcolumn_opt ::= */
   -1,  /* (396) kwcolumn_opt ::= COLUMNKW */
   -1,  /* (397) vtabarglist ::= vtabarg */
   -3,  /* (398) vtabarglist ::= vtabarglist COMMA vtabarg */
   -2,  /* (399) vtabarg ::= vtabarg vtabargtoken */
    0,  /* (400) anylist ::= */
   -4,  /* (401) anylist ::= anylist LP anylist RP */
   -2,  /* (402) anylist ::= anylist ANY */
    0,  /* (403) with ::= */
   -1,  /* (404) windowdefn_list ::= windowdefn */
   -1,  /* (405) window ::= frame_opt */
};

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

/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
174911
174912
174913
174914
174915
174916
174917
174918
174919
174920
174921
174922
174923
174924
174925
174926
174927
174928
174929
174930
174931
174932
174933
174934
      case 1: /* explain ::= EXPLAIN QUERY PLAN */
{ if( pParse->pReprepare==0 ) pParse->explain = 2; }
        break;
      case 2: /* cmdx ::= cmd */
{ sqlite3FinishCoding(pParse); }
        break;
      case 3: /* cmd ::= BEGIN transtype trans_opt */
{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy394);}
        break;
      case 4: /* transtype ::= */
{yymsp[1].minor.yy394 = TK_DEFERRED;}
        break;
      case 5: /* transtype ::= DEFERRED */
      case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
      case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
      case 321: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==321);
{yymsp[0].minor.yy394 = 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 */
{







|


|





|







175199
175200
175201
175202
175203
175204
175205
175206
175207
175208
175209
175210
175211
175212
175213
175214
175215
175216
175217
175218
175219
175220
175221
175222
      case 1: /* explain ::= EXPLAIN QUERY PLAN */
{ if( pParse->pReprepare==0 ) pParse->explain = 2; }
        break;
      case 2: /* cmdx ::= cmd */
{ sqlite3FinishCoding(pParse); }
        break;
      case 3: /* cmd ::= BEGIN transtype trans_opt */
{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy92);}
        break;
      case 4: /* transtype ::= */
{yymsp[1].minor.yy92 = TK_DEFERRED;}
        break;
      case 5: /* transtype ::= DEFERRED */
      case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
      case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
      case 321: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==321);
{yymsp[0].minor.yy92 = 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 */
{
174943
174944
174945
174946
174947
174948
174949
174950
174951
174952
174953
174954
174955
174956
174957
174958
174959
174960
174961
174962
174963
174964
174965
174966
174967
174968
174969
174970
174971
174972
174973
174974
174975
174976
174977
174978
174979
174980
174981
174982
174983
174984
174985
174986
174987
174988
174989
174990
174991
174992
174993
174994
174995
174996
174997
174998
174999
175000
175001
175002
175003
175004
175005
175006
175007
175008
175009
175010
175011
175012
175013
175014
175015
175016
      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.yy394,0,0,yymsp[-2].minor.yy394);
}
        break;
      case 14: /* createkw ::= CREATE */
{disableLookaside(pParse);}
        break;
      case 15: /* ifnotexists ::= */
      case 18: /* temp ::= */ yytestcase(yyruleno==18);
      case 47: /* autoinc ::= */ yytestcase(yyruleno==47);
      case 62: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==62);
      case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72);
      case 81: /* ifexists ::= */ yytestcase(yyruleno==81);
      case 98: /* distinct ::= */ yytestcase(yyruleno==98);
      case 244: /* collate ::= */ yytestcase(yyruleno==244);
{yymsp[1].minor.yy394 = 0;}
        break;
      case 16: /* ifnotexists ::= IF NOT EXISTS */
{yymsp[-2].minor.yy394 = 1;}
        break;
      case 17: /* temp ::= TEMP */
{yymsp[0].minor.yy394 = pParse->db->init.busy==0;}
        break;
      case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */
{
  sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy285,0);
}
        break;
      case 20: /* create_table_args ::= AS select */
{
  sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy47);
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy47);
}
        break;
      case 21: /* table_option_set ::= */
{yymsp[1].minor.yy285 = 0;}
        break;
      case 22: /* table_option_set ::= table_option_set COMMA table_option */
{yylhsminor.yy285 = yymsp[-2].minor.yy285|yymsp[0].minor.yy285;}
  yymsp[-2].minor.yy285 = yylhsminor.yy285;
        break;
      case 23: /* table_option ::= WITHOUT nm */
{
  if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
    yymsp[-1].minor.yy285 = TF_WithoutRowid | TF_NoVisibleRowid;
  }else{
    yymsp[-1].minor.yy285 = 0;
    sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
  }
}
        break;
      case 24: /* table_option ::= nm */
{
  if( yymsp[0].minor.yy0.n==6 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"strict",6)==0 ){
    yylhsminor.yy285 = TF_Strict;
  }else{
    yylhsminor.yy285 = 0;
    sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
  }
}
  yymsp[0].minor.yy285 = yylhsminor.yy285;
        break;
      case 25: /* columnname ::= nm typetoken */
{sqlite3AddColumn(pParse,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);}
        break;
      case 26: /* typetoken ::= */
      case 65: /* conslist_opt ::= */ yytestcase(yyruleno==65);
      case 104: /* as ::= */ yytestcase(yyruleno==104);







|













|


|


|



|




|
|



|


|
|




|

|







|

|



|







175231
175232
175233
175234
175235
175236
175237
175238
175239
175240
175241
175242
175243
175244
175245
175246
175247
175248
175249
175250
175251
175252
175253
175254
175255
175256
175257
175258
175259
175260
175261
175262
175263
175264
175265
175266
175267
175268
175269
175270
175271
175272
175273
175274
175275
175276
175277
175278
175279
175280
175281
175282
175283
175284
175285
175286
175287
175288
175289
175290
175291
175292
175293
175294
175295
175296
175297
175298
175299
175300
175301
175302
175303
175304
      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.yy92,0,0,yymsp[-2].minor.yy92);
}
        break;
      case 14: /* createkw ::= CREATE */
{disableLookaside(pParse);}
        break;
      case 15: /* ifnotexists ::= */
      case 18: /* temp ::= */ yytestcase(yyruleno==18);
      case 47: /* autoinc ::= */ yytestcase(yyruleno==47);
      case 62: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==62);
      case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72);
      case 81: /* ifexists ::= */ yytestcase(yyruleno==81);
      case 98: /* distinct ::= */ yytestcase(yyruleno==98);
      case 244: /* collate ::= */ yytestcase(yyruleno==244);
{yymsp[1].minor.yy92 = 0;}
        break;
      case 16: /* ifnotexists ::= IF NOT EXISTS */
{yymsp[-2].minor.yy92 = 1;}
        break;
      case 17: /* temp ::= TEMP */
{yymsp[0].minor.yy92 = pParse->db->init.busy==0;}
        break;
      case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */
{
  sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy527,0);
}
        break;
      case 20: /* create_table_args ::= AS select */
{
  sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy299);
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy299);
}
        break;
      case 21: /* table_option_set ::= */
{yymsp[1].minor.yy527 = 0;}
        break;
      case 22: /* table_option_set ::= table_option_set COMMA table_option */
{yylhsminor.yy527 = yymsp[-2].minor.yy527|yymsp[0].minor.yy527;}
  yymsp[-2].minor.yy527 = yylhsminor.yy527;
        break;
      case 23: /* table_option ::= WITHOUT nm */
{
  if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
    yymsp[-1].minor.yy527 = TF_WithoutRowid | TF_NoVisibleRowid;
  }else{
    yymsp[-1].minor.yy527 = 0;
    sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
  }
}
        break;
      case 24: /* table_option ::= nm */
{
  if( yymsp[0].minor.yy0.n==6 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"strict",6)==0 ){
    yylhsminor.yy527 = TF_Strict;
  }else{
    yylhsminor.yy527 = 0;
    sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
  }
}
  yymsp[0].minor.yy527 = yylhsminor.yy527;
        break;
      case 25: /* columnname ::= nm typetoken */
{sqlite3AddColumn(pParse,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);}
        break;
      case 26: /* typetoken ::= */
      case 65: /* conslist_opt ::= */ yytestcase(yyruleno==65);
      case 104: /* as ::= */ yytestcase(yyruleno==104);
175028
175029
175030
175031
175032
175033
175034
175035
175036
175037
175038
175039
175040
175041
175042
175043
175044
175045
175046
175047
175048
175049
175050
175051
175052
175053
175054
175055
175056
175057
175058
175059
175060
175061
175062
175063
175064
175065
175066
175067
175068
175069
175070
175071
175072
175073
175074
175075
175076
175077
175078
175079
175080
175081
175082
175083
175084
175085
175086
175087
175088
175089
175090
175091
175092
175093
175094
175095
175096
175097
175098
175099
175100
175101
175102
175103
175104
175105
175106
175107
175108
175109
175110
175111
175112
175113
175114
175115
175116
175117
175118
175119
175120
175121
175122
175123
175124
175125
175126
175127
175128
175129
175130
175131
175132
175133
175134
175135
175136
175137
175138
175139
175140
175141
175142
175143
175144
175145
175146
175147
175148
175149
175150
175151
175152
175153
175154
175155
175156
175157
175158
175159
175160
175161
175162
175163
175164
175165
175166
175167
175168
175169
175170
175171
175172
175173
175174
175175
175176
175177
175178
175179
175180
175181
175182
175183
175184
175185
175186
175187
175188
175189
175190
175191
175192
175193
175194
175195
175196
175197
175198
175199
175200
175201
175202
175203
175204
175205
175206
175207
175208
175209
175210
175211
175212
175213
175214
175215
175216
175217
175218
175219
175220
175221
175222
175223
175224
175225
175226
175227
175228
175229
175230
175231
175232
175233
175234
175235
175236
175237
175238
175239
175240
175241
175242
175243
175244
175245
175246
175247
175248
175249
175250
175251
175252
175253
175254
175255
175256
175257
175258
175259
175260
175261
175262
175263
175264
175265
175266
175267
175268
175269
175270
175271
175272
175273
175274
175275
175276
175277
175278
175279
175280
175281
175282
175283
175284
175285
175286
175287
175288
175289
175290
175291
175292
175293
175294
175295
175296
175297
175298
175299
175300
175301
175302
175303
175304
175305
175306
175307
175308
175309
175310
175311
175312
175313
175314
175315
175316
175317
175318
175319
175320
175321
175322
175323
175324
175325
175326
175327
175328
175329
175330
175331
175332
175333
175334
175335
175336
175337
175338
175339
175340
175341
175342
175343
175344
175345
175346
175347
175348
175349
175350
175351
175352
175353
175354
175355
175356
175357
175358
175359
175360
175361
175362
175363
175364
175365
175366
175367
175368
175369
175370
175371
175372
175373
175374
175375
175376
175377
175378
175379
175380
175381
175382
175383
175384
175385
175386
175387
175388
175389
175390
175391
175392
175393
175394
175395
175396
175397
175398
175399
175400
175401
175402
175403
175404
175405
175406
175407
175408
175409
175410
175411
175412
175413
175414
175415
175416
175417
175418
175419
175420
175421
175422
175423
175424
175425
175426
175427
175428
175429
175430
175431
175432
175433
175434
175435
175436
175437
175438
175439
175440
175441
175442
175443
175444
175445
175446
175447
175448
175449
175450
175451
175452
175453
175454
175455
175456
175457
175458
175459
175460
175461
175462
175463
175464
175465
175466
175467
175468
175469
175470
175471
175472
175473
175474
175475
175476
175477
175478
175479
175480
175481
175482
175483
175484
175485
175486
175487
175488
175489
175490
175491
175492
175493
175494
175495
175496
175497
175498
175499
175500
175501
175502
175503
175504
175505
175506
175507
175508
175509
175510
175511
175512
175513
175514
175515
175516
175517
175518
175519
175520
175521
175522
175523
175524
175525
175526
175527
175528
175529
175530
175531
175532
175533
175534
175535
175536
175537
175538
175539
175540
175541
175542
175543
175544
175545
175546
175547
175548
175549
175550
175551
175552
175553
175554
175555
175556
175557
175558
175559
175560
175561
175562
175563
175564
175565
175566
175567
175568
175569
175570
175571
175572
175573
175574
175575
175576
175577
175578
175579
175580
175581
175582
175583
175584
175585
175586
175587
175588
175589
175590
175591
175592
175593
175594
175595
175596
175597
175598
175599
175600
175601
175602
175603
175604
175605
175606
175607
175608
175609
175610
175611
175612
175613
175614
175615
175616
175617
175618
175619
175620
175621
175622
175623
175624
175625
175626
175627
175628
175629
175630
175631
175632
175633
175634
175635
175636
175637
175638
175639
175640
175641
175642
175643
175644
175645
175646
175647
175648
175649
175650
175651
175652
175653
175654
175655
175656
175657
175658
175659
175660
175661
175662
175663
175664
175665
175666
175667
175668
175669
175670
175671
175672
175673
175674
175675
175676
175677
175678
175679
175680
175681
175682
175683
175684
175685
175686
175687
175688
175689
175690
175691
175692
175693
175694
175695
175696
175697
175698
175699
175700
175701
175702
175703
175704
175705
175706
175707
175708
175709
175710
175711
175712
175713
175714
175715
175716
175717
175718
175719
175720
175721
175722
175723
175724
175725
175726
175727
175728
175729
175730
175731
175732
175733
175734
175735
175736
175737
175738
175739
175740
175741
175742
175743
175744
175745
175746
175747
175748
175749
175750
175751
175752
175753
175754
175755
175756
175757
175758
175759
175760
175761
175762
175763
175764
175765
175766
175767
175768
175769
175770
175771
175772
175773
175774
175775
175776
175777
175778
175779
175780
175781
175782
175783
175784
175785
175786
175787
175788
175789
175790
175791
175792
175793
175794
175795
175796
175797
175798
175799
175800
175801
175802
175803
175804
175805
175806
175807
175808
175809
175810
175811
175812
175813
175814
175815
175816
175817
175818
175819
175820
175821
175822
175823
175824
175825
175826
175827
175828
175829
175830
175831
175832
175833
175834
175835
175836
175837
175838
175839
175840
175841
175842
175843
175844
175845
175846
175847
175848
175849
175850
175851
175852
175853
175854
175855
175856
175857
175858
175859
175860
175861
175862
175863
175864
175865
175866
175867
175868
175869
175870
175871
175872
175873
175874
175875
175876
175877
175878
175879
175880
175881
175882
175883
175884
175885
175886
175887
175888
175889
175890
175891
175892
175893
175894
175895
175896
175897
175898
175899
175900
175901
175902
175903
175904
175905
175906
175907
175908
175909
175910
175911
175912
175913
175914
175915
175916
175917
175918
175919
175920
175921
175922
175923
175924
175925
175926
175927
175928
175929
175930
175931
175932
175933
175934
175935
175936
175937
175938
175939
175940
175941
175942
175943
175944
175945
175946
175947
175948
175949
175950
175951
175952
175953
175954
175955
175956
175957
175958
175959
175960
175961
175962
175963
175964
175965
175966
175967
175968
175969
175970
175971
175972
175973
175974
175975
175976
175977
175978
175979
175980
175981
175982
175983
175984
175985
175986
175987
175988
175989
175990
175991
175992
175993
175994
175995
175996
175997
175998
175999
176000
176001
176002
176003
176004
176005
176006
176007
176008
        break;
      case 29: /* 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 30: /* scanpt ::= */
{
  assert( yyLookahead!=YYNOCODE );
  yymsp[1].minor.yy522 = yyLookaheadToken.z;
}
        break;
      case 31: /* scantok ::= */
{
  assert( yyLookahead!=YYNOCODE );
  yymsp[1].minor.yy0 = yyLookaheadToken;
}
        break;
      case 32: /* ccons ::= CONSTRAINT nm */
      case 67: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==67);
{pParse->constraintName = yymsp[0].minor.yy0;}
        break;
      case 33: /* ccons ::= DEFAULT scantok term */
{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy528,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
        break;
      case 34: /* ccons ::= DEFAULT LP expr RP */
{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy528,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
        break;
      case 35: /* ccons ::= DEFAULT PLUS scantok term */
{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy528,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
        break;
      case 36: /* ccons ::= DEFAULT MINUS scantok term */
{
  Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy528, 0);
  sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
}
        break;
      case 37: /* ccons ::= DEFAULT scantok 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 38: /* ccons ::= NOT NULL onconf */
{sqlite3AddNotNull(pParse, yymsp[0].minor.yy394);}
        break;
      case 39: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy394,yymsp[0].minor.yy394,yymsp[-2].minor.yy394);}
        break;
      case 40: /* ccons ::= UNIQUE onconf */
{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy394,0,0,0,0,
                                   SQLITE_IDXTYPE_UNIQUE);}
        break;
      case 41: /* ccons ::= CHECK LP expr RP */
{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy528,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
        break;
      case 42: /* ccons ::= REFERENCES nm eidlist_opt refargs */
{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy322,yymsp[0].minor.yy394);}
        break;
      case 43: /* ccons ::= defer_subclause */
{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy394);}
        break;
      case 44: /* ccons ::= COLLATE ID|STRING */
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
        break;
      case 45: /* generated ::= LP expr RP */
{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy528,0);}
        break;
      case 46: /* generated ::= LP expr RP ID */
{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy528,&yymsp[0].minor.yy0);}
        break;
      case 48: /* autoinc ::= AUTOINCR */
{yymsp[0].minor.yy394 = 1;}
        break;
      case 49: /* refargs ::= */
{ yymsp[1].minor.yy394 = OE_None*0x0101; /* EV: R-19803-45884 */}
        break;
      case 50: /* refargs ::= refargs refarg */
{ yymsp[-1].minor.yy394 = (yymsp[-1].minor.yy394 & ~yymsp[0].minor.yy231.mask) | yymsp[0].minor.yy231.value; }
        break;
      case 51: /* refarg ::= MATCH nm */
{ yymsp[-1].minor.yy231.value = 0;     yymsp[-1].minor.yy231.mask = 0x000000; }
        break;
      case 52: /* refarg ::= ON INSERT refact */
{ yymsp[-2].minor.yy231.value = 0;     yymsp[-2].minor.yy231.mask = 0x000000; }
        break;
      case 53: /* refarg ::= ON DELETE refact */
{ yymsp[-2].minor.yy231.value = yymsp[0].minor.yy394;     yymsp[-2].minor.yy231.mask = 0x0000ff; }
        break;
      case 54: /* refarg ::= ON UPDATE refact */
{ yymsp[-2].minor.yy231.value = yymsp[0].minor.yy394<<8;  yymsp[-2].minor.yy231.mask = 0x00ff00; }
        break;
      case 55: /* refact ::= SET NULL */
{ yymsp[-1].minor.yy394 = OE_SetNull;  /* EV: R-33326-45252 */}
        break;
      case 56: /* refact ::= SET DEFAULT */
{ yymsp[-1].minor.yy394 = OE_SetDflt;  /* EV: R-33326-45252 */}
        break;
      case 57: /* refact ::= CASCADE */
{ yymsp[0].minor.yy394 = OE_Cascade;  /* EV: R-33326-45252 */}
        break;
      case 58: /* refact ::= RESTRICT */
{ yymsp[0].minor.yy394 = OE_Restrict; /* EV: R-33326-45252 */}
        break;
      case 59: /* refact ::= NO ACTION */
{ yymsp[-1].minor.yy394 = OE_None;     /* EV: R-33326-45252 */}
        break;
      case 60: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
{yymsp[-2].minor.yy394 = 0;}
        break;
      case 61: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
      case 76: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==76);
      case 171: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==171);
{yymsp[-1].minor.yy394 = yymsp[0].minor.yy394;}
        break;
      case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
      case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80);
      case 217: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==217);
      case 220: /* in_op ::= NOT IN */ yytestcase(yyruleno==220);
      case 245: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==245);
{yymsp[-1].minor.yy394 = 1;}
        break;
      case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
{yymsp[-1].minor.yy394 = 0;}
        break;
      case 66: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}
        break;
      case 68: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy322,yymsp[0].minor.yy394,yymsp[-2].minor.yy394,0);}
        break;
      case 69: /* tcons ::= UNIQUE LP sortlist RP onconf */
{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy322,yymsp[0].minor.yy394,0,0,0,0,
                                       SQLITE_IDXTYPE_UNIQUE);}
        break;
      case 70: /* tcons ::= CHECK LP expr RP onconf */
{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy528,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
        break;
      case 71: /* 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.yy394);
    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy394);
}
        break;
      case 73: /* onconf ::= */
      case 75: /* orconf ::= */ yytestcase(yyruleno==75);
{yymsp[1].minor.yy394 = OE_Default;}
        break;
      case 74: /* onconf ::= ON CONFLICT resolvetype */
{yymsp[-2].minor.yy394 = yymsp[0].minor.yy394;}
        break;
      case 77: /* resolvetype ::= IGNORE */
{yymsp[0].minor.yy394 = OE_Ignore;}
        break;
      case 78: /* resolvetype ::= REPLACE */
      case 172: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==172);
{yymsp[0].minor.yy394 = OE_Replace;}
        break;
      case 79: /* cmd ::= DROP TABLE ifexists fullname */
{
  sqlite3DropTable(pParse, yymsp[0].minor.yy131, 0, yymsp[-1].minor.yy394);
}
        break;
      case 82: /* 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.yy47, yymsp[-7].minor.yy394, yymsp[-5].minor.yy394);
}
        break;
      case 83: /* cmd ::= DROP VIEW ifexists fullname */
{
  sqlite3DropTable(pParse, yymsp[0].minor.yy131, 1, yymsp[-1].minor.yy394);
}
        break;
      case 84: /* cmd ::= select */
{
  SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0};
  sqlite3Select(pParse, yymsp[0].minor.yy47, &dest);
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy47);
}
        break;
      case 85: /* select ::= WITH wqlist selectnowith */
{yymsp[-2].minor.yy47 = attachWithToSelect(pParse,yymsp[0].minor.yy47,yymsp[-1].minor.yy521);}
        break;
      case 86: /* select ::= WITH RECURSIVE wqlist selectnowith */
{yymsp[-3].minor.yy47 = attachWithToSelect(pParse,yymsp[0].minor.yy47,yymsp[-1].minor.yy521);}
        break;
      case 87: /* select ::= selectnowith */
{
  Select *p = yymsp[0].minor.yy47;
  if( p ){
    parserDoubleLinkSelect(pParse, p);
  }
}
        break;
      case 88: /* selectnowith ::= selectnowith multiselect_op oneselect */
{
  Select *pRhs = yymsp[0].minor.yy47;
  Select *pLhs = yymsp[-2].minor.yy47;
  if( pRhs && pRhs->pPrior ){
    SrcList *pFrom;
    Token x;
    x.n = 0;
    parserDoubleLinkSelect(pParse, pRhs);
    pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0);
    pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
  }
  if( pRhs ){
    pRhs->op = (u8)yymsp[-1].minor.yy394;
    pRhs->pPrior = pLhs;
    if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
    pRhs->selFlags &= ~SF_MultiValue;
    if( yymsp[-1].minor.yy394!=TK_ALL ) pParse->hasCompound = 1;
  }else{
    sqlite3SelectDelete(pParse->db, pLhs);
  }
  yymsp[-2].minor.yy47 = pRhs;
}
        break;
      case 89: /* multiselect_op ::= UNION */
      case 91: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==91);
{yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-OP*/}
        break;
      case 90: /* multiselect_op ::= UNION ALL */
{yymsp[-1].minor.yy394 = TK_ALL;}
        break;
      case 92: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
{
  yymsp[-8].minor.yy47 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy322,yymsp[-5].minor.yy131,yymsp[-4].minor.yy528,yymsp[-3].minor.yy322,yymsp[-2].minor.yy528,yymsp[-1].minor.yy322,yymsp[-7].minor.yy394,yymsp[0].minor.yy528);
}
        break;
      case 93: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
{
  yymsp[-9].minor.yy47 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy322,yymsp[-6].minor.yy131,yymsp[-5].minor.yy528,yymsp[-4].minor.yy322,yymsp[-3].minor.yy528,yymsp[-1].minor.yy322,yymsp[-8].minor.yy394,yymsp[0].minor.yy528);
  if( yymsp[-9].minor.yy47 ){
    yymsp[-9].minor.yy47->pWinDefn = yymsp[-2].minor.yy41;
  }else{
    sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy41);
  }
}
        break;
      case 94: /* values ::= VALUES LP nexprlist RP */
{
  yymsp[-3].minor.yy47 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,0,0,0,0,0,SF_Values,0);
}
        break;
      case 95: /* values ::= values COMMA LP nexprlist RP */
{
  Select *pRight, *pLeft = yymsp[-4].minor.yy47;
  pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,0,0,0,0,0,SF_Values|SF_MultiValue,0);
  if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
  if( pRight ){
    pRight->op = TK_ALL;
    pRight->pPrior = pLeft;
    yymsp[-4].minor.yy47 = pRight;
  }else{
    yymsp[-4].minor.yy47 = pLeft;
  }
}
        break;
      case 96: /* distinct ::= DISTINCT */
{yymsp[0].minor.yy394 = SF_Distinct;}
        break;
      case 97: /* distinct ::= ALL */
{yymsp[0].minor.yy394 = SF_All;}
        break;
      case 99: /* sclp ::= */
      case 132: /* orderby_opt ::= */ yytestcase(yyruleno==132);
      case 142: /* groupby_opt ::= */ yytestcase(yyruleno==142);
      case 232: /* exprlist ::= */ yytestcase(yyruleno==232);
      case 235: /* paren_exprlist ::= */ yytestcase(yyruleno==235);
      case 240: /* eidlist_opt ::= */ yytestcase(yyruleno==240);
{yymsp[1].minor.yy322 = 0;}
        break;
      case 100: /* selcollist ::= sclp scanpt expr scanpt as */
{
   yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy528);
   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.yy522,yymsp[-1].minor.yy522);
}
        break;
      case 101: /* selcollist ::= sclp scanpt STAR */
{
  Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
  sqlite3ExprSetErrorOffset(p, (int)(yymsp[0].minor.yy0.z - pParse->zTail));
  yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, p);
}
        break;
      case 102: /* selcollist ::= sclp scanpt nm DOT STAR */
{
  Expr *pRight, *pLeft, *pDot;
  pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
  sqlite3ExprSetErrorOffset(pRight, (int)(yymsp[0].minor.yy0.z - pParse->zTail));
  pLeft = tokenExpr(pParse, TK_ID, yymsp[-2].minor.yy0);
  pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, pDot);
}
        break;
      case 103: /* as ::= AS nm */
      case 115: /* dbnm ::= DOT nm */ yytestcase(yyruleno==115);
      case 256: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==256);
      case 257: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==257);
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 105: /* from ::= */
      case 108: /* stl_prefix ::= */ yytestcase(yyruleno==108);
{yymsp[1].minor.yy131 = 0;}
        break;
      case 106: /* from ::= FROM seltablist */
{
  yymsp[-1].minor.yy131 = yymsp[0].minor.yy131;
  sqlite3SrcListShiftJoinType(pParse,yymsp[-1].minor.yy131);
}
        break;
      case 107: /* stl_prefix ::= seltablist joinop */
{
   if( ALWAYS(yymsp[-1].minor.yy131 && yymsp[-1].minor.yy131->nSrc>0) ) yymsp[-1].minor.yy131->a[yymsp[-1].minor.yy131->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy394;
}
        break;
      case 109: /* seltablist ::= stl_prefix nm dbnm as on_using */
{
  yymsp[-4].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-4].minor.yy131,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy561);
}
        break;
      case 110: /* seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
{
  yymsp[-5].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy131,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,0,&yymsp[0].minor.yy561);
  sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy131, &yymsp[-1].minor.yy0);
}
        break;
      case 111: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
{
  yymsp[-7].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-7].minor.yy131,&yymsp[-6].minor.yy0,&yymsp[-5].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy561);
  sqlite3SrcListFuncArgs(pParse, yymsp[-7].minor.yy131, yymsp[-3].minor.yy322);
}
        break;
      case 112: /* seltablist ::= stl_prefix LP select RP as on_using */
{
    yymsp[-5].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy131,0,0,&yymsp[-1].minor.yy0,yymsp[-3].minor.yy47,&yymsp[0].minor.yy561);
  }
        break;
      case 113: /* seltablist ::= stl_prefix LP seltablist RP as on_using */
{
    if( yymsp[-5].minor.yy131==0 && yymsp[-1].minor.yy0.n==0 && yymsp[0].minor.yy561.pOn==0 && yymsp[0].minor.yy561.pUsing==0 ){
      yymsp[-5].minor.yy131 = yymsp[-3].minor.yy131;
    }else if( ALWAYS(yymsp[-3].minor.yy131!=0) && yymsp[-3].minor.yy131->nSrc==1 ){
      yymsp[-5].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy131,0,0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy561);
      if( yymsp[-5].minor.yy131 ){
        SrcItem *pNew = &yymsp[-5].minor.yy131->a[yymsp[-5].minor.yy131->nSrc-1];
        SrcItem *pOld = yymsp[-3].minor.yy131->a;
        pNew->zName = pOld->zName;
        pNew->zDatabase = pOld->zDatabase;
        pNew->pSelect = pOld->pSelect;
        if( pNew->pSelect && (pNew->pSelect->selFlags & SF_NestedFrom)!=0 ){
          pNew->fg.isNestedFrom = 1;
        }
        if( pOld->fg.isTabFunc ){
          pNew->u1.pFuncArg = pOld->u1.pFuncArg;
          pOld->u1.pFuncArg = 0;
          pOld->fg.isTabFunc = 0;
          pNew->fg.isTabFunc = 1;
        }
        pOld->zName = pOld->zDatabase = 0;
        pOld->pSelect = 0;
      }
      sqlite3SrcListDelete(pParse->db, yymsp[-3].minor.yy131);
    }else{
      Select *pSubquery;
      sqlite3SrcListShiftJoinType(pParse,yymsp[-3].minor.yy131);
      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-3].minor.yy131,0,0,0,0,SF_NestedFrom,0);
      yymsp[-5].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy131,0,0,&yymsp[-1].minor.yy0,pSubquery,&yymsp[0].minor.yy561);
    }
  }
        break;
      case 114: /* dbnm ::= */
      case 129: /* indexed_opt ::= */ yytestcase(yyruleno==129);
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
        break;
      case 116: /* fullname ::= nm */
{
  yylhsminor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
  if( IN_RENAME_OBJECT && yylhsminor.yy131 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy131->a[0].zName, &yymsp[0].minor.yy0);
}
  yymsp[0].minor.yy131 = yylhsminor.yy131;
        break;
      case 117: /* fullname ::= nm DOT nm */
{
  yylhsminor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
  if( IN_RENAME_OBJECT && yylhsminor.yy131 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy131->a[0].zName, &yymsp[0].minor.yy0);
}
  yymsp[-2].minor.yy131 = yylhsminor.yy131;
        break;
      case 118: /* xfullname ::= nm */
{yymsp[0].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
        break;
      case 119: /* xfullname ::= nm DOT nm */
{yymsp[-2].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 120: /* xfullname ::= nm DOT nm AS nm */
{
   yymsp[-4].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
   if( yymsp[-4].minor.yy131 ) yymsp[-4].minor.yy131->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
        break;
      case 121: /* xfullname ::= nm AS nm */
{
   yymsp[-2].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
   if( yymsp[-2].minor.yy131 ) yymsp[-2].minor.yy131->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
        break;
      case 122: /* joinop ::= COMMA|JOIN */
{ yymsp[0].minor.yy394 = JT_INNER; }
        break;
      case 123: /* joinop ::= JOIN_KW JOIN */
{yymsp[-1].minor.yy394 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}
        break;
      case 124: /* joinop ::= JOIN_KW nm JOIN */
{yymsp[-2].minor.yy394 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
        break;
      case 125: /* joinop ::= JOIN_KW nm nm JOIN */
{yymsp[-3].minor.yy394 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
        break;
      case 126: /* on_using ::= ON expr */
{yymsp[-1].minor.yy561.pOn = yymsp[0].minor.yy528; yymsp[-1].minor.yy561.pUsing = 0;}
        break;
      case 127: /* on_using ::= USING LP idlist RP */
{yymsp[-3].minor.yy561.pOn = 0; yymsp[-3].minor.yy561.pUsing = yymsp[-1].minor.yy254;}
        break;
      case 128: /* on_using ::= */
{yymsp[1].minor.yy561.pOn = 0; yymsp[1].minor.yy561.pUsing = 0;}
        break;
      case 130: /* indexed_by ::= INDEXED BY nm */
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 131: /* indexed_by ::= NOT INDEXED */
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
        break;
      case 133: /* orderby_opt ::= ORDER BY sortlist */
      case 143: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==143);
{yymsp[-2].minor.yy322 = yymsp[0].minor.yy322;}
        break;
      case 134: /* sortlist ::= sortlist COMMA expr sortorder nulls */
{
  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322,yymsp[-2].minor.yy528);
  sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy322,yymsp[-1].minor.yy394,yymsp[0].minor.yy394);
}
        break;
      case 135: /* sortlist ::= expr sortorder nulls */
{
  yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy528); /*A-overwrites-Y*/
  sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy322,yymsp[-1].minor.yy394,yymsp[0].minor.yy394);
}
        break;
      case 136: /* sortorder ::= ASC */
{yymsp[0].minor.yy394 = SQLITE_SO_ASC;}
        break;
      case 137: /* sortorder ::= DESC */
{yymsp[0].minor.yy394 = SQLITE_SO_DESC;}
        break;
      case 138: /* sortorder ::= */
      case 141: /* nulls ::= */ yytestcase(yyruleno==141);
{yymsp[1].minor.yy394 = SQLITE_SO_UNDEFINED;}
        break;
      case 139: /* nulls ::= NULLS FIRST */
{yymsp[-1].minor.yy394 = SQLITE_SO_ASC;}
        break;
      case 140: /* nulls ::= NULLS LAST */
{yymsp[-1].minor.yy394 = SQLITE_SO_DESC;}
        break;
      case 144: /* having_opt ::= */
      case 146: /* limit_opt ::= */ yytestcase(yyruleno==146);
      case 151: /* where_opt ::= */ yytestcase(yyruleno==151);
      case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153);
      case 230: /* case_else ::= */ yytestcase(yyruleno==230);
      case 231: /* case_operand ::= */ yytestcase(yyruleno==231);
      case 250: /* vinto ::= */ yytestcase(yyruleno==250);
{yymsp[1].minor.yy528 = 0;}
        break;
      case 145: /* having_opt ::= HAVING expr */
      case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152);
      case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154);
      case 229: /* case_else ::= ELSE expr */ yytestcase(yyruleno==229);
      case 249: /* vinto ::= INTO expr */ yytestcase(yyruleno==249);
{yymsp[-1].minor.yy528 = yymsp[0].minor.yy528;}
        break;
      case 147: /* limit_opt ::= LIMIT expr */
{yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy528,0);}
        break;
      case 148: /* limit_opt ::= LIMIT expr OFFSET expr */
{yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);}
        break;
      case 149: /* limit_opt ::= LIMIT expr COMMA expr */
{yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy528,yymsp[-2].minor.yy528);}
        break;
      case 150: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
{
  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy131, &yymsp[-1].minor.yy0);
  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy131,yymsp[0].minor.yy528,0,0);
}
        break;
      case 155: /* where_opt_ret ::= RETURNING selcollist */
{sqlite3AddReturning(pParse,yymsp[0].minor.yy322); yymsp[-1].minor.yy528 = 0;}
        break;
      case 156: /* where_opt_ret ::= WHERE expr RETURNING selcollist */
{sqlite3AddReturning(pParse,yymsp[0].minor.yy322); yymsp[-3].minor.yy528 = yymsp[-2].minor.yy528;}
        break;
      case 157: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
{
  sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy131, &yymsp[-4].minor.yy0);
  sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy322,"set list");
  if( yymsp[-1].minor.yy131 ){
    SrcList *pFromClause = yymsp[-1].minor.yy131;
    if( pFromClause->nSrc>1 ){
      Select *pSubquery;
      Token as;
      pSubquery = sqlite3SelectNew(pParse,0,pFromClause,0,0,0,0,SF_NestedFrom,0);
      as.n = 0;
      as.z = 0;
      pFromClause = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&as,pSubquery,0);
    }
    yymsp[-5].minor.yy131 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy131, pFromClause);
  }
  sqlite3Update(pParse,yymsp[-5].minor.yy131,yymsp[-2].minor.yy322,yymsp[0].minor.yy528,yymsp[-6].minor.yy394,0,0,0);
}
        break;
      case 158: /* setlist ::= setlist COMMA nm EQ expr */
{
  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy528);
  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, 1);
}
        break;
      case 159: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
{
  yymsp[-6].minor.yy322 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy322, yymsp[-3].minor.yy254, yymsp[0].minor.yy528);
}
        break;
      case 160: /* setlist ::= nm EQ expr */
{
  yylhsminor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy528);
  sqlite3ExprListSetName(pParse, yylhsminor.yy322, &yymsp[-2].minor.yy0, 1);
}
  yymsp[-2].minor.yy322 = yylhsminor.yy322;
        break;
      case 161: /* setlist ::= LP idlist RP EQ expr */
{
  yymsp[-4].minor.yy322 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy254, yymsp[0].minor.yy528);
}
        break;
      case 162: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
{
  sqlite3Insert(pParse, yymsp[-3].minor.yy131, yymsp[-1].minor.yy47, yymsp[-2].minor.yy254, yymsp[-5].minor.yy394, yymsp[0].minor.yy444);
}
        break;
      case 163: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
{
  sqlite3Insert(pParse, yymsp[-4].minor.yy131, 0, yymsp[-3].minor.yy254, yymsp[-6].minor.yy394, 0);
}
        break;
      case 164: /* upsert ::= */
{ yymsp[1].minor.yy444 = 0; }
        break;
      case 165: /* upsert ::= RETURNING selcollist */
{ yymsp[-1].minor.yy444 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy322); }
        break;
      case 166: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
{ yymsp[-11].minor.yy444 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy322,yymsp[-6].minor.yy528,yymsp[-2].minor.yy322,yymsp[-1].minor.yy528,yymsp[0].minor.yy444);}
        break;
      case 167: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
{ yymsp[-8].minor.yy444 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy322,yymsp[-3].minor.yy528,0,0,yymsp[0].minor.yy444); }
        break;
      case 168: /* upsert ::= ON CONFLICT DO NOTHING returning */
{ yymsp[-4].minor.yy444 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
        break;
      case 169: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
{ yymsp[-7].minor.yy444 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy322,yymsp[-1].minor.yy528,0);}
        break;
      case 170: /* returning ::= RETURNING selcollist */
{sqlite3AddReturning(pParse,yymsp[0].minor.yy322);}
        break;
      case 173: /* idlist_opt ::= */
{yymsp[1].minor.yy254 = 0;}
        break;
      case 174: /* idlist_opt ::= LP idlist RP */
{yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;}
        break;
      case 175: /* idlist ::= idlist COMMA nm */
{yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);}
        break;
      case 176: /* idlist ::= nm */
{yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
        break;
      case 177: /* expr ::= LP expr RP */
{yymsp[-2].minor.yy528 = yymsp[-1].minor.yy528;}
        break;
      case 178: /* expr ::= ID|INDEXED|JOIN_KW */
{yymsp[0].minor.yy528=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 179: /* expr ::= nm DOT nm */
{
  Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
  Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
  yylhsminor.yy528 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
}
  yymsp[-2].minor.yy528 = yylhsminor.yy528;
        break;
      case 180: /* expr ::= nm DOT nm DOT nm */
{
  Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-4].minor.yy0);
  Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
  Expr *temp3 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
  Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
  if( IN_RENAME_OBJECT ){
    sqlite3RenameTokenRemap(pParse, 0, temp1);
  }
  yylhsminor.yy528 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
}
  yymsp[-4].minor.yy528 = yylhsminor.yy528;
        break;
      case 181: /* term ::= NULL|FLOAT|BLOB */
      case 182: /* term ::= STRING */ yytestcase(yyruleno==182);
{yymsp[0].minor.yy528=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 183: /* term ::= INTEGER */
{
  yylhsminor.yy528 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
  if( yylhsminor.yy528 ) yylhsminor.yy528->w.iOfst = (int)(yymsp[0].minor.yy0.z - pParse->zTail);
}
  yymsp[0].minor.yy528 = yylhsminor.yy528;
        break;
      case 184: /* 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.yy528 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy528, 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.yy528 = 0;
    }else{
      yymsp[0].minor.yy528 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
      if( yymsp[0].minor.yy528 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy528->iTable);
    }
  }
}
        break;
      case 185: /* expr ::= expr COLLATE ID|STRING */
{
  yymsp[-2].minor.yy528 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy528, &yymsp[0].minor.yy0, 1);
}
        break;
      case 186: /* expr ::= CAST LP expr AS typetoken RP */
{
  yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy528, yymsp[-3].minor.yy528, 0);
}
        break;
      case 187: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
{
  yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy394);
}
  yymsp[-4].minor.yy528 = yylhsminor.yy528;
        break;
      case 188: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
{
  yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy322, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy394);
  sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy528, yymsp[-1].minor.yy322);
}
  yymsp[-7].minor.yy528 = yylhsminor.yy528;
        break;
      case 189: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
{
  yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
}
  yymsp[-3].minor.yy528 = yylhsminor.yy528;
        break;
      case 190: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
{
  yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy322, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy394);
  sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41);
}
  yymsp[-5].minor.yy528 = yylhsminor.yy528;
        break;
      case 191: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
{
  yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy322, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy394);
  sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41);
  sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy528, yymsp[-2].minor.yy322);
}
  yymsp[-8].minor.yy528 = yylhsminor.yy528;
        break;
      case 192: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
{
  yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
  sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41);
}
  yymsp[-4].minor.yy528 = yylhsminor.yy528;
        break;
      case 193: /* term ::= CTIME_KW */
{
  yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
}
  yymsp[0].minor.yy528 = yylhsminor.yy528;
        break;
      case 194: /* expr ::= LP nexprlist COMMA expr RP */
{
  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528);
  yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
  if( yymsp[-4].minor.yy528 ){
    yymsp[-4].minor.yy528->x.pList = pList;
    if( ALWAYS(pList->nExpr) ){
      yymsp[-4].minor.yy528->flags |= pList->a[0].pExpr->flags & EP_Propagate;
    }
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  }
}
        break;
      case 195: /* expr ::= expr AND expr */
{yymsp[-2].minor.yy528=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);}
        break;
      case 196: /* expr ::= expr OR expr */
      case 197: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==197);
      case 198: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==198);
      case 199: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==199);
      case 200: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==200);
      case 201: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==201);
      case 202: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==202);
{yymsp[-2].minor.yy528=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);}
        break;
      case 203: /* 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 204: /* 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.yy528);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy528);
  yymsp[-2].minor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
  if( bNot ) yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy528, 0);
  if( yymsp[-2].minor.yy528 ) yymsp[-2].minor.yy528->flags |= EP_InfixFunc;
}
        break;
      case 205: /* 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.yy528);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy528);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy528);
  yymsp[-4].minor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
  if( bNot ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
  if( yymsp[-4].minor.yy528 ) yymsp[-4].minor.yy528->flags |= EP_InfixFunc;
}
        break;
      case 206: /* expr ::= expr ISNULL|NOTNULL */
{yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy528,0);}
        break;
      case 207: /* expr ::= expr NOT NULL */
{yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy528,0);}
        break;
      case 208: /* expr ::= expr IS expr */
{
  yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-2].minor.yy528, TK_ISNULL);
}
        break;
      case 209: /* expr ::= expr IS NOT expr */
{
  yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy528,yymsp[0].minor.yy528);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-3].minor.yy528, TK_NOTNULL);
}
        break;
      case 210: /* expr ::= expr IS NOT DISTINCT FROM expr */
{
  yymsp[-5].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy528,yymsp[0].minor.yy528);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-5].minor.yy528, TK_ISNULL);
}
        break;
      case 211: /* expr ::= expr IS DISTINCT FROM expr */
{
  yymsp[-4].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy528,yymsp[0].minor.yy528);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-4].minor.yy528, TK_NOTNULL);
}
        break;
      case 212: /* expr ::= NOT expr */
      case 213: /* expr ::= BITNOT expr */ yytestcase(yyruleno==213);
{yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy528, 0);/*A-overwrites-B*/}
        break;
      case 214: /* expr ::= PLUS|MINUS expr */
{
  yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy528, 0);
  /*A-overwrites-B*/
}
        break;
      case 215: /* expr ::= expr PTR expr */
{
  ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy528);
  pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy528);
  yylhsminor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
}
  yymsp[-2].minor.yy528 = yylhsminor.yy528;
        break;
      case 216: /* between_op ::= BETWEEN */
      case 219: /* in_op ::= IN */ yytestcase(yyruleno==219);
{yymsp[0].minor.yy394 = 0;}
        break;
      case 218: /* expr ::= expr between_op expr AND expr */
{
  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy528);
  yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy528, 0);
  if( yymsp[-4].minor.yy528 ){
    yymsp[-4].minor.yy528->x.pList = pList;
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  }
  if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
}
        break;
      case 221: /* expr ::= expr in_op LP exprlist RP */
{
    if( yymsp[-1].minor.yy322==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.
      */
      sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy528);
      yymsp[-4].minor.yy528 = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy394 ? "true" : "false");
      if( yymsp[-4].minor.yy528 ) sqlite3ExprIdToTrueFalse(yymsp[-4].minor.yy528);
    }else{
      Expr *pRHS = yymsp[-1].minor.yy322->a[0].pExpr;
      if( yymsp[-1].minor.yy322->nExpr==1 && sqlite3ExprIsConstant(pRHS) && yymsp[-4].minor.yy528->op!=TK_VECTOR ){
        yymsp[-1].minor.yy322->a[0].pExpr = 0;
        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
        pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
        yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy528, pRHS);
      }else if( yymsp[-1].minor.yy322->nExpr==1 && pRHS->op==TK_SELECT ){
        yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0);
        sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, pRHS->x.pSelect);
        pRHS->x.pSelect = 0;
        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
      }else{
        yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0);
        if( yymsp[-4].minor.yy528==0 ){
          sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
        }else if( yymsp[-4].minor.yy528->pLeft->op==TK_VECTOR ){
          int nExpr = yymsp[-4].minor.yy528->pLeft->x.pList->nExpr;
          Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy322);
          if( pSelectRHS ){
            parserDoubleLinkSelect(pParse, pSelectRHS);
            sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, pSelectRHS);
          }
        }else{
          yymsp[-4].minor.yy528->x.pList = yymsp[-1].minor.yy322;
          sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy528);
        }
      }
      if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
    }
  }
        break;
      case 222: /* expr ::= LP select RP */
{
    yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy528, yymsp[-1].minor.yy47);
  }
        break;
      case 223: /* expr ::= expr in_op LP select RP */
{
    yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, yymsp[-1].minor.yy47);
    if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
  }
        break;
      case 224: /* expr ::= expr in_op nm dbnm paren_exprlist */
{
    SrcList *pSrc = sqlite3SrcListAppend(pParse, 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.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, pSelect);
    if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
  }
        break;
      case 225: /* expr ::= EXISTS LP select RP */
{
    Expr *p;
    p = yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy47);
  }
        break;
      case 226: /* expr ::= CASE case_operand case_exprlist case_else END */
{
  yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy528, 0);
  if( yymsp[-4].minor.yy528 ){
    yymsp[-4].minor.yy528->x.pList = yymsp[-1].minor.yy528 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[-1].minor.yy528) : yymsp[-2].minor.yy322;
    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy528);
  }else{
    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322);
    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy528);
  }
}
        break;
      case 227: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy528);
  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy528);
}
        break;
      case 228: /* case_exprlist ::= WHEN expr THEN expr */
{
  yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528);
  yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy528);
}
        break;
      case 233: /* nexprlist ::= nexprlist COMMA expr */
{yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy528);}
        break;
      case 234: /* nexprlist ::= expr */
{yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy528); /*A-overwrites-Y*/}
        break;
      case 236: /* paren_exprlist ::= LP exprlist RP */
      case 241: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==241);
{yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;}
        break;
      case 237: /* 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,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy394,
                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy528, SQLITE_SO_ASC, yymsp[-8].minor.yy394, SQLITE_IDXTYPE_APPDEF);
  if( IN_RENAME_OBJECT && pParse->pNewIndex ){
    sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
  }
}
        break;
      case 238: /* uniqueflag ::= UNIQUE */
      case 280: /* raisetype ::= ABORT */ yytestcase(yyruleno==280);
{yymsp[0].minor.yy394 = OE_Abort;}
        break;
      case 239: /* uniqueflag ::= */
{yymsp[1].minor.yy394 = OE_None;}
        break;
      case 242: /* eidlist ::= eidlist COMMA nm collate sortorder */
{
  yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394);
}
        break;
      case 243: /* eidlist ::= nm collate sortorder */
{
  yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); /*A-overwrites-Y*/
}
        break;
      case 246: /* cmd ::= DROP INDEX ifexists fullname */
{sqlite3DropIndex(pParse, yymsp[0].minor.yy131, yymsp[-1].minor.yy394);}
        break;
      case 247: /* cmd ::= VACUUM vinto */
{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy528);}
        break;
      case 248: /* cmd ::= VACUUM nm vinto */
{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy528);}
        break;
      case 251: /* cmd ::= PRAGMA nm dbnm */
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
        break;
      case 252: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
        break;







|













|


|


|



|














|


|


|



|


|


|





|


|


|


|


|


|


|


|


|


|


|


|


|


|


|




|






|


|





|


|



|



|
|




|


|


|



|



|




|




|





|
|



|


|



|







|
|









|



|



|




|


|



|




|
|
|

|





|




|
|




|

|




|


|







|



|
|
|






|









|










|



|
|




|




|




|
|




|
|




|




|
|
|
|
|
|
|















|


|
|
|









|
|

|



|
|

|


|


|



|
|




|
|



|


|


|


|


|


|


|









|



|
|




|
|



|


|



|


|


|








|






|


|


|


|



|
|



|


|



|
|
|
|








|

|




|
|




|




|
|

|



|




|




|



|


|


|


|


|


|


|


|


|


|


|


|


|





|

|










|

|



|



|
|

|





|
|








|

|
|






|




|
|




|

|



|
|

|



|

|



|
|

|



|
|
|

|



|
|

|



|

|



|
|
|
|

|







|








|









|
|
|
|
|







|
|
|
|
|
|



|


|



|
|




|
|




|
|




|
|




|



|





|
|
|

|



|



|
|
|
|
|



|




|








|
|
|

|
|
|
|

|
|
|
|

|

|
|
|
|
|
|


|


|
|


|





|
|




|
|
|






|
|
|
|





|
|




|
|
|
|

|
|





|
|




|
|



|


|



|




|
|







|


|



|




|



|


|


|







175316
175317
175318
175319
175320
175321
175322
175323
175324
175325
175326
175327
175328
175329
175330
175331
175332
175333
175334
175335
175336
175337
175338
175339
175340
175341
175342
175343
175344
175345
175346
175347
175348
175349
175350
175351
175352
175353
175354
175355
175356
175357
175358
175359
175360
175361
175362
175363
175364
175365
175366
175367
175368
175369
175370
175371
175372
175373
175374
175375
175376
175377
175378
175379
175380
175381
175382
175383
175384
175385
175386
175387
175388
175389
175390
175391
175392
175393
175394
175395
175396
175397
175398
175399
175400
175401
175402
175403
175404
175405
175406
175407
175408
175409
175410
175411
175412
175413
175414
175415
175416
175417
175418
175419
175420
175421
175422
175423
175424
175425
175426
175427
175428
175429
175430
175431
175432
175433
175434
175435
175436
175437
175438
175439
175440
175441
175442
175443
175444
175445
175446
175447
175448
175449
175450
175451
175452
175453
175454
175455
175456
175457
175458
175459
175460
175461
175462
175463
175464
175465
175466
175467
175468
175469
175470
175471
175472
175473
175474
175475
175476
175477
175478
175479
175480
175481
175482
175483
175484
175485
175486
175487
175488
175489
175490
175491
175492
175493
175494
175495
175496
175497
175498
175499
175500
175501
175502
175503
175504
175505
175506
175507
175508
175509
175510
175511
175512
175513
175514
175515
175516
175517
175518
175519
175520
175521
175522
175523
175524
175525
175526
175527
175528
175529
175530
175531
175532
175533
175534
175535
175536
175537
175538
175539
175540
175541
175542
175543
175544
175545
175546
175547
175548
175549
175550
175551
175552
175553
175554
175555
175556
175557
175558
175559
175560
175561
175562
175563
175564
175565
175566
175567
175568
175569
175570
175571
175572
175573
175574
175575
175576
175577
175578
175579
175580
175581
175582
175583
175584
175585
175586
175587
175588
175589
175590
175591
175592
175593
175594
175595
175596
175597
175598
175599
175600
175601
175602
175603
175604
175605
175606
175607
175608
175609
175610
175611
175612
175613
175614
175615
175616
175617
175618
175619
175620
175621
175622
175623
175624
175625
175626
175627
175628
175629
175630
175631
175632
175633
175634
175635
175636
175637
175638
175639
175640
175641
175642
175643
175644
175645
175646
175647
175648
175649
175650
175651
175652
175653
175654
175655
175656
175657
175658
175659
175660
175661
175662
175663
175664
175665
175666
175667
175668
175669
175670
175671
175672
175673
175674
175675
175676
175677
175678
175679
175680
175681
175682
175683
175684
175685
175686
175687
175688
175689
175690
175691
175692
175693
175694
175695
175696
175697
175698
175699
175700
175701
175702
175703
175704
175705
175706
175707
175708
175709
175710
175711
175712
175713
175714
175715
175716
175717
175718
175719
175720
175721
175722
175723
175724
175725
175726
175727
175728
175729
175730
175731
175732
175733
175734
175735
175736
175737
175738
175739
175740
175741
175742
175743
175744
175745
175746
175747
175748
175749
175750
175751
175752
175753
175754
175755
175756
175757
175758
175759
175760
175761
175762
175763
175764
175765
175766
175767
175768
175769
175770
175771
175772
175773
175774
175775
175776
175777
175778
175779
175780
175781
175782
175783
175784
175785
175786
175787
175788
175789
175790
175791
175792
175793
175794
175795
175796
175797
175798
175799
175800
175801
175802
175803
175804
175805
175806
175807
175808
175809
175810
175811
175812
175813
175814
175815
175816
175817
175818
175819
175820
175821
175822
175823
175824
175825
175826
175827
175828
175829
175830
175831
175832
175833
175834
175835
175836
175837
175838
175839
175840
175841
175842
175843
175844
175845
175846
175847
175848
175849
175850
175851
175852
175853
175854
175855
175856
175857
175858
175859
175860
175861
175862
175863
175864
175865
175866
175867
175868
175869
175870
175871
175872
175873
175874
175875
175876
175877
175878
175879
175880
175881
175882
175883
175884
175885
175886
175887
175888
175889
175890
175891
175892
175893
175894
175895
175896
175897
175898
175899
175900
175901
175902
175903
175904
175905
175906
175907
175908
175909
175910
175911
175912
175913
175914
175915
175916
175917
175918
175919
175920
175921
175922
175923
175924
175925
175926
175927
175928
175929
175930
175931
175932
175933
175934
175935
175936
175937
175938
175939
175940
175941
175942
175943
175944
175945
175946
175947
175948
175949
175950
175951
175952
175953
175954
175955
175956
175957
175958
175959
175960
175961
175962
175963
175964
175965
175966
175967
175968
175969
175970
175971
175972
175973
175974
175975
175976
175977
175978
175979
175980
175981
175982
175983
175984
175985
175986
175987
175988
175989
175990
175991
175992
175993
175994
175995
175996
175997
175998
175999
176000
176001
176002
176003
176004
176005
176006
176007
176008
176009
176010
176011
176012
176013
176014
176015
176016
176017
176018
176019
176020
176021
176022
176023
176024
176025
176026
176027
176028
176029
176030
176031
176032
176033
176034
176035
176036
176037
176038
176039
176040
176041
176042
176043
176044
176045
176046
176047
176048
176049
176050
176051
176052
176053
176054
176055
176056
176057
176058
176059
176060
176061
176062
176063
176064
176065
176066
176067
176068
176069
176070
176071
176072
176073
176074
176075
176076
176077
176078
176079
176080
176081
176082
176083
176084
176085
176086
176087
176088
176089
176090
176091
176092
176093
176094
176095
176096
176097
176098
176099
176100
176101
176102
176103
176104
176105
176106
176107
176108
176109
176110
176111
176112
176113
176114
176115
176116
176117
176118
176119
176120
176121
176122
176123
176124
176125
176126
176127
176128
176129
176130
176131
176132
176133
176134
176135
176136
176137
176138
176139
176140
176141
176142
176143
176144
176145
176146
176147
176148
176149
176150
176151
176152
176153
176154
176155
176156
176157
176158
176159
176160
176161
176162
176163
176164
176165
176166
176167
176168
176169
176170
176171
176172
176173
176174
176175
176176
176177
176178
176179
176180
176181
176182
176183
176184
176185
176186
176187
176188
176189
176190
176191
176192
176193
176194
176195
176196
176197
176198
176199
176200
176201
176202
176203
176204
176205
176206
176207
176208
176209
176210
176211
176212
176213
176214
176215
176216
176217
176218
176219
176220
176221
176222
176223
176224
176225
176226
176227
176228
176229
176230
176231
176232
176233
176234
176235
176236
176237
176238
176239
176240
176241
176242
176243
176244
176245
176246
176247
176248
176249
176250
176251
176252
176253
176254
176255
176256
176257
176258
176259
176260
176261
176262
176263
176264
176265
176266
176267
176268
176269
176270
176271
176272
176273
176274
176275
176276
176277
176278
176279
176280
176281
176282
176283
176284
176285
176286
176287
176288
176289
176290
176291
176292
176293
176294
176295
176296
        break;
      case 29: /* 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 30: /* scanpt ::= */
{
  assert( yyLookahead!=YYNOCODE );
  yymsp[1].minor.yy616 = yyLookaheadToken.z;
}
        break;
      case 31: /* scantok ::= */
{
  assert( yyLookahead!=YYNOCODE );
  yymsp[1].minor.yy0 = yyLookaheadToken;
}
        break;
      case 32: /* ccons ::= CONSTRAINT nm */
      case 67: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==67);
{pParse->constraintName = yymsp[0].minor.yy0;}
        break;
      case 33: /* ccons ::= DEFAULT scantok term */
{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy2,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
        break;
      case 34: /* ccons ::= DEFAULT LP expr RP */
{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy2,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
        break;
      case 35: /* ccons ::= DEFAULT PLUS scantok term */
{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy2,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
        break;
      case 36: /* ccons ::= DEFAULT MINUS scantok term */
{
  Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy2, 0);
  sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
}
        break;
      case 37: /* ccons ::= DEFAULT scantok 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 38: /* ccons ::= NOT NULL onconf */
{sqlite3AddNotNull(pParse, yymsp[0].minor.yy92);}
        break;
      case 39: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy92,yymsp[0].minor.yy92,yymsp[-2].minor.yy92);}
        break;
      case 40: /* ccons ::= UNIQUE onconf */
{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy92,0,0,0,0,
                                   SQLITE_IDXTYPE_UNIQUE);}
        break;
      case 41: /* ccons ::= CHECK LP expr RP */
{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy2,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
        break;
      case 42: /* ccons ::= REFERENCES nm eidlist_opt refargs */
{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy402,yymsp[0].minor.yy92);}
        break;
      case 43: /* ccons ::= defer_subclause */
{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy92);}
        break;
      case 44: /* ccons ::= COLLATE ID|STRING */
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
        break;
      case 45: /* generated ::= LP expr RP */
{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy2,0);}
        break;
      case 46: /* generated ::= LP expr RP ID */
{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy2,&yymsp[0].minor.yy0);}
        break;
      case 48: /* autoinc ::= AUTOINCR */
{yymsp[0].minor.yy92 = 1;}
        break;
      case 49: /* refargs ::= */
{ yymsp[1].minor.yy92 = OE_None*0x0101; /* EV: R-19803-45884 */}
        break;
      case 50: /* refargs ::= refargs refarg */
{ yymsp[-1].minor.yy92 = (yymsp[-1].minor.yy92 & ~yymsp[0].minor.yy367.mask) | yymsp[0].minor.yy367.value; }
        break;
      case 51: /* refarg ::= MATCH nm */
{ yymsp[-1].minor.yy367.value = 0;     yymsp[-1].minor.yy367.mask = 0x000000; }
        break;
      case 52: /* refarg ::= ON INSERT refact */
{ yymsp[-2].minor.yy367.value = 0;     yymsp[-2].minor.yy367.mask = 0x000000; }
        break;
      case 53: /* refarg ::= ON DELETE refact */
{ yymsp[-2].minor.yy367.value = yymsp[0].minor.yy92;     yymsp[-2].minor.yy367.mask = 0x0000ff; }
        break;
      case 54: /* refarg ::= ON UPDATE refact */
{ yymsp[-2].minor.yy367.value = yymsp[0].minor.yy92<<8;  yymsp[-2].minor.yy367.mask = 0x00ff00; }
        break;
      case 55: /* refact ::= SET NULL */
{ yymsp[-1].minor.yy92 = OE_SetNull;  /* EV: R-33326-45252 */}
        break;
      case 56: /* refact ::= SET DEFAULT */
{ yymsp[-1].minor.yy92 = OE_SetDflt;  /* EV: R-33326-45252 */}
        break;
      case 57: /* refact ::= CASCADE */
{ yymsp[0].minor.yy92 = OE_Cascade;  /* EV: R-33326-45252 */}
        break;
      case 58: /* refact ::= RESTRICT */
{ yymsp[0].minor.yy92 = OE_Restrict; /* EV: R-33326-45252 */}
        break;
      case 59: /* refact ::= NO ACTION */
{ yymsp[-1].minor.yy92 = OE_None;     /* EV: R-33326-45252 */}
        break;
      case 60: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
{yymsp[-2].minor.yy92 = 0;}
        break;
      case 61: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
      case 76: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==76);
      case 171: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==171);
{yymsp[-1].minor.yy92 = yymsp[0].minor.yy92;}
        break;
      case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
      case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80);
      case 217: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==217);
      case 220: /* in_op ::= NOT IN */ yytestcase(yyruleno==220);
      case 245: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==245);
{yymsp[-1].minor.yy92 = 1;}
        break;
      case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
{yymsp[-1].minor.yy92 = 0;}
        break;
      case 66: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}
        break;
      case 68: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy402,yymsp[0].minor.yy92,yymsp[-2].minor.yy92,0);}
        break;
      case 69: /* tcons ::= UNIQUE LP sortlist RP onconf */
{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy402,yymsp[0].minor.yy92,0,0,0,0,
                                       SQLITE_IDXTYPE_UNIQUE);}
        break;
      case 70: /* tcons ::= CHECK LP expr RP onconf */
{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy2,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
        break;
      case 71: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
{
    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy402, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy402, yymsp[-1].minor.yy92);
    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy92);
}
        break;
      case 73: /* onconf ::= */
      case 75: /* orconf ::= */ yytestcase(yyruleno==75);
{yymsp[1].minor.yy92 = OE_Default;}
        break;
      case 74: /* onconf ::= ON CONFLICT resolvetype */
{yymsp[-2].minor.yy92 = yymsp[0].minor.yy92;}
        break;
      case 77: /* resolvetype ::= IGNORE */
{yymsp[0].minor.yy92 = OE_Ignore;}
        break;
      case 78: /* resolvetype ::= REPLACE */
      case 172: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==172);
{yymsp[0].minor.yy92 = OE_Replace;}
        break;
      case 79: /* cmd ::= DROP TABLE ifexists fullname */
{
  sqlite3DropTable(pParse, yymsp[0].minor.yy387, 0, yymsp[-1].minor.yy92);
}
        break;
      case 82: /* 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.yy402, yymsp[0].minor.yy299, yymsp[-7].minor.yy92, yymsp[-5].minor.yy92);
}
        break;
      case 83: /* cmd ::= DROP VIEW ifexists fullname */
{
  sqlite3DropTable(pParse, yymsp[0].minor.yy387, 1, yymsp[-1].minor.yy92);
}
        break;
      case 84: /* cmd ::= select */
{
  SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0};
  sqlite3Select(pParse, yymsp[0].minor.yy299, &dest);
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy299);
}
        break;
      case 85: /* select ::= WITH wqlist selectnowith */
{yymsp[-2].minor.yy299 = attachWithToSelect(pParse,yymsp[0].minor.yy299,yymsp[-1].minor.yy131);}
        break;
      case 86: /* select ::= WITH RECURSIVE wqlist selectnowith */
{yymsp[-3].minor.yy299 = attachWithToSelect(pParse,yymsp[0].minor.yy299,yymsp[-1].minor.yy131);}
        break;
      case 87: /* select ::= selectnowith */
{
  Select *p = yymsp[0].minor.yy299;
  if( p ){
    parserDoubleLinkSelect(pParse, p);
  }
}
        break;
      case 88: /* selectnowith ::= selectnowith multiselect_op oneselect */
{
  Select *pRhs = yymsp[0].minor.yy299;
  Select *pLhs = yymsp[-2].minor.yy299;
  if( pRhs && pRhs->pPrior ){
    SrcList *pFrom;
    Token x;
    x.n = 0;
    parserDoubleLinkSelect(pParse, pRhs);
    pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0);
    pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
  }
  if( pRhs ){
    pRhs->op = (u8)yymsp[-1].minor.yy92;
    pRhs->pPrior = pLhs;
    if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
    pRhs->selFlags &= ~SF_MultiValue;
    if( yymsp[-1].minor.yy92!=TK_ALL ) pParse->hasCompound = 1;
  }else{
    sqlite3SelectDelete(pParse->db, pLhs);
  }
  yymsp[-2].minor.yy299 = pRhs;
}
        break;
      case 89: /* multiselect_op ::= UNION */
      case 91: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==91);
{yymsp[0].minor.yy92 = yymsp[0].major; /*A-overwrites-OP*/}
        break;
      case 90: /* multiselect_op ::= UNION ALL */
{yymsp[-1].minor.yy92 = TK_ALL;}
        break;
      case 92: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
{
  yymsp[-8].minor.yy299 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy402,yymsp[-5].minor.yy387,yymsp[-4].minor.yy2,yymsp[-3].minor.yy402,yymsp[-2].minor.yy2,yymsp[-1].minor.yy402,yymsp[-7].minor.yy92,yymsp[0].minor.yy2);
}
        break;
      case 93: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
{
  yymsp[-9].minor.yy299 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy402,yymsp[-6].minor.yy387,yymsp[-5].minor.yy2,yymsp[-4].minor.yy402,yymsp[-3].minor.yy2,yymsp[-1].minor.yy402,yymsp[-8].minor.yy92,yymsp[0].minor.yy2);
  if( yymsp[-9].minor.yy299 ){
    yymsp[-9].minor.yy299->pWinDefn = yymsp[-2].minor.yy3;
  }else{
    sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy3);
  }
}
        break;
      case 94: /* values ::= VALUES LP nexprlist RP */
{
  yymsp[-3].minor.yy299 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy402,0,0,0,0,0,SF_Values,0);
}
        break;
      case 95: /* values ::= values COMMA LP nexprlist RP */
{
  Select *pRight, *pLeft = yymsp[-4].minor.yy299;
  pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy402,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.yy299 = pRight;
  }else{
    yymsp[-4].minor.yy299 = pLeft;
  }
}
        break;
      case 96: /* distinct ::= DISTINCT */
{yymsp[0].minor.yy92 = SF_Distinct;}
        break;
      case 97: /* distinct ::= ALL */
{yymsp[0].minor.yy92 = SF_All;}
        break;
      case 99: /* sclp ::= */
      case 132: /* orderby_opt ::= */ yytestcase(yyruleno==132);
      case 142: /* groupby_opt ::= */ yytestcase(yyruleno==142);
      case 232: /* exprlist ::= */ yytestcase(yyruleno==232);
      case 235: /* paren_exprlist ::= */ yytestcase(yyruleno==235);
      case 240: /* eidlist_opt ::= */ yytestcase(yyruleno==240);
{yymsp[1].minor.yy402 = 0;}
        break;
      case 100: /* selcollist ::= sclp scanpt expr scanpt as */
{
   yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy402, yymsp[-2].minor.yy2);
   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy402, &yymsp[0].minor.yy0, 1);
   sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy402,yymsp[-3].minor.yy616,yymsp[-1].minor.yy616);
}
        break;
      case 101: /* selcollist ::= sclp scanpt STAR */
{
  Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
  sqlite3ExprSetErrorOffset(p, (int)(yymsp[0].minor.yy0.z - pParse->zTail));
  yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy402, p);
}
        break;
      case 102: /* selcollist ::= sclp scanpt nm DOT STAR */
{
  Expr *pRight, *pLeft, *pDot;
  pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
  sqlite3ExprSetErrorOffset(pRight, (int)(yymsp[0].minor.yy0.z - pParse->zTail));
  pLeft = tokenExpr(pParse, TK_ID, yymsp[-2].minor.yy0);
  pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
  yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, pDot);
}
        break;
      case 103: /* as ::= AS nm */
      case 115: /* dbnm ::= DOT nm */ yytestcase(yyruleno==115);
      case 256: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==256);
      case 257: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==257);
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 105: /* from ::= */
      case 108: /* stl_prefix ::= */ yytestcase(yyruleno==108);
{yymsp[1].minor.yy387 = 0;}
        break;
      case 106: /* from ::= FROM seltablist */
{
  yymsp[-1].minor.yy387 = yymsp[0].minor.yy387;
  sqlite3SrcListShiftJoinType(pParse,yymsp[-1].minor.yy387);
}
        break;
      case 107: /* stl_prefix ::= seltablist joinop */
{
   if( ALWAYS(yymsp[-1].minor.yy387 && yymsp[-1].minor.yy387->nSrc>0) ) yymsp[-1].minor.yy387->a[yymsp[-1].minor.yy387->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy92;
}
        break;
      case 109: /* seltablist ::= stl_prefix nm dbnm as on_using */
{
  yymsp[-4].minor.yy387 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-4].minor.yy387,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy305);
}
        break;
      case 110: /* seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
{
  yymsp[-5].minor.yy387 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy387,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,0,&yymsp[0].minor.yy305);
  sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy387, &yymsp[-1].minor.yy0);
}
        break;
      case 111: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
{
  yymsp[-7].minor.yy387 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-7].minor.yy387,&yymsp[-6].minor.yy0,&yymsp[-5].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy305);
  sqlite3SrcListFuncArgs(pParse, yymsp[-7].minor.yy387, yymsp[-3].minor.yy402);
}
        break;
      case 112: /* seltablist ::= stl_prefix LP select RP as on_using */
{
    yymsp[-5].minor.yy387 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy387,0,0,&yymsp[-1].minor.yy0,yymsp[-3].minor.yy299,&yymsp[0].minor.yy305);
  }
        break;
      case 113: /* seltablist ::= stl_prefix LP seltablist RP as on_using */
{
    if( yymsp[-5].minor.yy387==0 && yymsp[-1].minor.yy0.n==0 && yymsp[0].minor.yy305.pOn==0 && yymsp[0].minor.yy305.pUsing==0 ){
      yymsp[-5].minor.yy387 = yymsp[-3].minor.yy387;
    }else if( ALWAYS(yymsp[-3].minor.yy387!=0) && yymsp[-3].minor.yy387->nSrc==1 ){
      yymsp[-5].minor.yy387 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy387,0,0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy305);
      if( yymsp[-5].minor.yy387 ){
        SrcItem *pNew = &yymsp[-5].minor.yy387->a[yymsp[-5].minor.yy387->nSrc-1];
        SrcItem *pOld = yymsp[-3].minor.yy387->a;
        pNew->zName = pOld->zName;
        pNew->zDatabase = pOld->zDatabase;
        pNew->pSelect = pOld->pSelect;
        if( pNew->pSelect && (pNew->pSelect->selFlags & SF_NestedFrom)!=0 ){
          pNew->fg.isNestedFrom = 1;
        }
        if( pOld->fg.isTabFunc ){
          pNew->u1.pFuncArg = pOld->u1.pFuncArg;
          pOld->u1.pFuncArg = 0;
          pOld->fg.isTabFunc = 0;
          pNew->fg.isTabFunc = 1;
        }
        pOld->zName = pOld->zDatabase = 0;
        pOld->pSelect = 0;
      }
      sqlite3SrcListDelete(pParse->db, yymsp[-3].minor.yy387);
    }else{
      Select *pSubquery;
      sqlite3SrcListShiftJoinType(pParse,yymsp[-3].minor.yy387);
      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-3].minor.yy387,0,0,0,0,SF_NestedFrom,0);
      yymsp[-5].minor.yy387 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy387,0,0,&yymsp[-1].minor.yy0,pSubquery,&yymsp[0].minor.yy305);
    }
  }
        break;
      case 114: /* dbnm ::= */
      case 129: /* indexed_opt ::= */ yytestcase(yyruleno==129);
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
        break;
      case 116: /* fullname ::= nm */
{
  yylhsminor.yy387 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
  if( IN_RENAME_OBJECT && yylhsminor.yy387 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy387->a[0].zName, &yymsp[0].minor.yy0);
}
  yymsp[0].minor.yy387 = yylhsminor.yy387;
        break;
      case 117: /* fullname ::= nm DOT nm */
{
  yylhsminor.yy387 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
  if( IN_RENAME_OBJECT && yylhsminor.yy387 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy387->a[0].zName, &yymsp[0].minor.yy0);
}
  yymsp[-2].minor.yy387 = yylhsminor.yy387;
        break;
      case 118: /* xfullname ::= nm */
{yymsp[0].minor.yy387 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
        break;
      case 119: /* xfullname ::= nm DOT nm */
{yymsp[-2].minor.yy387 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 120: /* xfullname ::= nm DOT nm AS nm */
{
   yymsp[-4].minor.yy387 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
   if( yymsp[-4].minor.yy387 ) yymsp[-4].minor.yy387->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
        break;
      case 121: /* xfullname ::= nm AS nm */
{
   yymsp[-2].minor.yy387 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
   if( yymsp[-2].minor.yy387 ) yymsp[-2].minor.yy387->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
        break;
      case 122: /* joinop ::= COMMA|JOIN */
{ yymsp[0].minor.yy92 = JT_INNER; }
        break;
      case 123: /* joinop ::= JOIN_KW JOIN */
{yymsp[-1].minor.yy92 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}
        break;
      case 124: /* joinop ::= JOIN_KW nm JOIN */
{yymsp[-2].minor.yy92 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
        break;
      case 125: /* joinop ::= JOIN_KW nm nm JOIN */
{yymsp[-3].minor.yy92 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
        break;
      case 126: /* on_using ::= ON expr */
{yymsp[-1].minor.yy305.pOn = yymsp[0].minor.yy2; yymsp[-1].minor.yy305.pUsing = 0;}
        break;
      case 127: /* on_using ::= USING LP idlist RP */
{yymsp[-3].minor.yy305.pOn = 0; yymsp[-3].minor.yy305.pUsing = yymsp[-1].minor.yy400;}
        break;
      case 128: /* on_using ::= */
{yymsp[1].minor.yy305.pOn = 0; yymsp[1].minor.yy305.pUsing = 0;}
        break;
      case 130: /* indexed_by ::= INDEXED BY nm */
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 131: /* indexed_by ::= NOT INDEXED */
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
        break;
      case 133: /* orderby_opt ::= ORDER BY sortlist */
      case 143: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==143);
{yymsp[-2].minor.yy402 = yymsp[0].minor.yy402;}
        break;
      case 134: /* sortlist ::= sortlist COMMA expr sortorder nulls */
{
  yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402,yymsp[-2].minor.yy2);
  sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy402,yymsp[-1].minor.yy92,yymsp[0].minor.yy92);
}
        break;
      case 135: /* sortlist ::= expr sortorder nulls */
{
  yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy2); /*A-overwrites-Y*/
  sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy402,yymsp[-1].minor.yy92,yymsp[0].minor.yy92);
}
        break;
      case 136: /* sortorder ::= ASC */
{yymsp[0].minor.yy92 = SQLITE_SO_ASC;}
        break;
      case 137: /* sortorder ::= DESC */
{yymsp[0].minor.yy92 = SQLITE_SO_DESC;}
        break;
      case 138: /* sortorder ::= */
      case 141: /* nulls ::= */ yytestcase(yyruleno==141);
{yymsp[1].minor.yy92 = SQLITE_SO_UNDEFINED;}
        break;
      case 139: /* nulls ::= NULLS FIRST */
{yymsp[-1].minor.yy92 = SQLITE_SO_ASC;}
        break;
      case 140: /* nulls ::= NULLS LAST */
{yymsp[-1].minor.yy92 = SQLITE_SO_DESC;}
        break;
      case 144: /* having_opt ::= */
      case 146: /* limit_opt ::= */ yytestcase(yyruleno==146);
      case 151: /* where_opt ::= */ yytestcase(yyruleno==151);
      case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153);
      case 230: /* case_else ::= */ yytestcase(yyruleno==230);
      case 231: /* case_operand ::= */ yytestcase(yyruleno==231);
      case 250: /* vinto ::= */ yytestcase(yyruleno==250);
{yymsp[1].minor.yy2 = 0;}
        break;
      case 145: /* having_opt ::= HAVING expr */
      case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152);
      case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154);
      case 229: /* case_else ::= ELSE expr */ yytestcase(yyruleno==229);
      case 249: /* vinto ::= INTO expr */ yytestcase(yyruleno==249);
{yymsp[-1].minor.yy2 = yymsp[0].minor.yy2;}
        break;
      case 147: /* limit_opt ::= LIMIT expr */
{yymsp[-1].minor.yy2 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy2,0);}
        break;
      case 148: /* limit_opt ::= LIMIT expr OFFSET expr */
{yymsp[-3].minor.yy2 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy2,yymsp[0].minor.yy2);}
        break;
      case 149: /* limit_opt ::= LIMIT expr COMMA expr */
{yymsp[-3].minor.yy2 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy2,yymsp[-2].minor.yy2);}
        break;
      case 150: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
{
  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy387, &yymsp[-1].minor.yy0);
  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy387,yymsp[0].minor.yy2,0,0);
}
        break;
      case 155: /* where_opt_ret ::= RETURNING selcollist */
{sqlite3AddReturning(pParse,yymsp[0].minor.yy402); yymsp[-1].minor.yy2 = 0;}
        break;
      case 156: /* where_opt_ret ::= WHERE expr RETURNING selcollist */
{sqlite3AddReturning(pParse,yymsp[0].minor.yy402); yymsp[-3].minor.yy2 = yymsp[-2].minor.yy2;}
        break;
      case 157: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
{
  sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy387, &yymsp[-4].minor.yy0);
  sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy402,"set list");
  if( yymsp[-1].minor.yy387 ){
    SrcList *pFromClause = yymsp[-1].minor.yy387;
    if( pFromClause->nSrc>1 ){
      Select *pSubquery;
      Token as;
      pSubquery = sqlite3SelectNew(pParse,0,pFromClause,0,0,0,0,SF_NestedFrom,0);
      as.n = 0;
      as.z = 0;
      pFromClause = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&as,pSubquery,0);
    }
    yymsp[-5].minor.yy387 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy387, pFromClause);
  }
  sqlite3Update(pParse,yymsp[-5].minor.yy387,yymsp[-2].minor.yy402,yymsp[0].minor.yy2,yymsp[-6].minor.yy92,0,0,0);
}
        break;
      case 158: /* setlist ::= setlist COMMA nm EQ expr */
{
  yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy402, yymsp[0].minor.yy2);
  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy402, &yymsp[-2].minor.yy0, 1);
}
        break;
      case 159: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
{
  yymsp[-6].minor.yy402 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy402, yymsp[-3].minor.yy400, yymsp[0].minor.yy2);
}
        break;
      case 160: /* setlist ::= nm EQ expr */
{
  yylhsminor.yy402 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy2);
  sqlite3ExprListSetName(pParse, yylhsminor.yy402, &yymsp[-2].minor.yy0, 1);
}
  yymsp[-2].minor.yy402 = yylhsminor.yy402;
        break;
      case 161: /* setlist ::= LP idlist RP EQ expr */
{
  yymsp[-4].minor.yy402 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy400, yymsp[0].minor.yy2);
}
        break;
      case 162: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
{
  sqlite3Insert(pParse, yymsp[-3].minor.yy387, yymsp[-1].minor.yy299, yymsp[-2].minor.yy400, yymsp[-5].minor.yy92, yymsp[0].minor.yy258);
}
        break;
      case 163: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
{
  sqlite3Insert(pParse, yymsp[-4].minor.yy387, 0, yymsp[-3].minor.yy400, yymsp[-6].minor.yy92, 0);
}
        break;
      case 164: /* upsert ::= */
{ yymsp[1].minor.yy258 = 0; }
        break;
      case 165: /* upsert ::= RETURNING selcollist */
{ yymsp[-1].minor.yy258 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy402); }
        break;
      case 166: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
{ yymsp[-11].minor.yy258 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy402,yymsp[-6].minor.yy2,yymsp[-2].minor.yy402,yymsp[-1].minor.yy2,yymsp[0].minor.yy258);}
        break;
      case 167: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
{ yymsp[-8].minor.yy258 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy402,yymsp[-3].minor.yy2,0,0,yymsp[0].minor.yy258); }
        break;
      case 168: /* upsert ::= ON CONFLICT DO NOTHING returning */
{ yymsp[-4].minor.yy258 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
        break;
      case 169: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
{ yymsp[-7].minor.yy258 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy402,yymsp[-1].minor.yy2,0);}
        break;
      case 170: /* returning ::= RETURNING selcollist */
{sqlite3AddReturning(pParse,yymsp[0].minor.yy402);}
        break;
      case 173: /* idlist_opt ::= */
{yymsp[1].minor.yy400 = 0;}
        break;
      case 174: /* idlist_opt ::= LP idlist RP */
{yymsp[-2].minor.yy400 = yymsp[-1].minor.yy400;}
        break;
      case 175: /* idlist ::= idlist COMMA nm */
{yymsp[-2].minor.yy400 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy400,&yymsp[0].minor.yy0);}
        break;
      case 176: /* idlist ::= nm */
{yymsp[0].minor.yy400 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
        break;
      case 177: /* expr ::= LP expr RP */
{yymsp[-2].minor.yy2 = yymsp[-1].minor.yy2;}
        break;
      case 178: /* expr ::= ID|INDEXED|JOIN_KW */
{yymsp[0].minor.yy2=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 179: /* expr ::= nm DOT nm */
{
  Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
  Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
  yylhsminor.yy2 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
}
  yymsp[-2].minor.yy2 = yylhsminor.yy2;
        break;
      case 180: /* expr ::= nm DOT nm DOT nm */
{
  Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-4].minor.yy0);
  Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
  Expr *temp3 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
  Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
  if( IN_RENAME_OBJECT ){
    sqlite3RenameTokenRemap(pParse, 0, temp1);
  }
  yylhsminor.yy2 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
}
  yymsp[-4].minor.yy2 = yylhsminor.yy2;
        break;
      case 181: /* term ::= NULL|FLOAT|BLOB */
      case 182: /* term ::= STRING */ yytestcase(yyruleno==182);
{yymsp[0].minor.yy2=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 183: /* term ::= INTEGER */
{
  yylhsminor.yy2 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
  if( yylhsminor.yy2 ) yylhsminor.yy2->w.iOfst = (int)(yymsp[0].minor.yy0.z - pParse->zTail);
}
  yymsp[0].minor.yy2 = yylhsminor.yy2;
        break;
      case 184: /* 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.yy2 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy2, 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.yy2 = 0;
    }else{
      yymsp[0].minor.yy2 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
      if( yymsp[0].minor.yy2 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy2->iTable);
    }
  }
}
        break;
      case 185: /* expr ::= expr COLLATE ID|STRING */
{
  yymsp[-2].minor.yy2 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy2, &yymsp[0].minor.yy0, 1);
}
        break;
      case 186: /* expr ::= CAST LP expr AS typetoken RP */
{
  yymsp[-5].minor.yy2 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy2, yymsp[-3].minor.yy2, 0);
}
        break;
      case 187: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
{
  yylhsminor.yy2 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy402, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy92);
}
  yymsp[-4].minor.yy2 = yylhsminor.yy2;
        break;
      case 188: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
{
  yylhsminor.yy2 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy402, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy92);
  sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy2, yymsp[-1].minor.yy402);
}
  yymsp[-7].minor.yy2 = yylhsminor.yy2;
        break;
      case 189: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
{
  yylhsminor.yy2 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
}
  yymsp[-3].minor.yy2 = yylhsminor.yy2;
        break;
      case 190: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
{
  yylhsminor.yy2 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy402, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy92);
  sqlite3WindowAttach(pParse, yylhsminor.yy2, yymsp[0].minor.yy3);
}
  yymsp[-5].minor.yy2 = yylhsminor.yy2;
        break;
      case 191: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
{
  yylhsminor.yy2 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy402, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy92);
  sqlite3WindowAttach(pParse, yylhsminor.yy2, yymsp[0].minor.yy3);
  sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy2, yymsp[-2].minor.yy402);
}
  yymsp[-8].minor.yy2 = yylhsminor.yy2;
        break;
      case 192: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
{
  yylhsminor.yy2 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
  sqlite3WindowAttach(pParse, yylhsminor.yy2, yymsp[0].minor.yy3);
}
  yymsp[-4].minor.yy2 = yylhsminor.yy2;
        break;
      case 193: /* term ::= CTIME_KW */
{
  yylhsminor.yy2 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
}
  yymsp[0].minor.yy2 = yylhsminor.yy2;
        break;
      case 194: /* expr ::= LP nexprlist COMMA expr RP */
{
  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy402, yymsp[-1].minor.yy2);
  yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
  if( yymsp[-4].minor.yy2 ){
    yymsp[-4].minor.yy2->x.pList = pList;
    if( ALWAYS(pList->nExpr) ){
      yymsp[-4].minor.yy2->flags |= pList->a[0].pExpr->flags & EP_Propagate;
    }
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  }
}
        break;
      case 195: /* expr ::= expr AND expr */
{yymsp[-2].minor.yy2=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy2,yymsp[0].minor.yy2);}
        break;
      case 196: /* expr ::= expr OR expr */
      case 197: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==197);
      case 198: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==198);
      case 199: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==199);
      case 200: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==200);
      case 201: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==201);
      case 202: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==202);
{yymsp[-2].minor.yy2=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy2,yymsp[0].minor.yy2);}
        break;
      case 203: /* 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 204: /* 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.yy2);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy2);
  yymsp[-2].minor.yy2 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
  if( bNot ) yymsp[-2].minor.yy2 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy2, 0);
  if( yymsp[-2].minor.yy2 ) yymsp[-2].minor.yy2->flags |= EP_InfixFunc;
}
        break;
      case 205: /* 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.yy2);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy2);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy2);
  yymsp[-4].minor.yy2 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
  if( bNot ) yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy2, 0);
  if( yymsp[-4].minor.yy2 ) yymsp[-4].minor.yy2->flags |= EP_InfixFunc;
}
        break;
      case 206: /* expr ::= expr ISNULL|NOTNULL */
{yymsp[-1].minor.yy2 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy2,0);}
        break;
      case 207: /* expr ::= expr NOT NULL */
{yymsp[-2].minor.yy2 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy2,0);}
        break;
      case 208: /* expr ::= expr IS expr */
{
  yymsp[-2].minor.yy2 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy2,yymsp[0].minor.yy2);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy2, yymsp[-2].minor.yy2, TK_ISNULL);
}
        break;
      case 209: /* expr ::= expr IS NOT expr */
{
  yymsp[-3].minor.yy2 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy2,yymsp[0].minor.yy2);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy2, yymsp[-3].minor.yy2, TK_NOTNULL);
}
        break;
      case 210: /* expr ::= expr IS NOT DISTINCT FROM expr */
{
  yymsp[-5].minor.yy2 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy2,yymsp[0].minor.yy2);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy2, yymsp[-5].minor.yy2, TK_ISNULL);
}
        break;
      case 211: /* expr ::= expr IS DISTINCT FROM expr */
{
  yymsp[-4].minor.yy2 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy2,yymsp[0].minor.yy2);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy2, yymsp[-4].minor.yy2, TK_NOTNULL);
}
        break;
      case 212: /* expr ::= NOT expr */
      case 213: /* expr ::= BITNOT expr */ yytestcase(yyruleno==213);
{yymsp[-1].minor.yy2 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy2, 0);/*A-overwrites-B*/}
        break;
      case 214: /* expr ::= PLUS|MINUS expr */
{
  yymsp[-1].minor.yy2 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy2, 0);
  /*A-overwrites-B*/
}
        break;
      case 215: /* expr ::= expr PTR expr */
{
  ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy2);
  pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy2);
  yylhsminor.yy2 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
}
  yymsp[-2].minor.yy2 = yylhsminor.yy2;
        break;
      case 216: /* between_op ::= BETWEEN */
      case 219: /* in_op ::= IN */ yytestcase(yyruleno==219);
{yymsp[0].minor.yy92 = 0;}
        break;
      case 218: /* expr ::= expr between_op expr AND expr */
{
  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy2);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy2);
  yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy2, 0);
  if( yymsp[-4].minor.yy2 ){
    yymsp[-4].minor.yy2->x.pList = pList;
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  }
  if( yymsp[-3].minor.yy92 ) yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy2, 0);
}
        break;
      case 221: /* expr ::= expr in_op LP exprlist RP */
{
    if( yymsp[-1].minor.yy402==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.
      */
      sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy2);
      yymsp[-4].minor.yy2 = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy92 ? "true" : "false");
      if( yymsp[-4].minor.yy2 ) sqlite3ExprIdToTrueFalse(yymsp[-4].minor.yy2);
    }else{
      Expr *pRHS = yymsp[-1].minor.yy402->a[0].pExpr;
      if( yymsp[-1].minor.yy402->nExpr==1 && sqlite3ExprIsConstant(pRHS) && yymsp[-4].minor.yy2->op!=TK_VECTOR ){
        yymsp[-1].minor.yy402->a[0].pExpr = 0;
        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
        pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
        yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy2, pRHS);
      }else if( yymsp[-1].minor.yy402->nExpr==1 && pRHS->op==TK_SELECT ){
        yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy2, 0);
        sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy2, pRHS->x.pSelect);
        pRHS->x.pSelect = 0;
        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
      }else{
        yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy2, 0);
        if( yymsp[-4].minor.yy2==0 ){
          sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
        }else if( yymsp[-4].minor.yy2->pLeft->op==TK_VECTOR ){
          int nExpr = yymsp[-4].minor.yy2->pLeft->x.pList->nExpr;
          Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy402);
          if( pSelectRHS ){
            parserDoubleLinkSelect(pParse, pSelectRHS);
            sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy2, pSelectRHS);
          }
        }else{
          yymsp[-4].minor.yy2->x.pList = yymsp[-1].minor.yy402;
          sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy2);
        }
      }
      if( yymsp[-3].minor.yy92 ) yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy2, 0);
    }
  }
        break;
      case 222: /* expr ::= LP select RP */
{
    yymsp[-2].minor.yy2 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy2, yymsp[-1].minor.yy299);
  }
        break;
      case 223: /* expr ::= expr in_op LP select RP */
{
    yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy2, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy2, yymsp[-1].minor.yy299);
    if( yymsp[-3].minor.yy92 ) yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy2, 0);
  }
        break;
      case 224: /* expr ::= expr in_op nm dbnm paren_exprlist */
{
    SrcList *pSrc = sqlite3SrcListAppend(pParse, 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.yy402 )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy402);
    yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy2, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy2, pSelect);
    if( yymsp[-3].minor.yy92 ) yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy2, 0);
  }
        break;
      case 225: /* expr ::= EXISTS LP select RP */
{
    Expr *p;
    p = yymsp[-3].minor.yy2 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy299);
  }
        break;
      case 226: /* expr ::= CASE case_operand case_exprlist case_else END */
{
  yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy2, 0);
  if( yymsp[-4].minor.yy2 ){
    yymsp[-4].minor.yy2->x.pList = yymsp[-1].minor.yy2 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy402,yymsp[-1].minor.yy2) : yymsp[-2].minor.yy402;
    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy2);
  }else{
    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy402);
    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy2);
  }
}
        break;
      case 227: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
  yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, yymsp[-2].minor.yy2);
  yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, yymsp[0].minor.yy2);
}
        break;
      case 228: /* case_exprlist ::= WHEN expr THEN expr */
{
  yymsp[-3].minor.yy402 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy2);
  yymsp[-3].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy402, yymsp[0].minor.yy2);
}
        break;
      case 233: /* nexprlist ::= nexprlist COMMA expr */
{yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy402,yymsp[0].minor.yy2);}
        break;
      case 234: /* nexprlist ::= expr */
{yymsp[0].minor.yy402 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy2); /*A-overwrites-Y*/}
        break;
      case 236: /* paren_exprlist ::= LP exprlist RP */
      case 241: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==241);
{yymsp[-2].minor.yy402 = yymsp[-1].minor.yy402;}
        break;
      case 237: /* 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,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy402, yymsp[-10].minor.yy92,
                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy2, SQLITE_SO_ASC, yymsp[-8].minor.yy92, SQLITE_IDXTYPE_APPDEF);
  if( IN_RENAME_OBJECT && pParse->pNewIndex ){
    sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
  }
}
        break;
      case 238: /* uniqueflag ::= UNIQUE */
      case 280: /* raisetype ::= ABORT */ yytestcase(yyruleno==280);
{yymsp[0].minor.yy92 = OE_Abort;}
        break;
      case 239: /* uniqueflag ::= */
{yymsp[1].minor.yy92 = OE_None;}
        break;
      case 242: /* eidlist ::= eidlist COMMA nm collate sortorder */
{
  yymsp[-4].minor.yy402 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy402, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy92, yymsp[0].minor.yy92);
}
        break;
      case 243: /* eidlist ::= nm collate sortorder */
{
  yymsp[-2].minor.yy402 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy92, yymsp[0].minor.yy92); /*A-overwrites-Y*/
}
        break;
      case 246: /* cmd ::= DROP INDEX ifexists fullname */
{sqlite3DropIndex(pParse, yymsp[0].minor.yy387, yymsp[-1].minor.yy92);}
        break;
      case 247: /* cmd ::= VACUUM vinto */
{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy2);}
        break;
      case 248: /* cmd ::= VACUUM nm vinto */
{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy2);}
        break;
      case 251: /* cmd ::= PRAGMA nm dbnm */
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
        break;
      case 252: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
        break;
176016
176017
176018
176019
176020
176021
176022
176023
176024
176025
176026
176027
176028
176029
176030
176031
176032
176033
176034
176035
176036
176037
176038
176039
176040
176041
176042
176043
176044
176045
176046
176047
176048
176049
176050
176051
176052
176053
176054
176055
176056
176057
176058
176059
176060
176061
176062
176063
176064
176065
176066
176067
176068
176069
176070
176071
176072
176073
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
        break;
      case 258: /* 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.yy33, &all);
}
        break;
      case 259: /* 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.yy394, yymsp[-4].minor.yy180.a, yymsp[-4].minor.yy180.b, yymsp[-2].minor.yy131, yymsp[0].minor.yy528, yymsp[-10].minor.yy394, yymsp[-8].minor.yy394);
  yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
}
        break;
      case 260: /* trigger_time ::= BEFORE|AFTER */
{ yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/ }
        break;
      case 261: /* trigger_time ::= INSTEAD OF */
{ yymsp[-1].minor.yy394 = TK_INSTEAD;}
        break;
      case 262: /* trigger_time ::= */
{ yymsp[1].minor.yy394 = TK_BEFORE; }
        break;
      case 263: /* trigger_event ::= DELETE|INSERT */
      case 264: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==264);
{yymsp[0].minor.yy180.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy180.b = 0;}
        break;
      case 265: /* trigger_event ::= UPDATE OF idlist */
{yymsp[-2].minor.yy180.a = TK_UPDATE; yymsp[-2].minor.yy180.b = yymsp[0].minor.yy254;}
        break;
      case 266: /* when_clause ::= */
      case 285: /* key_opt ::= */ yytestcase(yyruleno==285);
{ yymsp[1].minor.yy528 = 0; }
        break;
      case 267: /* when_clause ::= WHEN expr */
      case 286: /* key_opt ::= KEY expr */ yytestcase(yyruleno==286);
{ yymsp[-1].minor.yy528 = yymsp[0].minor.yy528; }
        break;
      case 268: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
  assert( yymsp[-2].minor.yy33!=0 );
  yymsp[-2].minor.yy33->pLast->pNext = yymsp[-1].minor.yy33;
  yymsp[-2].minor.yy33->pLast = yymsp[-1].minor.yy33;
}
        break;
      case 269: /* trigger_cmd_list ::= trigger_cmd SEMI */
{
  assert( yymsp[-1].minor.yy33!=0 );
  yymsp[-1].minor.yy33->pLast = yymsp[-1].minor.yy33;
}
        break;
      case 270: /* 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 "







|




|




|


|


|



|


|



|



|



|
|
|




|
|







176304
176305
176306
176307
176308
176309
176310
176311
176312
176313
176314
176315
176316
176317
176318
176319
176320
176321
176322
176323
176324
176325
176326
176327
176328
176329
176330
176331
176332
176333
176334
176335
176336
176337
176338
176339
176340
176341
176342
176343
176344
176345
176346
176347
176348
176349
176350
176351
176352
176353
176354
176355
176356
176357
176358
176359
176360
176361
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
        break;
      case 258: /* 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.yy347, &all);
}
        break;
      case 259: /* 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.yy92, yymsp[-4].minor.yy210.a, yymsp[-4].minor.yy210.b, yymsp[-2].minor.yy387, yymsp[0].minor.yy2, yymsp[-10].minor.yy92, yymsp[-8].minor.yy92);
  yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
}
        break;
      case 260: /* trigger_time ::= BEFORE|AFTER */
{ yymsp[0].minor.yy92 = yymsp[0].major; /*A-overwrites-X*/ }
        break;
      case 261: /* trigger_time ::= INSTEAD OF */
{ yymsp[-1].minor.yy92 = TK_INSTEAD;}
        break;
      case 262: /* trigger_time ::= */
{ yymsp[1].minor.yy92 = TK_BEFORE; }
        break;
      case 263: /* trigger_event ::= DELETE|INSERT */
      case 264: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==264);
{yymsp[0].minor.yy210.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy210.b = 0;}
        break;
      case 265: /* trigger_event ::= UPDATE OF idlist */
{yymsp[-2].minor.yy210.a = TK_UPDATE; yymsp[-2].minor.yy210.b = yymsp[0].minor.yy400;}
        break;
      case 266: /* when_clause ::= */
      case 285: /* key_opt ::= */ yytestcase(yyruleno==285);
{ yymsp[1].minor.yy2 = 0; }
        break;
      case 267: /* when_clause ::= WHEN expr */
      case 286: /* key_opt ::= KEY expr */ yytestcase(yyruleno==286);
{ yymsp[-1].minor.yy2 = yymsp[0].minor.yy2; }
        break;
      case 268: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
  assert( yymsp[-2].minor.yy347!=0 );
  yymsp[-2].minor.yy347->pLast->pNext = yymsp[-1].minor.yy347;
  yymsp[-2].minor.yy347->pLast = yymsp[-1].minor.yy347;
}
        break;
      case 269: /* trigger_cmd_list ::= trigger_cmd SEMI */
{
  assert( yymsp[-1].minor.yy347!=0 );
  yymsp[-1].minor.yy347->pLast = yymsp[-1].minor.yy347;
}
        break;
      case 270: /* 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 "
176085
176086
176087
176088
176089
176090
176091
176092
176093
176094
176095
176096
176097
176098
176099
176100
176101
176102
176103
176104
176105
176106
176107
176108
176109
176110
176111
176112
176113
176114
176115
176116
176117
176118
176119
176120
176121
176122
176123
176124
176125
176126
176127
176128
176129
176130
176131
176132
176133
176134
176135
176136
176137
176138
176139
176140
176141
176142
176143
176144
176145
176146
176147
176148
176149
176150
176151
176152
176153
176154
176155
176156
176157
176158
176159
176160
176161
176162
176163
176164
176165
176166
176167
176168
176169
176170
176171
176172
176173
176174
176175
176176
176177
176178
176179
176180
176181
176182
176183
176184
176185
176186
176187
176188
176189
176190
176191
176192
176193
176194
176195
176196
176197
176198
176199
176200
176201
176202
176203
176204
176205
176206
176207
176208
176209
176210
176211
176212
176213
176214
176215
176216
176217
176218
176219
176220
176221
176222
176223
176224
176225
176226
176227
176228
176229
176230
176231
176232
176233
176234
176235
176236
176237
176238
176239
176240
176241
176242
176243
176244
176245
176246
176247
176248
176249
176250
176251
176252
176253
176254
176255
176256
176257
176258
176259
176260
176261
176262
176263
176264
176265
176266
176267
176268
176269
176270
176271
176272
176273
176274
176275
176276
176277
176278
176279
176280
176281
176282
176283
176284
176285
176286
176287
176288
176289
176290
176291
176292
176293
176294
176295
176296
176297
176298
176299
176300
176301
176302
176303
176304
176305
176306
176307
176308
176309
176310
176311
176312
176313
176314
176315
176316
176317
176318
176319
176320
176321
176322
176323
176324
176325
176326
176327
176328
176329
176330
176331
176332
176333
176334
176335
176336
176337
176338
176339
176340
176341
176342
176343
176344
176345
176346
176347
176348
176349
176350
176351
176352
176353
176354
176355
176356
176357
176358
176359
176360
176361
176362
176363
176364
176365
176366
176367
176368
176369
176370







176371
176372
176373
176374
176375
176376
176377
176378
176379
176380
176381
176382
176383
176384
176385
176386
176387
176388
176389
176390
176391
176392
176393
176394
176395
176396
176397
176398
176399
176400
176401
176402
176403
176404
176405
176406
176407
176408
176409
176410
176411
176412
176413
176414
176415
176416
176417
176418
176419
176420
176421
176422
176423
176424
176425
176426
176427
176428
176429
176430
176431
176432
176433
176434
176435
176436
176437
176438
176439
176440
176441
176442
176443
176444
{
  sqlite3ErrorMsg(pParse,
        "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
        "within triggers");
}
        break;
      case 273: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
{yylhsminor.yy33 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy131, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528, yymsp[-7].minor.yy394, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy522);}
  yymsp[-8].minor.yy33 = yylhsminor.yy33;
        break;
      case 274: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
{
   yylhsminor.yy33 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy254,yymsp[-2].minor.yy47,yymsp[-6].minor.yy394,yymsp[-1].minor.yy444,yymsp[-7].minor.yy522,yymsp[0].minor.yy522);/*yylhsminor.yy33-overwrites-yymsp[-6].minor.yy394*/
}
  yymsp[-7].minor.yy33 = yylhsminor.yy33;
        break;
      case 275: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
{yylhsminor.yy33 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy528, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy522);}
  yymsp[-5].minor.yy33 = yylhsminor.yy33;
        break;
      case 276: /* trigger_cmd ::= scanpt select scanpt */
{yylhsminor.yy33 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy47, yymsp[-2].minor.yy522, yymsp[0].minor.yy522); /*yylhsminor.yy33-overwrites-yymsp[-1].minor.yy47*/}
  yymsp[-2].minor.yy33 = yylhsminor.yy33;
        break;
      case 277: /* expr ::= RAISE LP IGNORE RP */
{
  yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
  if( yymsp[-3].minor.yy528 ){
    yymsp[-3].minor.yy528->affExpr = OE_Ignore;
  }
}
        break;
      case 278: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
  yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
  if( yymsp[-5].minor.yy528 ) {
    yymsp[-5].minor.yy528->affExpr = (char)yymsp[-3].minor.yy394;
  }
}
        break;
      case 279: /* raisetype ::= ROLLBACK */
{yymsp[0].minor.yy394 = OE_Rollback;}
        break;
      case 281: /* raisetype ::= FAIL */
{yymsp[0].minor.yy394 = OE_Fail;}
        break;
      case 282: /* cmd ::= DROP TRIGGER ifexists fullname */
{
  sqlite3DropTrigger(pParse,yymsp[0].minor.yy131,yymsp[-1].minor.yy394);
}
        break;
      case 283: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
  sqlite3Attach(pParse, yymsp[-3].minor.yy528, yymsp[-1].minor.yy528, yymsp[0].minor.yy528);
}
        break;
      case 284: /* cmd ::= DETACH database_kw_opt expr */
{
  sqlite3Detach(pParse, yymsp[0].minor.yy528);
}
        break;
      case 287: /* cmd ::= REINDEX */
{sqlite3Reindex(pParse, 0, 0);}
        break;
      case 288: /* cmd ::= REINDEX nm dbnm */
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 289: /* cmd ::= ANALYZE */
{sqlite3Analyze(pParse, 0, 0);}
        break;
      case 290: /* cmd ::= ANALYZE nm dbnm */
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 291: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy131,&yymsp[0].minor.yy0);
}
        break;
      case 292: /* 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 293: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
{
  sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy131, &yymsp[0].minor.yy0);
}
        break;
      case 294: /* add_column_fullname ::= fullname */
{
  disableLookaside(pParse);
  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy131);
}
        break;
      case 295: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
{
  sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy131, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
}
        break;
      case 296: /* cmd ::= create_vtab */
{sqlite3VtabFinishParse(pParse,0);}
        break;
      case 297: /* cmd ::= create_vtab LP vtabarglist RP */
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
        break;
      case 298: /* 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.yy394);
}
        break;
      case 299: /* vtabarg ::= */
{sqlite3VtabArgInit(pParse);}
        break;
      case 300: /* vtabargtoken ::= ANY */
      case 301: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==301);
      case 302: /* lp ::= LP */ yytestcase(yyruleno==302);
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
        break;
      case 303: /* with ::= WITH wqlist */
      case 304: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==304);
{ sqlite3WithPush(pParse, yymsp[0].minor.yy521, 1); }
        break;
      case 305: /* wqas ::= AS */
{yymsp[0].minor.yy516 = M10d_Any;}
        break;
      case 306: /* wqas ::= AS MATERIALIZED */
{yymsp[-1].minor.yy516 = M10d_Yes;}
        break;
      case 307: /* wqas ::= AS NOT MATERIALIZED */
{yymsp[-2].minor.yy516 = M10d_No;}
        break;
      case 308: /* wqitem ::= nm eidlist_opt wqas LP select RP */
{
  yymsp[-5].minor.yy385 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy47, yymsp[-3].minor.yy516); /*A-overwrites-X*/
}
        break;
      case 309: /* wqlist ::= wqitem */
{
  yymsp[0].minor.yy521 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy385); /*A-overwrites-X*/
}
        break;
      case 310: /* wqlist ::= wqlist COMMA wqitem */
{
  yymsp[-2].minor.yy521 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy521, yymsp[0].minor.yy385);
}
        break;
      case 311: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
{
  assert( yymsp[0].minor.yy41!=0 );
  sqlite3WindowChain(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy41);
  yymsp[0].minor.yy41->pNextWin = yymsp[-2].minor.yy41;
  yylhsminor.yy41 = yymsp[0].minor.yy41;
}
  yymsp[-2].minor.yy41 = yylhsminor.yy41;
        break;
      case 312: /* windowdefn ::= nm AS LP window RP */
{
  if( ALWAYS(yymsp[-1].minor.yy41) ){
    yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
  }
  yylhsminor.yy41 = yymsp[-1].minor.yy41;
}
  yymsp[-4].minor.yy41 = yylhsminor.yy41;
        break;
      case 313: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
{
  yymsp[-4].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, 0);
}
        break;
      case 314: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
{
  yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, &yymsp[-5].minor.yy0);
}
  yymsp[-5].minor.yy41 = yylhsminor.yy41;
        break;
      case 315: /* window ::= ORDER BY sortlist frame_opt */
{
  yymsp[-3].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, 0);
}
        break;
      case 316: /* window ::= nm ORDER BY sortlist frame_opt */
{
  yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0);
}
  yymsp[-4].minor.yy41 = yylhsminor.yy41;
        break;
      case 317: /* window ::= nm frame_opt */
{
  yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, 0, &yymsp[-1].minor.yy0);
}
  yymsp[-1].minor.yy41 = yylhsminor.yy41;
        break;
      case 318: /* frame_opt ::= */
{
  yymsp[1].minor.yy41 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
}
        break;
      case 319: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
{
  yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy394, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy516);
}
  yymsp[-2].minor.yy41 = yylhsminor.yy41;
        break;
      case 320: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
{
  yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy394, yymsp[-3].minor.yy595.eType, yymsp[-3].minor.yy595.pExpr, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, yymsp[0].minor.yy516);
}
  yymsp[-5].minor.yy41 = yylhsminor.yy41;
        break;
      case 322: /* frame_bound_s ::= frame_bound */
      case 324: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==324);
{yylhsminor.yy595 = yymsp[0].minor.yy595;}
  yymsp[0].minor.yy595 = yylhsminor.yy595;
        break;
      case 323: /* frame_bound_s ::= UNBOUNDED PRECEDING */
      case 325: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==325);
      case 327: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==327);
{yylhsminor.yy595.eType = yymsp[-1].major; yylhsminor.yy595.pExpr = 0;}
  yymsp[-1].minor.yy595 = yylhsminor.yy595;
        break;
      case 326: /* frame_bound ::= expr PRECEDING|FOLLOWING */
{yylhsminor.yy595.eType = yymsp[0].major; yylhsminor.yy595.pExpr = yymsp[-1].minor.yy528;}
  yymsp[-1].minor.yy595 = yylhsminor.yy595;
        break;
      case 328: /* frame_exclude_opt ::= */
{yymsp[1].minor.yy516 = 0;}
        break;
      case 329: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
{yymsp[-1].minor.yy516 = yymsp[0].minor.yy516;}
        break;
      case 330: /* frame_exclude ::= NO OTHERS */
      case 331: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==331);
{yymsp[-1].minor.yy516 = yymsp[-1].major; /*A-overwrites-X*/}
        break;
      case 332: /* frame_exclude ::= GROUP|TIES */
{yymsp[0].minor.yy516 = yymsp[0].major; /*A-overwrites-X*/}
        break;
      case 333: /* window_clause ::= WINDOW windowdefn_list */
{ yymsp[-1].minor.yy41 = yymsp[0].minor.yy41; }
        break;
      case 334: /* filter_over ::= filter_clause over_clause */
{
  if( yymsp[0].minor.yy41 ){
    yymsp[0].minor.yy41->pFilter = yymsp[-1].minor.yy528;
  }else{
    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy528);
  }
  yylhsminor.yy41 = yymsp[0].minor.yy41;
}
  yymsp[-1].minor.yy41 = yylhsminor.yy41;
        break;
      case 335: /* filter_over ::= over_clause */
{
  yylhsminor.yy41 = yymsp[0].minor.yy41;
}
  yymsp[0].minor.yy41 = yylhsminor.yy41;
        break;
      case 336: /* filter_over ::= filter_clause */
{
  yylhsminor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
  if( yylhsminor.yy41 ){
    yylhsminor.yy41->eFrmType = TK_FILTER;
    yylhsminor.yy41->pFilter = yymsp[0].minor.yy528;
  }else{
    sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy528);
  }
}
  yymsp[0].minor.yy41 = yylhsminor.yy41;
        break;
      case 337: /* over_clause ::= OVER LP window RP */
{
  yymsp[-3].minor.yy41 = yymsp[-1].minor.yy41;
  assert( yymsp[-3].minor.yy41!=0 );
}
        break;
      case 338: /* over_clause ::= OVER nm */
{
  yymsp[-1].minor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
  if( yymsp[-1].minor.yy41 ){
    yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
  }
}
        break;
      case 339: /* filter_clause ::= FILTER LP WHERE expr RP */
{ yymsp[-4].minor.yy528 = yymsp[-1].minor.yy528; }







        break;
      default:
      /* (340) input ::= cmdlist */ yytestcase(yyruleno==340);
      /* (341) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==341);
      /* (342) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=342);
      /* (343) ecmd ::= SEMI */ yytestcase(yyruleno==343);
      /* (344) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==344);
      /* (345) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=345);
      /* (346) trans_opt ::= */ yytestcase(yyruleno==346);
      /* (347) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==347);
      /* (348) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==348);
      /* (349) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==349);
      /* (350) savepoint_opt ::= */ yytestcase(yyruleno==350);
      /* (351) cmd ::= create_table create_table_args */ yytestcase(yyruleno==351);
      /* (352) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=352);
      /* (353) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==353);
      /* (354) columnlist ::= columnname carglist */ yytestcase(yyruleno==354);
      /* (355) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==355);
      /* (356) nm ::= STRING */ yytestcase(yyruleno==356);
      /* (357) typetoken ::= typename */ yytestcase(yyruleno==357);
      /* (358) typename ::= ID|STRING */ yytestcase(yyruleno==358);
      /* (359) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=359);
      /* (360) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=360);
      /* (361) carglist ::= carglist ccons */ yytestcase(yyruleno==361);
      /* (362) carglist ::= */ yytestcase(yyruleno==362);
      /* (363) ccons ::= NULL onconf */ yytestcase(yyruleno==363);
      /* (364) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==364);
      /* (365) ccons ::= AS generated */ yytestcase(yyruleno==365);
      /* (366) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==366);
      /* (367) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==367);
      /* (368) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=368);
      /* (369) tconscomma ::= */ yytestcase(yyruleno==369);
      /* (370) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=370);
      /* (371) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=371);
      /* (372) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=372);
      /* (373) oneselect ::= values */ yytestcase(yyruleno==373);
      /* (374) sclp ::= selcollist COMMA */ yytestcase(yyruleno==374);
      /* (375) as ::= ID|STRING */ yytestcase(yyruleno==375);
      /* (376) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=376);
      /* (377) returning ::= */ yytestcase(yyruleno==377);
      /* (378) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=378);
      /* (379) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==379);
      /* (380) case_operand ::= expr */ yytestcase(yyruleno==380);
      /* (381) exprlist ::= nexprlist */ yytestcase(yyruleno==381);
      /* (382) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=382);
      /* (383) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=383);
      /* (384) nmnum ::= ON */ yytestcase(yyruleno==384);
      /* (385) nmnum ::= DELETE */ yytestcase(yyruleno==385);
      /* (386) nmnum ::= DEFAULT */ yytestcase(yyruleno==386);
      /* (387) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==387);
      /* (388) foreach_clause ::= */ yytestcase(yyruleno==388);
      /* (389) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==389);
      /* (390) trnm ::= nm */ yytestcase(yyruleno==390);
      /* (391) tridxby ::= */ yytestcase(yyruleno==391);
      /* (392) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==392);
      /* (393) database_kw_opt ::= */ yytestcase(yyruleno==393);
      /* (394) kwcolumn_opt ::= */ yytestcase(yyruleno==394);
      /* (395) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==395);
      /* (396) vtabarglist ::= vtabarg */ yytestcase(yyruleno==396);
      /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==397);
      /* (398) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==398);
      /* (399) anylist ::= */ yytestcase(yyruleno==399);
      /* (400) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==400);
      /* (401) anylist ::= anylist ANY */ yytestcase(yyruleno==401);
      /* (402) with ::= */ yytestcase(yyruleno==402);
      /* (403) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=403);
      /* (404) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=404);
        break;
/********** End reduce actions ************************************************/
  };
  assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
  yygoto = yyRuleInfoLhs[yyruleno];
  yysize = yyRuleInfoNRhs[yyruleno];
  yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);







|
|



|

|


|
|


|
|



|
|
|





|
|
|




|


|



|




|




|
















|










|





|




|










|












|


|


|


|



|




|




|




|
|
|
|

|



|
|

|

|



|




|

|



|




|

|



|

|



|




|

|



|

|



|
|




|
|


|
|


|


|



|


|


|



|
|

|

|

|



|

|



|
|
|
|

|


|



|
|




|
|
|




|
>
>
>
>
>
>
>


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







176373
176374
176375
176376
176377
176378
176379
176380
176381
176382
176383
176384
176385
176386
176387
176388
176389
176390
176391
176392
176393
176394
176395
176396
176397
176398
176399
176400
176401
176402
176403
176404
176405
176406
176407
176408
176409
176410
176411
176412
176413
176414
176415
176416
176417
176418
176419
176420
176421
176422
176423
176424
176425
176426
176427
176428
176429
176430
176431
176432
176433
176434
176435
176436
176437
176438
176439
176440
176441
176442
176443
176444
176445
176446
176447
176448
176449
176450
176451
176452
176453
176454
176455
176456
176457
176458
176459
176460
176461
176462
176463
176464
176465
176466
176467
176468
176469
176470
176471
176472
176473
176474
176475
176476
176477
176478
176479
176480
176481
176482
176483
176484
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
176514
176515
176516
176517
176518
176519
176520
176521
176522
176523
176524
176525
176526
176527
176528
176529
176530
176531
176532
176533
176534
176535
176536
176537
176538
176539
176540
176541
176542
176543
176544
176545
176546
176547
176548
176549
176550
176551
176552
176553
176554
176555
176556
176557
176558
176559
176560
176561
176562
176563
176564
176565
176566
176567
176568
176569
176570
176571
176572
176573
176574
176575
176576
176577
176578
176579
176580
176581
176582
176583
176584
176585
176586
176587
176588
176589
176590
176591
176592
176593
176594
176595
176596
176597
176598
176599
176600
176601
176602
176603
176604
176605
176606
176607
176608
176609
176610
176611
176612
176613
176614
176615
176616
176617
176618
176619
176620
176621
176622
176623
176624
176625
176626
176627
176628
176629
176630
176631
176632
176633
176634
176635
176636
176637
176638
176639
176640
176641
176642
176643
176644
176645
176646
176647
176648
176649
176650
176651
176652
176653
176654
176655
176656
176657
176658
176659
176660
176661
176662
176663
176664
176665
176666
176667
176668
176669
176670
176671
176672
176673
176674
176675
176676
176677
176678
176679
176680
176681
176682
176683
176684
176685
176686
176687
176688
176689
176690
176691
176692
176693
176694
176695
176696
176697
176698
176699
176700
176701
176702
176703
176704
176705
176706
176707
176708
176709
176710
176711
176712
176713
176714
176715
176716
176717
176718
176719
176720
176721
176722
176723
176724
176725
176726
176727
176728
176729
176730
176731
176732
176733
176734
176735
176736
176737
176738
176739
{
  sqlite3ErrorMsg(pParse,
        "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
        "within triggers");
}
        break;
      case 273: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
{yylhsminor.yy347 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy387, yymsp[-3].minor.yy402, yymsp[-1].minor.yy2, yymsp[-7].minor.yy92, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy616);}
  yymsp[-8].minor.yy347 = yylhsminor.yy347;
        break;
      case 274: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
{
   yylhsminor.yy347 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy400,yymsp[-2].minor.yy299,yymsp[-6].minor.yy92,yymsp[-1].minor.yy258,yymsp[-7].minor.yy616,yymsp[0].minor.yy616);/*yylhsminor.yy347-overwrites-yymsp[-6].minor.yy92*/
}
  yymsp[-7].minor.yy347 = yylhsminor.yy347;
        break;
      case 275: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
{yylhsminor.yy347 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy2, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy616);}
  yymsp[-5].minor.yy347 = yylhsminor.yy347;
        break;
      case 276: /* trigger_cmd ::= scanpt select scanpt */
{yylhsminor.yy347 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy299, yymsp[-2].minor.yy616, yymsp[0].minor.yy616); /*yylhsminor.yy347-overwrites-yymsp[-1].minor.yy299*/}
  yymsp[-2].minor.yy347 = yylhsminor.yy347;
        break;
      case 277: /* expr ::= RAISE LP IGNORE RP */
{
  yymsp[-3].minor.yy2 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
  if( yymsp[-3].minor.yy2 ){
    yymsp[-3].minor.yy2->affExpr = OE_Ignore;
  }
}
        break;
      case 278: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
  yymsp[-5].minor.yy2 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
  if( yymsp[-5].minor.yy2 ) {
    yymsp[-5].minor.yy2->affExpr = (char)yymsp[-3].minor.yy92;
  }
}
        break;
      case 279: /* raisetype ::= ROLLBACK */
{yymsp[0].minor.yy92 = OE_Rollback;}
        break;
      case 281: /* raisetype ::= FAIL */
{yymsp[0].minor.yy92 = OE_Fail;}
        break;
      case 282: /* cmd ::= DROP TRIGGER ifexists fullname */
{
  sqlite3DropTrigger(pParse,yymsp[0].minor.yy387,yymsp[-1].minor.yy92);
}
        break;
      case 283: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
  sqlite3Attach(pParse, yymsp[-3].minor.yy2, yymsp[-1].minor.yy2, yymsp[0].minor.yy2);
}
        break;
      case 284: /* cmd ::= DETACH database_kw_opt expr */
{
  sqlite3Detach(pParse, yymsp[0].minor.yy2);
}
        break;
      case 287: /* cmd ::= REINDEX */
{sqlite3Reindex(pParse, 0, 0);}
        break;
      case 288: /* cmd ::= REINDEX nm dbnm */
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 289: /* cmd ::= ANALYZE */
{sqlite3Analyze(pParse, 0, 0);}
        break;
      case 290: /* cmd ::= ANALYZE nm dbnm */
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 291: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy387,&yymsp[0].minor.yy0);
}
        break;
      case 292: /* 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 293: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
{
  sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy387, &yymsp[0].minor.yy0);
}
        break;
      case 294: /* add_column_fullname ::= fullname */
{
  disableLookaside(pParse);
  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy387);
}
        break;
      case 295: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
{
  sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy387, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
}
        break;
      case 296: /* cmd ::= create_vtab */
{sqlite3VtabFinishParse(pParse,0);}
        break;
      case 297: /* cmd ::= create_vtab LP vtabarglist RP */
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
        break;
      case 298: /* 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.yy92);
}
        break;
      case 299: /* vtabarg ::= */
{sqlite3VtabArgInit(pParse);}
        break;
      case 300: /* vtabargtoken ::= ANY */
      case 301: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==301);
      case 302: /* lp ::= LP */ yytestcase(yyruleno==302);
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
        break;
      case 303: /* with ::= WITH wqlist */
      case 304: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==304);
{ sqlite3WithPush(pParse, yymsp[0].minor.yy131, 1); }
        break;
      case 305: /* wqas ::= AS */
{yymsp[0].minor.yy498 = M10d_Any;}
        break;
      case 306: /* wqas ::= AS MATERIALIZED */
{yymsp[-1].minor.yy498 = M10d_Yes;}
        break;
      case 307: /* wqas ::= AS NOT MATERIALIZED */
{yymsp[-2].minor.yy498 = M10d_No;}
        break;
      case 308: /* wqitem ::= nm eidlist_opt wqas LP select RP */
{
  yymsp[-5].minor.yy79 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy402, yymsp[-1].minor.yy299, yymsp[-3].minor.yy498); /*A-overwrites-X*/
}
        break;
      case 309: /* wqlist ::= wqitem */
{
  yymsp[0].minor.yy131 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy79); /*A-overwrites-X*/
}
        break;
      case 310: /* wqlist ::= wqlist COMMA wqitem */
{
  yymsp[-2].minor.yy131 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy131, yymsp[0].minor.yy79);
}
        break;
      case 311: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
{
  assert( yymsp[0].minor.yy3!=0 );
  sqlite3WindowChain(pParse, yymsp[0].minor.yy3, yymsp[-2].minor.yy3);
  yymsp[0].minor.yy3->pNextWin = yymsp[-2].minor.yy3;
  yylhsminor.yy3 = yymsp[0].minor.yy3;
}
  yymsp[-2].minor.yy3 = yylhsminor.yy3;
        break;
      case 312: /* windowdefn ::= nm AS LP window RP */
{
  if( ALWAYS(yymsp[-1].minor.yy3) ){
    yymsp[-1].minor.yy3->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
  }
  yylhsminor.yy3 = yymsp[-1].minor.yy3;
}
  yymsp[-4].minor.yy3 = yylhsminor.yy3;
        break;
      case 313: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
{
  yymsp[-4].minor.yy3 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy3, yymsp[-2].minor.yy402, yymsp[-1].minor.yy402, 0);
}
        break;
      case 314: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
{
  yylhsminor.yy3 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy3, yymsp[-2].minor.yy402, yymsp[-1].minor.yy402, &yymsp[-5].minor.yy0);
}
  yymsp[-5].minor.yy3 = yylhsminor.yy3;
        break;
      case 315: /* window ::= ORDER BY sortlist frame_opt */
{
  yymsp[-3].minor.yy3 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy3, 0, yymsp[-1].minor.yy402, 0);
}
        break;
      case 316: /* window ::= nm ORDER BY sortlist frame_opt */
{
  yylhsminor.yy3 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy3, 0, yymsp[-1].minor.yy402, &yymsp[-4].minor.yy0);
}
  yymsp[-4].minor.yy3 = yylhsminor.yy3;
        break;
      case 317: /* window ::= nm frame_opt */
{
  yylhsminor.yy3 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy3, 0, 0, &yymsp[-1].minor.yy0);
}
  yymsp[-1].minor.yy3 = yylhsminor.yy3;
        break;
      case 318: /* frame_opt ::= */
{
  yymsp[1].minor.yy3 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
}
        break;
      case 319: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
{
  yylhsminor.yy3 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy92, yymsp[-1].minor.yy337.eType, yymsp[-1].minor.yy337.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy498);
}
  yymsp[-2].minor.yy3 = yylhsminor.yy3;
        break;
      case 320: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
{
  yylhsminor.yy3 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy92, yymsp[-3].minor.yy337.eType, yymsp[-3].minor.yy337.pExpr, yymsp[-1].minor.yy337.eType, yymsp[-1].minor.yy337.pExpr, yymsp[0].minor.yy498);
}
  yymsp[-5].minor.yy3 = yylhsminor.yy3;
        break;
      case 322: /* frame_bound_s ::= frame_bound */
      case 324: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==324);
{yylhsminor.yy337 = yymsp[0].minor.yy337;}
  yymsp[0].minor.yy337 = yylhsminor.yy337;
        break;
      case 323: /* frame_bound_s ::= UNBOUNDED PRECEDING */
      case 325: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==325);
      case 327: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==327);
{yylhsminor.yy337.eType = yymsp[-1].major; yylhsminor.yy337.pExpr = 0;}
  yymsp[-1].minor.yy337 = yylhsminor.yy337;
        break;
      case 326: /* frame_bound ::= expr PRECEDING|FOLLOWING */
{yylhsminor.yy337.eType = yymsp[0].major; yylhsminor.yy337.pExpr = yymsp[-1].minor.yy2;}
  yymsp[-1].minor.yy337 = yylhsminor.yy337;
        break;
      case 328: /* frame_exclude_opt ::= */
{yymsp[1].minor.yy498 = 0;}
        break;
      case 329: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
{yymsp[-1].minor.yy498 = yymsp[0].minor.yy498;}
        break;
      case 330: /* frame_exclude ::= NO OTHERS */
      case 331: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==331);
{yymsp[-1].minor.yy498 = yymsp[-1].major; /*A-overwrites-X*/}
        break;
      case 332: /* frame_exclude ::= GROUP|TIES */
{yymsp[0].minor.yy498 = yymsp[0].major; /*A-overwrites-X*/}
        break;
      case 333: /* window_clause ::= WINDOW windowdefn_list */
{ yymsp[-1].minor.yy3 = yymsp[0].minor.yy3; }
        break;
      case 334: /* filter_over ::= filter_clause over_clause */
{
  if( yymsp[0].minor.yy3 ){
    yymsp[0].minor.yy3->pFilter = yymsp[-1].minor.yy2;
  }else{
    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy2);
  }
  yylhsminor.yy3 = yymsp[0].minor.yy3;
}
  yymsp[-1].minor.yy3 = yylhsminor.yy3;
        break;
      case 335: /* filter_over ::= over_clause */
{
  yylhsminor.yy3 = yymsp[0].minor.yy3;
}
  yymsp[0].minor.yy3 = yylhsminor.yy3;
        break;
      case 336: /* filter_over ::= filter_clause */
{
  yylhsminor.yy3 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
  if( yylhsminor.yy3 ){
    yylhsminor.yy3->eFrmType = TK_FILTER;
    yylhsminor.yy3->pFilter = yymsp[0].minor.yy2;
  }else{
    sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy2);
  }
}
  yymsp[0].minor.yy3 = yylhsminor.yy3;
        break;
      case 337: /* over_clause ::= OVER LP window RP */
{
  yymsp[-3].minor.yy3 = yymsp[-1].minor.yy3;
  assert( yymsp[-3].minor.yy3!=0 );
}
        break;
      case 338: /* over_clause ::= OVER nm */
{
  yymsp[-1].minor.yy3 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
  if( yymsp[-1].minor.yy3 ){
    yymsp[-1].minor.yy3->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
  }
}
        break;
      case 339: /* filter_clause ::= FILTER LP WHERE expr RP */
{ yymsp[-4].minor.yy2 = yymsp[-1].minor.yy2; }
        break;
      case 340: /* term ::= QNUMBER */
{
  yylhsminor.yy2=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0);
  sqlite3DequoteNumber(pParse, yylhsminor.yy2);
}
  yymsp[0].minor.yy2 = yylhsminor.yy2;
        break;
      default:
      /* (341) input ::= cmdlist */ yytestcase(yyruleno==341);
      /* (342) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==342);
      /* (343) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=343);
      /* (344) ecmd ::= SEMI */ yytestcase(yyruleno==344);
      /* (345) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==345);
      /* (346) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=346);
      /* (347) trans_opt ::= */ yytestcase(yyruleno==347);
      /* (348) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==348);
      /* (349) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==349);
      /* (350) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==350);
      /* (351) savepoint_opt ::= */ yytestcase(yyruleno==351);
      /* (352) cmd ::= create_table create_table_args */ yytestcase(yyruleno==352);
      /* (353) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=353);
      /* (354) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==354);
      /* (355) columnlist ::= columnname carglist */ yytestcase(yyruleno==355);
      /* (356) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==356);
      /* (357) nm ::= STRING */ yytestcase(yyruleno==357);
      /* (358) typetoken ::= typename */ yytestcase(yyruleno==358);
      /* (359) typename ::= ID|STRING */ yytestcase(yyruleno==359);
      /* (360) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=360);
      /* (361) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=361);
      /* (362) carglist ::= carglist ccons */ yytestcase(yyruleno==362);
      /* (363) carglist ::= */ yytestcase(yyruleno==363);
      /* (364) ccons ::= NULL onconf */ yytestcase(yyruleno==364);
      /* (365) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==365);
      /* (366) ccons ::= AS generated */ yytestcase(yyruleno==366);
      /* (367) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==367);
      /* (368) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==368);
      /* (369) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=369);
      /* (370) tconscomma ::= */ yytestcase(yyruleno==370);
      /* (371) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=371);
      /* (372) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=372);
      /* (373) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=373);
      /* (374) oneselect ::= values */ yytestcase(yyruleno==374);
      /* (375) sclp ::= selcollist COMMA */ yytestcase(yyruleno==375);
      /* (376) as ::= ID|STRING */ yytestcase(yyruleno==376);
      /* (377) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=377);
      /* (378) returning ::= */ yytestcase(yyruleno==378);
      /* (379) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=379);
      /* (380) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==380);
      /* (381) case_operand ::= expr */ yytestcase(yyruleno==381);
      /* (382) exprlist ::= nexprlist */ yytestcase(yyruleno==382);
      /* (383) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=383);
      /* (384) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=384);
      /* (385) nmnum ::= ON */ yytestcase(yyruleno==385);
      /* (386) nmnum ::= DELETE */ yytestcase(yyruleno==386);
      /* (387) nmnum ::= DEFAULT */ yytestcase(yyruleno==387);
      /* (388) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==388);
      /* (389) foreach_clause ::= */ yytestcase(yyruleno==389);
      /* (390) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==390);
      /* (391) trnm ::= nm */ yytestcase(yyruleno==391);
      /* (392) tridxby ::= */ yytestcase(yyruleno==392);
      /* (393) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==393);
      /* (394) database_kw_opt ::= */ yytestcase(yyruleno==394);
      /* (395) kwcolumn_opt ::= */ yytestcase(yyruleno==395);
      /* (396) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==396);
      /* (397) vtabarglist ::= vtabarg */ yytestcase(yyruleno==397);
      /* (398) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==398);
      /* (399) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==399);
      /* (400) anylist ::= */ yytestcase(yyruleno==400);
      /* (401) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==401);
      /* (402) anylist ::= anylist ANY */ yytestcase(yyruleno==402);
      /* (403) with ::= */ yytestcase(yyruleno==403);
      /* (404) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=404);
      /* (405) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=405);
        break;
/********** End reduce actions ************************************************/
  };
  assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
  yygoto = yyRuleInfoLhs[yyruleno];
  yysize = yyRuleInfoNRhs[yyruleno];
  yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
177693
177694
177695
177696
177697
177698
177699

177700



177701
177702



177703


177704







177705
177706

177707
177708

177709


177710



177711
177712
177713
177714
177715

177716
177717

177718


177719



177720

177721
177722
177723
177724
177725
177726
177727
      testcase( z[0]=='0' );  testcase( z[0]=='1' );  testcase( z[0]=='2' );
      testcase( z[0]=='3' );  testcase( z[0]=='4' );  testcase( z[0]=='5' );
      testcase( z[0]=='6' );  testcase( z[0]=='7' );  testcase( z[0]=='8' );
      testcase( z[0]=='9' );  testcase( z[0]=='.' );
      *tokenType = TK_INTEGER;
#ifndef SQLITE_OMIT_HEX_INTEGER
      if( z[0]=='0' && (z[1]=='x' || z[1]=='X') && sqlite3Isxdigit(z[2]) ){

        for(i=3; sqlite3Isxdigit(z[i]); i++){}



        return i;
      }



#endif


      for(i=0; sqlite3Isdigit(z[i]); i++){}







#ifndef SQLITE_OMIT_FLOATING_POINT
      if( z[i]=='.' ){

        i++;
        while( sqlite3Isdigit(z[i]) ){ i++; }

        *tokenType = TK_FLOAT;


      }



      if( (z[i]=='e' || z[i]=='E') &&
           ( sqlite3Isdigit(z[i+1])
            || ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2]))
           )
      ){

        i += 2;
        while( sqlite3Isdigit(z[i]) ){ i++; }

        *tokenType = TK_FLOAT;


      }



#endif

      while( IdChar(z[i]) ){
        *tokenType = TK_ILLEGAL;
        i++;
      }
      return i;
    }
    case CC_QUOTE2: {







>
|
>
>
>
|
|
>
>
>

>
>
|
>
>
>
>
>
>
>

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

>







177988
177989
177990
177991
177992
177993
177994
177995
177996
177997
177998
177999
178000
178001
178002
178003
178004
178005
178006
178007
178008
178009
178010
178011
178012
178013
178014
178015
178016
178017
178018
178019
178020
178021
178022
178023
178024
178025
178026
178027
178028
178029
178030
178031
178032
178033
178034
178035
178036
178037
178038
178039
178040
178041
178042
178043
178044
178045
178046
178047
178048
178049
178050
178051
178052
178053
      testcase( z[0]=='0' );  testcase( z[0]=='1' );  testcase( z[0]=='2' );
      testcase( z[0]=='3' );  testcase( z[0]=='4' );  testcase( z[0]=='5' );
      testcase( z[0]=='6' );  testcase( z[0]=='7' );  testcase( z[0]=='8' );
      testcase( z[0]=='9' );  testcase( z[0]=='.' );
      *tokenType = TK_INTEGER;
#ifndef SQLITE_OMIT_HEX_INTEGER
      if( z[0]=='0' && (z[1]=='x' || z[1]=='X') && sqlite3Isxdigit(z[2]) ){
        for(i=3; 1; i++){
          if( sqlite3Isxdigit(z[i])==0 ){
            if( z[i]==SQLITE_DIGIT_SEPARATOR ){
              *tokenType = TK_QNUMBER;
            }else{
              break;
            }
          }
        }
      }else
#endif
        {
        for(i=0; 1; i++){
          if( sqlite3Isdigit(z[i])==0 ){
            if( z[i]==SQLITE_DIGIT_SEPARATOR ){
              *tokenType = TK_QNUMBER;
            }else{
              break;
            }
          }
        }
#ifndef SQLITE_OMIT_FLOATING_POINT
        if( z[i]=='.' ){
          if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT;
          for(i++; 1; i++){
            if( sqlite3Isdigit(z[i])==0 ){
              if( z[i]==SQLITE_DIGIT_SEPARATOR ){
                *tokenType = TK_QNUMBER;
              }else{
                break;
              }
            }
          }
        }
        if( (z[i]=='e' || z[i]=='E') &&
             ( sqlite3Isdigit(z[i+1])
              || ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2]))
             )
        ){
          if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT;
          for(i+=2; 1; i++){
            if( sqlite3Isdigit(z[i])==0 ){
              if( z[i]==SQLITE_DIGIT_SEPARATOR ){
                *tokenType = TK_QNUMBER;
              }else{
                break;
              }
            }
          }
        }
#endif
      }
      while( IdChar(z[i]) ){
        *tokenType = TK_ILLEGAL;
        i++;
      }
      return i;
    }
    case CC_QUOTE2: {
177878
177879
177880
177881
177882
177883
177884

177885
177886
177887
177888


177889
177890
177891
177892
177893
177894
177895
      pParse->nErr++;
      break;
    }
#ifndef SQLITE_OMIT_WINDOWFUNC
    if( tokenType>=TK_WINDOW ){
      assert( tokenType==TK_SPACE || tokenType==TK_OVER || tokenType==TK_FILTER
           || tokenType==TK_ILLEGAL || tokenType==TK_WINDOW

      );
#else
    if( tokenType>=TK_SPACE ){
      assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL );


#endif /* SQLITE_OMIT_WINDOWFUNC */
      if( AtomicLoad(&db->u1.isInterrupted) ){
        pParse->rc = SQLITE_INTERRUPT;
        pParse->nErr++;
        break;
      }
      if( tokenType==TK_SPACE ){







>



|
>
>







178204
178205
178206
178207
178208
178209
178210
178211
178212
178213
178214
178215
178216
178217
178218
178219
178220
178221
178222
178223
178224
      pParse->nErr++;
      break;
    }
#ifndef SQLITE_OMIT_WINDOWFUNC
    if( tokenType>=TK_WINDOW ){
      assert( tokenType==TK_SPACE || tokenType==TK_OVER || tokenType==TK_FILTER
           || tokenType==TK_ILLEGAL || tokenType==TK_WINDOW
           || tokenType==TK_QNUMBER
      );
#else
    if( tokenType>=TK_SPACE ){
      assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL
           || tokenType==TK_QNUMBER
      );
#endif /* SQLITE_OMIT_WINDOWFUNC */
      if( AtomicLoad(&db->u1.isInterrupted) ){
        pParse->rc = SQLITE_INTERRUPT;
        pParse->nErr++;
        break;
      }
      if( tokenType==TK_SPACE ){
177914
177915
177916
177917
177918
177919
177920
177921
177922
177923
177924
177925
177926
177927
177928
      }else if( tokenType==TK_OVER ){
        assert( n==4 );
        tokenType = analyzeOverKeyword((const u8*)&zSql[4], lastTokenParsed);
      }else if( tokenType==TK_FILTER ){
        assert( n==6 );
        tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed);
#endif /* SQLITE_OMIT_WINDOWFUNC */
      }else{
        Token x;
        x.z = zSql;
        x.n = n;
        sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"", &x);
        break;
      }
    }







|







178243
178244
178245
178246
178247
178248
178249
178250
178251
178252
178253
178254
178255
178256
178257
      }else if( tokenType==TK_OVER ){
        assert( n==4 );
        tokenType = analyzeOverKeyword((const u8*)&zSql[4], lastTokenParsed);
      }else if( tokenType==TK_FILTER ){
        assert( n==6 );
        tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed);
#endif /* SQLITE_OMIT_WINDOWFUNC */
      }else if( tokenType!=TK_QNUMBER ){
        Token x;
        x.z = zSql;
        x.n = n;
        sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"", &x);
        break;
      }
    }
204148
204149
204150
204151
204152
204153
204154
204155
204156
204157
204158
204159
204160
204161
204162
    jsonStringExpandAndAppend(p,zIn,N);
  }else{
    memcpy(p->zBuf+p->nUsed, zIn, N);
    p->nUsed += N;
  }
}


/* Append formatted text (not to exceed N bytes) to the JsonString.
*/
static void jsonPrintf(int N, JsonString *p, const char *zFormat, ...){
  va_list ap;
  if( (p->nUsed + N >= p->nAlloc) && jsonStringGrow(p, N) ) return;
  va_start(ap, zFormat);
  sqlite3_vsnprintf(N, p->zBuf+p->nUsed, zFormat, ap);







<







204477
204478
204479
204480
204481
204482
204483

204484
204485
204486
204487
204488
204489
204490
    jsonStringExpandAndAppend(p,zIn,N);
  }else{
    memcpy(p->zBuf+p->nUsed, zIn, N);
    p->nUsed += N;
  }
}


/* Append formatted text (not to exceed N bytes) to the JsonString.
*/
static void jsonPrintf(int N, JsonString *p, const char *zFormat, ...){
  va_list ap;
  if( (p->nUsed + N >= p->nAlloc) && jsonStringGrow(p, N) ) return;
  va_start(ap, zFormat);
  sqlite3_vsnprintf(N, p->zBuf+p->nUsed, zFormat, ap);
205208
205209
205210
205211
205212
205213
205214
205215
205216
205217
205218
205219
205220
205221
205222
    jsonBlobChangePayloadSize(pParse, iThis, pParse->nBlob - iStart);
    pParse->iDepth--;
    return j+1;
  }
  case '[': {
    /* Parse array */
    iThis = pParse->nBlob;
    assert( i<=pParse->nJson );
    jsonBlobAppendNode(pParse, JSONB_ARRAY, pParse->nJson - i, 0);
    iStart = pParse->nBlob;
    if( pParse->oom ) return -1;
    if( ++pParse->iDepth > JSON_MAX_DEPTH ){
      pParse->iErr = i;
      return -1;
    }







|







205536
205537
205538
205539
205540
205541
205542
205543
205544
205545
205546
205547
205548
205549
205550
    jsonBlobChangePayloadSize(pParse, iThis, pParse->nBlob - iStart);
    pParse->iDepth--;
    return j+1;
  }
  case '[': {
    /* Parse array */
    iThis = pParse->nBlob;
    assert( i<=(u32)pParse->nJson );
    jsonBlobAppendNode(pParse, JSONB_ARRAY, pParse->nJson - i, 0);
    iStart = pParse->nBlob;
    if( pParse->oom ) return -1;
    if( ++pParse->iDepth > JSON_MAX_DEPTH ){
      pParse->iErr = i;
      return -1;
    }
205920
205921
205922
205923
205924
205925
205926










































































































205927
205928
205929
205930
205931
205932
205933
      malformed_jsonb:
      pOut->eErr |= JSTRING_MALFORMED;
      break;
    }
  }
  return i+n+sz;
}











































































































/* Return true if the input pJson
**
** For performance reasons, this routine does not do a detailed check of the
** input BLOB to ensure that it is well-formed.  Hence, false positives are
** possible.  False negatives should never occur, however.
*/







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







206248
206249
206250
206251
206252
206253
206254
206255
206256
206257
206258
206259
206260
206261
206262
206263
206264
206265
206266
206267
206268
206269
206270
206271
206272
206273
206274
206275
206276
206277
206278
206279
206280
206281
206282
206283
206284
206285
206286
206287
206288
206289
206290
206291
206292
206293
206294
206295
206296
206297
206298
206299
206300
206301
206302
206303
206304
206305
206306
206307
206308
206309
206310
206311
206312
206313
206314
206315
206316
206317
206318
206319
206320
206321
206322
206323
206324
206325
206326
206327
206328
206329
206330
206331
206332
206333
206334
206335
206336
206337
206338
206339
206340
206341
206342
206343
206344
206345
206346
206347
206348
206349
206350
206351
206352
206353
206354
206355
206356
206357
206358
206359
206360
206361
206362
206363
206364
206365
206366
206367
      malformed_jsonb:
      pOut->eErr |= JSTRING_MALFORMED;
      break;
    }
  }
  return i+n+sz;
}

/* Context for recursion of json_pretty()
*/
typedef struct JsonPretty JsonPretty;
struct JsonPretty {
  JsonParse *pParse;        /* The BLOB being rendered */
  JsonString *pOut;         /* Generate pretty output into this string */
  const char *zIndent;      /* Use this text for indentation */
  u32 szIndent;             /* Bytes in zIndent[] */
  u32 nIndent;              /* Current level of indentation */
};

/* Append indentation to the pretty JSON under construction */
static void jsonPrettyIndent(JsonPretty *pPretty){
  u32 jj;
  for(jj=0; jj<pPretty->nIndent; jj++){
    jsonAppendRaw(pPretty->pOut, pPretty->zIndent, pPretty->szIndent);
  }
}

/*
** Translate the binary JSONB representation of JSON beginning at
** pParse->aBlob[i] into a JSON text string.  Append the JSON
** text onto the end of pOut.  Return the index in pParse->aBlob[]
** of the first byte past the end of the element that is translated.
**
** This is a variant of jsonTranslateBlobToText() that "pretty-prints"
** the output.  Extra whitespace is inserted to make the JSON easier
** for humans to read.
**
** If an error is detected in the BLOB input, the pOut->eErr flag
** might get set to JSTRING_MALFORMED.  But not all BLOB input errors
** are detected.  So a malformed JSONB input might either result
** in an error, or in incorrect JSON.
**
** The pOut->eErr JSTRING_OOM flag is set on a OOM.
*/
static u32 jsonTranslateBlobToPrettyText(
  JsonPretty *pPretty,       /* Pretty-printing context */
  u32 i                      /* Start rendering at this index */
){
  u32 sz, n, j, iEnd;
  const JsonParse *pParse = pPretty->pParse;
  JsonString *pOut = pPretty->pOut;
  n = jsonbPayloadSize(pParse, i, &sz);
  if( n==0 ){
    pOut->eErr |= JSTRING_MALFORMED;
    return pParse->nBlob+1;
  }
  switch( pParse->aBlob[i] & 0x0f ){
    case JSONB_ARRAY: {
      j = i+n;
      iEnd = j+sz;
      jsonAppendChar(pOut, '[');
      if( j<iEnd ){
        jsonAppendChar(pOut, '\n');
        pPretty->nIndent++;
        while( pOut->eErr==0 ){
          jsonPrettyIndent(pPretty);
          j = jsonTranslateBlobToPrettyText(pPretty, j);
          if( j>=iEnd ) break;
          jsonAppendRawNZ(pOut, ",\n", 2);
        }
        jsonAppendChar(pOut, '\n');
        pPretty->nIndent--;
        jsonPrettyIndent(pPretty);
      }
      jsonAppendChar(pOut, ']');
      i = iEnd;
      break;
    }
    case JSONB_OBJECT: {
      j = i+n;
      iEnd = j+sz;
      jsonAppendChar(pOut, '{');
      if( j<iEnd ){
        jsonAppendChar(pOut, '\n');
        pPretty->nIndent++;
        while( pOut->eErr==0 ){
          jsonPrettyIndent(pPretty);
          j = jsonTranslateBlobToText(pParse, j, pOut);
          if( j>iEnd ){
            pOut->eErr |= JSTRING_MALFORMED;
            break;
          }
          jsonAppendRawNZ(pOut, ": ", 2);
          j = jsonTranslateBlobToPrettyText(pPretty, j);
          if( j>=iEnd ) break;
          jsonAppendRawNZ(pOut, ",\n", 2);
        }
        jsonAppendChar(pOut, '\n');
        pPretty->nIndent--;
        jsonPrettyIndent(pPretty);
      }
      jsonAppendChar(pOut, '}');
      i = iEnd;
      break;
    }
    default: {
      i = jsonTranslateBlobToText(pParse, i, pOut);
      break;
    }
  }
  return i;
}


/* Return true if the input pJson
**
** For performance reasons, this routine does not do a detailed check of the
** input BLOB to ensure that it is well-formed.  Hence, false positives are
** possible.  False negatives should never occur, however.
*/
207839
207840
207841
207842
207843
207844
207845


































207846
207847
207848
207849
207850
207851
207852
  }else{
    i = 0;
  }
  sqlite3_result_text(ctx, jsonbType[p->aBlob[i]&0x0f], -1, SQLITE_STATIC);
json_type_done:
  jsonParseFree(p);
}



































/*
** json_valid(JSON)
** json_valid(JSON, FLAGS)
**
** Check the JSON argument to see if it is well-formed.  The FLAGS argument
** encodes the various constraints on what is meant by "well-formed":







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







208273
208274
208275
208276
208277
208278
208279
208280
208281
208282
208283
208284
208285
208286
208287
208288
208289
208290
208291
208292
208293
208294
208295
208296
208297
208298
208299
208300
208301
208302
208303
208304
208305
208306
208307
208308
208309
208310
208311
208312
208313
208314
208315
208316
208317
208318
208319
208320
  }else{
    i = 0;
  }
  sqlite3_result_text(ctx, jsonbType[p->aBlob[i]&0x0f], -1, SQLITE_STATIC);
json_type_done:
  jsonParseFree(p);
}

/*
** json_pretty(JSON)
** json_pretty(JSON, INDENT)
**
** Return text that is a pretty-printed rendering of the input JSON.
** If the argument is not valid JSON, return NULL.
**
** The INDENT argument is text that is used for indentation.  If omitted,
** it defaults to four spaces (the same as PostgreSQL).
*/
static void jsonPrettyFunc(
  sqlite3_context *ctx,
  int argc,
  sqlite3_value **argv
){
  JsonString s;          /* The output string */
  JsonPretty x;          /* Pretty printing context */

  memset(&x, 0, sizeof(x));
  x.pParse = jsonParseFuncArg(ctx, argv[0], 0);
  if( x.pParse==0 ) return;
  x.pOut = &s;
  jsonStringInit(&s, ctx);
  if( argc==1 || (x.zIndent = (const char*)sqlite3_value_text(argv[1]))==0 ){
    x.zIndent = "    ";
    x.szIndent = 4;
  }else{
    x.szIndent = (u32)strlen(x.zIndent);
  }
  jsonTranslateBlobToPrettyText(&x, 0);
  jsonReturnString(&s, 0, 0);
  jsonParseFree(x.pParse);
}

/*
** json_valid(JSON)
** json_valid(JSON, FLAGS)
**
** Check the JSON argument to see if it is well-formed.  The FLAGS argument
** encodes the various constraints on what is meant by "well-formed":
208578
208579
208580
208581
208582
208583
208584
208585
208586
208587
208588
208589
208590
208591
208592
208593
208594
    default: {
      sqlite3_result_text(ctx, p->path.zBuf, p->nRoot, SQLITE_STATIC);
      break;
    }
    case JEACH_JSON: {
      if( p->sParse.zJson==0 ){
        sqlite3_result_blob(ctx, p->sParse.aBlob, p->sParse.nBlob,
                            SQLITE_STATIC);
      }else{
        sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC);
      }
      break;
    }
  }
  return SQLITE_OK;
}








|

|







209046
209047
209048
209049
209050
209051
209052
209053
209054
209055
209056
209057
209058
209059
209060
209061
209062
    default: {
      sqlite3_result_text(ctx, p->path.zBuf, p->nRoot, SQLITE_STATIC);
      break;
    }
    case JEACH_JSON: {
      if( p->sParse.zJson==0 ){
        sqlite3_result_blob(ctx, p->sParse.aBlob, p->sParse.nBlob,
                            SQLITE_TRANSIENT);
      }else{
        sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_TRANSIENT);
      }
      break;
    }
  }
  return SQLITE_OK;
}

208854
208855
208856
208857
208858
208859
208860


208861
208862
208863
208864
208865
208866
208867
    JFUNCTION(->>,                2,1,0, 0,0,JSON_SQL,   jsonExtractFunc),
    JFUNCTION(json_insert,       -1,1,1, 1,0,0,          jsonSetFunc),
    JFUNCTION(jsonb_insert,      -1,1,0, 1,1,0,          jsonSetFunc),
    JFUNCTION(json_object,       -1,0,1, 1,0,0,          jsonObjectFunc),
    JFUNCTION(jsonb_object,      -1,0,1, 1,1,0,          jsonObjectFunc),
    JFUNCTION(json_patch,         2,1,1, 0,0,0,          jsonPatchFunc),
    JFUNCTION(jsonb_patch,        2,1,0, 0,1,0,          jsonPatchFunc),


    JFUNCTION(json_quote,         1,0,1, 1,0,0,          jsonQuoteFunc),
    JFUNCTION(json_remove,       -1,1,1, 0,0,0,          jsonRemoveFunc),
    JFUNCTION(jsonb_remove,      -1,1,0, 0,1,0,          jsonRemoveFunc),
    JFUNCTION(json_replace,      -1,1,1, 1,0,0,          jsonReplaceFunc),
    JFUNCTION(jsonb_replace,     -1,1,0, 1,1,0,          jsonReplaceFunc),
    JFUNCTION(json_set,          -1,1,1, 1,0,JSON_ISSET, jsonSetFunc),
    JFUNCTION(jsonb_set,         -1,1,0, 1,1,JSON_ISSET, jsonSetFunc),







>
>







209322
209323
209324
209325
209326
209327
209328
209329
209330
209331
209332
209333
209334
209335
209336
209337
    JFUNCTION(->>,                2,1,0, 0,0,JSON_SQL,   jsonExtractFunc),
    JFUNCTION(json_insert,       -1,1,1, 1,0,0,          jsonSetFunc),
    JFUNCTION(jsonb_insert,      -1,1,0, 1,1,0,          jsonSetFunc),
    JFUNCTION(json_object,       -1,0,1, 1,0,0,          jsonObjectFunc),
    JFUNCTION(jsonb_object,      -1,0,1, 1,1,0,          jsonObjectFunc),
    JFUNCTION(json_patch,         2,1,1, 0,0,0,          jsonPatchFunc),
    JFUNCTION(jsonb_patch,        2,1,0, 0,1,0,          jsonPatchFunc),
    JFUNCTION(json_pretty,        1,1,0, 0,0,0,          jsonPrettyFunc),
    JFUNCTION(json_pretty,        2,1,0, 0,0,0,          jsonPrettyFunc),
    JFUNCTION(json_quote,         1,0,1, 1,0,0,          jsonQuoteFunc),
    JFUNCTION(json_remove,       -1,1,1, 0,0,0,          jsonRemoveFunc),
    JFUNCTION(jsonb_remove,      -1,1,0, 0,1,0,          jsonRemoveFunc),
    JFUNCTION(json_replace,      -1,1,1, 1,0,0,          jsonReplaceFunc),
    JFUNCTION(jsonb_replace,     -1,1,0, 1,1,0,          jsonReplaceFunc),
    JFUNCTION(json_set,          -1,1,1, 1,0,JSON_ISSET, jsonSetFunc),
    JFUNCTION(jsonb_set,         -1,1,0, 1,1,JSON_ISSET, jsonSetFunc),
210753
210754
210755
210756
210757
210758
210759


210760
210761
210762
210763
210764
210765
210766
    pCons->op = RTREE_QUERY;
    pCons->u.xQueryFunc = pBlob->cb.xQueryFunc;
  }
  pCons->pInfo = pInfo;
  return SQLITE_OK;
}



/*
** Rtree virtual table module xFilter method.
*/
static int rtreeFilter(
  sqlite3_vtab_cursor *pVtabCursor,
  int idxNum, const char *idxStr,
  int argc, sqlite3_value **argv







>
>







211223
211224
211225
211226
211227
211228
211229
211230
211231
211232
211233
211234
211235
211236
211237
211238
    pCons->op = RTREE_QUERY;
    pCons->u.xQueryFunc = pBlob->cb.xQueryFunc;
  }
  pCons->pInfo = pInfo;
  return SQLITE_OK;
}

SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double);

/*
** Rtree virtual table module xFilter method.
*/
static int rtreeFilter(
  sqlite3_vtab_cursor *pVtabCursor,
  int idxNum, const char *idxStr,
  int argc, sqlite3_value **argv
210782
210783
210784
210785
210786
210787
210788
210789

210790
210791
210792
210793
210794
210795
210796
    /* 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]);
    i64 iNode = 0;
    int eType = sqlite3_value_numeric_type(argv[0]);
    if( eType==SQLITE_INTEGER
     || (eType==SQLITE_FLOAT && sqlite3_value_double(argv[0])==iRowid)

    ){
      rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
    }else{
      rc = SQLITE_OK;
      pLeaf = 0;
    }
    if( rc==SQLITE_OK && pLeaf!=0 ){







|
>







211254
211255
211256
211257
211258
211259
211260
211261
211262
211263
211264
211265
211266
211267
211268
211269
    /* 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]);
    i64 iNode = 0;
    int eType = sqlite3_value_numeric_type(argv[0]);
    if( eType==SQLITE_INTEGER
     || (eType==SQLITE_FLOAT
         && 0==sqlite3IntFloatCompare(iRowid,sqlite3_value_double(argv[0])))
    ){
      rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
    }else{
      rc = SQLITE_OK;
      pLeaf = 0;
    }
    if( rc==SQLITE_OK && pLeaf!=0 ){
251028
251029
251030
251031
251032
251033
251034
251035
251036
251037
251038
251039
251040
251041
251042
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: 2024-02-20 12:14:07 6c5a0c85454e3c658e51fab611c169c034447174022eebc52fd8619b528a4765", -1, SQLITE_TRANSIENT);
}

/*
** Return true if zName is the extension on one of the shadow tables used
** by this module.
*/
static int fts5ShadowName(const char *zName){







|







251501
251502
251503
251504
251505
251506
251507
251508
251509
251510
251511
251512
251513
251514
251515
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: 2024-03-09 18:41:40 7ead022edaf7a0cd6a8976a1261246084975c9a5be5c893f6c751bb5f963ac0f", -1, SQLITE_TRANSIENT);
}

/*
** Return true if zName is the extension on one of the shadow tables used
** by this module.
*/
static int fts5ShadowName(const char *zName){
Changes to extsrc/sqlite3.h.
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION        "3.46.0"
#define SQLITE_VERSION_NUMBER 3046000
#define SQLITE_SOURCE_ID      "2024-02-22 00:50:54 ce5df19dc4aff3fde03ef62261a5e095a16a8f4e46e2924becea4fed56ce49e3"

/*
** 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







|







144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION        "3.46.0"
#define SQLITE_VERSION_NUMBER 3046000
#define SQLITE_SOURCE_ID      "2024-03-09 18:41:40 7ead022edaf7a0cd6a8976a1261246084975c9a5be5c893f6c751bb5f963ac0f"

/*
** 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
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
** <li> [SQLITE_LOCK_SHARED],
** <li> [SQLITE_LOCK_RESERVED],
** <li> [SQLITE_LOCK_PENDING], or
** <li> [SQLITE_LOCK_EXCLUSIVE].
** </ul>
** xLock() upgrades the database file lock.  In other words, xLock() moves the
** database file lock in the direction NONE toward EXCLUSIVE. The argument to
** xLock() is always on of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
** SQLITE_LOCK_NONE.  If the database file lock is already at or above the
** requested lock, then the call to xLock() is a no-op.
** xUnlock() downgrades the database file lock to either SHARED or NONE.
*  If the lock is already at or below the requested lock state, then the call
** to xUnlock() is a no-op.
** The xCheckReservedLock() method checks whether any database connection,
** either in this process or in some other process, is holding a RESERVED,
** PENDING, or EXCLUSIVE lock on the file.  It returns true
** if such a lock exists and false otherwise.
**
** The xFileControl() method is a generic interface that allows custom







|



|







760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
** <li> [SQLITE_LOCK_SHARED],
** <li> [SQLITE_LOCK_RESERVED],
** <li> [SQLITE_LOCK_PENDING], or
** <li> [SQLITE_LOCK_EXCLUSIVE].
** </ul>
** xLock() upgrades the database file lock.  In other words, xLock() moves the
** database file lock in the direction NONE toward EXCLUSIVE. The argument to
** xLock() is always one of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
** SQLITE_LOCK_NONE.  If the database file lock is already at or above the
** requested lock, then the call to xLock() is a no-op.
** xUnlock() downgrades the database file lock to either SHARED or NONE.
** If the lock is already at or below the requested lock state, then the call
** to xUnlock() is a no-op.
** The xCheckReservedLock() method checks whether any database connection,
** either in this process or in some other process, is holding a RESERVED,
** PENDING, or EXCLUSIVE lock on the file.  It returns true
** if such a lock exists and false otherwise.
**
** The xFileControl() method is a generic interface that allows custom