sqllogictest
Check-in [c3a3dfe2cb]
Not logged in

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

Overview
Comment:Update the SQLite core to version 3.6.12.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:c3a3dfe2cb37da2fb64e245d88c6b603c329ca99
User & Date: drh 2009-03-31 13:02:08
Context
2009-05-06
16:58
Update the SQLite build to version 3.6.14. check-in: e6cd5e74a2 user: drh tags: trunk
2009-03-31
13:02
Update the SQLite core to version 3.6.12. check-in: c3a3dfe2cb user: drh tags: trunk
2009-03-23
15:27
Update the SQLite amalgamation to the latest code from CVS. check-in: 73f66663ec user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/sqlite3.c.

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
....
6095
6096
6097
6098
6099
6100
6101
6102
6103

6104
6105
6106
6107
6108
6109
6110
....
6406
6407
6408
6409
6410
6411
6412
6413





6414
6415
6416
6417
6418
6419
6420
....
7941
7942
7943
7944
7945
7946
7947







7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
....
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
....
8706
8707
8708
8709
8710
8711
8712

8713
8714
8715
8716
8717
8718
8719
8720
....
8766
8767
8768
8769
8770
8771
8772









8773
8774
8775
8776
8777
8778
8779
....
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
....
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
.....
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
.....
11601
11602
11603
11604
11605
11606
11607

11608
11609


11610
11611
11612
11613
11614
11615
11616
.....
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
.....
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
.....
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
.....
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
.....
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
.....
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
.....
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
.....
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
.....
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
.....
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
.....
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
.....
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
.....
15324
15325
15326
15327
15328
15329
15330

15331
15332
15333
15334
15335
15336
15337
.....
15353
15354
15355
15356
15357
15358
15359

15360
15361
15362
15363
15364
15365
15366
.....
15461
15462
15463
15464
15465
15466
15467

15468
15469
15470
15471
15472
15473
15474
.....
15495
15496
15497
15498
15499
15500
15501


15502
15503
15504
15505
15506
15507
15508
.....
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
.....
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
.....
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
.....
22114
22115
22116
22117
22118
22119
22120
22121
22122
22123
22124
22125

22126
22127
22128
22129
22130
22131
22132
.....
22140
22141
22142
22143
22144
22145
22146
22147
22148
22149
22150
22151
22152
22153
22154
22155
22156
22157
22158
22159
22160
22161
22162
22163
22164
22165
22166
22167
22168
22169
22170
22171
22172
22173
22174
22175
22176
22177
22178
22179


22180
22181
22182
22183
22184
22185
22186
.....
23484
23485
23486
23487
23488
23489
23490
23491
23492


23493
23494

23495
23496
23497
23498
23499
23500
23501
.....
25774
25775
25776
25777
25778
25779
25780
25781
25782
25783
25784
25785
25786
25787
25788
.....
27350
27351
27352
27353
27354
27355
27356
27357
27358
27359
27360
27361
27362
27363
27364
.....
27747
27748
27749
27750
27751
27752
27753
27754














27755
27756
27757
27758
27759
27760
27761
27762
27763
27764
27765
27766
27767
27768
27769

27770
27771
27772
27773
27774
27775
27776
27777
27778
27779
27780
27781
27782
27783
27784
27785
27786
27787
27788
27789
27790
27791
.....
28266
28267
28268
28269
28270
28271
28272
28273
28274
28275
28276
28277
28278
28279
28280
.....
28590
28591
28592
28593
28594
28595
28596
28597
28598
28599
28600
28601
28602
28603
28604
28605
28606
28607
28608
.....
28857
28858
28859
28860
28861
28862
28863
28864
28865
28866
28867
28868
28869
28870
28871
.....
28969
28970
28971
28972
28973
28974
28975
28976
28977
28978
28979
28980
28981
28982
28983
.....
29853
29854
29855
29856
29857
29858
29859
29860
29861
29862
29863
29864
29865
29866
29867
.....
29933
29934
29935
29936
29937
29938
29939
29940
29941
29942
29943
29944
29945
29946
29947
29948
29949
29950
29951
29952
.....
31339
31340
31341
31342
31343
31344
31345

31346
31347
31348
31349
31350
31351
31352
.....
33113
33114
33115
33116
33117
33118
33119
33120
33121
33122
33123
33124
33125
33126
33127
.....
33169
33170
33171
33172
33173
33174
33175
33176
33177
33178
33179
33180

33181
33182
33183
33184
33185
33186
33187
33188
33189
33190
33191
33192
33193
33194
33195

33196
33197
33198
33199
33200
33201
33202
33203
33204
33205
33206
33207
33208
33209
33210
33211

33212
33213
33214
33215

33216
33217
33218





33219
33220
33221
33222
33223















33224

33225
33226
33227
33228

33229
33230
33231
33232
33233
33234
33235
.....
33247
33248
33249
33250
33251
33252
33253
33254
33255
33256
33257



33258
33259
33260
33261
33262
33263
33264
.....
33634
33635
33636
33637
33638
33639
33640
33641
33642
33643
33644
33645
33646
33647
33648
.....
33767
33768
33769
33770
33771
33772
33773
33774
33775
33776
33777
33778
33779
33780
33781
.....
34831
34832
34833
34834
34835
34836
34837

34838
34839
34840
34841
34842
34843
34844
.....
34889
34890
34891
34892
34893
34894
34895

34896
34897
34898
34899
34900
34901
34902
.....
34930
34931
34932
34933
34934
34935
34936













34937
34938
34939
34940
34941
34942
34943
.....
36004
36005
36006
36007
36008
36009
36010
36011
36012
36013
36014
36015
36016
36017
36018
.....
36850
36851
36852
36853
36854
36855
36856
36857
36858
36859
36860
36861
36862
36863
36864
.....
37299
37300
37301
37302
37303
37304
37305






37306
37307
37308
37309
37310
37311
37312
.....
38161
38162
38163
38164
38165
38166
38167
38168
38169
38170
38171
38172
38173
38174
38175
.....
38468
38469
38470
38471
38472
38473
38474












38475
38476
38477
38478
38479
38480
38481
.....
40421
40422
40423
40424
40425
40426
40427

40428
40429






40430
40431
40432
40433
40434
40435
40436
.....
43094
43095
43096
43097
43098
43099
43100
43101


43102
43103
43104
43105
43106
43107
43108
.....
44135
44136
44137
44138
44139
44140
44141
44142
44143
44144
44145
44146
44147
44148
44149
.....
44439
44440
44441
44442
44443
44444
44445




44446
44447
44448
44449
44450
44451
44452
44453
44454
44455
44456
44457
44458

44459
44460
44461
44462
44463
44464
44465
44466
44467
.....
45177
45178
45179
45180
45181
45182
45183
45184
45185
45186
45187
45188
45189
45190
45191
.....
46064
46065
46066
46067
46068
46069
46070
46071
46072
46073
46074
46075
46076
46077
46078
46079
.....
46081
46082
46083
46084
46085
46086
46087
46088
46089
46090
46091
46092
46093
46094
46095
46096
.....
46185
46186
46187
46188
46189
46190
46191
46192
46193
46194
46195
46196
46197
46198
46199
.....
47816
47817
47818
47819
47820
47821
47822
47823
47824
47825
47826
47827
47828
47829
47830
.....
48304
48305
48306
48307
48308
48309
48310
48311
48312
48313
48314
48315
48316
48317
48318
48319
48320
48321
48322
48323
48324
48325








48326
48327
48328
48329
48330
48331
48332
.....
49160
49161
49162
49163
49164
49165
49166
49167
49168
49169
49170
49171
49172
49173
49174
.....
53577
53578
53579
53580
53581
53582
53583
53584
53585
53586
53587
53588
53589
53590
53591
53592
























53593


53594
53595
53596
53597
53598
53599
53600


53601
53602
53603
53604
53605
53606
53607
53608
53609
53610



53611
53612
53613
53614
53615
53616
53617
.....
54610
54611
54612
54613
54614
54615
54616
54617
54618
54619
54620
54621
54622
54623
54624
.....
54860
54861
54862
54863
54864
54865
54866

54867


54868
54869

54870
54871
54872
54873
54874
54875
54876
.....
56753
56754
56755
56756
56757
56758
56759
56760
56761
56762
56763
56764
56765
56766
56767
.....
57144
57145
57146
57147
57148
57149
57150

57151












57152



57153
57154
57155
57156
57157
57158
57159
.....
57251
57252
57253
57254
57255
57256
57257
57258
57259
57260
57261
57262
57263
57264
57265
57266
57267
57268
57269
57270
57271
57272
57273
57274
.....
57384
57385
57386
57387
57388
57389
57390
57391
57392
57393
57394
57395
57396
57397
57398
57399
57400
57401
57402
57403
57404
57405
57406
57407
57408
57409
57410
57411

57412

57413
57414
57415
57416
57417
57418
57419
.....
57454
57455
57456
57457
57458
57459
57460
57461
57462
57463
57464
57465
57466
57467
57468
.....
57616
57617
57618
57619
57620
57621
57622
57623
57624
57625
57626
57627
57628
57629
57630
.....
58736
58737
58738
58739
58740
58741
58742
58743
58744
58745
58746
58747
58748
58749
58750
.....
59238
59239
59240
59241
59242
59243
59244
59245
59246
59247
59248
59249
59250
59251
59252
.....
60066
60067
60068
60069
60070
60071
60072
60073
60074
60075
60076
60077
60078
60079
60080
.....
60646
60647
60648
60649
60650
60651
60652
60653
60654
60655
60656
60657
60658
60659
60660
.....
61917
61918
61919
61920
61921
61922
61923
61924
61925
61926
61927
61928
61929
61930
61931
.....
62233
62234
62235
62236
62237
62238
62239
62240
62241
62242
62243
62244
62245
62246
62247
.....
62361
62362
62363
62364
62365
62366
62367
62368
62369
62370
62371
62372
62373
62374
62375
.....
62392
62393
62394
62395
62396
62397
62398
62399
62400
62401
62402
62403
62404
62405
62406
.....
62730
62731
62732
62733
62734
62735
62736
62737
62738
62739
62740
62741
62742
62743
62744
.....
63749
63750
63751
63752
63753
63754
63755

63756
63757
63758

63759
63760
63761
63762
63763
63764
63765
63766

63767
63768
63769
63770
63771
63772
63773
.....
65589
65590
65591
65592
65593
65594
65595
65596
65597
65598
65599
65600
65601
65602
65603
.....
65998
65999
66000
66001
66002
66003
66004

66005
66006
66007
66008
66009
66010
66011
.....
66681
66682
66683
66684
66685
66686
66687
66688
66689
66690
66691
66692
66693
66694
66695
.....
67966
67967
67968
67969
67970
67971
67972
67973
67974
67975
67976
67977
67978
67979
67980
67981
67982
.....
72428
72429
72430
72431
72432
72433
72434
72435
72436
72437
72438
72439
72440
72441
72442
.....
72491
72492
72493
72494
72495
72496
72497
72498
72499
72500
72501
72502
72503
72504
72505
72506
72507
72508
72509
72510
72511
72512
72513
72514
72515
72516
72517
72518
72519
.....
73266
73267
73268
73269
73270
73271
73272
73273
73274
73275
73276
73277
73278
73279
73280
.....
74482
74483
74484
74485
74486
74487
74488
74489
74490
74491
74492
74493
74494
74495
74496
.....
74537
74538
74539
74540
74541
74542
74543
74544
74545
74546
74547
74548
74549
74550
74551
.....
76333
76334
76335
76336
76337
76338
76339
76340
76341
76342
76343
76344
76345
76346
76347
.....
79619
79620
79621
79622
79623
79624
79625
79626
79627
79628
79629
79630
79631
79632
79633
.....
79725
79726
79727
79728
79729
79730
79731

79732
79733
79734
79735
79736
79737
79738
79739
.....
80471
80472
80473
80474
80475
80476
80477
80478
80479
80480
80481
80482
80483
80484
80485
.....
81110
81111
81112
81113
81114
81115
81116
81117
81118
81119
81120
81121
81122
81123
81124
.....
82380
82381
82382
82383
82384
82385
82386
82387

82388
82389
82390
82391
82392





82393
82394
82395
82396
82397
82398
82399
82400
82401
82402
82403
82404

82405
82406
82407
82408
82409
82410
82411







82412
82413
82414
82415
82416
82417

82418
82419

82420
82421
82422
82423
82424
82425
82426
.....
82429
82430
82431
82432
82433
82434
82435
82436

82437
82438
82439
82440
82441
82442
82443
.....
84015
84016
84017
84018
84019
84020
84021
84022
84023
84024
84025
84026
84027
84028
84029
84030
84031
84032
84033
84034
84035
84036
84037
84038
84039
84040
84041
84042
84043
84044
84045
84046
84047
84048
84049
84050
84051
84052
84053
84054
84055
84056
.....
84101
84102
84103
84104
84105
84106
84107
84108
84109
84110
84111
84112
84113
84114
84115
84116
84117
84118
84119
84120
84121
84122
84123
84124
84125
84126
84127
84128
84129
84130
84131
84132
84133
84134
84135
84136
84137
84138
84139
84140
84141
84142
84143
84144
84145
84146
84147
84148
84149
84150
84151
84152
84153
84154
84155
84156
84157
84158
84159
84160
84161
84162
84163
84164
84165
84166
84167
84168
84169
84170
84171
84172
84173
84174
84175
84176
84177
84178
84179
84180
84181
84182
84183
84184
84185
84186
84187
84188
84189
84190
84191
84192
84193
84194
84195
84196
84197
84198
84199
84200
84201
84202
84203
84204
84205
84206
84207
84208
84209
84210
84211
84212
84213
84214
84215
84216
84217
84218
84219
84220
84221
84222
84223
84224
84225
84226
84227
84228
84229
84230
84231
84232
84233
84234
84235
84236
84237
84238
84239
84240
84241
84242
84243
84244
84245
84246
84247
84248
84249
84250
84251
84252
84253
84254
84255
84256
84257
84258
84259
84260
84261
84262
84263
84264
84265
84266
84267
84268
84269
84270
84271
84272
84273
84274
84275
84276
84277
84278
84279
84280
84281
84282
84283
84284
84285
84286
84287
84288
84289
84290
84291
84292
84293
84294
84295
84296
84297
84298
84299
84300
84301
84302
84303
84304
84305
84306
84307
84308
84309
84310
84311
84312
84313
84314
84315
84316
84317
84318
84319
84320
84321
84322
84323
84324
84325
84326
84327
84328
84329
84330
84331
84332
84333
84334
84335
84336
84337
84338
84339
84340
84341
84342
84343
84344
84345
84346
84347
84348
84349
84350
84351
84352
84353
84354
84355
84356
84357
84358
84359
84360
84361
84362
84363
84364
84365
84366
84367
84368
84369
84370
84371
84372
84373
84374
84375
84376
84377
84378
84379
84380
84381
84382
84383
84384
84385
84386
84387
84388
84389
84390
84391
84392
84393
84394
84395
84396
84397
84398
84399
84400
84401
84402
84403
84404
84405
84406
84407
84408
84409
84410
84411
84412
84413
84414
84415
84416
84417
84418
84419
84420
84421
84422
84423
84424
84425
84426
84427
84428
84429
84430
84431
84432
84433
84434
84435
84436
84437
84438
84439
84440
84441
84442
84443
84444
84445
84446
84447
84448
84449
84450
84451
84452
84453
84454
84455
84456
84457
84458
84459
84460
84461
84462
84463
84464
84465
84466
84467
84468
84469
84470
84471
84472
84473
84474
84475
84476
84477
84478
84479
84480
84481
84482
84483
84484
84485
84486
84487
84488
84489
84490
84491
84492
84493
84494
84495
84496
84497
84498
84499
84500
84501
84502
84503
84504
84505
84506
84507
84508
84509
84510
84511
84512
84513
84514
84515
84516
.....
84534
84535
84536
84537
84538
84539
84540
84541
84542

84543
84544
84545
84546
84547
84548
84549
.....
84738
84739
84740
84741
84742
84743
84744
84745
84746
84747
84748
84749
84750
84751
84752
.....
84772
84773
84774
84775
84776
84777
84778
84779
84780
84781
84782
84783
84784
84785
84786
84787
84788
84789
84790
84791
84792
84793
84794
84795
84796
84797
84798
84799
84800
84801
84802
84803
84804
84805
84806
84807
.....
84827
84828
84829
84830
84831
84832
84833
84834

84835
84836
84837
84838
84839
84840
84841
84842
84843
84844
84845
84846
84847
84848
84849
84850
84851
84852
84853
84854
84855
84856
84857
84858
84859
84860
84861
84862
84863
84864
84865
84866
84867
84868
84869
84870
84871
84872
84873
84874
84875
84876
84877
84878
84879
84880
84881
84882
84883
84884
84885
84886
84887
84888
84889
84890
84891
84892
84893
84894
84895
84896
84897
84898
84899
84900
84901
84902
84903
84904
84905
84906
84907
84908
84909
84910
84911
84912
84913
84914
84915
84916
84917
84918
84919
84920
84921
84922
84923
84924
84925
84926
84927
84928
84929
84930
84931
84932
84933
84934
84935
84936
84937
84938
84939
84940
84941
84942
84943
84944
84945
84946
84947
84948
84949
84950
84951
84952
84953
84954
84955
84956
84957
84958
84959
84960
84961
84962
84963
84964
84965
84966
84967
84968
84969
84970
84971
84972
84973
84974
84975
84976
84977
84978
84979
84980
84981
84982
84983
84984
84985
84986
84987
84988
84989
84990
84991
84992
84993
84994
84995
84996
84997
84998
84999
85000
85001
85002
85003
85004
85005
85006
85007
85008
85009
85010
85011
85012
85013
85014
85015
85016
85017
85018
85019
85020
85021
85022
85023
85024
85025
85026
85027
85028
85029
85030
85031
85032
85033
85034
85035
85036
85037
85038
85039
85040
85041
85042
85043
85044
85045
85046
85047
85048
85049
85050
85051
85052
85053
85054
85055
85056
85057
85058
85059
85060
85061
85062
85063
85064
85065
85066
85067
85068
85069
85070
85071
85072
85073
85074
85075
85076
85077
85078
85079
85080
85081
85082
85083
85084
85085
85086
85087
85088
85089
85090
85091
85092
85093
85094
85095
85096
85097
.....
85162
85163
85164
85165
85166
85167
85168
85169
85170
85171
85172
85173
85174
85175
85176
85177
85178
85179
85180
85181
85182
85183
85184
85185
85186
85187
85188
85189
85190
85191
85192
85193
85194
85195
85196
85197
85198
85199
85200
85201
85202
85203
85204
85205
85206
85207
85208
85209
85210
85211
85212
85213
85214
85215
85216
85217
85218
85219
85220
85221
85222
85223
85224
85225
85226
85227
85228
85229
85230
85231
85232
85233
85234
85235
.....
85481
85482
85483
85484
85485
85486
85487

85488
85489
85490
85491
85492
85493
85494
85495
85496
85497
85498
85499
85500
85501
85502
85503
85504
85505
85506
85507
85508
85509
85510
85511
85512
85513
85514
85515
85516
85517
85518
85519
85520
85521
85522
85523
85524
85525
85526
85527
85528
85529
85530
85531
85532
85533
85534
85535
85536
85537
85538
85539
85540
85541
85542
85543
85544
85545
85546
85547
85548
85549
85550
85551
85552
85553
85554
85555
85556
85557
85558
85559
85560
85561
85562
85563
85564
85565
85566
85567
85568
85569
85570
85571
85572
85573
85574
85575
85576
85577
85578
85579
85580
85581
85582
85583
85584
85585
85586
85587
85588
85589
85590
85591
85592
85593
85594
85595
85596
85597
85598
85599
85600
85601
85602
85603
85604
85605
85606
85607
85608
85609
85610
85611
85612
85613
85614
85615
85616
85617
85618
85619
85620
85621
85622
85623
85624
85625
85626
85627
85628
85629
85630
85631
85632
85633
85634
85635
85636
85637
85638
85639
85640
85641
85642
85643
85644
85645
85646
85647
85648
85649
85650
85651
85652
85653
85654
85655
85656
85657
85658
85659
85660
85661
85662
85663
85664
85665
85666
85667
85668
85669
85670
85671
85672
85673
85674
85675
85676
85677
85678
85679
85680
85681
85682
85683
85684
85685
85686
85687
85688
85689
85690
85691
85692
85693
85694
85695
85696
85697
85698
85699
85700
85701
85702
85703
85704
85705
85706
85707
85708
85709
85710
85711
85712
85713
85714
85715
85716
85717
85718
85719
85720
85721
85722
85723
85724
85725
85726
85727
85728
85729
85730


85731
85732
85733
85734
85735
85736
85737
85738
85739
85740
85741
85742
85743
85744
85745
85746
85747
85748
85749
.....
85802
85803
85804
85805
85806
85807
85808
85809
85810
85811
85812
85813
85814
85815
85816
85817
85818
85819
85820
85821
85822
85823
85824
85825
85826
85827
85828
85829
85830
85831
85832
85833
.....
85836
85837
85838
85839
85840
85841
85842
85843
85844
85845
85846
85847
85848
85849
85850
85851
85852
85853
85854
85855
85856
85857
85858
85859
85860
.....
85870
85871
85872
85873
85874
85875
85876
85877
85878
85879
85880
85881






85882
85883
85884
85885
85886
85887
85888
85889
85890
85891
85892
85893
85894
85895
85896
85897
85898
85899
85900
85901
85902
85903
85904
85905
85906
85907
85908
85909
85910
85911
85912
85913
85914
85915
85916
85917
85918
85919
85920
85921
85922
85923
85924
85925
85926
85927
85928
85929
85930
85931
85932
85933
85934
85935
85936
85937
85938
85939
85940
85941
85942
85943
85944
85945
85946
85947
85948
85949
85950
85951
85952
85953
85954
85955
85956
85957
85958
85959
85960
85961
85962
85963
85964
85965
85966
85967
85968
85969
85970
85971
85972
85973
85974
85975
85976
85977
85978
85979
85980
85981
85982
85983
85984
85985
85986
85987
85988
85989
85990
85991
85992
85993
85994
85995
85996
85997
85998
85999
86000
86001
86002
86003
86004
86005
86006
86007
86008
86009
86010
86011
86012
86013
86014
86015
86016
86017
86018
86019
86020
86021
86022
86023
86024
86025
86026
86027
86028
86029
86030
86031
86032
86033
86034
86035
86036
86037
86038
86039
86040
86041
86042
86043
86044
86045
86046
86047
86048
86049
86050
86051
86052
86053
86054
86055
86056
86057
86058
86059
86060
86061
86062
86063
86064
86065
86066
86067
86068
86069
86070
86071
86072
86073
86074
86075
86076
86077
86078
86079
86080
86081
86082
86083
86084
86085
86086
86087
86088
86089
86090
86091
86092
86093
86094
86095
86096
86097
86098
86099
86100
86101
86102
86103
86104
86105
86106
86107
86108
86109
86110
86111
86112
86113
86114
86115
86116
86117
86118
86119
86120
86121
86122
86123
86124
86125
86126
86127
86128
86129
86130
86131
86132
86133
86134
86135
86136
86137
86138
86139
86140
86141
86142
86143
86144
86145
86146
86147
86148
86149
86150
86151
86152
86153
86154
86155
86156
86157
86158
86159
86160
86161
86162
86163
86164
86165
86166
86167
86168
86169
86170
86171
86172
86173
86174
86175
86176
86177
86178
86179
86180
86181
86182
86183
86184
86185
86186
86187
86188
86189
86190
86191
86192
86193
86194
86195
86196
86197
86198
86199
86200
86201
86202
86203
86204
86205
86206
86207
86208
86209
86210
86211
86212
86213
86214
86215
86216
86217
86218
86219
86220
86221
86222
86223
86224
86225
86226
86227
86228
86229
86230
86231
86232
86233
86234
86235
86236
86237
86238
86239
86240
86241
86242
86243
86244
86245
86246
86247
86248
86249
86250
86251
86252
86253
86254
86255
86256
86257
86258
86259
86260
86261
86262
86263
86264
86265
86266
86267
86268
86269
86270
86271
86272
86273
86274
86275
86276
86277
86278
86279
86280
86281
86282
86283
86284
86285
86286
86287
86288
86289
86290
86291
86292
86293
86294
86295
86296
86297
86298
86299
86300
86301
86302
86303
86304
86305
86306
86307
86308
86309
86310
86311
86312
86313
86314
86315
86316
86317
86318
86319
86320
86321
86322
86323
86324
86325
86326
86327
86328
86329
86330
86331
86332
86333
86334
86335
86336
86337
86338
86339
86340
86341
86342
86343
86344
86345
86346
86347
86348
86349
86350
86351
86352
86353
86354
86355
86356
86357
86358
86359
86360
86361
86362
86363
86364
86365
86366
86367
86368
86369
86370
86371
86372
86373
86374
86375
86376
86377
86378
86379
86380
86381
86382
86383
86384
86385
86386
86387
86388
86389
86390
86391
86392
86393
86394
86395
86396
86397
86398
86399
86400
86401
86402
86403
86404
86405
86406
86407
86408
86409
86410
86411
86412
86413
86414
86415
86416
86417
86418
86419
86420
86421
86422
86423
86424
86425
86426
86427
86428
86429
86430
86431
86432
86433
86434
86435
86436
86437
86438
86439
86440
86441
86442
86443
86444
86445
86446
86447
86448
86449
86450
86451
86452
86453
86454
86455
86456
86457
86458
86459
86460
86461
86462
86463
86464
86465
86466
86467
86468
86469
86470
86471
86472
86473
86474
86475
86476
86477
86478
86479
86480
86481
86482
86483
86484
86485
86486
86487
86488
86489
86490
86491
86492
86493
86494
86495
86496
86497
86498
86499
86500
86501
86502
86503
86504
86505
86506
86507
86508
86509
86510
86511
86512
86513
86514
86515
86516
86517
86518
86519
86520
86521
86522
86523
86524
86525
86526
86527
86528
86529
86530
86531
86532
86533
86534
86535
86536
86537
86538
86539
86540
86541
86542
86543
86544
86545
86546
86547
86548
86549
86550
86551
86552
86553
86554
86555
86556
86557
86558
86559
86560
86561
86562
86563
86564
86565
86566
86567
86568
86569
86570
86571
86572
86573
86574
86575
86576
86577
86578
86579
86580
86581
86582
86583
86584
86585
86586
86587
86588
86589
86590
86591
86592
86593












86594
86595
86596
86597
86598
86599
86600
86601
86602
86603
86604
86605
86606
86607
86608
86609
86610
86611
86612
86613
86614
86615
86616
86617
86618
86619
86620
86621
86622
86623
86624
86625
86626
86627
86628
86629
86630
86631
86632
86633
86634
86635
86636
86637
86638
86639
86640
86641
86642
86643
86644
86645
86646
86647
86648
86649
86650
86651
86652
86653
86654
86655
86656
86657
86658
86659
86660
86661
86662
86663
86664
86665
86666
86667
86668
86669
86670
86671
86672
86673
86674
86675
86676
86677
86678
86679
86680
86681
86682
86683
86684
86685
86686
86687
86688
86689
86690
86691
86692
86693
86694
86695
86696
86697
86698
86699
86700
86701
86702
86703









86704
86705
86706
86707
86708
86709
86710
86711
86712
86713
86714
86715
86716
86717
86718
86719
86720
86721
86722
86723
86724
86725
86726
86727
86728
86729
86730
86731
.....
86979
86980
86981
86982
86983
86984
86985
86986
86987
86988
86989
86990
86991
86992
86993
.....
87583
87584
87585
87586
87587
87588
87589
87590
87591
87592
87593
87594

87595
87596

87597


87598
87599
87600
87601
87602
87603
87604
.....
87610
87611
87612
87613
87614
87615
87616


87617
87618
87619
87620
87621
87622
87623
.....
87664
87665
87666
87667
87668
87669
87670

87671
87672
87673
87674
87675
87676
87677
.....
88013
88014
88015
88016
88017
88018
88019
88020
88021
88022
88023
88024
88025
88026
88027
.....
88490
88491
88492
88493
88494
88495
88496
88497
88498
88499
88500
88501
88502
88503
88504
88505
88506
88507
88508
88509
.....
90281
90282
90283
90284
90285
90286
90287
90288
90289
90290
90291
90292
90293
90294
90295
.....
90496
90497
90498
90499
90500
90501
90502
90503
90504
90505
90506
90507
90508
90509
90510
90511
90512
.....
90573
90574
90575
90576
90577
90578
90579
90580
90581
90582
90583
90584
90585
90586
90587
** the "sqlite3.h" header file at hand, you will find a copy in the first
** 5487 lines past this header comment.)  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.
**
** This amalgamation was generated on 2009-03-23 14:30:20 UTC.
*/
#define SQLITE_CORE 1
#define SQLITE_AMALGAMATION 1
#ifndef SQLITE_PRIVATE
# define SQLITE_PRIVATE static
#endif
#ifndef SQLITE_API
................................................................................
**    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.
**
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.844 2009/03/20 14:18:52 danielk1977 Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_

/*
** Include the configuration header output by 'configure' if we're using the
** autoconf-based build
................................................................................
#define TK_EXCLUSIVE                       9
#define TK_COMMIT                         10
#define TK_END                            11
#define TK_ROLLBACK                       12
#define TK_SAVEPOINT                      13
#define TK_RELEASE                        14
#define TK_TO                             15
#define TK_CREATE                         16
#define TK_TABLE                          17

#define TK_IF                             18
#define TK_NOT                            19
#define TK_EXISTS                         20
#define TK_TEMP                           21
#define TK_LP                             22
#define TK_RP                             23
#define TK_AS                             24
................................................................................
#define LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))
#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)

/* 
** Round up a number to the next larger multiple of 8.  This is used
** to force 8-byte alignment on 64-bit architectures.
*/
#define ROUND8(x)    ((x+7)&~7)






/*
** An instance of the following structure is used to store the busy-handler
** callback for a given sqlite handle. 
**
** The sqlite.busyHandler member of the sqlite struct contains the busy
** callback for the database handle. Each pager opened via the sqlite
................................................................................
** (approx 10%) by avoiding numerous malloc/free requests while parsing
** SQL statements.
**
** The Lookaside structure holds configuration information about the
** lookaside malloc subsystem.  Each available memory allocation in
** the lookaside subsystem is stored on a linked list of LookasideSlot
** objects.







*/
struct Lookaside {
  u16 sz;                 /* Size of each buffer in bytes */
  u8 bEnabled;            /* True if use lookaside.  False to ignore it */
  u8 bMalloced;           /* True if pStart obtained from sqlite3_malloc() */
  int nOut;               /* Number of buffers currently checked out */
  int mxOut;              /* Highwater mark for nOut */
  LookasideSlot *pFree;   /* List of available buffers */
  void *pStart;           /* First byte of available memory space */
  void *pEnd;             /* First byte past end of available space */
};
................................................................................
** when the VDBE cursor to the table is closed.  In this case Table.tnum 
** refers VDBE cursor number that holds the table open, not to the root
** page number.  Transient tables are used to hold the results of a
** sub-query that appears instead of a real table name in the FROM clause 
** of a SELECT statement.
*/
struct Table {
  sqlite3 *db;         /* Associated database connection.  Might be NULL. */
  char *zName;         /* Name of the table or view */
  int iPKey;           /* If not negative, use aCol[iPKey] as the primary key */
  int nCol;            /* Number of columns in this table */
  Column *aCol;        /* Information about each column */
  Index *pIndex;       /* List of SQL indexes on this table. */
  int tnum;            /* Root BTree node for this table (see note above) */
  Select *pSelect;     /* NULL for tables.  Points to definition if a view. */
................................................................................
** If the EP_TokenOnly flag is set in Expr.flags, then only EXPR_TOKENONLYSIZE
** bytes of space are allocated for the expression structure. This is enough
** space to store all fields up to and including the "Token token;" field.
*/
struct Expr {
  u8 op;                 /* Operation performed by this node */
  char affinity;         /* The affinity of the column or 0 if not a column */

  u16 flags;             /* Various flags.  See below */
  Token token;           /* An operand token */

  /* If the EP_TokenOnly flag is set in the Expr.flags mask, then no
  ** space is allocated for the fields below this point. An attempt to
  ** access them will result in a segfault or malfunction. 
  *********************************************************************/

................................................................................
#define EP_IntValue   0x0800  /* Integer value contained in iTable */
#define EP_xIsSelect  0x1000  /* x.pSelect is valid (otherwise x.pList is) */

#define EP_Reduced    0x2000  /* Expr struct is EXPR_REDUCEDSIZE bytes only */
#define EP_TokenOnly  0x4000  /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
#define EP_SpanOnly   0x8000  /* Expr struct is EXPR_SPANONLYSIZE bytes only */










/*
** These macros can be used to test, set, or clear bits in the 
** Expr.flags field.
*/
#define ExprHasProperty(E,P)     (((E)->flags&(P))==(P))
#define ExprHasAnyProperty(E,P)  (((E)->flags&(P))!=0)
#define ExprSetProperty(E,P)     (E)->flags|=(P)
................................................................................
#if defined(SQLITE_TEST)
SQLITE_PRIVATE   void *sqlite3TestTextToPtr(const char*);
#endif
SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*, ...);
SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...);
SQLITE_PRIVATE void sqlite3ErrorClear(Parse*);
SQLITE_PRIVATE void sqlite3Dequote(char*);
SQLITE_PRIVATE void sqlite3DequoteExpr(sqlite3*, Expr*);
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int);
SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*, char **);
SQLITE_PRIVATE void sqlite3FinishCoding(Parse*);
SQLITE_PRIVATE int sqlite3GetTempReg(Parse*);
SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse*,int);
SQLITE_PRIVATE int sqlite3GetTempRange(Parse*,int);
SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse*,int,int);
................................................................................
SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int);
SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
                                     int*,int,int,int,int);
SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);
SQLITE_PRIVATE void sqlite3TokenCopy(sqlite3*,Token*, Token*);
SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);
SQLITE_PRIVATE void sqlite3FuncDefInsert(FuncDefHash*, FuncDef*);
SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,int);
SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(sqlite3*);
................................................................................
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file contains OS interface code that is common to all
** architectures.
**
** $Id: os.c,v 1.125 2008/12/08 18:19:18 drh Exp $
*/
#define _SQLITE_OS_C_ 1
#undef _SQLITE_OS_C_

/*
** The default SQLite sqlite3_vfs implementations do not allocate
** memory (actually, os_unix.c allocates a small amount of memory
................................................................................
SQLITE_PRIVATE int sqlite3OsOpen(
  sqlite3_vfs *pVfs, 
  const char *zPath, 
  sqlite3_file *pFile, 
  int flags, 
  int *pFlagsOut
){

  DO_OS_MALLOC_TEST;
  return pVfs->xOpen(pVfs, zPath, pFile, flags, pFlagsOut);


}
SQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
  return pVfs->xDelete(pVfs, zPath, dirSync);
}
SQLITE_PRIVATE int sqlite3OsAccess(
  sqlite3_vfs *pVfs, 
  const char *zPath, 
................................................................................
** This file contains low-level memory allocation drivers for when
** SQLite will use the standard C-library malloc/realloc/free interface
** to obtain the memory it needs.
**
** This file contains implementations of the low-level memory allocation
** routines specified in the sqlite3_mem_methods object.
**
** $Id: mem1.c,v 1.29 2008/12/10 21:19:57 drh Exp $
*/

/*
** This version of the memory allocator is the default.  It is
** used when no other memory allocator is specified using compile-time
** macros.
*/
................................................................................
** For this low-level routine, we are guaranteed that nByte>0 because
** cases of nByte<=0 will be intercepted and dealt with by higher level
** routines.
*/
static void *sqlite3MemMalloc(int nByte){
  sqlite3_int64 *p;
  assert( nByte>0 );
  nByte = (nByte+7)&~7;
  p = malloc( nByte+8 );
  if( p ){
    p[0] = nByte;
    p++;
  }
  return (void *)p;
}
................................................................................
** redirected to xMalloc.  Similarly, we know that nByte>0 becauses
** cases where nByte<=0 will have been intercepted by higher-level
** routines and redirected to xFree.
*/
static void *sqlite3MemRealloc(void *pPrior, int nByte){
  sqlite3_int64 *p = (sqlite3_int64*)pPrior;
  assert( pPrior!=0 && nByte>0 );
  nByte = (nByte+7)&~7;
  p = (sqlite3_int64*)pPrior;
  p--;
  p = realloc(p, nByte+8 );
  if( p ){
    p[0] = nByte;
    p++;
  }
................................................................................
  return (int)p[0];
}

/*
** Round up a request size to the next valid allocation size.
*/
static int sqlite3MemRoundup(int n){
  return (n+7) & ~7;
}

/*
** Initialize this module.
*/
static int sqlite3MemInit(void *NotUsed){
  UNUSED_PARAMETER(NotUsed);
................................................................................
** to obtain the memory it needs while adding lots of additional debugging
** information to each allocation in order to help detect and fix memory
** leaks and memory usage errors.
**
** This file contains implementations of the low-level memory allocation
** routines specified in the sqlite3_mem_methods object.
**
** $Id: mem2.c,v 1.44 2009/02/19 14:39:25 danielk1977 Exp $
*/

/*
** This version of the memory allocator is used only if the
** SQLITE_MEMDEBUG macro is defined
*/
#ifdef SQLITE_MEMDEBUG
................................................................................
} mem;


/*
** Adjust memory usage statistics
*/
static void adjustStats(int iSize, int increment){
  int i = ((iSize+7)&~7)/8;
  if( i>NCSIZE-1 ){
    i = NCSIZE - 1;
  }
  if( increment>0 ){
    mem.nAlloc[i]++;
    mem.nCurrent[i]++;
    if( mem.nCurrent[i]>mem.mxCurrent[i] ){
................................................................................
  int *pInt;
  u8 *pU8;
  int nReserve;

  p = (struct MemBlockHdr*)pAllocation;
  p--;
  assert( p->iForeGuard==(int)FOREGUARD );
  nReserve = (p->iSize+7)&~7;
  pInt = (int*)pAllocation;
  pU8 = (u8*)pAllocation;
  assert( pInt[nReserve/sizeof(int)]==(int)REARGUARD );
  /* This checks any of the "extra" bytes allocated due
  ** to rounding up to an 8 byte boundary to ensure 
  ** they haven't been overwritten.
  */
................................................................................
  mem.mutex = 0;
}

/*
** Round up a request size to the next valid allocation size.
*/
static int sqlite3MemRoundup(int n){
  return (n+7) & ~7;
}

/*
** Allocate nByte bytes of memory.
*/
static void *sqlite3MemMalloc(int nByte){
  struct MemBlockHdr *pHdr;
................................................................................
  char *z;
  int *pInt;
  void *p = 0;
  int totalSize;
  int nReserve;
  sqlite3_mutex_enter(mem.mutex);
  assert( mem.disallow==0 );
  nReserve = (nByte+7)&~7;
  totalSize = nReserve + sizeof(*pHdr) + sizeof(int) +
               mem.nBacktrace*sizeof(void*) + mem.nTitle;
  p = malloc(totalSize);
  if( p ){
    z = p;
    pBt = (void**)&z[mem.nTitle];
    pHdr = (struct MemBlockHdr*)&pBt[mem.nBacktrace];
................................................................................
*/
SQLITE_PRIVATE void sqlite3MemdebugSettitle(const char *zTitle){
  unsigned int n = sqlite3Strlen30(zTitle) + 1;
  sqlite3_mutex_enter(mem.mutex);
  if( n>=sizeof(mem.zTitle) ) n = sizeof(mem.zTitle)-1;
  memcpy(mem.zTitle, zTitle, n);
  mem.zTitle[n] = 0;
  mem.nTitle = (n+7)&~7;
  sqlite3_mutex_leave(mem.mutex);
}

SQLITE_PRIVATE void sqlite3MemdebugSync(){
  struct MemBlockHdr *pHdr;
  for(pHdr=mem.pFirst; pHdr; pHdr=pHdr->pNext){
    void **pBt = (void**)pHdr;
................................................................................
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** Memory allocation functions used throughout sqlite.
**
** $Id: malloc.c,v 1.58 2009/03/05 04:20:32 shane Exp $
*/

/*
** This routine runs when the memory allocator sees that the
** total memory allocation is about to exceed the soft heap
** limit.
*/
................................................................................
  memset(&mem0, 0, sizeof(mem0));
  if( sqlite3GlobalConfig.bCoreMutex ){
    mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
  }
  if( sqlite3GlobalConfig.pScratch && sqlite3GlobalConfig.szScratch>=100
      && sqlite3GlobalConfig.nScratch>=0 ){
    int i;
    sqlite3GlobalConfig.szScratch = (sqlite3GlobalConfig.szScratch - 4) & ~7;
    mem0.aScratchFree = (u32*)&((char*)sqlite3GlobalConfig.pScratch)
                  [sqlite3GlobalConfig.szScratch*sqlite3GlobalConfig.nScratch];
    for(i=0; i<sqlite3GlobalConfig.nScratch; i++){ mem0.aScratchFree[i] = i; }
    mem0.nScratchFree = sqlite3GlobalConfig.nScratch;
  }else{
    sqlite3GlobalConfig.pScratch = 0;
    sqlite3GlobalConfig.szScratch = 0;
  }
  if( sqlite3GlobalConfig.pPage && sqlite3GlobalConfig.szPage>=512
      && sqlite3GlobalConfig.nPage>=1 ){
    int i;
    int overhead;
    int sz = sqlite3GlobalConfig.szPage & ~7;
    int n = sqlite3GlobalConfig.nPage;
    overhead = (4*n + sz - 1)/sz;
    sqlite3GlobalConfig.nPage -= overhead;
    mem0.aPageFree = (u32*)&((char*)sqlite3GlobalConfig.pPage)
                  [sqlite3GlobalConfig.szPage*sqlite3GlobalConfig.nPage];
    for(i=0; i<sqlite3GlobalConfig.nPage; i++){ mem0.aPageFree[i] = i; }
    mem0.nPageFree = sqlite3GlobalConfig.nPage;
................................................................................
** Return the size of a memory allocation previously obtained from
** sqlite3Malloc() or sqlite3_malloc().
*/
SQLITE_PRIVATE int sqlite3MallocSize(void *p){
  return sqlite3GlobalConfig.m.xSize(p);
}
SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){

  if( p==0 ){
    return 0;
  }else if( isLookaside(db, p) ){
    return db->lookaside.sz;
  }else{
    return sqlite3GlobalConfig.m.xSize(p);
  }
................................................................................
}

/*
** Free memory that might be associated with a particular database
** connection.
*/
SQLITE_PRIVATE void sqlite3DbFree(sqlite3 *db, void *p){

  if( isLookaside(db, p) ){
    LookasideSlot *pBuf = (LookasideSlot*)p;
    pBuf->pNext = db->lookaside.pFree;
    db->lookaside.pFree = pBuf;
    db->lookaside.nOut--;
  }else{
    sqlite3_free(p);
................................................................................
**         if( b ) a[10] = 9;
**
** In other words, if a subsequent malloc (ex: "b") worked, it is assumed
** that all prior mallocs (ex: "a") worked too.
*/
SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3 *db, int n){
  void *p;

#ifndef SQLITE_OMIT_LOOKASIDE
  if( db ){
    LookasideSlot *pBuf;
    if( db->mallocFailed ){
      return 0;
    }
    if( db->lookaside.bEnabled && n<=db->lookaside.sz
................................................................................

/*
** Resize the block of memory pointed to by p to n bytes. If the
** resize fails, set the mallocFailed flag in the connection object.
*/
SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, int n){
  void *pNew = 0;


  if( db->mallocFailed==0 ){
    if( p==0 ){
      return sqlite3DbMallocRaw(db, n);
    }
    if( isLookaside(db, p) ){
      if( n<=db->lookaside.sz ){
        return p;
................................................................................
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains routines used to translate between UTF-8, 
** UTF-16, UTF-16BE, and UTF-16LE.
**
** $Id: utf.c,v 1.70 2008/12/10 22:30:25 shane Exp $
**
** Notes on UTF-8:
**
**   Byte-0    Byte-1    Byte-2    Byte-3    Value
**  0xxxxxxx                                 00000000 00000000 0xxxxxxx
**  110yyyyy  10xxxxxx                       00000000 00000yyy yyxxxxxx
**  1110zzzz  10yyyyyy  10xxxxxx             00000000 zzzzyyyy yyxxxxxx
................................................................................
  while( zIn[0] ){
    c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn);
    if( c!=0xfffd ){
      WRITE_UTF8(zOut, c);
    }
  }
  *zOut = 0;
  return zOut - zStart;
}
#endif

#ifndef SQLITE_OMIT_UTF16
/*
** Convert a UTF-16 string in the native encoding into a UTF-8 string.
** Memory to hold the UTF-8 string is obtained from sqlite3_malloc and must
................................................................................
**   *  Definitions of sqlite3_io_methods objects for all locking
**      methods plus "finder" functions for each locking method.
**   *  sqlite3_vfs method implementations.
**   *  Locking primitives for the proxy uber-locking-method. (MacOSX only)
**   *  Definitions of sqlite3_vfs objects for all locking methods
**      plus implementations of sqlite3_os_init() and sqlite3_os_end().
**
** $Id: os_unix.c,v 1.244 2009/03/21 14:56:52 drh Exp $
*/
#if SQLITE_OS_UNIX              /* This file is used on unix only */

/*
** There are various methods for file locking used for concurrency
** control:
**
................................................................................
      pLock->locktype = SHARED_LOCK;
    }else{
      int tErrno = errno;
      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);
      if( IS_LOCK_ERROR(rc) ){
        pFile->lastErrno = tErrno;
      }
			goto end_unlock;
    }
  }
  if( locktype==NO_LOCK ){
    struct unixOpenCnt *pOpen;


    /* Decrement the shared lock counter.  Release the lock using an
    ** OS call only when all threads in this same process have released
    ** the lock.
    */
    pLock->cnt--;
    if( pLock->cnt==0 ){
................................................................................
        pLock->locktype = NO_LOCK;
      }else{
        int tErrno = errno;
        rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);
        if( IS_LOCK_ERROR(rc) ){
          pFile->lastErrno = tErrno;
        }
        pLock->cnt = 1;
				goto end_unlock;
      }
    }

    /* Decrement the count of locks against this same file.  When the
    ** count reaches zero, close any other file descriptors whose close
    ** was deferred because of outstanding locks.
    */
    if( rc==SQLITE_OK ){
      pOpen = pFile->pOpen;
      pOpen->nLock--;
      assert( pOpen->nLock>=0 );
      if( pOpen->nLock==0 && pOpen->nPending>0 ){
        int i;
        for(i=0; i<pOpen->nPending; i++){
          /* close pending fds, but if closing fails don't free the array
          ** assign -1 to the successfully closed descriptors and record the
          ** error.  The next attempt to unlock will try again. */
          if( pOpen->aPending[i] < 0 ) continue;
          if( close(pOpen->aPending[i]) ){
            pFile->lastErrno = errno;
            rc = SQLITE_IOERR_CLOSE;
          }else{
            pOpen->aPending[i] = -1;
          }
        }
        if( rc==SQLITE_OK ){
          sqlite3_free(pOpen->aPending);
          pOpen->nPending = 0;
          pOpen->aPending = 0;
        }
      }


    }
  }
	
end_unlock:
  unixLeaveMutex();
  if( rc==SQLITE_OK ) pFile->locktype = locktype;
  return rc;
................................................................................
** that syncs and fullsyncs are occurring at the right times.
*/
SQLITE_API int sqlite3_sync_count = 0;
SQLITE_API int sqlite3_fullsync_count = 0;
#endif

/*
** We assume that most systems these days support fdatasync().  Those
** machines that do not can define -Dfdatasync=fsync.


*/
#if 0

# define fdatasync fsync
#endif

/*
** Define HAVE_FULLFSYNC to 0 or 1 depending on whether or not
** the F_FULLFSYNC macro is defined.  F_FULLFSYNC is currently
** only available on Mac OS X.  But that could change.
................................................................................
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file contains code that is specific to windows.
**
** $Id: os_win.c,v 1.150 2009/03/05 05:54:55 shane Exp $
*/
#if SQLITE_OS_WIN               /* This file is used for windows only */


/*
** A Note About Memory Allocation:
**
................................................................................
       NULL
    );
#endif
  }
  if( h==INVALID_HANDLE_VALUE ){
    free(zConverted);
    if( flags & SQLITE_OPEN_READWRITE ){
      return winOpen(0, zName, id, 
             ((flags|SQLITE_OPEN_READONLY)&~SQLITE_OPEN_READWRITE), pOutFlags);
    }else{
      return SQLITE_CANTOPEN;
    }
  }
  if( pOutFlags ){
    if( flags & SQLITE_OPEN_READWRITE ){
................................................................................
** return 0.  Return 1 if the time and date cannot be found.
*/
int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){
  FILETIME ft;
  /* FILETIME structure is a 64-bit value representing the number of 
     100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). 
  */
  sqlite3_int64 timeW, timeF;














#if SQLITE_OS_WINCE
  SYSTEMTIME time;
  GetSystemTime(&time);
  /* if SystemTimeToFileTime() fails, it returns zero. */
  if (!SystemTimeToFileTime(&time,&ft)){
    return 1;
  }
#else
  GetSystemTimeAsFileTime( &ft );
#endif
  UNUSED_PARAMETER(pVfs);
#if defined(_MSC_VER)
  timeW = (((sqlite3_int64)ft.dwHighDateTime)*4294967296) + ft.dwLowDateTime;
  timeF = timeW % 864000000000;           /* fractional days (100-nanoseconds) */
  timeW = timeW / 864000000000;           /* whole days */

  timeW = timeW + 2305813;                /* add whole days (from 2305813.5) */
  timeF = timeF + 432000000000;           /* add half a day (from 2305813.5) */
  timeW = timeW + (timeF / 864000000000); /* add whole day if half day made one */
  timeF = timeF % 864000000000;           /* compute new fractional days */
  *prNow = (double)timeW + ((double)timeF / (double)864000000000);
#else
  timeW = (((sqlite3_int64)ft.dwHighDateTime)*4294967296LL) + ft.dwLowDateTime;
  timeF = timeW % 864000000000LL;           /* fractional days (100-nanoseconds) */
  timeW = timeW / 864000000000LL;           /* whole days */
  timeW = timeW + 2305813;                  /* add whole days (from 2305813.5) */
  timeF = timeF + 432000000000LL;           /* add half a day (from 2305813.5) */
  timeW = timeW + (timeF / 864000000000LL); /* add whole day if half day made one */
  timeF = timeF % 864000000000LL;           /* compute new fractional days */
  *prNow = (double)timeW + ((double)timeF / (double)864000000000LL);
#endif
#ifdef SQLITE_TEST
  if( sqlite3_current_time ){
    *prNow = ((double)sqlite3_current_time + (double)43200) / (double)86400 + (double)2440587;
  }
#endif
  return 0;
}
................................................................................
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file implements that page cache.
**
** @(#) $Id: pcache.c,v 1.43 2009/01/23 16:45:01 danielk1977 Exp $
*/

/*
** A complete page cache is an instance of this structure.
*/
struct PCache {
  PgHdr *pDirty, *pDirtyTail;         /* List of dirty pages in LRU order */
................................................................................
}

/*
** Make sure the page is marked as dirty. If it isn't dirty already,
** make it so.
*/
SQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr *p){
  PCache *pCache;
  p->flags &= ~PGHDR_DONT_WRITE;
  assert( p->nRef>0 );
  if( 0==(p->flags & PGHDR_DIRTY) ){
    pCache = p->pCache;
    p->flags |= PGHDR_DIRTY;
    pcacheAddToDirtyList( p);
  }
}

/*
** Make sure the page is marked as clean. If it isn't clean already,
................................................................................
**
** This file implements the default page cache implementation (the
** sqlite3_pcache interface). It also contains part of the implementation
** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features.
** If the default page cache implementation is overriden, then neither of
** these two features are available.
**
** @(#) $Id: pcache1.c,v 1.9 2009/03/05 14:59:40 danielk1977 Exp $
*/


typedef struct PCache1 PCache1;
typedef struct PgHdr1 PgHdr1;
typedef struct PgFreeslot PgFreeslot;

................................................................................
** This function is called during initialization if a static buffer is 
** supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE
** verb to sqlite3_config(). Parameter pBuf points to an allocation large
** enough to contain 'n' buffers of 'sz' bytes each.
*/
SQLITE_PRIVATE void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){
  PgFreeslot *p;
  sz &= ~7;
  pcache1.szSlot = sz;
  pcache1.pStart = pBuf;
  pcache1.pFree = 0;
  while( n-- ){
    p = (PgFreeslot*)pBuf;
    p->pNext = pcache1.pFree;
    pcache1.pFree = p;
................................................................................
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.571 2009/03/05 04:20:32 shane Exp $
*/
#ifndef SQLITE_OMIT_DISKIO

/*
** Macros for troubleshooting.  Normally turned off
*/
#if 0
................................................................................
*/
#define PAGER_UNLOCK      0
#define PAGER_SHARED      1   /* same as SHARED_LOCK */
#define PAGER_RESERVED    2   /* same as RESERVED_LOCK */
#define PAGER_EXCLUSIVE   4   /* same as EXCLUSIVE_LOCK */
#define PAGER_SYNCED      5

/*
** This macro rounds values up so that if the value is an address it
** is guaranteed to be an address that is aligned to an 8-byte boundary.
*/
#define FORCE_ALIGNMENT(X)   (((X)+7)&~7)

/*
** A macro used for invoking the codec if there is one
*/
#ifdef SQLITE_HAS_CODEC
# define CODEC1(P,D,N,X) if( P->xCodec!=0 ){ P->xCodec(P->pCodecArg,D,N,X); }
# define CODEC2(P,D,N,X) ((char*)(P->xCodec!=0?P->xCodec(P->pCodecArg,D,N,X):D))
#else
................................................................................
  ** the page is marked as needSync==0.
  **
  ** 2008-04-14:  When attempting to vacuum a corrupt database file, it
  ** is possible to fail a statement on a database that does not yet exist.
  ** Do not attempt to write if database file has never been opened.
  */
  pPg = pager_lookup(pPager, pgno);

  PAGERTRACE(("PLAYBACK %d page %d hash(%08x) %s\n",
               PAGERID(pPager), pgno, pager_datahash(pPager->pageSize, aData),
               (isMainJrnl?"main-journal":"sub-journal")
  ));
  if( (pPager->state>=PAGER_EXCLUSIVE)
   && (pPg==0 || 0==(pPg->flags&PGHDR_NEED_SYNC))
   && isOpen(pPager->fd)
................................................................................
    assert( !pPager->pTmpSpace );
    sqlite3OsClose(pPager->fd);
    sqlite3_free(pPager);
    return rc;
  }

  /* Initialize the PCache object. */
  nExtra = FORCE_ALIGNMENT(nExtra);
  sqlite3PcacheOpen(szPageDflt, nExtra, !memDb,
                    !memDb?pagerStress:0, (void *)pPager, pPager->pPCache);

  PAGERTRACE(("OPEN %d %s\n", FILEHANDLEID(pPager->fd), pPager->zFilename));
  IOTRACE(("OPEN %p %s\n", pPager, pPager->zFilename))

  pPager->useJournal = (u8)useJournal;
................................................................................


/*
** This function is called after transitioning from PAGER_UNLOCK to
** PAGER_SHARED state. It tests if there is a hot journal present in
** the file-system for the given pager. A hot journal is one that 
** needs to be played back. According to this function, a hot-journal
** file exists if the following three criteria are met:
**
**   * The journal file exists in the file system, and
**   * No process holds a RESERVED or greater lock on the database file, and
**   * The database file itself is greater than 0 bytes in size.

**
** If the current size of the database file is 0 but a journal file
** exists, that is probably an old journal left over from a prior
** database with the same name. In this case the journal file is
** just deleted using OsDelete, *pExists is set to 0 and SQLITE_OK
** is returned.
**
** This routine does not open the journal file to examine its
** content.  Hence, the journal might contain the name of a master
** journal file that has been deleted, and hence not be hot.  Or
** the header of the journal might be zeroed out.  This routine
** does not discover these cases of a non-hot journal - if the
** journal file exists and is not empty this routine assumes it
** is hot.  The pager_playback() routine will discover that the
** journal file is not really hot and will no-op.

**
** If a hot-journal file is found to exist, *pExists is set to 1 and 
** SQLITE_OK returned. If no hot-journal file is present, *pExists is
** set to 0 and SQLITE_OK returned. If an IO error occurs while trying
** to determine whether or not a hot-journal file exists, the IO error
** code is returned and the value of *pExists is undefined.
*/
static int hasHotJournal(Pager *pPager, int *pExists){
  sqlite3_vfs * const pVfs = pPager->pVfs;
  int rc;                       /* Return code */
  int exists = 0;               /* True if a journal file is present */
  int locked = 0;               /* True if some process holds a RESERVED lock */

  assert( pPager!=0 );
  assert( pPager->useJournal );
  assert( isOpen(pPager->fd) );


  *pExists = 0;
  rc = sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &exists);
  if( rc==SQLITE_OK && exists ){

    rc = sqlite3OsCheckReservedLock(pPager->fd, &locked);
    if( rc==SQLITE_OK && !locked ){
      int nPage;





      rc = sqlite3PagerPagecount(pPager, &nPage);
      if( rc==SQLITE_OK ){
       if( nPage==0 ){
          sqlite3OsDelete(pVfs, pPager->zJournal, 0);
        }else{















          *pExists = 1;

        }
      }
    }
  }

  return rc;
}

/*
** Read the content for page pPg out of the database file and into 
** pPg->pData. A shared lock or greater must be held on the database
** file before this function is called.
................................................................................
  i64 iOffset;                 /* Byte offset of file to read from */

  assert( pPager->state>=PAGER_SHARED && !MEMDB );

  if( !isOpen(pPager->fd) ){
    assert( pPager->tempFile );
    memset(pPg->pData, 0, pPager->pageSize);
    return SQLITE_IOERR_SHORT_READ;
  }
  iOffset = (pgno-1)*(i64)pPager->pageSize;
  rc = sqlite3OsRead(pPager->fd, pPg->pData, pPager->pageSize, iOffset);



  if( pgno==1 ){
    u8 *dbFileVers = &((u8*)pPg->pData)[24];
    memcpy(&pPager->dbFileVers, dbFileVers, sizeof(pPager->dbFileVers));
  }
  CODEC1(pPager, pPg->pData, pgno, 3);

  PAGER_INCR(sqlite3_pager_readdb_count);
................................................................................
      }else{
        memset(pPg->pData, 0, pPager->pageSize);
      }
      IOTRACE(("ZERO %p %d\n", pPager, pgno));
    }else{
      assert( pPg->pPager==pPager );
      rc = readDbPage(pPg);
      if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){
        pagerDropPage(pPg);
        return rc;
      }
    }
#ifdef SQLITE_CHECK_PAGES
    pPg->pageHash = pager_pagehash(pPg);
#endif
................................................................................

  /* Open the journal file if it is not already open. */
  if( !isOpen(pPager->jfd) ){
    if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ){
      sqlite3MemJournalOpen(pPager->jfd);
    }else{
      const int flags =                   /* VFS flags to open journal file */
        SQLITE_OPEN_READWRITE|SQLITE_OPEN_EXCLUSIVE|SQLITE_OPEN_CREATE|
        (pPager->tempFile ? 
          (SQLITE_OPEN_DELETEONCLOSE|SQLITE_OPEN_TEMP_JOURNAL):
          (SQLITE_OPEN_MAIN_JOURNAL)
        );
#ifdef SQLITE_ENABLE_ATOMIC_WRITE
      rc = sqlite3JournalOpen(
          pVfs, pPager->zJournal, pPager->jfd, flags, jrnlBufferSize(pPager)
................................................................................
** This function may return SQLITE_NOMEM or an IO error code if an error
** occurs. Otherwise, it returns SQLITE_OK.
*/
SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){
  PgHdr *pPgOld;               /* The page being overwritten. */
  Pgno needSyncPgno = 0;       /* Old value of pPg->pgno, if sync is required */
  int rc;                      /* Return code */


  assert( pPg->nRef>0 );

  /* If the page being moved is dirty and has not been saved by the latest
  ** savepoint, then save the current contents of the page into the 
  ** sub-journal now. This is required to handle the following scenario:
  **
................................................................................
  pPg->flags &= ~PGHDR_NEED_SYNC;
  pPgOld = pager_lookup(pPager, pgno);
  assert( !pPgOld || pPgOld->nRef==1 );
  if( pPgOld ){
    pPg->flags |= (pPgOld->flags&PGHDR_NEED_SYNC);
  }


  sqlite3PcacheMove(pPg, pgno);
  if( pPgOld ){
    sqlite3PcacheDrop(pPgOld);
  }

  sqlite3PcacheMakeDirty(pPg);
  pPager->dbModified = 1;
................................................................................
    }
    pPager->needSync = 1;
    assert( pPager->noSync==0 && !MEMDB );
    pPgHdr->flags |= PGHDR_NEED_SYNC;
    sqlite3PcacheMakeDirty(pPgHdr);
    sqlite3PagerUnref(pPgHdr);
  }














  return SQLITE_OK;
}
#endif

/*
** Return a pointer to the data for the specified page.
................................................................................
** 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.
**
*************************************************************************
** $Id: btree.c,v 1.576 2009/03/20 13:15:30 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
** Including a description of file format and an overview of operation.
*/

/*
................................................................................
**
** Return the index into pPage->aData[] of the first byte of
** the new allocation.  The caller guarantees that there is enough
** space.  This routine will never fail.
**
** If the page contains nBytes of free space but does not contain
** nBytes of contiguous free space, then this routine automatically
** calls defragementPage() to consolidate all free space before 
** allocating the new chunk.
*/
static int allocateSpace(MemPage *pPage, int nByte){
  int addr, pc, hdr;
  int size;
  int nFrag;
  int top;
................................................................................
static void pageReinit(DbPage *pData){
  MemPage *pPage;
  pPage = (MemPage *)sqlite3PagerGetExtra(pData);
  if( pPage->isInit ){
    assert( sqlite3_mutex_held(pPage->pBt->mutex) );
    pPage->isInit = 0;
    if( sqlite3PagerPageRefcount(pData)>0 ){






      sqlite3BtreeInitPage(pPage);
    }
  }
}

/*
** Invoke the busy handler for a btree.
................................................................................
    if( p->inTrans>pBt->inTransaction ){
      pBt->inTransaction = p->inTrans;
    }
#ifndef SQLITE_OMIT_SHARED_CACHE
    if( wrflag ){
      assert( !pBt->pWriter );
      pBt->pWriter = p;
      pBt->isExclusive = (wrflag>1);
    }
#endif
  }


trans_begun:
  if( rc==SQLITE_OK && wrflag ){
................................................................................
      }
    }
  }

  if( nFin==0 ){
    iLastPg--;
    while( iLastPg==PENDING_BYTE_PAGE(pBt)||PTRMAP_ISPAGE(pBt, iLastPg) ){












      iLastPg--;
    }
    sqlite3PagerTruncateImage(pBt->pPager, iLastPg);
  }
  return SQLITE_OK;
}

................................................................................

#ifndef SQLITE_OMIT_AUTOVACUUM
    if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt, *pPgno) ){
      /* If *pPgno refers to a pointer-map page, allocate two new pages
      ** at the end of the file instead of one. The first allocated page
      ** becomes a new pointer-map page, the second is used by the caller.
      */

      TRACE(("ALLOCATE: %d from end of file (pointer-map page)\n", *pPgno));
      assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );






      (*pPgno)++;
      if( *pPgno==PENDING_BYTE_PAGE(pBt) ){ (*pPgno)++; }
    }
#endif

    assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
    rc = sqlite3BtreeGetPage(pBt, *pPgno, ppPage, 0);
................................................................................
    sqlite3_snprintf(sizeof(zContext), zContext,
             "On tree page %d cell %d: ", iPage, i);
    pCell = findCell(pPage,i);
    sqlite3BtreeParseCellPtr(pPage, pCell, &info);
    sz = info.nData;
    if( !pPage->intKey ) sz += (int)info.nKey;
    assert( sz==info.nPayload );
    if( sz>info.nLocal ){


      int nPage = (sz - info.nLocal + usableSize - 5)/(usableSize - 4);
      Pgno pgnoOvfl = get4byte(&pCell[info.iOverflow]);
#ifndef SQLITE_OMIT_AUTOVACUUM
      if( pBt->autoVacuum ){
        checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage, zContext);
      }
#endif
................................................................................
*************************************************************************
**
** This file contains code use to manipulate "Mem" structure.  A "Mem"
** stores a single value in the VDBE.  Mem is an opaque structure visible
** only within the VDBE.  Interface routines refer to a Mem using the
** name sqlite_value
**
** $Id: vdbemem.c,v 1.137 2009/02/04 03:59:25 shane Exp $
*/

/*
** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem*)
** P if required.
*/
#define expandBlob(P) (((P)->flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0)
................................................................................
  */
  static const i64 maxInt = LARGEST_INT64;
  static const i64 minInt = SMALLEST_INT64;

  if( r<(double)minInt ){
    return minInt;
  }else if( r>(double)maxInt ){




    return minInt;
  }else{
    return (i64)r;
  }
}

/*
** Return some kind of integer value which is the best we can do
** at representing the value that *pMem describes as an integer.
** If pMem is an integer, then the value is exact.  If pMem is
** a floating-point then the value returned is the integer part.
** If pMem is a string or blob, then we make an attempt to convert
** it into a integer and return that.  If pMem is NULL, return 0.

**
** If pMem is a string, its encoding might be changed.
*/
SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
  int flags;
  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
  flags = pMem->flags;
  if( flags & MEM_Int ){
    return pMem->u.i;
................................................................................
**
*************************************************************************
** This file contains code used for creating, destroying, and populating
** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.)  Prior
** to version 2.8.7, all this code was combined into the vdbe.c source file.
** But that file was getting too big so this subroutines were split out.
**
** $Id: vdbeaux.c,v 1.444 2009/03/20 14:42:11 danielk1977 Exp $
*/



/*
** When debugging the code generator in a symbolic debugger, one can
** set the sqlite3VdbeAddopTrace to 1 and all opcodes will be printed
................................................................................
      pMem->flags = MEM_Int;
      pMem->u.i = pOp->p3;                          /* P3 */
      pMem->type = SQLITE_INTEGER;
      pMem++;
    }

    if( sqlite3VdbeMemGrow(pMem, 32, 0) ){            /* P4 */
      p->db->mallocFailed = 1;
      return SQLITE_NOMEM;
    }
    pMem->flags = MEM_Dyn|MEM_Str|MEM_Term;
    z = displayP4(pOp, pMem->z, 32);
    if( z!=pMem->z ){
      sqlite3VdbeMemSetStr(pMem, z, -1, SQLITE_UTF8, 0);
    }else{
      assert( pMem->z!=0 );
................................................................................
      pMem->enc = SQLITE_UTF8;
    }
    pMem->type = SQLITE_TEXT;
    pMem++;

    if( p->explain==1 ){
      if( sqlite3VdbeMemGrow(pMem, 4, 0) ){
        p->db->mallocFailed = 1;
        return SQLITE_NOMEM;
      }
      pMem->flags = MEM_Dyn|MEM_Str|MEM_Term;
      pMem->n = 2;
      sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5);   /* P5 */
      pMem->type = SQLITE_TEXT;
      pMem->enc = SQLITE_UTF8;
      pMem++;
................................................................................
  char *pp,            /* IN/OUT: Set *pp to point to allocated buffer */
  int nByte,           /* Number of bytes to allocate */
  u8 **ppFrom,         /* IN/OUT: Allocate from *ppFrom */
  u8 *pEnd,            /* Pointer to 1 byte past the end of *ppFrom buffer */
  int *pnByte          /* If allocation cannot be made, increment *pnByte */
){
  if( (*(void**)pp)==0 ){
    nByte = (nByte+7)&~7;
    if( (pEnd - *ppFrom)>=nByte ){
      *(void**)pp = (void *)*ppFrom;
      *ppFrom += nByte;
    }else{
      *pnByte += nByte;
    }
  }
................................................................................
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains code use to implement APIs that are part of the
** VDBE.
**
** $Id: vdbeapi.c,v 1.155 2009/03/19 18:51:07 danielk1977 Exp $
*/

#if 0 && defined(SQLITE_ENABLE_MEMORY_MANAGEMENT)
/*
** The following structure contains pointers to the end points of a
** doubly-linked list of all compiled SQL statements that may be holding
** buffers eligible for release when the sqlite3_release_memory() interface is
................................................................................
    elapseTime = (u64)((rNow - (int)rNow)*3600.0*24.0*1000000000.0);
    elapseTime -= p->startTime;
    db->xProfile(db->pProfileArg, p->zSql, elapseTime);
  }
#endif

  db->errCode = rc;
  /*sqlite3Error(p->db, rc, 0);*/
  p->rc = sqlite3ApiExit(p->db, p->rc);
end_of_step:
  assert( (rc&0xff)==rc );
  if( p->isPrepareV2 && (rc&0xff)<SQLITE_ROW ){
    /* This behavior occurs if sqlite3_prepare_v2() was used to build
    ** the prepared statement.  Return error codes directly */
    p->db->errCode = p->rc;
    /* sqlite3Error(p->db, p->rc, 0); */
    return p->rc;
  }else{
    /* This is for legacy sqlite3_prepare() builds and when the code
    ** is SQLITE_ROW or SQLITE_DONE */
    return rc;
  }








}

/*
** This is the top-level implementation of sqlite3_step().  Call
** sqlite3Step() to do most of the work.  If a schema error occurs,
** call sqlite3Reprepare() and try again.
*/
................................................................................
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** in this file for details.  If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.827 2009/03/18 10:33:02 danielk1977 Exp $
*/

/*
** The following global variable is incremented every time a cursor
** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes.  The test
** procedures use this information to make sure that indices are
** working correctly.  This variable has no function other than to
................................................................................
** is false, the SQLITE_MASTER table is only parsed if the rest of the
** schema is already loaded into the symbol table.
**
** This opcode invokes the parser to create a new virtual machine,
** then runs the new virtual machine.  It is thus a re-entrant opcode.
*/
case OP_ParseSchema: {
  char *zSql;
  int iDb = pOp->p1;
  const char *zMaster;
  InitData initData;

  assert( iDb>=0 && iDb<db->nDb );
  if( !pOp->p2 && !DbHasProperty(db, iDb, DB_SchemaLoaded) ){
    break;
  }
























  zMaster = SCHEMA_TABLE(iDb);


  initData.db = db;
  initData.iDb = pOp->p1;
  initData.pzErrMsg = &p->zErrMsg;
  zSql = sqlite3MPrintf(db,
     "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s",
     db->aDb[iDb].zName, zMaster, pOp->p4.z);
  if( zSql==0 ) goto no_mem;


  (void)sqlite3SafetyOff(db);
  assert( db->init.busy==0 );
  db->init.busy = 1;
  initData.rc = SQLITE_OK;
  assert( !db->mallocFailed );
  rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);
  if( rc==SQLITE_OK ) rc = initData.rc;
  sqlite3DbFree(db, zSql);
  db->init.busy = 0;
  (void)sqlite3SafetyOn(db);



  if( rc==SQLITE_NOMEM ){
    goto no_mem;
  }
  break;  
}

#if !defined(SQLITE_OMIT_ANALYZE) && !defined(SQLITE_OMIT_PARSER)
................................................................................
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains code used to implement incremental BLOB I/O.
**
** $Id: vdbeblob.c,v 1.30 2009/03/19 18:51:07 danielk1977 Exp $
*/


#ifndef SQLITE_OMIT_INCRBLOB

/*
** Valid sqlite3_blob* handles point to Incrblob structures.
................................................................................
/*
** Close a blob handle that was previously created using
** sqlite3_blob_open().
*/
SQLITE_API int sqlite3_blob_close(sqlite3_blob *pBlob){
  Incrblob *p = (Incrblob *)pBlob;
  int rc;




  rc = sqlite3_finalize(p->pStmt);
  sqlite3DbFree(p->db, p);

  return rc;
}

/*
** Perform a read or write operation on a blob
*/
static int blobReadWrite(
................................................................................
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.420 2009/03/18 10:36:13 drh Exp $
*/

/*
** Return the 'affinity' of the expression pExpr if any.
**
** If pExpr is a column, a reference to a column via an 'AS' alias,
** or a sub-select with a column as the return value, then the 
................................................................................
  }
  pNew->op = (u8)op;
  pNew->pLeft = pLeft;
  pNew->pRight = pRight;
  pNew->iAgg = -1;
  pNew->span.z = (u8*)"";
  if( pToken ){

    assert( pToken->dyn==0 );












    pNew->span = pNew->token = *pToken;



  }else if( pLeft ){
    if( pRight ){
      if( pRight->span.dyn==0 && pLeft->span.dyn==0 ){
        sqlite3ExprSpan(pNew, &pLeft->span, &pRight->span);
      }
      if( pRight->flags & EP_ExpCollate ){
        pNew->flags |= EP_ExpCollate;
................................................................................
*/
SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse *pParse, ExprList *pList, Token *pToken){
  Expr *pNew;
  sqlite3 *db = pParse->db;
  assert( pToken );
  pNew = sqlite3DbMallocZero(db, sizeof(Expr) );
  if( pNew==0 ){
    sqlite3ExprListDelete(db, pList); /* Avoid leaking memory when malloc fails */
    return 0;
  }
  pNew->op = TK_FUNCTION;
  pNew->x.pList = pList;
  assert( !ExprHasProperty(pNew, EP_xIsSelect) );
  assert( pToken->dyn==0 );
  pNew->token = *pToken;
  pNew->span = pNew->token;

  sqlite3ExprSetHeight(pParse, pNew);
  return pNew;
}

/*
** Assign a variable number to an expression that encodes a wildcard
** in the original SQL statement.  
................................................................................
  sqlite3DbFree(db, p);
}

/*
** The Expr.token field might be a string literal that is quoted.
** If so, remove the quotation marks.
*/
SQLITE_PRIVATE void sqlite3DequoteExpr(sqlite3 *db, Expr *p){
  if( ExprHasAnyProperty(p, EP_Dequoted) ){
    return;
  }
  ExprSetProperty(p, EP_Dequoted);

  /* If p->token.dyn==0 and none of EP_Reduced, EP_TokenOnly, or
  ** EP_SpanOnly are set, that means that the p->token.z string points
  ** back to the original SQL statement text.  In that case, we need
  ** to make a copy before modifying the string, otherwise we would
  ** corrupt the original SQL statement text.
  */
  testcase( p->token.dyn==0 && ExprHasProperty(p, EP_Reduced) );
  testcase( p->token.dyn==0 && ExprHasProperty(p, EP_TokenOnly) );
  testcase( p->token.dyn==0 && ExprHasProperty(p, EP_SpanOnly) );
  if( p->token.dyn==0
   && !ExprHasAnyProperty(p, EP_Reduced|EP_TokenOnly|EP_SpanOnly) 
  ){
    sqlite3TokenCopy(db, &p->token, &p->token);
  }


  sqlite3Dequote((char*)p->token.z);

}

/*
** Return the number of bytes allocated for the expression structure 
** passed as the first argument. This is always one of EXPR_FULLSIZE,
** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE.
*/
................................................................................
static int dupedExprNodeSize(Expr *p, int flags){
  int nByte = dupedExprStructSize(p, flags) + (p->token.z ? p->token.n + 1 : 0);
  if( (flags&EXPRDUP_DISTINCTSPAN)
   || (flags&EXPRDUP_SPAN && (p->token.z!=p->span.z || p->token.n!=p->span.n)) 
  ){
    nByte += p->span.n;
  }
  return (nByte+7)&~7;
}

/*
** Return the number of bytes required to create a duplicate of the 
** expression passed as the first argument. The second argument is a
** mask containing EXPRDUP_XXX flags.
**
................................................................................
** If the EXPRDUP_REDUCE flag is set, then the structure returned is a
** truncated version of the usual Expr structure that will be stored as
** part of the in-memory representation of the database schema.
*/
SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3 *db, Expr *p, int flags){
  return exprDup(db, p, flags, 0);
}
SQLITE_PRIVATE void sqlite3TokenCopy(sqlite3 *db, Token *pTo, Token *pFrom){
  if( pTo->dyn ) sqlite3DbFree(db, (char*)pTo->z);
  if( pFrom->z ){
    pTo->n = pFrom->n;
    pTo->z = (u8*)sqlite3DbStrNDup(db, (char*)pFrom->z, pFrom->n);
    pTo->dyn = 1;
  }else{
    pTo->z = 0;
................................................................................
      break;
    }
    case TK_FLOAT: {
      codeReal(v, (char*)pExpr->token.z, pExpr->token.n, 0, target);
      break;
    }
    case TK_STRING: {
      sqlite3DequoteExpr(db, pExpr);
      sqlite3VdbeAddOp4(v,OP_String8, 0, target, 0,
                        (char*)pExpr->token.z, pExpr->token.n);
      break;
    }
    case TK_NULL: {
      sqlite3VdbeAddOp2(v, OP_Null, 0, target);
      break;
................................................................................
                       "RAISE() may only be used within a trigger-program");
        return 0;
      }
      if( pExpr->affinity!=OE_Ignore ){
         assert( pExpr->affinity==OE_Rollback ||
                 pExpr->affinity == OE_Abort ||
                 pExpr->affinity == OE_Fail );
         sqlite3DequoteExpr(db, pExpr);
         sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CONSTRAINT, pExpr->affinity, 0,
                        (char*)pExpr->token.z, pExpr->token.n);
      } else {
         assert( pExpr->affinity == OE_Ignore );
         sqlite3VdbeAddOp2(v, OP_ContextPop, 0, 0);
         sqlite3VdbeAddOp2(v, OP_Goto, 0, pParse->trigStack->ignoreJump);
         VdbeComment((v, "raise(IGNORE)"));
................................................................................
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that used to generate VDBE code
** that implements the ALTER TABLE command.
**
** $Id: alter.c,v 1.54 2009/02/28 10:47:42 danielk1977 Exp $
*/

/*
** The code in this file only exists if we are not omitting the
** ALTER TABLE logic from the build.
*/
#ifndef SQLITE_OMIT_ALTERTABLE
................................................................................
  ** table because user table are not allowed to have the "sqlite_"
  ** prefix on their name.
  */
  pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));
  if( !pNew ) goto exit_begin_add_column;
  pParse->pNewTable = pNew;
  pNew->nRef = 1;
  pNew->db = db;
  pNew->nCol = pTab->nCol;
  assert( pNew->nCol>0 );
  nAlloc = (((pNew->nCol-1)/8)*8)+8;
  assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );
  pNew->aCol = (Column*)sqlite3DbMallocZero(db, sizeof(Column)*nAlloc);
  pNew->zName = sqlite3MPrintf(db, "sqlite_altertab_%s", pTab->zName);
  if( !pNew->aCol || !pNew->zName ){
................................................................................
**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**
** $Id: build.c,v 1.525 2009/03/21 16:19:26 drh Exp $
*/

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Initialize the pParse structure as needed.
*/
SQLITE_PRIVATE void sqlite3BeginParse(Parse *pParse, int explainFlag){
................................................................................
  return p;
}

/*
** Reclaim the memory used by an index
*/
static void freeIndex(Index *p){
  sqlite3 *db = p->pTable->db;
  sqlite3DbFree(db, p->zColAff);
  sqlite3DbFree(db, p);
}

/*
** Remove the given index from the index hash table, and free
** its memory structures.
................................................................................

/*
** Clear the column names from a table or view.
*/
static void sqliteResetColumnNames(Table *pTable){
  int i;
  Column *pCol;
  sqlite3 *db = pTable->db;
  assert( pTable!=0 );
  if( (pCol = pTable->aCol)!=0 ){
    for(i=0; i<pTable->nCol; i++, pCol++){
      sqlite3DbFree(db, pCol->zName);
      sqlite3ExprDelete(db, pCol->pDflt);
      sqlite3DbFree(db, pCol->zType);
      sqlite3DbFree(db, pCol->zColl);
................................................................................
*/
SQLITE_PRIVATE void sqlite3DeleteTable(Table *pTable){
  Index *pIndex, *pNext;
  FKey *pFKey, *pNextFKey;
  sqlite3 *db;

  if( pTable==0 ) return;
  db = pTable->db;

  /* Do not delete the table until the reference count reaches zero. */
  pTable->nRef--;
  if( pTable->nRef>0 ){
    return;
  }
  assert( pTable->nRef==0 );
................................................................................
    pParse->nErr++;
    goto begin_table_error;
  }
  pTable->zName = zName;
  pTable->iPKey = -1;
  pTable->pSchema = db->aDb[iDb].pSchema;
  pTable->nRef = 1;
  pTable->db = db;
  if( pParse->pNewTable ) sqlite3DeleteTable(pParse->pNewTable);
  pParse->pNewTable = pTable;

  /* If this is the magic sqlite_sequence table used by autoincrement,
  ** then record a pointer to this table in the main database structure
  ** so that INSERT can find the table easily.
  */
................................................................................
  ** to the elements of the FROM clause.  But we do not want these changes
  ** to be permanent.  So the computation is done on a copy of the SELECT
  ** statement that defines the view.
  */
  assert( pTable->pSelect );
  pSel = sqlite3SelectDup(db, pTable->pSelect, 0);
  if( pSel ){

    n = pParse->nTab;
    sqlite3SrcListAssignCursors(pParse, pSel->pSrc);
    pTable->nCol = -1;

#ifndef SQLITE_OMIT_AUTHORIZATION
    xAuth = db->xAuth;
    db->xAuth = 0;
    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
    db->xAuth = xAuth;
#else
    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
#endif

    pParse->nTab = n;
    if( pSelTab ){
      assert( pTable->aCol==0 );
      pTable->nCol = pSelTab->nCol;
      pTable->aCol = pSelTab->aCol;
      pSelTab->nCol = 0;
      pSelTab->aCol = 0;
................................................................................
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains functions used to access the internal hash tables
** of user defined functions and collation sequences.
**
** $Id: callback.c,v 1.36 2009/03/05 04:20:32 shane Exp $
*/


/*
** Invoke the 'collation needed' callback to request a collation sequence
** in the database text encoding of name zName, length nName.
** If the collation sequence
................................................................................
  for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){
    sqlite3DeleteTrigger(0, (Trigger*)sqliteHashData(pElem));
  }
  sqlite3HashClear(&temp2);
  sqlite3HashInit(&pSchema->tblHash, 0);
  for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){
    Table *pTab = sqliteHashData(pElem);

    sqlite3DeleteTable(pTab);
  }
  sqlite3HashClear(&temp1);
  pSchema->pSeqTab = 0;
  pSchema->flags &= ~DB_SchemaLoaded;
}

................................................................................
** This file contains the C functions that implement various SQL
** functions of SQLite.  
**
** There is only one exported symbol in this file - the function
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: func.c,v 1.224 2009/02/24 10:01:52 danielk1977 Exp $
*/

/*
** Return the collating function associated with a function.
*/
static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){
  return context->pColl;
................................................................................
SQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive){
  struct compareInfo *pInfo;
  if( caseSensitive ){
    pInfo = (struct compareInfo*)&likeInfoAlt;
  }else{
    pInfo = (struct compareInfo*)&likeInfoNorm;
  }
  sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0);
  sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0);
  sqlite3CreateFunc(db, "glob", 2, SQLITE_UTF8, 
      (struct compareInfo*)&globInfo, likeFunc, 0,0);
  setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE);
  setLikeOptFlag(db, "like", 
      caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE);
}

/*
................................................................................
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the implementation of the sqlite3_prepare()
** interface, and routines that contribute to loading the database schema
** from disk.
**
** $Id: prepare.c,v 1.111 2009/03/19 18:51:07 danielk1977 Exp $
*/

/*
** Fill the InitData structure with an error message that indicates
** that the database is corrupt.
*/
static void corruptSchema(
................................................................................
    /* Call the parser to process a CREATE TABLE, INDEX or VIEW.
    ** But because db->init.busy is set to 1, no VDBE code is generated
    ** or executed.  All the parser does is build the internal data
    ** structures that describe the table, index, or view.
    */
    char *zErr;
    int rc;
    u8 lookasideEnabled;
    assert( db->init.busy );
    db->init.iDb = iDb;
    db->init.newTnum = atoi(argv[1]);
    lookasideEnabled = db->lookaside.bEnabled;
    db->lookaside.bEnabled = 0;
    rc = sqlite3_exec(db, argv[2], 0, 0, &zErr);
    db->init.iDb = 0;
    db->lookaside.bEnabled = lookasideEnabled;
    assert( rc!=SQLITE_OK || zErr==0 );
    if( SQLITE_OK!=rc ){
      pData->rc = rc;
      if( rc==SQLITE_NOMEM ){
        db->mallocFailed = 1;
      }else if( rc!=SQLITE_INTERRUPT ){
        corruptSchema(pData, argv[0], zErr);
      }
      sqlite3DbFree(db, zErr);
    }
  }else if( argv[0]==0 ){
    corruptSchema(pData, 0, 0);
  }else{
................................................................................
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.504 2009/02/25 08:56:47 danielk1977 Exp $
*/


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
*/
................................................................................
** Add type and collation information to a column list based on
** a SELECT statement.
** 
** The column list presumably came from selectColumnNamesFromExprList().
** The column list has only names, not types or collations.  This
** routine goes through and adds the types and collations.
**
** This routine requires that all indentifiers in the SELECT
** statement be resolved.
*/
static void selectAddColumnTypeAndCollation(
  Parse *pParse,        /* Parsing contexts */
  int nCol,             /* Number of columns */
  Column *aCol,         /* List of columns */
  Select *pSelect       /* SELECT used to determine types and collations */
................................................................................
  if( pParse->nErr ) return 0;
  while( pSelect->pPrior ) pSelect = pSelect->pPrior;
  db->flags = savedFlags;
  pTab = sqlite3DbMallocZero(db, sizeof(Table) );
  if( pTab==0 ){
    return 0;
  }
  pTab->db = db;
  pTab->nRef = 1;
  pTab->zName = 0;
  selectColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol);
  selectAddColumnTypeAndCollation(pParse, pTab->nCol, pTab->aCol, pSelect);
  pTab->iPKey = -1;
  if( db->mallocFailed ){
    sqlite3DeleteTable(pTab);
................................................................................
      Select *pSel = pFrom->pSelect;
      /* A sub-query in the FROM clause of a SELECT */
      assert( pSel!=0 );
      assert( pFrom->pTab==0 );
      sqlite3WalkSelect(pWalker, pSel);
      pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
      if( pTab==0 ) return WRC_Abort;
      pTab->db = db;
      pTab->nRef = 1;
      pTab->zName = sqlite3MPrintf(db, "sqlite_subquery_%p_", (void*)pTab);
      while( pSel->pPrior ){ pSel = pSel->pPrior; }
      selectColumnsFromExprList(pParse, pSel->pEList, &pTab->nCol, &pTab->aCol);
      pTab->iPKey = -1;
      pTab->tabFlags |= TF_Ephemeral;
#endif
................................................................................
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code used to help implement virtual tables.
**
** $Id: vtab.c,v 1.83 2009/03/19 18:51:07 danielk1977 Exp $
*/
#ifndef SQLITE_OMIT_VIRTUALTABLE

static int createModule(
  sqlite3 *db,                    /* Database in which module is registered */
  const char *zName,              /* Name assigned to this module */
  const sqlite3_module *pModule,  /* The definition of the module */
................................................................................
/*
** Clear any and all virtual-table information from the Table record.
** This routine is called, for example, just before deleting the Table
** record.
*/
SQLITE_PRIVATE void sqlite3VtabClear(Table *p){
  sqlite3_vtab *pVtab = p->pVtab;

  sqlite3 *db = p->db;
  if( pVtab ){
    assert( p->pMod && p->pMod->pModule );
    sqlite3VtabUnlock(db, pVtab);
    p->pVtab = 0;
  }
  if( p->azModuleArg ){
    int i;
................................................................................
** This module contains C code that generates VDBE code used to process
** the WHERE clause of SQL statements.  This module is responsible for
** generating the code that loops through a table looking for applicable
** rows.  Indices are selected and used to speed the search when doing
** so is applicable.  Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
** $Id: where.c,v 1.376 2009/03/22 20:36:19 drh Exp $
*/

/*
** Trace output macros
*/
#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
SQLITE_PRIVATE int sqlite3WhereTrace = 0;
................................................................................
    /* No collation is defined for the ROWID.  Use the default. */
    pColl = db->pDfltColl;
  }
  if( (pColl->type!=SQLITE_COLL_BINARY || *pnoCase) &&
      (pColl->type!=SQLITE_COLL_NOCASE || !*pnoCase) ){
    return 0;
  }
  sqlite3DequoteExpr(db, pRight);
  z = (char *)pRight->token.z;
  cnt = 0;
  if( z ){
    while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){ cnt++; }
  }
  if( cnt==0 || 255==(u8)z[cnt-1] ){
    return 0;
................................................................................

  /* Look at each index.
  */
  if( pSrc->pIndex ){
    pProbe = pSrc->pIndex;
  }
  for(; pProbe; pProbe=(pSrc->pIndex ? 0 : pProbe->pNext)){
    double inMultiplier = 1;


    WHERETRACE(("... index %s:\n", pProbe->zName));

    /* Count the number of columns in the index that are satisfied
    ** by x=EXPR constraints or x IN (...) constraints.





    */
    wsFlags = 0;
    for(i=0; i<pProbe->nColumn; i++){
      int j = pProbe->aiColumn[i];
      pTerm = findTerm(pWC, iCur, j, notReady, eqTermMask, pProbe);
      if( pTerm==0 ) break;
      wsFlags |= WHERE_COLUMN_EQ;
      if( pTerm->eOperator & WO_IN ){
        Expr *pExpr = pTerm->pExpr;
        wsFlags |= WHERE_COLUMN_IN;
        if( ExprHasProperty(pExpr, EP_xIsSelect) ){
          inMultiplier *= 25;

        }else if( pExpr->x.pList ){
          inMultiplier *= pExpr->x.pList->nExpr + 1;
        }
      }
    }
    nRow = pProbe->aiRowEst[i] * inMultiplier;
    cost = nRow * estLog(inMultiplier);







    nEq = i;
    if( pProbe->onError!=OE_None && (wsFlags & WHERE_COLUMN_IN)==0
         && nEq==pProbe->nColumn ){
      wsFlags |= WHERE_UNIQUE;
    }
    WHERETRACE(("...... nEq=%d inMult=%.9g cost=%.9g\n",nEq,inMultiplier,cost));


    /* Look for range constraints

    */
    if( nEq<pProbe->nColumn ){
      int j = pProbe->aiColumn[nEq];
      pTerm = findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE|WO_GT|WO_GE, pProbe);
      if( pTerm ){
        wsFlags |= WHERE_COLUMN_RANGE;
        if( findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE, pProbe) ){
................................................................................
          nRow /= 3;
        }
        if( findTerm(pWC, iCur, j, notReady, WO_GT|WO_GE, pProbe) ){
          wsFlags |= WHERE_BTM_LIMIT;
          cost /= 3;
          nRow /= 3;
        }
        WHERETRACE(("...... range reduces cost to %.9g\n", cost));

      }
    }

    /* Add the additional cost of sorting if that is a factor.
    */
    if( pOrderBy ){
      if( (wsFlags & WHERE_COLUMN_IN)==0 &&
................................................................................
**    sqlite3ParserARG_FETCH     Code to extract %extra_argument from yypParser
**    YYNSTATE           the combined number of states.
**    YYNRULE            the number of rules in the grammar
**    YYERRORSYMBOL      is the code number of the error symbol.  If not
**                       defined, then do no error processing.
*/
#define YYCODETYPE unsigned char
#define YYNOCODE 238
#define YYACTIONTYPE unsigned short int
#define YYWILDCARD 65
#define sqlite3ParserTOKENTYPE Token
typedef union {
  int yyinit;
  sqlite3ParserTOKENTYPE yy0;
  struct LimitVal yy4;
  ExprList* yy22;
  Expr* yy128;
  SrcList* yy133;
  TriggerStep* yy167;
  IdList* yy288;
  struct {int value; int mask;} yy299;
  struct TrigEvent yy366;
  int yy376;
  struct LikeOp yy450;
  Select* yy465;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
#endif
#define sqlite3ParserARG_SDECL Parse *pParse;
#define sqlite3ParserARG_PDECL ,Parse *pParse
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
#define YYNSTATE 548
#define YYNRULE 283
#define YYFALLBACK 1
#define YY_NO_ACTION      (YYNSTATE+YYNRULE+2)
#define YY_ACCEPT_ACTION  (YYNSTATE+YYNRULE+1)
#define YY_ERROR_ACTION   (YYNSTATE+YYNRULE)

/* The yyzerominor constant is used to initialize instances of
** YYMINORTYPE objects to zero. */
................................................................................
**  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.
*/
static const YYACTIONTYPE yy_action[] = {
 /*     0 */   273,  832,  155,  547,    5,  138,  192,  396,   21,   21,
 /*    10 */    21,   21,  226,   23,   23,   23,   23,   24,   24,   25,
 /*    20 */    25,   25,   26,  194,  370,  371,  372,  370,  371,  403,
 /*    30 */   409,   28,   23,   23,   23,   23,   24,   24,   25,   25,
 /*    40 */    25,   26,  194,   27,  440,   29,  122,   20,   19,  277,
 /*    50 */   413,  414,  410,  410,   22,   22,   21,   21,   21,   21,
 /*    60 */   469,   23,   23,   23,   23,   24,   24,   25,   25,   25,
 /*    70 */    26,  194,  273,  194,  280,  396,  152,  447,   42,   23,
 /*    80 */    23,   23,   23,   24,   24,   25,   25,   25,   26,  194,
 /*    90 */   370,  371,  373,  374,  144,  373,  374,  326,  329,  330,
 /*   100 */   280,  403,  409,  365,  362,   18,  471,  452,  331,   24,
 /*   110 */    24,   25,   25,   25,   26,  194,  425,  196,  254,   20,
 /*   120 */    19,  277,  413,  414,  410,  410,   22,   22,   21,   21,
 /*   130 */    21,   21,  372,   23,   23,   23,   23,   24,   24,   25,
 /*   140 */    25,   25,   26,  194,  273,  206,  461,  123,   14,  115,
 /*   150 */   162,  133,  120,  234,  324,  239,  325,  141,  373,  374,
 /*   160 */   255,  124,  297,   27,  243,   29,  122,   27,  529,   29,
 /*   170 */   122,  206,  447,  403,  409,  372,  294,   44,  120,  234,
 /*   180 */   324,  239,  325,  141,  448,  392,   68,  278,  420,  421,
 /*   190 */   243,   20,   19,  277,  413,  414,  410,  410,   22,   22,
 /*   200 */    21,   21,   21,   21,  452,   23,   23,   23,   23,   24,
 /*   210 */    24,   25,   25,   25,   26,  194,  273,  297,  354,  260,
 /*   220 */   259,  511,  486,  512,  504,  334,  170,  311,  510,  192,
 /*   230 */   297,  294,  321,  297,  386,   54,  192,  169,  372,  505,
 /*   240 */   392,   62,  171,  200,  294,  403,  409,  294,  353,  195,
 /*   250 */   427,  303,  178,  392,   75,  142,  392,   68,  168,  513,
 /*   260 */   393,  308,  429,   20,   19,  277,  413,  414,  410,  410,
 /*   270 */    22,   22,   21,   21,   21,   21,  393,   23,   23,   23,
 /*   280 */    23,   24,   24,   25,   25,   25,   26,  194,  273,  299,
 /*   290 */   530,  464,  470,  313,  199,  242,  398,  300,  311,  416,
 /*   300 */   416,  290,  367,  310,  302,  420,  421,  191,  144,  372,
 /*   310 */   275,  326,  329,  330,  189,  243,  144,  403,  409,  326,
 /*   320 */   329,  330,  331,  387,  502,  219,  396,  400,  400,  400,
 /*   330 */   331,  283,  499,   37,  529,   20,   19,  277,  413,  414,
 /*   340 */   410,  410,   22,   22,   21,   21,   21,   21,  393,   23,
 /*   350 */    23,   23,   23,   24,   24,   25,   25,   25,   26,  194,
 /*   360 */   273,  322,  242,  388,  465,    1,  195,  504,  411,  370,
 /*   370 */   371,  499,  359,  297,  218,  524,  372,  514,   54,  297,
 /*   380 */   300,  372,  416,  416,  354,  260,  259,  294,  391,  403,
 /*   390 */   409,  446,  390,  294,  396,  192,  392,   69,  207,  187,
 /*   400 */   174,  212,  392,   75,    3,   40,  242,   20,   19,  277,
 /*   410 */   413,  414,  410,  410,   22,   22,   21,   21,   21,   21,
 /*   420 */   372,   23,   23,   23,   23,   24,   24,   25,   25,   25,
 /*   430 */    26,  194,  273,  393,  393,  254,  468,  373,  374,  351,
 /*   440 */   417,  297,  284,  198,  426,  297,  175,  125,  225,  372,
 /*   450 */   370,  371,  297,  372,  526,  294,  522,  352,  472,  294,
 /*   460 */   521,  403,  409,  442,  392,   68,  294,  389,  392,   83,
 /*   470 */   370,  371,  443,   53,  343,  392,   83,  537,  355,   20,
 /*   480 */    19,  277,  413,  414,  410,  410,   22,   22,   21,   21,
 /*   490 */    21,   21,  792,   23,   23,   23,   23,   24,   24,   25,
 /*   500 */    25,   25,   26,  194,  273,  208,  315,  430,  485,   25,
 /*   510 */    25,   25,   26,  194,  288,  158,  190,  447,  373,  374,
 /*   520 */    57,  289,  320,  456,  370,  371,  456,  404,  405,  300,
 /*   530 */   463,  416,  416,  403,  409,  488,  294,  372,  373,  374,
 /*   540 */   372,  493,  276,   55,  449,  392,    7,  396,  407,  408,
 /*   550 */   393,   20,   19,  277,  413,  414,  410,  410,   22,   22,
 /*   560 */    21,   21,   21,   21,  445,   23,   23,   23,   23,   24,
 /*   570 */    24,   25,   25,   25,   26,  194,  273,  406,  434,  270,
 /*   580 */   246,  316,  427,  503,  178,  279,  434,  123,  342,  351,
 /*   590 */   297,  361,  373,  374,  435,  372,  300,  186,  416,  416,
 /*   600 */    26,  194,  435,  372,  294,  403,  409,  474,  475,  436,
 /*   610 */   192,  476,  447,  392,   63,  396,  344,  436,  494,  307,
 /*   620 */   347,  477,  360,   20,   19,  277,  413,  414,  410,  410,
 /*   630 */    22,   22,   21,   21,   21,   21,  297,   23,   23,   23,
 /*   640 */    23,   24,   24,   25,   25,   25,   26,  194,  273,  297,
 /*   650 */   294,  297,  242,  527,  475,  211,  319,  297,  165,  392,
 /*   660 */    58,  143,  297,  294,  318,  294,  372,  157,  297,  338,
 /*   670 */   297,  294,  392,   66,  392,   85,  294,  403,  409,  384,
 /*   680 */   392,   84,  294,  391,  294,  392,   89,  390,  285,  364,
 /*   690 */     5,  392,   87,  392,   92,   20,   19,  277,  413,  414,
 /*   700 */   410,  410,   22,   22,   21,   21,   21,   21,  297,   23,
 /*   710 */    23,   23,   23,   24,   24,   25,   25,   25,   26,  194,
 /*   720 */   273,  297,  294,  297,  242,  548,  365,  362,  418,  297,
 /*   730 */    56,  392,   93,  164,  456,  294,  220,  294,  372,  483,
 /*   740 */   138,  297,  396,  294,  392,  114,  392,  116,  372,  403,
 /*   750 */   409,  397,  392,   52,  422,  294,  300,  305,  416,  416,
 /*   760 */   286,  375,  376,  377,  392,   90,  452,   20,   30,  277,
 /*   770 */   413,  414,  410,  410,   22,   22,   21,   21,   21,   21,
 /*   780 */   297,   23,   23,   23,   23,   24,   24,   25,   25,   25,
 /*   790 */    26,  194,  273,  297,  294,  297,  287,  520,  341,  520,
 /*   800 */   297,  227,  441,  392,   67,  230,  297,  294,  424,  294,
 /*   810 */   396,  297,  491,  444,  294,  372,  392,   88,  392,   59,
 /*   820 */   294,  403,  409,  392,   86,  294,  180,  181,  182,  392,
 /*   830 */   117,  452,  142,  492,  392,  118,  179,  125,  237,  248,
 /*   840 */    19,  277,  413,  414,  410,  410,   22,   22,   21,   21,
 /*   850 */    21,   21,  297,   23,   23,   23,   23,   24,   24,   25,
 /*   860 */    25,   25,   26,  194,  273,  297,  294,  297,  263,  188,
 /*   870 */   232,  172,  297,  423,  423,  392,  119,  228,  297,  294,
 /*   880 */   252,  294,  250,  298,  297,  282,  294,  275,  392,   60,
 /*   890 */   392,   70,  294,  403,  409,  392,   71,  372,  294,  490,
 /*   900 */   489,  392,   61,  393,  497,  393,  183,  392,   72,  266,
 /*   910 */    36,  264,   38,  277,  413,  414,  410,  410,   22,   22,
 /*   920 */    21,   21,   21,   21,  297,   23,   23,   23,   23,   24,
 /*   930 */    24,   25,   25,   25,   26,  194,   32,  304,  294,    2,
 /*   940 */   393,  297,  187,  293,  371,  480,  481,  392,   73,  297,
 /*   950 */   193,   32,  304,  301,    2,  294,  297,   15,  293,  371,
 /*   960 */   297,  369,  496,  294,  392,   74,  486,  454,  301,  139,
 /*   970 */   294,  306,  392,   76,  294,  372,  393,  381,  254,  392,
 /*   980 */    77,  429,  235,  392,   78,  495,  306,  143,  498,  265,
 /*   990 */   297,  372,  372,  236,  500,  254,  429,  245,  328,  143,
 /*  1000 */   352,   35,   34,  532,  294,  297,  267,  543,  297,  372,
 /*  1010 */    33,  295,  296,  392,   64,  398,   35,   34,  462,  294,
 /*  1020 */   539,  348,  294,  358,  368,   33,  295,  296,  392,   65,
 /*  1030 */   398,  392,   79,  192,  378,   32,  304,  540,    2,  130,
 /*  1040 */   382,  254,  293,  371,  129,  297,  400,  400,  400,  401,
 /*  1050 */   402,    8,  301,   16,  372,  372,  379,  370,  371,  294,
 /*  1060 */   184,  400,  400,  400,  401,  402,    8,  176,  392,   80,
 /*  1070 */   306,  254,  213,  214,  215,  131,  217,  254,  113,  297,
 /*  1080 */   429,  380,  297,  541,  254,  372,  333,  525,  143,  143,
 /*  1090 */   383,  372,  291,  294,  393,  429,  294,  533,  372,  139,
 /*  1100 */    35,   34,  392,   81,  372,  392,   82,  121,  399,   33,
 /*  1110 */   295,  296,  132,  209,  398,  166,  167,  529,    6,  210,
 /*  1120 */   309,  372,  372,  438,  451,  470,  269,  455,  457,  398,
 /*  1130 */   240,  534,  394,   51,  372,  221,  314,  372,  372,  487,
 /*  1140 */   241,  372,  372,  292,  372,  400,  400,  400,  401,  402,
 /*  1150 */     8,  506,  222,  372,  372,   44,   43,  247,  249,  223,
 /*  1160 */   400,  400,  400,  251,  312,  372,  253,  357,  268,  259,
 /*  1170 */   258,  372,  372,  274,  346,  349,  350,  372,  192,   17,
 /*  1180 */   372,  261,  262,  224,  372,  544,  395,   51,  372,  372,
 /*  1190 */   372,   39,  197,  137,  439,  372,  372,  156,   45,  317,
 /*  1200 */   229,  323,  453,  231,  281,  459,  233,  483,  460,  473,
 /*  1210 */   478,  479,  238,   95,  204,  203,  482,  484,  335,  146,
 /*  1220 */   507,  271,  205,  508,  509,  272,  515,  501,  339,  147,
 /*  1230 */    48,  337,  148,  518,  185,  517,  256,  149,  128,  345,
 /*  1240 */   104,  528,  356,  151,  535,  366,  202,  105,  106,  107,
 /*  1250 */   108,  160,   91,  110,  216,  385,  177,  588,  589,   99,
 /*  1260 */   590,  542,  134,  135,  412,  415,  419,   31,  159,  428,
 /*  1270 */   161,  431,  173,  450,  432,    4,  433,  136,  437,   41,
 /*  1280 */    94,    9,  126,   10,  466,  467,  458,  201,   46,   96,
 /*  1290 */   327,  140,  244,   97,   47,   98,  145,  332,  236,  336,
 /*  1300 */   163,  127,  516,  100,  139,  257,  340,  150,  102,   13,
 /*  1310 */   531,   11,  103,  153,  154,  536,   49,  538,  111,  101,
 /*  1320 */   109,  523,  519,  112,   12,  545,  363,  833,  546,  833,
 /*  1330 */   833,  833,  833,  833,  833,  833,  833,  833,  833,  833,
 /*  1340 */   833,  833,  833,  833,  833,  833,  833,  833,   50,
};
static const YYCODETYPE yy_lookahead[] = {
 /*     0 */    19,  140,  141,  142,  143,   24,  116,   26,   75,   76,
 /*    10 */    77,   78,  148,   80,   81,   82,   83,   84,   85,   86,
 /*    20 */    87,   88,   89,   90,   26,   27,  162,   26,   27,   48,
 /*    30 */    49,   79,   80,   81,   82,   83,   84,   85,   86,   87,
 /*    40 */    88,   89,   90,  219,  220,  221,  222,   66,   67,   68,
 /*    50 */    69,   70,   71,   72,   73,   74,   75,   76,   77,   78,
 /*    60 */   171,   80,   81,   82,   83,   84,   85,   86,   87,   88,
 /*    70 */    89,   90,   19,   90,   19,   94,   25,   25,   25,   80,
 /*    80 */    81,   82,   83,   84,   85,   86,   87,   88,   89,   90,
 /*    90 */    26,   27,   94,   95,   96,   94,   95,   99,  100,  101,
 /*   100 */    19,   48,   49,    1,    2,   52,  171,  163,  110,   84,
 /*   110 */    85,   86,   87,   88,   89,   90,   84,   85,  148,   66,
 /*   120 */    67,   68,   69,   70,   71,   72,   73,   74,   75,   76,
 /*   130 */    77,   78,  162,   80,   81,   82,   83,   84,   85,   86,
 /*   140 */    87,   88,   89,   90,   19,   90,  202,   95,   22,   24,
 /*   150 */    24,   96,   97,   98,   99,  100,  101,  102,   94,   95,
 /*   160 */   190,  148,  148,  219,  109,  221,  222,  219,   55,  221,
 /*   170 */   222,   90,  120,   48,   49,  162,  162,  126,   97,   98,
 /*   180 */    99,  100,  101,  102,  120,  171,  172,  166,  167,  168,
 /*   190 */   109,   66,   67,   68,   69,   70,   71,   72,   73,   74,
 /*   200 */    75,   76,   77,   78,  163,   80,   81,   82,   83,   84,
 /*   210 */    85,   86,   87,   88,   89,   90,   19,  148,  105,  106,
 /*   220 */   107,  178,  179,  183,  148,   19,  157,  213,  185,  116,
 /*   230 */   148,  162,  218,  148,  158,  159,  116,   25,  162,  183,
 /*   240 */   171,  172,  157,  202,  162,   48,   49,  162,  128,  228,
 /*   250 */   163,  164,  165,  171,  172,   49,  171,  172,  182,  183,
 /*   260 */   191,  188,   64,   66,   67,   68,   69,   70,   71,   72,
 /*   270 */    73,   74,   75,   76,   77,   78,  191,   80,   81,   82,
 /*   280 */    83,   84,   85,   86,   87,   88,   89,   90,   19,   19,
 /*   290 */    11,   23,   94,  211,  212,  148,   98,  112,  213,  114,
 /*   300 */   115,  144,  145,  218,  166,  167,  168,  150,   96,  162,
 /*   310 */   104,   99,  100,  101,  157,  109,   96,   48,   49,   99,
 /*   320 */   100,  101,  110,  169,  170,  192,   26,  129,  130,  131,
 /*   330 */   110,  184,  178,  136,   55,   66,   67,   68,   69,   70,
 /*   340 */    71,   72,   73,   74,   75,   76,   77,   78,  191,   80,
 /*   350 */    81,   82,   83,   84,   85,   86,   87,   88,   89,   90,
 /*   360 */    19,   86,  148,  170,   23,   22,  228,  148,   98,   26,
 /*   370 */    27,  178,  215,  148,  155,   21,  162,  158,  159,  148,
 /*   380 */   112,  162,  114,  115,  105,  106,  107,  162,  113,   48,
 /*   390 */    49,  205,  117,  162,   94,  116,  171,  172,  184,  157,
 /*   400 */   157,  146,  171,  172,  193,  136,  148,   66,   67,   68,
 /*   410 */    69,   70,   71,   72,   73,   74,   75,   76,   77,   78,
 /*   420 */   162,   80,   81,   82,   83,   84,   85,   86,   87,   88,
 /*   430 */    89,   90,   19,  191,  191,  148,   23,   94,   95,  148,
 /*   440 */    23,  148,  184,  212,  163,  148,  203,  204,  223,  162,
 /*   450 */    26,   27,  148,  162,  100,  162,   29,  215,  162,  162,
 /*   460 */    33,   48,   49,   31,  171,  172,  162,  171,  171,  172,
 /*   470 */    26,   27,   40,  231,   47,  171,  172,  190,  236,   66,
 /*   480 */    67,   68,   69,   70,   71,   72,   73,   74,   75,   76,
 /*   490 */    77,   78,  138,   80,   81,   82,   83,   84,   85,   86,
 /*   500 */    87,   88,   89,   90,   19,  214,  213,   23,   23,   86,
 /*   510 */    87,   88,   89,   90,  217,   23,  157,   25,   94,   95,
 /*   520 */    22,  217,  148,  148,   26,   27,  148,   48,   49,  112,
 /*   530 */    86,  114,  115,   48,   49,  180,  162,  162,   94,   95,
 /*   540 */   162,  180,  152,   22,  120,  171,  172,   26,   69,   70,
 /*   550 */   191,   66,   67,   68,   69,   70,   71,   72,   73,   74,
 /*   560 */    75,   76,   77,   78,   25,   80,   81,   82,   83,   84,
 /*   570 */    85,   86,   87,   88,   89,   90,   19,   98,   12,  160,
 /*   580 */    23,  148,  163,  164,  165,  210,   12,   95,  210,  148,
 /*   590 */   148,   97,   94,   95,   28,  162,  112,  232,  114,  115,
 /*   600 */    89,   90,   28,  162,  162,   48,   49,  187,  188,   43,
 /*   610 */   116,   45,  120,  171,  172,   94,  226,   43,  180,   45,
 /*   620 */   230,   55,  128,   66,   67,   68,   69,   70,   71,   72,
 /*   630 */    73,   74,   75,   76,   77,   78,  148,   80,   81,   82,
 /*   640 */    83,   84,   85,   86,   87,   88,   89,   90,   19,  148,
 /*   650 */   162,  148,  148,  187,  188,  214,   19,  148,  119,  171,
 /*   660 */   172,   25,  148,  162,   27,  162,  162,   23,  148,  233,
 /*   670 */   148,  162,  171,  172,  171,  172,  162,   48,   49,  151,
 /*   680 */   171,  172,  162,  113,  162,  171,  172,  117,  184,  142,
 /*   690 */   143,  171,  172,  171,  172,   66,   67,   68,   69,   70,
 /*   700 */    71,   72,   73,   74,   75,   76,   77,   78,  148,   80,
 /*   710 */    81,   82,   83,   84,   85,   86,   87,   88,   89,   90,
 /*   720 */    19,  148,  162,  148,  148,    0,    1,    2,   23,  148,
 /*   730 */    25,  171,  172,  193,  148,  162,  195,  162,  162,  103,
 /*   740 */    24,  148,   26,  162,  171,  172,  171,  172,  162,   48,
 /*   750 */    49,  163,  171,  172,  229,  162,  112,  225,  114,  115,
 /*   760 */   184,    7,    8,    9,  171,  172,  163,   66,   67,   68,
 /*   770 */    69,   70,   71,   72,   73,   74,   75,   76,   77,   78,
 /*   780 */   148,   80,   81,   82,   83,   84,   85,   86,   87,   88,
 /*   790 */    89,   90,   19,  148,  162,  148,  210,  105,  106,  107,
 /*   800 */   148,  148,  174,  171,  172,  202,  148,  162,  229,  162,
 /*   810 */    94,  148,   35,  174,  162,  162,  171,  172,  171,  172,
 /*   820 */   162,   48,   49,  171,  172,  162,  105,  106,  107,  171,
 /*   830 */   172,  163,   49,   56,  171,  172,  203,  204,  174,   17,
 /*   840 */    67,   68,   69,   70,   71,   72,   73,   74,   75,   76,
 /*   850 */    77,   78,  148,   80,   81,   82,   83,   84,   85,   86,
 /*   860 */    87,   88,   89,   90,   19,  148,  162,  148,   17,  157,
 /*   870 */   202,  157,  148,  129,  130,  171,  172,  206,  148,  162,
 /*   880 */    58,  162,   60,  148,  148,  108,  162,  104,  171,  172,
 /*   890 */   171,  172,  162,   48,   49,  171,  172,  162,  162,   97,
 /*   900 */    98,  171,  172,  191,  163,  191,  157,  171,  172,   58,
 /*   910 */   135,   60,  137,   68,   69,   70,   71,   72,   73,   74,
 /*   920 */    75,   76,   77,   78,  148,   80,   81,   82,   83,   84,
 /*   930 */    85,   86,   87,   88,   89,   90,   19,   20,  162,   22,
 /*   940 */   191,  148,  157,   26,   27,    7,    8,  171,  172,  148,
 /*   950 */   194,   19,   20,   36,   22,  162,  148,  201,   26,   27,
 /*   960 */   148,  148,  174,  162,  171,  172,  179,   23,   36,   25,
 /*   970 */   162,   54,  171,  172,  162,  162,  191,  148,  148,  171,
 /*   980 */   172,   64,   98,  171,  172,   23,   54,   25,  174,  138,
 /*   990 */   148,  162,  162,  109,  163,  148,   64,   23,  175,   25,
 /*  1000 */   215,   84,   85,  196,  162,  148,  206,  196,  148,  162,
 /*  1010 */    93,   94,   95,  171,  172,   98,   84,   85,   86,  162,
 /*  1020 */   190,  236,  162,  206,  147,   93,   94,   95,  171,  172,
 /*  1030 */    98,  171,  172,  116,  147,   19,   20,  190,   22,  149,
 /*  1040 */   148,  148,   26,   27,    6,  148,  129,  130,  131,  132,
 /*  1050 */   133,  134,   36,   22,  162,  162,  147,   26,   27,  162,
 /*  1060 */   157,  129,  130,  131,  132,  133,  134,    5,  171,  172,
 /*  1070 */    54,  148,   10,   11,   12,   13,   14,  148,   16,  148,
 /*  1080 */    64,   13,  148,  190,  148,  162,   23,   23,   25,   25,
 /*  1090 */   148,  162,  147,  162,  191,   64,  162,   23,  162,   25,
 /*  1100 */    84,   85,  171,  172,  162,  171,  172,  148,  148,   93,
 /*  1110 */    94,   95,  149,  190,   98,   84,   85,   55,   25,  190,
 /*  1120 */   148,  162,  162,  148,  148,   94,  190,  148,  148,   98,
 /*  1130 */   148,   23,  191,   25,  162,  196,  123,  162,  162,  148,
 /*  1140 */   148,  162,  162,  156,  162,  129,  130,  131,  132,  133,
 /*  1150 */   134,  148,  197,  162,  162,  126,  124,  148,  148,  198,
 /*  1160 */   129,  130,  131,  148,  122,  162,  148,  105,  106,  107,
 /*  1170 */   148,  162,  162,  111,  148,  148,  148,  162,  116,  125,
 /*  1180 */   162,  148,  148,  199,  162,   23,  200,   25,  162,  162,
 /*  1190 */   162,  135,  224,  118,  154,  162,  162,  154,  104,  121,
 /*  1200 */   207,  104,  208,  207,   46,  208,  207,  103,  208,  173,
 /*  1210 */   173,  181,  173,   22,   90,  227,  175,  173,   18,  153,
 /*  1220 */   173,  176,  227,  173,  173,  176,  154,  181,   44,  153,
 /*  1230 */   135,  154,  153,  235,  154,  154,  234,  153,   66,  154,
 /*  1240 */    22,  186,   18,  186,  196,    1,  177,  189,  189,  189,
 /*  1250 */   189,  216,  161,  186,   15,   23,   22,  118,  118,  177,
 /*  1260 */   118,  196,  118,  118,   98,  113,   23,   22,  216,   23,
 /*  1270 */    22,   11,   22,  120,   23,   34,   23,   25,   23,   25,
 /*  1280 */    22,   25,  118,   34,   23,   23,   27,   50,   22,   22,
 /*  1290 */    50,   34,   23,   22,   22,   22,  102,   50,  109,   19,
 /*  1300 */    24,   38,   20,  104,   25,  138,   42,  104,   22,    5,
 /*  1310 */     1,   22,  108,  127,  119,    1,   74,   20,  108,   51,
 /*  1320 */   119,   51,   57,  127,   22,  128,    3,  237,    4,  237,
 /*  1330 */   237,  237,  237,  237,  237,  237,  237,  237,  237,  237,
 /*  1340 */   237,  237,  237,  237,  237,  237,  237,  237,   74,
};
#define YY_SHIFT_USE_DFLT (-111)
#define YY_SHIFT_MAX 363
static const short yy_shift_ofst[] = {
 /*     0 */   102,  917,  917, 1016, 1016, 1062,   -2,  -19, 1016, 1016,
 /*    10 */  1016, 1016, 1016,  113,    1,  932, 1016, 1016, 1016, 1016,
 /*    20 */  1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016,
 /*    30 */  1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016,
 /*    40 */  1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016,
 /*    50 */  1016, 1016,  -48,  279,  300,   32,   32, -110,   53,  125,
 /*    60 */   197,  269,  341,  413,  485,  557,  629,  701,  629,  629,
 /*    70 */   629,  629,  629,  629,  629,  629,  629,  629,  629,  629,
 /*    80 */   629,  629,  629,  629,  773,  845,  845,  -67,  -67,   -1,
 /*    90 */    -1,   55,   25,  423,    1,    1,    1,    1,    1,  206,
 /*   100 */     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 /*   110 */     1,    1,    1,  354,  511,  300,  -17, -111, -111, -111,
 /*   120 */  1031,   81,  343,   64,  424,  498,  444,  566,  566,    1,
 /*   130 */     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 /*   140 */     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 /*   150 */     1,    1,    1,    1,    1,  725,  716,  716,  716,  494,
 /*   160 */   120, -110, -110, -110, -111, -111,  198,  198,  212,  220,
 /*   170 */   268,  417,  484,  574,  644,  492,  754,  275,  521,   52,
 /*   180 */   777,  777,  777,  185,  185,  427,  692,  185,  185,  185,
 /*   190 */   185,  126,  570,  539,  300,  744,  744,  775,  432,  432,
 /*   200 */   637,  432,  783,  432,  300,  432,  300,  636,   51,  637,
 /*   210 */   637,   51, 1038, 1038, 1038, 1038, 1068, 1068, 1093, -110,
 /*   220 */  1029, 1013, 1032, 1042, 1054, 1056, 1075, 1075, 1094, 1078,
 /*   230 */  1094, 1078, 1094, 1078, 1097, 1097, 1158, 1097, 1104, 1097,
 /*   240 */  1191, 1124, 1124, 1158, 1097, 1097, 1097, 1191, 1200, 1075,
 /*   250 */  1200, 1075, 1200, 1075, 1075, 1184, 1095, 1200, 1075, 1172,
 /*   260 */  1172, 1218, 1029, 1224, 1224, 1224, 1224, 1029, 1172, 1218,
 /*   270 */  -111, -111, -111,  479,  851,  721,  822,  270,  705,  944,
 /*   280 */   884,  938,  802,  962,  974, 1063, 1064, 1074, 1108, 1162,
 /*   290 */  1244, 1239, 1232, 1234, 1139, 1140, 1142, 1144, 1145, 1166,
 /*   300 */  1152, 1245, 1243, 1246, 1248, 1260, 1250, 1251, 1252, 1253,
 /*   310 */  1255, 1254, 1241, 1256, 1249, 1254, 1153, 1258, 1257, 1259,
 /*   320 */  1164, 1261, 1262, 1263, 1237, 1266, 1240, 1267, 1269, 1271,
 /*   330 */  1272, 1247, 1273, 1194, 1189, 1280, 1282, 1276, 1199, 1264,
 /*   340 */  1265, 1268, 1279, 1270, 1167, 1203, 1286, 1304, 1309, 1204,
 /*   350 */  1242, 1274, 1186, 1289, 1195, 1314, 1297, 1201, 1210, 1196,
 /*   360 */  1302, 1197, 1323, 1324,
};
#define YY_REDUCE_USE_DFLT (-177)
#define YY_REDUCE_MAX 272
static const short yy_reduce_ofst[] = {
 /*     0 */  -139,   85,   69,   14,   82,  157,   76,  -56,  225,  231,
 /*    10 */   293,  297,  304,  242,  219,  374,  442,  488,  501,  503,
 /*    20 */   509,  514,  520,  522,  560,  573,  575,  581,  593,  632,
 /*    30 */   645,  647,  652,  658,  663,  704,  717,  719,  724,  730,
 /*    40 */   736,  776,  793,  801,  808,  812,  842,  857,  860,  897,
 /*    50 */   931,  934, -176,  785,  419,   21,  138,  243,  -52,  -52,
 /*    60 */   -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,
 /*    70 */   -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,
 /*    80 */   -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,
 /*    90 */   -52,  154,  -52,  -52,  375,  147,  214,  258,  504,   43,
 /*   100 */   -30,  378,  576,  291,  586,  287,  830,  847,  893,  923,
 /*   110 */   929,  441,  936,  390,  -52,   87,  -52,  -52,  -52,  -52,
 /*   120 */   296,  193, -136,   13,  433,  653,  735,  420,  466,  813,
 /*   130 */   829,  892,  942,  959,  735,  960,  972,  975,  976,  979,
 /*   140 */   980,  982,  991,  992, 1003, 1009, 1010, 1015, 1018, 1022,
 /*   150 */  1026, 1027, 1028, 1033, 1034,  547,   41,  603,  668,  359,
 /*   160 */   712,  714,  749,  903,  756,  633, -111,  -65,   40,   56,
 /*   170 */   133,  133,  133,   73,  133,  186,  255,  211,  281,  186,
 /*   180 */   355,  361,  438,  133,  133,  365,  436,  133,  133,  133,
 /*   190 */   133,  528,  540,  541,  588,  525,  579,  532,  628,  639,
 /*   200 */   671,  664,  787,  788,  741,  814,  831,  823,  807,  800,
 /*   210 */   817,  811,  877,  887,  909,  945,  890,  963,  987,  941,
 /*   220 */   939,  955,  961,  984,  986,  968, 1040, 1043,  993,  994,
 /*   230 */   996,  997,  999, 1000, 1036, 1037, 1030, 1039, 1041, 1044,
 /*   240 */  1045,  988,  995, 1046, 1047, 1050, 1051, 1049, 1066, 1072,
 /*   250 */  1076, 1077, 1079, 1080, 1081, 1002,  998, 1084, 1085, 1055,
 /*   260 */  1057, 1035, 1048, 1058, 1059, 1060, 1061, 1065, 1067, 1052,
 /*   270 */  1091, 1069, 1082,
};
static const YYACTIONTYPE yy_default[] = {
 /*     0 */   553,  787,  831,  787,  831,  831,  831,  675,  785,  831,
 /*    10 */   831,  831,  831,  831,  831,  831,  831,  831,  831,  831,
 /*    20 */   831,  831,  831,  831,  831,  831,  831,  831,  831,  831,
 /*    30 */   831,  831,  831,  831,  831,  831,  831,  831,  831,  831,
 /*    40 */   831,  831,  831,  831,  831,  831,  831,  831,  831,  831,
 /*    50 */   831,  831,  759,  831,  591,  804,  804,  679,  710,  831,
 /*    60 */   831,  831,  831,  831,  831,  831,  711,  831,  789,  784,
 /*    70 */   780,  782,  781,  788,  712,  701,  708,  715,  690,  817,
 /*    80 */   717,  718,  724,  725,  747,  746,  765,  749,  771,  748,
 /*    90 */   758,  583,  750,  751,  831,  831,  831,  831,  831,  644,
 /*   100 */   831,  831,  831,  831,  831,  831,  831,  831,  831,  831,
 /*   110 */   831,  831,  831,  578,  752,  831,  753,  766,  767,  768,
 /*   120 */   831,  831,  831,  831,  831,  831,  831,  831,  831,  559,
 /*   130 */   831,  831,  831,  831,  831,  831,  831,  831,  831,  831,
 /*   140 */   831,  831,  831,  831,  831,  831,  831,  831,  831,  831,
 /*   150 */   831,  831,  831,  831,  831,  553,  675,  675,  675,  831,
 /*   160 */   831,  831,  831,  831,  669,  679,  831,  831,  635,  831,
 /*   170 */   831,  831,  831,  831,  831,  831,  561,  667,  593,  677,
 /*   180 */   831,  831,  831,  580,  656,  810,  831,  824,  822,  658,
 /*   190 */   720,  831,  667,  676,  831,  831,  831,  783,  704,  704,
 /*   200 */   692,  704,  614,  704,  831,  704,  831,  617,  714,  692,
 /*   210 */   692,  714,  558,  558,  558,  558,  569,  569,  634,  831,
 /*   220 */   714,  705,  707,  697,  709,  831,  683,  683,  691,  696,
 /*   230 */   691,  696,  691,  696,  646,  646,  631,  646,  617,  646,
 /*   240 */   793,  797,  797,  631,  646,  646,  646,  793,  575,  683,
 /*   250 */   575,  683,  575,  683,  683,  814,  816,  575,  683,  648,
 /*   260 */   648,  726,  714,  655,  655,  655,  655,  714,  648,  726,
 /*   270 */   601,  619,  619,  831,  831,  831,  831,  831,  831,  831,
 /*   280 */   831,  831,  831,  831,  831,  831,  831,  831,  831,  831,
 /*   290 */   831,  567,  831,  585,  733,  738,  734,  831,  735,  831,
 /*   300 */   661,  831,  831,  831,  831,  831,  831,  831,  831,  831,
 /*   310 */   831,  786,  831,  698,  831,  706,  831,  831,  831,  831,
 /*   320 */   831,  831,  831,  831,  831,  831,  831,  831,  831,  831,
 /*   330 */   831,  831,  831,  831,  831,  831,  831,  831,  831,  831,
 /*   340 */   831,  812,  813,  831,  831,  831,  831,  831,  831,  831,
 /*   350 */   831,  831,  831,  831,  831,  831,  831,  831,  831,  831,
 /*   360 */   831,  831,  554,  831,  549,  551,  552,  556,  557,  560,
 /*   370 */   585,  586,  588,  589,  590,  562,  563,  564,  565,  566,
 /*   380 */   568,  572,  570,  571,  573,  579,  581,  600,  602,  604,
 /*   390 */   665,  666,  730,  659,  660,  664,  587,  741,  732,  736,
 /*   400 */   737,  739,  740,  754,  755,  757,  763,  770,  773,  756,
 /*   410 */   761,  762,  764,  769,  772,  662,  663,  776,  594,  595,
 /*   420 */   598,  599,  800,  802,  801,  803,  597,  596,  742,  745,
 /*   430 */   778,  779,  825,  826,  827,  828,  829,  774,  684,  777,
 /*   440 */   760,  699,  702,  703,  700,  668,  678,  686,  687,  688,
 /*   450 */   689,  673,  674,  680,  695,  728,  729,  693,  694,  681,
 /*   460 */   682,  670,  671,  672,  775,  731,  743,  744,  605,  606,
 /*   470 */   738,  607,  608,  609,  647,  650,  651,  652,  610,  629,
 /*   480 */   632,  633,  611,  618,  612,  613,  620,  621,  622,  625,
 /*   490 */   626,  627,  628,  623,  624,  794,  795,  798,  796,  615,
 /*   500 */   616,  630,  603,  592,  584,  636,  639,  640,  641,  642,
 /*   510 */   643,  645,  637,  638,  582,  574,  576,  685,  806,  815,
 /*   520 */   811,  807,  808,  809,  577,  790,  791,  649,  722,  723,
 /*   530 */   805,  818,  820,  727,  821,  823,  819,  653,  654,  657,
 /*   540 */   799,  830,  713,  716,  719,  721,  555,  550,
};
#define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))

/* The next table maps tokens into fallback tokens.  If a construct
** like the following:
** 
**      %fallback ID X Y Z.
................................................................................
   26,  /*  EXCLUSIVE => ID */
    0,  /*     COMMIT => nothing */
   26,  /*        END => ID */
   26,  /*   ROLLBACK => ID */
   26,  /*  SAVEPOINT => ID */
   26,  /*    RELEASE => ID */
    0,  /*         TO => nothing */
    0,  /*     CREATE => nothing */
    0,  /*      TABLE => nothing */

   26,  /*         IF => ID */
    0,  /*        NOT => nothing */
    0,  /*     EXISTS => nothing */
   26,  /*       TEMP => ID */
    0,  /*         LP => nothing */
    0,  /*         RP => nothing */
    0,  /*         AS => nothing */
................................................................................
/* For tracing shifts, the names of all terminals and nonterminals
** are required.  The following table supplies these names */
static const char *const yyTokenName[] = { 
  "$",             "SEMI",          "EXPLAIN",       "QUERY",       
  "PLAN",          "BEGIN",         "TRANSACTION",   "DEFERRED",    
  "IMMEDIATE",     "EXCLUSIVE",     "COMMIT",        "END",         
  "ROLLBACK",      "SAVEPOINT",     "RELEASE",       "TO",          
  "CREATE",        "TABLE",         "IF",            "NOT",         
  "EXISTS",        "TEMP",          "LP",            "RP",          
  "AS",            "COMMA",         "ID",            "INDEXED",     
  "ABORT",         "AFTER",         "ANALYZE",       "ASC",         
  "ATTACH",        "BEFORE",        "BY",            "CASCADE",     
  "CAST",          "COLUMNKW",      "CONFLICT",      "DATABASE",    
  "DESC",          "DETACH",        "EACH",          "FAIL",        
  "FOR",           "IGNORE",        "INITIALLY",     "INSTEAD",     
................................................................................
  "HAVING",        "LIMIT",         "WHERE",         "INTO",        
  "VALUES",        "INTEGER",       "FLOAT",         "BLOB",        
  "REGISTER",      "VARIABLE",      "CASE",          "WHEN",        
  "THEN",          "ELSE",          "INDEX",         "error",       
  "input",         "cmdlist",       "ecmd",          "explain",     
  "cmdx",          "cmd",           "transtype",     "trans_opt",   
  "nm",            "savepoint_opt",  "create_table",  "create_table_args",
  "temp",          "ifnotexists",   "dbnm",          "columnlist",  
  "conslist_opt",  "select",        "column",        "columnid",    
  "type",          "carglist",      "id",            "ids",         
  "typetoken",     "typename",      "signed",        "plus_num",    
  "minus_num",     "carg",          "ccons",         "term",        
  "expr",          "onconf",        "sortorder",     "autoinc",     
  "idxlist_opt",   "refargs",       "defer_subclause",  "refarg",      
  "refact",        "init_deferred_pred_opt",  "conslist",      "tcons",       
  "idxlist",       "defer_subclause_opt",  "orconf",        "resolvetype", 
  "raisetype",     "ifexists",      "fullname",      "oneselect",   
  "multiselect_op",  "distinct",      "selcollist",    "from",        
  "where_opt",     "groupby_opt",   "having_opt",    "orderby_opt", 
  "limit_opt",     "sclp",          "as",            "seltablist",  
  "stl_prefix",    "joinop",        "indexed_opt",   "on_opt",      
  "using_opt",     "joinop2",       "inscollist",    "sortlist",    
  "sortitem",      "nexprlist",     "setlist",       "insert_cmd",  
  "inscollist_opt",  "itemlist",      "exprlist",      "likeop",      
  "escape",        "between_op",    "in_op",         "case_operand",
  "case_exprlist",  "case_else",     "uniqueflag",    "collate",     
  "plus_opt",      "number",        "trigger_decl",  "trigger_cmd_list",
  "trigger_time",  "trigger_event",  "foreach_clause",  "when_clause", 
  "trigger_cmd", 
};
#endif /* NDEBUG */

#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
*/
static const char *const yyRuleName[] = {
................................................................................
 /*  19 */ "cmd ::= ROLLBACK trans_opt",
 /*  20 */ "savepoint_opt ::= SAVEPOINT",
 /*  21 */ "savepoint_opt ::=",
 /*  22 */ "cmd ::= SAVEPOINT nm",
 /*  23 */ "cmd ::= RELEASE savepoint_opt nm",
 /*  24 */ "cmd ::= ROLLBACK trans_opt TO savepoint_opt nm",
 /*  25 */ "cmd ::= create_table create_table_args",
 /*  26 */ "create_table ::= CREATE temp TABLE ifnotexists nm dbnm",

 /*  27 */ "ifnotexists ::=",
 /*  28 */ "ifnotexists ::= IF NOT EXISTS",
 /*  29 */ "temp ::= TEMP",
 /*  30 */ "temp ::=",
 /*  31 */ "create_table_args ::= LP columnlist conslist_opt RP",
 /*  32 */ "create_table_args ::= AS select",
 /*  33 */ "columnlist ::= columnlist COMMA column",
 /*  34 */ "columnlist ::= column",
 /*  35 */ "column ::= columnid type carglist",
 /*  36 */ "columnid ::= nm",
 /*  37 */ "id ::= ID",
 /*  38 */ "id ::= INDEXED",
 /*  39 */ "ids ::= ID|STRING",
 /*  40 */ "nm ::= id",
 /*  41 */ "nm ::= STRING",
 /*  42 */ "nm ::= JOIN_KW",
 /*  43 */ "type ::=",
 /*  44 */ "type ::= typetoken",
 /*  45 */ "typetoken ::= typename",
 /*  46 */ "typetoken ::= typename LP signed RP",
 /*  47 */ "typetoken ::= typename LP signed COMMA signed RP",
 /*  48 */ "typename ::= ids",
 /*  49 */ "typename ::= typename ids",
 /*  50 */ "signed ::= plus_num",
 /*  51 */ "signed ::= minus_num",
 /*  52 */ "carglist ::= carglist carg",
 /*  53 */ "carglist ::=",
 /*  54 */ "carg ::= CONSTRAINT nm ccons",
 /*  55 */ "carg ::= ccons",
 /*  56 */ "ccons ::= DEFAULT term",
 /*  57 */ "ccons ::= DEFAULT LP expr RP",
 /*  58 */ "ccons ::= DEFAULT PLUS term",
 /*  59 */ "ccons ::= DEFAULT MINUS term",
 /*  60 */ "ccons ::= DEFAULT id",
 /*  61 */ "ccons ::= NULL onconf",
 /*  62 */ "ccons ::= NOT NULL onconf",
 /*  63 */ "ccons ::= PRIMARY KEY sortorder onconf autoinc",
 /*  64 */ "ccons ::= UNIQUE onconf",
 /*  65 */ "ccons ::= CHECK LP expr RP",
 /*  66 */ "ccons ::= REFERENCES nm idxlist_opt refargs",
 /*  67 */ "ccons ::= defer_subclause",
 /*  68 */ "ccons ::= COLLATE ids",
 /*  69 */ "autoinc ::=",
 /*  70 */ "autoinc ::= AUTOINCR",
 /*  71 */ "refargs ::=",
 /*  72 */ "refargs ::= refargs refarg",
 /*  73 */ "refarg ::= MATCH nm",
 /*  74 */ "refarg ::= ON DELETE refact",
 /*  75 */ "refarg ::= ON UPDATE refact",
 /*  76 */ "refarg ::= ON INSERT refact",
 /*  77 */ "refact ::= SET NULL",
 /*  78 */ "refact ::= SET DEFAULT",
 /*  79 */ "refact ::= CASCADE",
 /*  80 */ "refact ::= RESTRICT",
 /*  81 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
 /*  82 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
 /*  83 */ "init_deferred_pred_opt ::=",
 /*  84 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
 /*  85 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
 /*  86 */ "conslist_opt ::=",
 /*  87 */ "conslist_opt ::= COMMA conslist",
 /*  88 */ "conslist ::= conslist COMMA tcons",
 /*  89 */ "conslist ::= conslist tcons",
 /*  90 */ "conslist ::= tcons",
 /*  91 */ "tcons ::= CONSTRAINT nm",
 /*  92 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
 /*  93 */ "tcons ::= UNIQUE LP idxlist RP onconf",
 /*  94 */ "tcons ::= CHECK LP expr RP onconf",
 /*  95 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
 /*  96 */ "defer_subclause_opt ::=",
 /*  97 */ "defer_subclause_opt ::= defer_subclause",
 /*  98 */ "onconf ::=",
 /*  99 */ "onconf ::= ON CONFLICT resolvetype",
 /* 100 */ "orconf ::=",
 /* 101 */ "orconf ::= OR resolvetype",
 /* 102 */ "resolvetype ::= raisetype",
 /* 103 */ "resolvetype ::= IGNORE",
 /* 104 */ "resolvetype ::= REPLACE",
 /* 105 */ "cmd ::= DROP TABLE ifexists fullname",
 /* 106 */ "ifexists ::= IF EXISTS",
 /* 107 */ "ifexists ::=",
 /* 108 */ "cmd ::= CREATE temp VIEW ifnotexists nm dbnm AS select",
 /* 109 */ "cmd ::= DROP VIEW ifexists fullname",
 /* 110 */ "cmd ::= select",
 /* 111 */ "select ::= oneselect",
 /* 112 */ "select ::= select multiselect_op oneselect",
 /* 113 */ "multiselect_op ::= UNION",
 /* 114 */ "multiselect_op ::= UNION ALL",
 /* 115 */ "multiselect_op ::= EXCEPT|INTERSECT",
 /* 116 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
 /* 117 */ "distinct ::= DISTINCT",
 /* 118 */ "distinct ::= ALL",
 /* 119 */ "distinct ::=",
 /* 120 */ "sclp ::= selcollist COMMA",
 /* 121 */ "sclp ::=",
 /* 122 */ "selcollist ::= sclp expr as",
 /* 123 */ "selcollist ::= sclp STAR",
 /* 124 */ "selcollist ::= sclp nm DOT STAR",
 /* 125 */ "as ::= AS nm",
 /* 126 */ "as ::= ids",
 /* 127 */ "as ::=",
 /* 128 */ "from ::=",
 /* 129 */ "from ::= FROM seltablist",
 /* 130 */ "stl_prefix ::= seltablist joinop",
 /* 131 */ "stl_prefix ::=",
 /* 132 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
 /* 133 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
 /* 134 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
 /* 135 */ "dbnm ::=",
 /* 136 */ "dbnm ::= DOT nm",
 /* 137 */ "fullname ::= nm dbnm",
 /* 138 */ "joinop ::= COMMA|JOIN",
 /* 139 */ "joinop ::= JOIN_KW JOIN",
 /* 140 */ "joinop ::= JOIN_KW nm JOIN",
 /* 141 */ "joinop ::= JOIN_KW nm nm JOIN",
 /* 142 */ "on_opt ::= ON expr",
 /* 143 */ "on_opt ::=",
 /* 144 */ "indexed_opt ::=",
 /* 145 */ "indexed_opt ::= INDEXED BY nm",
 /* 146 */ "indexed_opt ::= NOT INDEXED",
 /* 147 */ "using_opt ::= USING LP inscollist RP",
 /* 148 */ "using_opt ::=",
 /* 149 */ "orderby_opt ::=",
 /* 150 */ "orderby_opt ::= ORDER BY sortlist",
 /* 151 */ "sortlist ::= sortlist COMMA sortitem sortorder",
 /* 152 */ "sortlist ::= sortitem sortorder",
 /* 153 */ "sortitem ::= expr",
 /* 154 */ "sortorder ::= ASC",
 /* 155 */ "sortorder ::= DESC",
 /* 156 */ "sortorder ::=",
 /* 157 */ "groupby_opt ::=",
 /* 158 */ "groupby_opt ::= GROUP BY nexprlist",
 /* 159 */ "having_opt ::=",
 /* 160 */ "having_opt ::= HAVING expr",
 /* 161 */ "limit_opt ::=",
 /* 162 */ "limit_opt ::= LIMIT expr",
 /* 163 */ "limit_opt ::= LIMIT expr OFFSET expr",
 /* 164 */ "limit_opt ::= LIMIT expr COMMA expr",
 /* 165 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
 /* 166 */ "where_opt ::=",
 /* 167 */ "where_opt ::= WHERE expr",
 /* 168 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
 /* 169 */ "setlist ::= setlist COMMA nm EQ expr",
 /* 170 */ "setlist ::= nm EQ expr",
 /* 171 */ "cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP",
 /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
 /* 173 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
 /* 174 */ "insert_cmd ::= INSERT orconf",
 /* 175 */ "insert_cmd ::= REPLACE",
 /* 176 */ "itemlist ::= itemlist COMMA expr",
 /* 177 */ "itemlist ::= expr",
 /* 178 */ "inscollist_opt ::=",
 /* 179 */ "inscollist_opt ::= LP inscollist RP",
 /* 180 */ "inscollist ::= inscollist COMMA nm",
 /* 181 */ "inscollist ::= nm",
 /* 182 */ "expr ::= term",
 /* 183 */ "expr ::= LP expr RP",
 /* 184 */ "term ::= NULL",
 /* 185 */ "expr ::= id",
 /* 186 */ "expr ::= JOIN_KW",
 /* 187 */ "expr ::= nm DOT nm",
 /* 188 */ "expr ::= nm DOT nm DOT nm",
 /* 189 */ "term ::= INTEGER|FLOAT|BLOB",
 /* 190 */ "term ::= STRING",
 /* 191 */ "expr ::= REGISTER",
 /* 192 */ "expr ::= VARIABLE",
 /* 193 */ "expr ::= expr COLLATE ids",
 /* 194 */ "expr ::= CAST LP expr AS typetoken RP",
 /* 195 */ "expr ::= ID LP distinct exprlist RP",
 /* 196 */ "expr ::= ID LP STAR RP",
 /* 197 */ "term ::= CTIME_KW",
 /* 198 */ "expr ::= expr AND expr",
 /* 199 */ "expr ::= expr OR expr",
 /* 200 */ "expr ::= expr LT|GT|GE|LE expr",
 /* 201 */ "expr ::= expr EQ|NE expr",
 /* 202 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
 /* 203 */ "expr ::= expr PLUS|MINUS expr",
 /* 204 */ "expr ::= expr STAR|SLASH|REM expr",
 /* 205 */ "expr ::= expr CONCAT expr",
 /* 206 */ "likeop ::= LIKE_KW",
 /* 207 */ "likeop ::= NOT LIKE_KW",
 /* 208 */ "likeop ::= MATCH",
 /* 209 */ "likeop ::= NOT MATCH",
 /* 210 */ "escape ::= ESCAPE expr",
 /* 211 */ "escape ::=",
 /* 212 */ "expr ::= expr likeop expr escape",
 /* 213 */ "expr ::= expr ISNULL|NOTNULL",
 /* 214 */ "expr ::= expr IS NULL",
 /* 215 */ "expr ::= expr NOT NULL",
 /* 216 */ "expr ::= expr IS NOT NULL",
 /* 217 */ "expr ::= NOT expr",
 /* 218 */ "expr ::= BITNOT expr",
 /* 219 */ "expr ::= MINUS expr",
 /* 220 */ "expr ::= PLUS expr",
 /* 221 */ "between_op ::= BETWEEN",
 /* 222 */ "between_op ::= NOT BETWEEN",
 /* 223 */ "expr ::= expr between_op expr AND expr",
 /* 224 */ "in_op ::= IN",
 /* 225 */ "in_op ::= NOT IN",
 /* 226 */ "expr ::= expr in_op LP exprlist RP",
 /* 227 */ "expr ::= LP select RP",
 /* 228 */ "expr ::= expr in_op LP select RP",
 /* 229 */ "expr ::= expr in_op nm dbnm",
 /* 230 */ "expr ::= EXISTS LP select RP",
 /* 231 */ "expr ::= CASE case_operand case_exprlist case_else END",
 /* 232 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
 /* 233 */ "case_exprlist ::= WHEN expr THEN expr",
 /* 234 */ "case_else ::= ELSE expr",
 /* 235 */ "case_else ::=",
 /* 236 */ "case_operand ::= expr",
 /* 237 */ "case_operand ::=",
 /* 238 */ "exprlist ::= nexprlist",
 /* 239 */ "exprlist ::=",
 /* 240 */ "nexprlist ::= nexprlist COMMA expr",
 /* 241 */ "nexprlist ::= expr",
 /* 242 */ "cmd ::= CREATE uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
 /* 243 */ "uniqueflag ::= UNIQUE",
 /* 244 */ "uniqueflag ::=",
 /* 245 */ "idxlist_opt ::=",
 /* 246 */ "idxlist_opt ::= LP idxlist RP",
 /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder",
 /* 248 */ "idxlist ::= nm collate sortorder",
 /* 249 */ "collate ::=",
 /* 250 */ "collate ::= COLLATE ids",
 /* 251 */ "cmd ::= DROP INDEX ifexists fullname",
 /* 252 */ "plus_num ::= plus_opt number",
 /* 253 */ "minus_num ::= MINUS number",
 /* 254 */ "number ::= INTEGER|FLOAT",
 /* 255 */ "plus_opt ::= PLUS",
 /* 256 */ "plus_opt ::=",
 /* 257 */ "cmd ::= CREATE trigger_decl BEGIN trigger_cmd_list END",
 /* 258 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
 /* 259 */ "trigger_time ::= BEFORE",
 /* 260 */ "trigger_time ::= AFTER",
 /* 261 */ "trigger_time ::= INSTEAD OF",
 /* 262 */ "trigger_time ::=",
 /* 263 */ "trigger_event ::= DELETE|INSERT",
 /* 264 */ "trigger_event ::= UPDATE",
 /* 265 */ "trigger_event ::= UPDATE OF inscollist",
 /* 266 */ "foreach_clause ::=",
 /* 267 */ "foreach_clause ::= FOR EACH ROW",
 /* 268 */ "when_clause ::=",
 /* 269 */ "when_clause ::= WHEN expr",
 /* 270 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
 /* 271 */ "trigger_cmd_list ::= trigger_cmd SEMI",
 /* 272 */ "trigger_cmd ::= UPDATE orconf nm SET setlist where_opt",
 /* 273 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP",
 /* 274 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt select",
 /* 275 */ "trigger_cmd ::= DELETE FROM nm where_opt",
 /* 276 */ "trigger_cmd ::= select",
 /* 277 */ "expr ::= RAISE LP IGNORE RP",
 /* 278 */ "expr ::= RAISE LP raisetype COMMA nm RP",
 /* 279 */ "raisetype ::= ROLLBACK",
 /* 280 */ "raisetype ::= ABORT",
 /* 281 */ "raisetype ::= FAIL",
 /* 282 */ "cmd ::= DROP TRIGGER ifexists fullname",
};
#endif /* NDEBUG */


#if YYSTACKDEPTH<=0
/*
** Try to increase the size of the parser stack.
................................................................................
    ** reduce or during error processing or when a parser is 
    ** being destroyed before it is finished parsing.
    **
    ** Note: during a reduce, the only symbols destroyed are those
    ** which appear on the RHS of the rule, but which are not used
    ** inside the C code.
    */
    case 157: /* select */
    case 191: /* oneselect */
{
sqlite3SelectDelete(pParse->db, (yypminor->yy465));
}
      break;
    case 171: /* term */
    case 172: /* expr */
    case 196: /* where_opt */
    case 198: /* having_opt */
    case 207: /* on_opt */
    case 212: /* sortitem */
    case 220: /* escape */
    case 223: /* case_operand */
    case 225: /* case_else */
    case 235: /* when_clause */
{
sqlite3ExprDelete(pParse->db, (yypminor->yy128));
}
      break;
    case 176: /* idxlist_opt */
    case 184: /* idxlist */
    case 194: /* selcollist */
    case 197: /* groupby_opt */
    case 199: /* orderby_opt */
    case 201: /* sclp */
    case 211: /* sortlist */
    case 213: /* nexprlist */
    case 214: /* setlist */
    case 217: /* itemlist */
    case 218: /* exprlist */
    case 224: /* case_exprlist */
{
sqlite3ExprListDelete(pParse->db, (yypminor->yy22));
}
      break;
    case 190: /* fullname */
    case 195: /* from */
    case 203: /* seltablist */
    case 204: /* stl_prefix */
{
sqlite3SrcListDelete(pParse->db, (yypminor->yy133));
}
      break;
    case 208: /* using_opt */
    case 210: /* inscollist */
    case 216: /* inscollist_opt */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy288));
}
      break;
    case 231: /* trigger_cmd_list */
    case 236: /* trigger_cmd */
{
sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy167));
}
      break;
    case 233: /* trigger_event */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy366).b);
}
      break;
    default:  break;   /* If no destructor action specified: do nothing */
  }
}

/*
................................................................................
  { 149, 1 },
  { 149, 0 },
  { 145, 2 },
  { 145, 3 },
  { 145, 5 },
  { 145, 2 },
  { 150, 6 },

  { 153, 0 },
  { 153, 3 },
  { 152, 1 },
  { 152, 0 },
  { 151, 4 },
  { 151, 2 },
  { 155, 3 },
  { 155, 1 },
  { 158, 3 },
  { 159, 1 },
  { 162, 1 },
  { 162, 1 },
  { 163, 1 },
  { 148, 1 },
  { 148, 1 },
  { 148, 1 },
  { 160, 0 },
  { 160, 1 },
  { 164, 1 },
  { 164, 4 },
  { 164, 6 },
  { 165, 1 },
  { 165, 2 },
  { 166, 1 },
  { 166, 1 },
  { 161, 2 },
  { 161, 0 },
  { 169, 3 },
  { 169, 1 },
  { 170, 2 },
  { 170, 4 },
  { 170, 3 },
  { 170, 3 },
  { 170, 2 },
  { 170, 2 },
  { 170, 3 },
  { 170, 5 },
  { 170, 2 },
  { 170, 4 },
  { 170, 4 },
  { 170, 1 },
  { 170, 2 },
  { 175, 0 },
  { 175, 1 },
  { 177, 0 },
  { 177, 2 },
  { 179, 2 },
  { 179, 3 },
  { 179, 3 },
  { 179, 3 },
  { 180, 2 },
  { 180, 2 },
  { 180, 1 },
  { 180, 1 },
  { 178, 3 },
  { 178, 2 },
  { 181, 0 },
  { 181, 2 },
  { 181, 2 },
  { 156, 0 },
  { 156, 2 },
  { 182, 3 },
  { 182, 2 },
  { 182, 1 },
  { 183, 2 },
  { 183, 7 },
  { 183, 5 },
  { 183, 5 },
  { 183, 10 },
  { 185, 0 },
  { 185, 1 },
  { 173, 0 },
  { 173, 3 },
  { 186, 0 },
  { 186, 2 },
  { 187, 1 },
  { 187, 1 },
  { 187, 1 },
  { 145, 4 },
  { 189, 2 },
  { 189, 0 },
  { 145, 8 },
  { 145, 4 },
  { 145, 1 },
  { 157, 1 },
  { 157, 3 },
  { 192, 1 },
  { 192, 2 },
  { 192, 1 },
  { 191, 9 },
  { 193, 1 },
  { 193, 1 },
  { 193, 0 },
  { 201, 2 },
  { 201, 0 },
  { 194, 3 },
  { 194, 2 },
  { 194, 4 },
  { 202, 2 },
  { 202, 1 },
  { 202, 0 },
  { 195, 0 },
  { 195, 2 },
  { 204, 2 },
  { 204, 0 },
  { 203, 7 },
  { 203, 7 },
  { 203, 7 },
  { 154, 0 },
  { 154, 2 },
  { 190, 2 },
  { 205, 1 },
  { 205, 2 },
  { 205, 3 },
  { 205, 4 },
  { 207, 2 },
  { 207, 0 },
  { 206, 0 },
  { 206, 3 },
  { 206, 2 },
  { 208, 4 },
  { 208, 0 },
  { 199, 0 },
  { 199, 3 },
  { 211, 4 },
  { 211, 2 },
  { 212, 1 },
  { 174, 1 },
  { 174, 1 },
  { 174, 0 },
  { 197, 0 },
  { 197, 3 },
  { 198, 0 },
  { 198, 2 },
  { 200, 0 },
  { 200, 2 },
  { 200, 4 },
  { 200, 4 },
  { 145, 5 },
  { 196, 0 },
  { 196, 2 },
  { 145, 7 },
  { 214, 5 },
  { 214, 3 },
  { 145, 8 },
  { 145, 5 },
  { 145, 6 },
  { 215, 2 },
  { 215, 1 },
  { 217, 3 },
  { 217, 1 },
  { 216, 0 },
  { 216, 3 },
  { 210, 3 },
  { 210, 1 },
  { 172, 1 },
  { 172, 3 },
  { 171, 1 },
  { 172, 1 },
  { 172, 1 },
  { 172, 3 },
  { 172, 5 },
  { 171, 1 },
  { 171, 1 },
  { 172, 1 },
  { 172, 1 },
  { 172, 3 },
  { 172, 6 },
  { 172, 5 },
  { 172, 4 },
  { 171, 1 },
  { 172, 3 },
  { 172, 3 },
  { 172, 3 },
  { 172, 3 },
  { 172, 3 },
  { 172, 3 },
  { 172, 3 },
  { 172, 3 },
  { 219, 1 },
  { 219, 2 },
  { 219, 1 },
  { 219, 2 },
  { 220, 2 },
  { 220, 0 },
  { 172, 4 },
  { 172, 2 },
  { 172, 3 },
  { 172, 3 },
  { 172, 4 },
  { 172, 2 },
  { 172, 2 },
  { 172, 2 },
  { 172, 2 },
  { 221, 1 },
  { 221, 2 },
  { 172, 5 },
  { 222, 1 },
  { 222, 2 },
  { 172, 5 },
  { 172, 3 },
  { 172, 5 },
  { 172, 4 },
  { 172, 4 },
  { 172, 5 },
  { 224, 5 },
  { 224, 4 },
  { 225, 2 },
  { 225, 0 },
  { 223, 1 },
  { 223, 0 },
  { 218, 1 },
  { 218, 0 },
  { 213, 3 },
  { 213, 1 },
  { 145, 11 },
  { 226, 1 },
  { 226, 0 },
  { 176, 0 },
  { 176, 3 },
  { 184, 5 },
  { 184, 3 },
  { 227, 0 },
  { 227, 2 },
  { 145, 4 },
  { 167, 2 },
  { 168, 2 },
  { 229, 1 },
  { 228, 1 },
  { 228, 0 },
  { 145, 5 },
  { 230, 11 },
  { 232, 1 },
  { 232, 1 },
  { 232, 2 },
  { 232, 0 },
  { 233, 1 },
  { 233, 1 },
  { 233, 3 },
  { 234, 0 },
  { 234, 3 },
  { 235, 0 },
  { 235, 2 },


  { 231, 3 },
  { 231, 2 },
  { 236, 6 },
  { 236, 8 },
  { 236, 5 },
  { 236, 4 },
  { 236, 1 },
  { 172, 4 },
  { 172, 6 },
  { 188, 1 },
  { 188, 1 },
  { 188, 1 },
  { 145, 4 },
};

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

/*
** Perform a reduce action and the shift that must immediately
................................................................................
      case 4: /* ecmd ::= explain cmdx SEMI */
      case 10: /* trans_opt ::= */
      case 11: /* trans_opt ::= TRANSACTION */
      case 12: /* trans_opt ::= TRANSACTION nm */
      case 20: /* savepoint_opt ::= SAVEPOINT */
      case 21: /* savepoint_opt ::= */
      case 25: /* cmd ::= create_table create_table_args */
      case 33: /* columnlist ::= columnlist COMMA column */
      case 34: /* columnlist ::= column */
      case 43: /* type ::= */
      case 50: /* signed ::= plus_num */
      case 51: /* signed ::= minus_num */
      case 52: /* carglist ::= carglist carg */
      case 53: /* carglist ::= */
      case 54: /* carg ::= CONSTRAINT nm ccons */
      case 55: /* carg ::= ccons */
      case 61: /* ccons ::= NULL onconf */
      case 88: /* conslist ::= conslist COMMA tcons */
      case 89: /* conslist ::= conslist tcons */
      case 90: /* conslist ::= tcons */
      case 91: /* tcons ::= CONSTRAINT nm */
      case 255: /* plus_opt ::= PLUS */
      case 256: /* plus_opt ::= */
      case 266: /* foreach_clause ::= */
      case 267: /* foreach_clause ::= FOR EACH ROW */
{
}
        break;
      case 5: /* explain ::= */
{ sqlite3BeginParse(pParse, 0); }
        break;
      case 6: /* explain ::= EXPLAIN */
................................................................................
      case 7: /* explain ::= EXPLAIN QUERY PLAN */
{ sqlite3BeginParse(pParse, 2); }
        break;
      case 8: /* cmdx ::= cmd */
{ sqlite3FinishCoding(pParse); }
        break;
      case 9: /* cmd ::= BEGIN transtype trans_opt */
{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy376);}
        break;
      case 13: /* transtype ::= */
{yygotominor.yy376 = TK_DEFERRED;}
        break;
      case 14: /* transtype ::= DEFERRED */
      case 15: /* transtype ::= IMMEDIATE */
      case 16: /* transtype ::= EXCLUSIVE */
      case 113: /* multiselect_op ::= UNION */
      case 115: /* multiselect_op ::= EXCEPT|INTERSECT */
{yygotominor.yy376 = yymsp[0].major;}
        break;
      case 17: /* cmd ::= COMMIT trans_opt */
      case 18: /* cmd ::= END trans_opt */
{sqlite3CommitTransaction(pParse);}
        break;
      case 19: /* cmd ::= ROLLBACK trans_opt */
{sqlite3RollbackTransaction(pParse);}
................................................................................
}
        break;
      case 24: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
{
  sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
}
        break;
      case 26: /* create_table ::= CREATE temp TABLE ifnotexists nm dbnm */
{
   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy376,0,0,yymsp[-2].minor.yy376);
}
        break;






      case 27: /* ifnotexists ::= */
      case 30: /* temp ::= */
      case 69: /* autoinc ::= */
      case 83: /* init_deferred_pred_opt ::= */
      case 85: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
      case 96: /* defer_subclause_opt ::= */
      case 107: /* ifexists ::= */
      case 118: /* distinct ::= ALL */
      case 119: /* distinct ::= */
      case 221: /* between_op ::= BETWEEN */
      case 224: /* in_op ::= IN */
{yygotominor.yy376 = 0;}
        break;
      case 28: /* ifnotexists ::= IF NOT EXISTS */
      case 29: /* temp ::= TEMP */
      case 70: /* autoinc ::= AUTOINCR */
      case 84: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
      case 106: /* ifexists ::= IF EXISTS */
      case 117: /* distinct ::= DISTINCT */
      case 222: /* between_op ::= NOT BETWEEN */
      case 225: /* in_op ::= NOT IN */
{yygotominor.yy376 = 1;}
        break;
      case 31: /* create_table_args ::= LP columnlist conslist_opt RP */
{
  sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0);
}
        break;
      case 32: /* create_table_args ::= AS select */
{
  sqlite3EndTable(pParse,0,0,yymsp[0].minor.yy465);
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy465);
}
        break;
      case 35: /* column ::= columnid type carglist */
{
  yygotominor.yy0.z = yymsp[-2].minor.yy0.z;
  yygotominor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-2].minor.yy0.z) + pParse->sLastToken.n;
}
        break;
      case 36: /* columnid ::= nm */
{
  sqlite3AddColumn(pParse,&yymsp[0].minor.yy0);
  yygotominor.yy0 = yymsp[0].minor.yy0;
}
        break;
      case 37: /* id ::= ID */
      case 38: /* id ::= INDEXED */
      case 39: /* ids ::= ID|STRING */
      case 40: /* nm ::= id */
      case 41: /* nm ::= STRING */
      case 42: /* nm ::= JOIN_KW */
      case 45: /* typetoken ::= typename */
      case 48: /* typename ::= ids */
      case 125: /* as ::= AS nm */
      case 126: /* as ::= ids */
      case 136: /* dbnm ::= DOT nm */
      case 145: /* indexed_opt ::= INDEXED BY nm */
      case 250: /* collate ::= COLLATE ids */
      case 252: /* plus_num ::= plus_opt number */
      case 253: /* minus_num ::= MINUS number */
      case 254: /* number ::= INTEGER|FLOAT */
{yygotominor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 44: /* type ::= typetoken */
{sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
        break;
      case 46: /* typetoken ::= typename LP signed RP */
{
  yygotominor.yy0.z = yymsp[-3].minor.yy0.z;
  yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);
}
        break;
      case 47: /* typetoken ::= typename LP signed COMMA signed RP */
{
  yygotominor.yy0.z = yymsp[-5].minor.yy0.z;
  yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);
}
        break;
      case 49: /* typename ::= typename ids */
{yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
        break;
      case 56: /* ccons ::= DEFAULT term */
      case 58: /* ccons ::= DEFAULT PLUS term */
{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy128);}
        break;
      case 57: /* ccons ::= DEFAULT LP expr RP */
{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy128);}
        break;
      case 59: /* ccons ::= DEFAULT MINUS term */
{
  Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy128, 0, 0);
  sqlite3ExprSpan(p,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy128->span);
  sqlite3AddDefaultValue(pParse,p);
}
        break;
      case 60: /* ccons ::= DEFAULT id */
{
  Expr *p = sqlite3PExpr(pParse, TK_STRING, 0, 0, &yymsp[0].minor.yy0);
  sqlite3AddDefaultValue(pParse,p);
}
        break;
      case 62: /* ccons ::= NOT NULL onconf */
{sqlite3AddNotNull(pParse, yymsp[0].minor.yy376);}
        break;
      case 63: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy376,yymsp[0].minor.yy376,yymsp[-2].minor.yy376);}
        break;
      case 64: /* ccons ::= UNIQUE onconf */
{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy376,0,0,0,0);}
        break;
      case 65: /* ccons ::= CHECK LP expr RP */
{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy128);}
        break;
      case 66: /* ccons ::= REFERENCES nm idxlist_opt refargs */
{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy22,yymsp[0].minor.yy376);}
        break;
      case 67: /* ccons ::= defer_subclause */
{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy376);}
        break;
      case 68: /* ccons ::= COLLATE ids */
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
        break;
      case 71: /* refargs ::= */
{ yygotominor.yy376 = OE_Restrict * 0x010101; }
        break;
      case 72: /* refargs ::= refargs refarg */
{ yygotominor.yy376 = (yymsp[-1].minor.yy376 & ~yymsp[0].minor.yy299.mask) | yymsp[0].minor.yy299.value; }
        break;
      case 73: /* refarg ::= MATCH nm */
{ yygotominor.yy299.value = 0;     yygotominor.yy299.mask = 0x000000; }
        break;
      case 74: /* refarg ::= ON DELETE refact */
{ yygotominor.yy299.value = yymsp[0].minor.yy376;     yygotominor.yy299.mask = 0x0000ff; }
        break;
      case 75: /* refarg ::= ON UPDATE refact */
{ yygotominor.yy299.value = yymsp[0].minor.yy376<<8;  yygotominor.yy299.mask = 0x00ff00; }
        break;
      case 76: /* refarg ::= ON INSERT refact */
{ yygotominor.yy299.value = yymsp[0].minor.yy376<<16; yygotominor.yy299.mask = 0xff0000; }
        break;
      case 77: /* refact ::= SET NULL */
{ yygotominor.yy376 = OE_SetNull; }
        break;
      case 78: /* refact ::= SET DEFAULT */
{ yygotominor.yy376 = OE_SetDflt; }
        break;
      case 79: /* refact ::= CASCADE */
{ yygotominor.yy376 = OE_Cascade; }
        break;
      case 80: /* refact ::= RESTRICT */
{ yygotominor.yy376 = OE_Restrict; }
        break;
      case 81: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
      case 82: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
      case 97: /* defer_subclause_opt ::= defer_subclause */
      case 99: /* onconf ::= ON CONFLICT resolvetype */
      case 101: /* orconf ::= OR resolvetype */
      case 102: /* resolvetype ::= raisetype */
      case 174: /* insert_cmd ::= INSERT orconf */
{yygotominor.yy376 = yymsp[0].minor.yy376;}
        break;
      case 86: /* conslist_opt ::= */
{yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}
        break;
      case 87: /* conslist_opt ::= COMMA conslist */
{yygotominor.yy0 = yymsp[-1].minor.yy0;}
        break;
      case 92: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy22,yymsp[0].minor.yy376,yymsp[-2].minor.yy376,0);}
        break;
      case 93: /* tcons ::= UNIQUE LP idxlist RP onconf */
{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy22,yymsp[0].minor.yy376,0,0,0,0);}
        break;
      case 94: /* tcons ::= CHECK LP expr RP onconf */
{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy128);}
        break;
      case 95: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
{
    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy22, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy22, yymsp[-1].minor.yy376);
    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy376);
}
        break;
      case 98: /* onconf ::= */
      case 100: /* orconf ::= */
{yygotominor.yy376 = OE_Default;}
        break;
      case 103: /* resolvetype ::= IGNORE */
{yygotominor.yy376 = OE_Ignore;}
        break;
      case 104: /* resolvetype ::= REPLACE */
      case 175: /* insert_cmd ::= REPLACE */
{yygotominor.yy376 = OE_Replace;}
        break;
      case 105: /* cmd ::= DROP TABLE ifexists fullname */
{
  sqlite3DropTable(pParse, yymsp[0].minor.yy133, 0, yymsp[-1].minor.yy376);
}
        break;
      case 108: /* cmd ::= CREATE temp VIEW ifnotexists nm dbnm AS select */
{
  sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy465, yymsp[-6].minor.yy376, yymsp[-4].minor.yy376);
}
        break;
      case 109: /* cmd ::= DROP VIEW ifexists fullname */
{
  sqlite3DropTable(pParse, yymsp[0].minor.yy133, 1, yymsp[-1].minor.yy376);
}
        break;
      case 110: /* cmd ::= select */
{
  SelectDest dest = {SRT_Output, 0, 0, 0, 0};
  sqlite3Select(pParse, yymsp[0].minor.yy465, &dest);
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy465);
}
        break;
      case 111: /* select ::= oneselect */
{yygotominor.yy465 = yymsp[0].minor.yy465;}
        break;
      case 112: /* select ::= select multiselect_op oneselect */
{
  if( yymsp[0].minor.yy465 ){
    yymsp[0].minor.yy465->op = (u8)yymsp[-1].minor.yy376;
    yymsp[0].minor.yy465->pPrior = yymsp[-2].minor.yy465;
  }else{
    sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy465);
  }
  yygotominor.yy465 = yymsp[0].minor.yy465;
}
        break;
      case 114: /* multiselect_op ::= UNION ALL */
{yygotominor.yy376 = TK_ALL;}
        break;
      case 116: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
{
  yygotominor.yy465 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy22,yymsp[-5].minor.yy133,yymsp[-4].minor.yy128,yymsp[-3].minor.yy22,yymsp[-2].minor.yy128,yymsp[-1].minor.yy22,yymsp[-7].minor.yy376,yymsp[0].minor.yy4.pLimit,yymsp[0].minor.yy4.pOffset);
}
        break;
      case 120: /* sclp ::= selcollist COMMA */
      case 246: /* idxlist_opt ::= LP idxlist RP */
{yygotominor.yy22 = yymsp[-1].minor.yy22;}
        break;
      case 121: /* sclp ::= */
      case 149: /* orderby_opt ::= */
      case 157: /* groupby_opt ::= */
      case 239: /* exprlist ::= */
      case 245: /* idxlist_opt ::= */
{yygotominor.yy22 = 0;}
        break;
      case 122: /* selcollist ::= sclp expr as */
{
   yygotominor.yy22 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy22,yymsp[-1].minor.yy128,yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
}
        break;
      case 123: /* selcollist ::= sclp STAR */
{
  Expr *p = sqlite3PExpr(pParse, TK_ALL, 0, 0, 0);
  yygotominor.yy22 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy22, p, 0);
}
        break;
      case 124: /* selcollist ::= sclp nm DOT STAR */
{
  Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);
  Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
  Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
  yygotominor.yy22 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy22, pDot, 0);
}
        break;
      case 127: /* as ::= */
{yygotominor.yy0.n = 0;}
        break;
      case 128: /* from ::= */
{yygotominor.yy133 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy133));}
        break;
      case 129: /* from ::= FROM seltablist */
{
  yygotominor.yy133 = yymsp[0].minor.yy133;
  sqlite3SrcListShiftJoinType(yygotominor.yy133);
}
        break;
      case 130: /* stl_prefix ::= seltablist joinop */
{
   yygotominor.yy133 = yymsp[-1].minor.yy133;
   if( yygotominor.yy133 && yygotominor.yy133->nSrc>0 ) yygotominor.yy133->a[yygotominor.yy133->nSrc-1].jointype = (u8)yymsp[0].minor.yy376;
}
        break;
      case 131: /* stl_prefix ::= */
{yygotominor.yy133 = 0;}
        break;
      case 132: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
{
  yygotominor.yy133 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy133,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy128,yymsp[0].minor.yy288);
  sqlite3SrcListIndexedBy(pParse, yygotominor.yy133, &yymsp[-2].minor.yy0);
}
        break;
      case 133: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
{
    yygotominor.yy133 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy133,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy465,yymsp[-1].minor.yy128,yymsp[0].minor.yy288);
  }
        break;
      case 134: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
{
    if( yymsp[-6].minor.yy133==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy128==0 && yymsp[0].minor.yy288==0 ){
      yygotominor.yy133 = yymsp[-4].minor.yy133;
    }else{
      Select *pSubquery;
      sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy133);
      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy133,0,0,0,0,0,0,0);
      yygotominor.yy133 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy133,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy128,yymsp[0].minor.yy288);
    }
  }
        break;
      case 135: /* dbnm ::= */
      case 144: /* indexed_opt ::= */
{yygotominor.yy0.z=0; yygotominor.yy0.n=0;}
        break;
      case 137: /* fullname ::= nm dbnm */
{yygotominor.yy133 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
        break;
      case 138: /* joinop ::= COMMA|JOIN */
{ yygotominor.yy376 = JT_INNER; }
        break;
      case 139: /* joinop ::= JOIN_KW JOIN */
{ yygotominor.yy376 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
        break;
      case 140: /* joinop ::= JOIN_KW nm JOIN */
{ yygotominor.yy376 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
        break;
      case 141: /* joinop ::= JOIN_KW nm nm JOIN */
{ yygotominor.yy376 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
        break;
      case 142: /* on_opt ::= ON expr */
      case 153: /* sortitem ::= expr */
      case 160: /* having_opt ::= HAVING expr */
      case 167: /* where_opt ::= WHERE expr */
      case 182: /* expr ::= term */
      case 210: /* escape ::= ESCAPE expr */
      case 234: /* case_else ::= ELSE expr */
      case 236: /* case_operand ::= expr */
{yygotominor.yy128 = yymsp[0].minor.yy128;}
        break;
      case 143: /* on_opt ::= */
      case 159: /* having_opt ::= */
      case 166: /* where_opt ::= */
      case 211: /* escape ::= */
      case 235: /* case_else ::= */
      case 237: /* case_operand ::= */
{yygotominor.yy128 = 0;}
        break;
      case 146: /* indexed_opt ::= NOT INDEXED */
{yygotominor.yy0.z=0; yygotominor.yy0.n=1;}
        break;
      case 147: /* using_opt ::= USING LP inscollist RP */
      case 179: /* inscollist_opt ::= LP inscollist RP */
{yygotominor.yy288 = yymsp[-1].minor.yy288;}
        break;
      case 148: /* using_opt ::= */
      case 178: /* inscollist_opt ::= */
{yygotominor.yy288 = 0;}
        break;
      case 150: /* orderby_opt ::= ORDER BY sortlist */
      case 158: /* groupby_opt ::= GROUP BY nexprlist */
      case 238: /* exprlist ::= nexprlist */
{yygotominor.yy22 = yymsp[0].minor.yy22;}
        break;
      case 151: /* sortlist ::= sortlist COMMA sortitem sortorder */
{
  yygotominor.yy22 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy22,yymsp[-1].minor.yy128,0);
  if( yygotominor.yy22 ) yygotominor.yy22->a[yygotominor.yy22->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy376;
}
        break;
      case 152: /* sortlist ::= sortitem sortorder */
{
  yygotominor.yy22 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy128,0);
  if( yygotominor.yy22 && yygotominor.yy22->a ) yygotominor.yy22->a[0].sortOrder = (u8)yymsp[0].minor.yy376;
}
        break;
      case 154: /* sortorder ::= ASC */
      case 156: /* sortorder ::= */
{yygotominor.yy376 = SQLITE_SO_ASC;}
        break;
      case 155: /* sortorder ::= DESC */
{yygotominor.yy376 = SQLITE_SO_DESC;}
        break;
      case 161: /* limit_opt ::= */
{yygotominor.yy4.pLimit = 0; yygotominor.yy4.pOffset = 0;}
        break;
      case 162: /* limit_opt ::= LIMIT expr */
{yygotominor.yy4.pLimit = yymsp[0].minor.yy128; yygotominor.yy4.pOffset = 0;}
        break;
      case 163: /* limit_opt ::= LIMIT expr OFFSET expr */
{yygotominor.yy4.pLimit = yymsp[-2].minor.yy128; yygotominor.yy4.pOffset = yymsp[0].minor.yy128;}
        break;
      case 164: /* limit_opt ::= LIMIT expr COMMA expr */
{yygotominor.yy4.pOffset = yymsp[-2].minor.yy128; yygotominor.yy4.pLimit = yymsp[0].minor.yy128;}
        break;
      case 165: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
{
  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy133, &yymsp[-1].minor.yy0);
  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy133,yymsp[0].minor.yy128);
}
        break;
      case 168: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
{
  sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy133, &yymsp[-3].minor.yy0);
  sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy22,"set list"); 
  sqlite3Update(pParse,yymsp[-4].minor.yy133,yymsp[-1].minor.yy22,yymsp[0].minor.yy128,yymsp[-5].minor.yy376);
}
        break;
      case 169: /* setlist ::= setlist COMMA nm EQ expr */
{yygotominor.yy22 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy22,yymsp[0].minor.yy128,&yymsp[-2].minor.yy0);}
        break;
      case 170: /* setlist ::= nm EQ expr */
{yygotominor.yy22 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy128,&yymsp[-2].minor.yy0);}
        break;
      case 171: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */
{sqlite3Insert(pParse, yymsp[-5].minor.yy133, yymsp[-1].minor.yy22, 0, yymsp[-4].minor.yy288, yymsp[-7].minor.yy376);}
        break;
      case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
{sqlite3Insert(pParse, yymsp[-2].minor.yy133, 0, yymsp[0].minor.yy465, yymsp[-1].minor.yy288, yymsp[-4].minor.yy376);}
        break;
      case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
{sqlite3Insert(pParse, yymsp[-3].minor.yy133, 0, 0, yymsp[-2].minor.yy288, yymsp[-5].minor.yy376);}
        break;
      case 176: /* itemlist ::= itemlist COMMA expr */
      case 240: /* nexprlist ::= nexprlist COMMA expr */
{yygotominor.yy22 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy22,yymsp[0].minor.yy128,0);}
        break;
      case 177: /* itemlist ::= expr */
      case 241: /* nexprlist ::= expr */
{yygotominor.yy22 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy128,0);}
        break;
      case 180: /* inscollist ::= inscollist COMMA nm */
{yygotominor.yy288 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy288,&yymsp[0].minor.yy0);}
        break;
      case 181: /* inscollist ::= nm */
{yygotominor.yy288 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
        break;
      case 183: /* expr ::= LP expr RP */
{yygotominor.yy128 = yymsp[-1].minor.yy128; sqlite3ExprSpan(yygotominor.yy128,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); }
        break;
      case 184: /* term ::= NULL */
      case 189: /* term ::= INTEGER|FLOAT|BLOB */
      case 190: /* term ::= STRING */
{yygotominor.yy128 = sqlite3PExpr(pParse, yymsp[0].major, 0, 0, &yymsp[0].minor.yy0);}
        break;
      case 185: /* expr ::= id */
      case 186: /* expr ::= JOIN_KW */
{yygotominor.yy128 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);}
        break;
      case 187: /* expr ::= nm DOT nm */
{
  Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
  Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
  yygotominor.yy128 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
}
        break;
      case 188: /* expr ::= nm DOT nm DOT nm */
{
  Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
  Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
  Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
  Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
  yygotominor.yy128 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
}
        break;
      case 191: /* expr ::= REGISTER */
{yygotominor.yy128 = sqlite3RegisterExpr(pParse, &yymsp[0].minor.yy0);}
        break;
      case 192: /* expr ::= VARIABLE */
{
  Token *pToken = &yymsp[0].minor.yy0;
  Expr *pExpr = yygotominor.yy128 = sqlite3PExpr(pParse, TK_VARIABLE, 0, 0, pToken);
  sqlite3ExprAssignVarNumber(pParse, pExpr);
}
        break;
      case 193: /* expr ::= expr COLLATE ids */
{
  yygotominor.yy128 = sqlite3ExprSetColl(pParse, yymsp[-2].minor.yy128, &yymsp[0].minor.yy0);
}
        break;
      case 194: /* expr ::= CAST LP expr AS typetoken RP */
{
  yygotominor.yy128 = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy128, 0, &yymsp[-1].minor.yy0);
  sqlite3ExprSpan(yygotominor.yy128,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);
}
        break;
      case 195: /* expr ::= ID LP distinct exprlist RP */
{
  if( yymsp[-1].minor.yy22 && yymsp[-1].minor.yy22->nExpr>SQLITE_MAX_FUNCTION_ARG ){
    sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
  }
  yygotominor.yy128 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy22, &yymsp[-4].minor.yy0);
  sqlite3ExprSpan(yygotominor.yy128,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
  if( yymsp[-2].minor.yy376 && yygotominor.yy128 ){
    yygotominor.yy128->flags |= EP_Distinct;
  }
}
        break;
      case 196: /* expr ::= ID LP STAR RP */
{
  yygotominor.yy128 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
  sqlite3ExprSpan(yygotominor.yy128,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
}
        break;
      case 197: /* term ::= CTIME_KW */
{
  /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are
  ** treated as functions that return constants */
  yygotominor.yy128 = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
  if( yygotominor.yy128 ){
    yygotominor.yy128->op = TK_CONST_FUNC;  
    yygotominor.yy128->span = yymsp[0].minor.yy0;
  }
}
        break;
      case 198: /* expr ::= expr AND expr */
      case 199: /* expr ::= expr OR expr */
      case 200: /* expr ::= expr LT|GT|GE|LE expr */
      case 201: /* expr ::= expr EQ|NE expr */
      case 202: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
      case 203: /* expr ::= expr PLUS|MINUS expr */
      case 204: /* expr ::= expr STAR|SLASH|REM expr */
      case 205: /* expr ::= expr CONCAT expr */
{yygotominor.yy128 = sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy128,yymsp[0].minor.yy128,0);}
        break;
      case 206: /* likeop ::= LIKE_KW */
      case 208: /* likeop ::= MATCH */
{yygotominor.yy450.eOperator = yymsp[0].minor.yy0; yygotominor.yy450.not = 0;}
        break;
      case 207: /* likeop ::= NOT LIKE_KW */
      case 209: /* likeop ::= NOT MATCH */
{yygotominor.yy450.eOperator = yymsp[0].minor.yy0; yygotominor.yy450.not = 1;}
        break;
      case 212: /* expr ::= expr likeop expr escape */
{
  ExprList *pList;
  pList = sqlite3ExprListAppend(pParse,0, yymsp[-1].minor.yy128, 0);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-3].minor.yy128, 0);
  if( yymsp[0].minor.yy128 ){
    pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy128, 0);
  }
  yygotominor.yy128 = sqlite3ExprFunction(pParse, pList, &yymsp[-2].minor.yy450.eOperator);
  if( yymsp[-2].minor.yy450.not ) yygotominor.yy128 = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy128, 0, 0);
  sqlite3ExprSpan(yygotominor.yy128, &yymsp[-3].minor.yy128->span, &yymsp[-1].minor.yy128->span);
  if( yygotominor.yy128 ) yygotominor.yy128->flags |= EP_InfixFunc;
}
        break;
      case 213: /* expr ::= expr ISNULL|NOTNULL */
{
  yygotominor.yy128 = sqlite3PExpr(pParse, yymsp[0].major, yymsp[-1].minor.yy128, 0, 0);
  sqlite3ExprSpan(yygotominor.yy128,&yymsp[-1].minor.yy128->span,&yymsp[0].minor.yy0);
}
        break;
      case 214: /* expr ::= expr IS NULL */
{
  yygotominor.yy128 = sqlite3PExpr(pParse, TK_ISNULL, yymsp[-2].minor.yy128, 0, 0);
  sqlite3ExprSpan(yygotominor.yy128,&yymsp[-2].minor.yy128->span,&yymsp[0].minor.yy0);
}
        break;
      case 215: /* expr ::= expr NOT NULL */
{
  yygotominor.yy128 = sqlite3PExpr(pParse, TK_NOTNULL, yymsp[-2].minor.yy128, 0, 0);
  sqlite3ExprSpan(yygotominor.yy128,&yymsp[-2].minor.yy128->span,&yymsp[0].minor.yy0);
}
        break;
      case 216: /* expr ::= expr IS NOT NULL */
{
  yygotominor.yy128 = sqlite3PExpr(pParse, TK_NOTNULL, yymsp[-3].minor.yy128, 0, 0);
  sqlite3ExprSpan(yygotominor.yy128,&yymsp[-3].minor.yy128->span,&yymsp[0].minor.yy0);
}
        break;
      case 217: /* expr ::= NOT expr */
      case 218: /* expr ::= BITNOT expr */
{
  yygotominor.yy128 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy128, 0, 0);
  sqlite3ExprSpan(yygotominor.yy128,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy128->span);
}
        break;
      case 219: /* expr ::= MINUS expr */
{
  yygotominor.yy128 = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy128, 0, 0);
  sqlite3ExprSpan(yygotominor.yy128,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy128->span);
}
        break;
      case 220: /* expr ::= PLUS expr */
{
  yygotominor.yy128 = sqlite3PExpr(pParse, TK_UPLUS, yymsp[0].minor.yy128, 0, 0);
  sqlite3ExprSpan(yygotominor.yy128,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy128->span);
}
        break;
      case 223: /* expr ::= expr between_op expr AND expr */
{
  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy128, 0);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy128, 0);
  yygotominor.yy128 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy128, 0, 0);
  if( yygotominor.yy128 ){
    yygotominor.yy128->x.pList = pList;
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  } 
  if( yymsp[-3].minor.yy376 ) yygotominor.yy128 = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy128, 0, 0);
  sqlite3ExprSpan(yygotominor.yy128,&yymsp[-4].minor.yy128->span,&yymsp[0].minor.yy128->span);
}
        break;
      case 226: /* expr ::= expr in_op LP exprlist RP */
{
    yygotominor.yy128 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy128, 0, 0);
    if( yygotominor.yy128 ){
      yygotominor.yy128->x.pList = yymsp[-1].minor.yy22;
      sqlite3ExprSetHeight(pParse, yygotominor.yy128);
    }else{
      sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy22);
    }
    if( yymsp[-3].minor.yy376 ) yygotominor.yy128 = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy128, 0, 0);
    sqlite3ExprSpan(yygotominor.yy128,&yymsp[-4].minor.yy128->span,&yymsp[0].minor.yy0);
  }
        break;
      case 227: /* expr ::= LP select RP */
{
    yygotominor.yy128 = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
    if( yygotominor.yy128 ){
      yygotominor.yy128->x.pSelect = yymsp[-1].minor.yy465;
      ExprSetProperty(yygotominor.yy128, EP_xIsSelect);
      sqlite3ExprSetHeight(pParse, yygotominor.yy128);
    }else{
      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy465);
    }
    sqlite3ExprSpan(yygotominor.yy128,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
  }
        break;
      case 228: /* expr ::= expr in_op LP select RP */
{
    yygotominor.yy128 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy128, 0, 0);
    if( yygotominor.yy128 ){
      yygotominor.yy128->x.pSelect = yymsp[-1].minor.yy465;
      ExprSetProperty(yygotominor.yy128, EP_xIsSelect);
      sqlite3ExprSetHeight(pParse, yygotominor.yy128);
    }else{
      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy465);
    }
    if( yymsp[-3].minor.yy376 ) yygotominor.yy128 = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy128, 0, 0);
    sqlite3ExprSpan(yygotominor.yy128,&yymsp[-4].minor.yy128->span,&yymsp[0].minor.yy0);
  }
        break;
      case 229: /* expr ::= expr in_op nm dbnm */
{
    SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
    yygotominor.yy128 = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy128, 0, 0);
    if( yygotominor.yy128 ){
      yygotominor.yy128->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
      ExprSetProperty(yygotominor.yy128, EP_xIsSelect);
      sqlite3ExprSetHeight(pParse, yygotominor.yy128);
    }else{
      sqlite3SrcListDelete(pParse->db, pSrc);
    }
    if( yymsp[-2].minor.yy376 ) yygotominor.yy128 = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy128, 0, 0);
    sqlite3ExprSpan(yygotominor.yy128,&yymsp[-3].minor.yy128->span,yymsp[0].minor.yy0.z?&yymsp[0].minor.yy0:&yymsp[-1].minor.yy0);
  }
        break;
      case 230: /* expr ::= EXISTS LP select RP */
{
    Expr *p = yygotominor.yy128 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
    if( p ){
      p->x.pSelect = yymsp[-1].minor.yy465;
      ExprSetProperty(yygotominor.yy128, EP_xIsSelect);
      sqlite3ExprSpan(p,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
      sqlite3ExprSetHeight(pParse, yygotominor.yy128);
    }else{
      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy465);
    }
  }
        break;
      case 231: /* expr ::= CASE case_operand case_exprlist case_else END */
{
  yygotominor.yy128 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy128, yymsp[-1].minor.yy128, 0);
  if( yygotominor.yy128 ){
    yygotominor.yy128->x.pList = yymsp[-2].minor.yy22;
    sqlite3ExprSetHeight(pParse, yygotominor.yy128);
  }else{
    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy22);
  }
  sqlite3ExprSpan(yygotominor.yy128, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0);
}
        break;
      case 232: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
  yygotominor.yy22 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy22, yymsp[-2].minor.yy128, 0);
  yygotominor.yy22 = sqlite3ExprListAppend(pParse,yygotominor.yy22, yymsp[0].minor.yy128, 0);
}
        break;
      case 233: /* case_exprlist ::= WHEN expr THEN expr */
{
  yygotominor.yy22 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy128, 0);
  yygotominor.yy22 = sqlite3ExprListAppend(pParse,yygotominor.yy22, yymsp[0].minor.yy128, 0);
}
        break;
      case 242: /* cmd ::= CREATE uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
{
  sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0, 
                     sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy22, yymsp[-9].minor.yy376,
                      &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy376);
}
        break;
      case 243: /* uniqueflag ::= UNIQUE */
      case 280: /* raisetype ::= ABORT */
{yygotominor.yy376 = OE_Abort;}
        break;
      case 244: /* uniqueflag ::= */
{yygotominor.yy376 = OE_None;}
        break;
      case 247: /* idxlist ::= idxlist COMMA nm collate sortorder */












{
  Expr *p = 0;
  if( yymsp[-1].minor.yy0.n>0 ){
    p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
    sqlite3ExprSetColl(pParse, p, &yymsp[-1].minor.yy0);
  }
  yygotominor.yy22 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy22, p, &yymsp[-2].minor.yy0);
  sqlite3ExprListCheckLength(pParse, yygotominor.yy22, "index");
  if( yygotominor.yy22 ) yygotominor.yy22->a[yygotominor.yy22->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy376;
}
        break;
      case 248: /* idxlist ::= nm collate sortorder */
{
  Expr *p = 0;
  if( yymsp[-1].minor.yy0.n>0 ){
    p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
    sqlite3ExprSetColl(pParse, p, &yymsp[-1].minor.yy0);
  }
  yygotominor.yy22 = sqlite3ExprListAppend(pParse,0, p, &yymsp[-2].minor.yy0);
  sqlite3ExprListCheckLength(pParse, yygotominor.yy22, "index");
  if( yygotominor.yy22 ) yygotominor.yy22->a[yygotominor.yy22->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy376;
}
        break;
      case 249: /* collate ::= */
{yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}
        break;
      case 251: /* cmd ::= DROP INDEX ifexists fullname */
{sqlite3DropIndex(pParse, yymsp[0].minor.yy133, yymsp[-1].minor.yy376);}
        break;
      case 257: /* cmd ::= CREATE 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.yy167, &all);
}
        break;
      case 258: /* 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.yy376, yymsp[-4].minor.yy366.a, yymsp[-4].minor.yy366.b, yymsp[-2].minor.yy133, yymsp[0].minor.yy128, yymsp[-10].minor.yy376, yymsp[-8].minor.yy376);
  yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
}
        break;
      case 259: /* trigger_time ::= BEFORE */
      case 262: /* trigger_time ::= */
{ yygotominor.yy376 = TK_BEFORE; }
        break;
      case 260: /* trigger_time ::= AFTER */
{ yygotominor.yy376 = TK_AFTER;  }
        break;
      case 261: /* trigger_time ::= INSTEAD OF */
{ yygotominor.yy376 = TK_INSTEAD;}
        break;
      case 263: /* trigger_event ::= DELETE|INSERT */
      case 264: /* trigger_event ::= UPDATE */
{yygotominor.yy366.a = yymsp[0].major; yygotominor.yy366.b = 0;}
        break;
      case 265: /* trigger_event ::= UPDATE OF inscollist */
{yygotominor.yy366.a = TK_UPDATE; yygotominor.yy366.b = yymsp[0].minor.yy288;}
        break;
      case 268: /* when_clause ::= */
{ yygotominor.yy128 = 0; }
        break;
      case 269: /* when_clause ::= WHEN expr */
{ yygotominor.yy128 = yymsp[0].minor.yy128; }
        break;
      case 270: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
/*
  if( yymsp[-2].minor.yy167 ){
    yymsp[-2].minor.yy167->pLast->pNext = yymsp[-1].minor.yy167;
  }else{
    yymsp[-2].minor.yy167 = yymsp[-1].minor.yy167;
  }
*/
  assert( yymsp[-2].minor.yy167!=0 );
  yymsp[-2].minor.yy167->pLast->pNext = yymsp[-1].minor.yy167;
  yymsp[-2].minor.yy167->pLast = yymsp[-1].minor.yy167;
  yygotominor.yy167 = yymsp[-2].minor.yy167;
}
        break;
      case 271: /* trigger_cmd_list ::= trigger_cmd SEMI */
{ 
  /* if( yymsp[-1].minor.yy167 ) */
  assert( yymsp[-1].minor.yy167!=0 );
  yymsp[-1].minor.yy167->pLast = yymsp[-1].minor.yy167;
  yygotominor.yy167 = yymsp[-1].minor.yy167;
}
        break;
      case 272: /* trigger_cmd ::= UPDATE orconf nm SET setlist where_opt */
{ yygotominor.yy167 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy22, yymsp[0].minor.yy128, yymsp[-4].minor.yy376); }
        break;
      case 273: /* trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP */
{yygotominor.yy167 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy288, yymsp[-1].minor.yy22, 0, yymsp[-7].minor.yy376);}
        break;
      case 274: /* trigger_cmd ::= insert_cmd INTO nm inscollist_opt select */
{yygotominor.yy167 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy288, 0, yymsp[0].minor.yy465, yymsp[-4].minor.yy376);}
        break;
      case 275: /* trigger_cmd ::= DELETE FROM nm where_opt */
{yygotominor.yy167 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-1].minor.yy0, yymsp[0].minor.yy128);}
        break;
      case 276: /* trigger_cmd ::= select */
{yygotominor.yy167 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy465); }
        break;
      case 277: /* expr ::= RAISE LP IGNORE RP */
{
  yygotominor.yy128 = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); 
  if( yygotominor.yy128 ){
    yygotominor.yy128->affinity = OE_Ignore;
    sqlite3ExprSpan(yygotominor.yy128, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0);









  }
}
        break;
      case 278: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
  yygotominor.yy128 = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); 
  if( yygotominor.yy128 ) {
    yygotominor.yy128->affinity = (char)yymsp[-3].minor.yy376;
    sqlite3ExprSpan(yygotominor.yy128, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0);
  }
}
        break;
      case 279: /* raisetype ::= ROLLBACK */
{yygotominor.yy376 = OE_Rollback;}
        break;
      case 281: /* raisetype ::= FAIL */
{yygotominor.yy376 = OE_Fail;}
        break;
      case 282: /* cmd ::= DROP TRIGGER ifexists fullname */
{
  sqlite3DropTrigger(pParse,yymsp[0].minor.yy133,yymsp[-1].minor.yy376);
}
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
................................................................................
*************************************************************************
** An tokenizer for SQL
**
** This file contains C code that splits an SQL input string up into
** individual tokens and sends those tokens one-by-one over to the
** parser for analysis.
**
** $Id: tokenize.c,v 1.153 2009/01/20 16:53:41 danielk1977 Exp $
*/

/*
** The charMap() macro maps alphabetic characters into their
** lower-case ASCII equivalent.  On ASCII machines, this is just
** an upper-to-lower case map.  On EBCDIC machines we also need
** to adjust the encoding.  Only alphabetic characters and underscores
................................................................................
** Run the parser on the given SQL string.  The parser structure is
** passed in.  An SQLITE_ status code is returned.  If an error occurs
** then an and attempt is made to write an error message into 
** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that
** error message.
*/
SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
  int nErr = 0;
  int i;
  void *pEngine;
  int tokenType;
  int lastTokenParsed = -1;

  sqlite3 *db = pParse->db;
  int mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];




  if( db->activeVdbeCnt==0 ){
    db->u1.isInterrupted = 0;
  }
  pParse->rc = SQLITE_OK;
  pParse->zTail = pParse->zSql = zSql;
  i = 0;
  assert( pzErrMsg!=0 );
................................................................................
  assert( pParse->sLastToken.dyn==0 );
  assert( pParse->pNewTable==0 );
  assert( pParse->pNewTrigger==0 );
  assert( pParse->nVar==0 );
  assert( pParse->nVarExpr==0 );
  assert( pParse->nVarExprAlloc==0 );
  assert( pParse->apVarExpr==0 );


  while( !db->mallocFailed && zSql[i]!=0 ){
    assert( i>=0 );
    pParse->sLastToken.z = (u8*)&zSql[i];
    assert( pParse->sLastToken.dyn==0 );
    pParse->sLastToken.n = sqlite3GetToken((unsigned char*)&zSql[i],&tokenType);
    i += pParse->sLastToken.n;
    if( i>mxSqlLen ){
................................................................................
  }
#ifdef YYTRACKMAXSTACKDEPTH
  sqlite3StatusSet(SQLITE_STATUS_PARSER_STACK,
      sqlite3ParserStackPeak(pEngine)
  );
#endif /* YYDEBUG */
  sqlite3ParserFree(pEngine, sqlite3_free);

  if( db->mallocFailed ){
    pParse->rc = SQLITE_NOMEM;
  }
  if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){
    sqlite3SetString(&pParse->zErrMsg, db, "%s", sqlite3ErrStr(pParse->rc));
  }
  if( pParse->zErrMsg ){
................................................................................
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.533 2009/03/19 18:51:07 danielk1977 Exp $
*/

#ifdef SQLITE_ENABLE_FTS3
/************** Include fts3.h in the middle of main.c ***********************/
/************** Begin file fts3.h ********************************************/
/*
** 2006 Oct 10
................................................................................
  */
  if( sz<=(int)sizeof(LookasideSlot*) ) sz = 0;
  if( cnt<0 ) cnt = 0;
  if( sz==0 || cnt==0 ){
    sz = 0;
    pStart = 0;
  }else if( pBuf==0 ){
    sz = (sz + 7)&~7;
    sqlite3BeginBenignMalloc();
    pStart = sqlite3Malloc( sz*cnt );
    sqlite3EndBenignMalloc();
  }else{
    sz = sz&~7;
    pStart = pBuf;
  }
  db->lookaside.pStart = pStart;
  db->lookaside.pFree = 0;
  db->lookaside.sz = (u16)sz;
  if( pStart ){
    int i;
................................................................................
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains the implementation of the sqlite3_unlock_notify()
** API method and its associated functionality.
**
** $Id: notify.c,v 1.1 2009/03/16 13:19:36 danielk1977 Exp $
*/

/* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY

/*
** Public interfaces:
................................................................................
      if( p->xUnlockNotify!=xUnlockNotify && nArg!=0 ){
        xUnlockNotify(aArg, nArg);
        nArg = 0;
      }

      sqlite3BeginBenignMalloc();
      assert( aArg==aDyn || (aDyn==0 && aArg==aStatic) );
      assert( nArg<=ArraySize(aStatic) || aArg==aDyn );
      if( (!aDyn && nArg==ArraySize(aStatic))
       || (aDyn && nArg==(sqlite3DbMallocSize(db, aDyn)/sizeof(void*)))
      ){
        /* The aArg[] array needs to grow. */
        void **pNew = (void **)sqlite3Malloc(nArg*sizeof(void *)*2);
        if( pNew ){
          memcpy(pNew, aArg, nArg*sizeof(void *));
          sqlite3_free(aDyn);
          aDyn = aArg = pNew;
................................................................................
  sqlite3ConnectionUnlocked(db);
  enterMutex();
  removeFromBlockedList(db);
  checkListProperties(db);
  leaveMutex();
}
#endif


/************** End of notify.c **********************************************/
/************** Begin file fts3.c ********************************************/
/*
** 2006 Oct 10
**
** The author disclaims copyright to this source code.  In place of







|







 







|







 







<
|
>







 







|
>
>
>
>
>







 







>
>
>
>
>
>
>



|







 







|







 







>
|







 







>
>
>
>
>
>
>
>
>







 







|







 







|







 







|







 







>

|
>
>







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|












|







 







>







 







>







 







>







 







>
>







 







|







 







|







 







|







 







|




>







 







|
|







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







 







|
|
>
>

<
>







 







|







 







|







 







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











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







 







|







 







<



<







 







|







 







|







 







|







 







<
<
<
<
<
<







 







>







 







|







 







|



|
>







|
|
|
|
<
<
<
|
>










|
<




>




>



>
>
>
>
>


|
|

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




>







 







|



>
>
>







 







|







 







|







 







>







 







>







 







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







 







|







 







|







 







>
>
>
>
>
>







 







|







 







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







 







>


>
>
>
>
>
>







 







|
>
>







 







|







 







>
>
>
>












|
>

|







 







|







 







|
|







 







|
|







 







|







 







|







 







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







 







|







 







<

<
<
<

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







 







|







 







>

>
>

|
>







 







|







 







>

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







 







|






|
|
<







 







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







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







>



>








>







 







|







 







>







 







|







 







|
|
|







 







|







 







<



<
<


<





|







 







|







 







|







 







|







 







|







 







|







 







>
|







 







|







 







|







 







|
>




|
>
>
>
>
>












>






|
>
>
>
>
>
>
>





|
>

|
>







 







|
>







 







|






|
|
|
|
|
|
|
|
|
|
|








|
|







 







|
|
|



|
|

|
|
|

|
|
|
|
|
|

|
|
|
|
|
|
|

|
|
|
|
|
|


|
|
|
|
|

|
|
|
|
|
|

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


|
|
|
|
|


|
|
|
|
|


|
|
|
|
|


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



|
|

|

|
|

|
|
|

|
|
|
|
|
|

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

|
|
|
|
|

|
|
|
|
|
|

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


|
|
|
|
|


|
|
|
|
|


|
|
|
|
|


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




|
|



|



|

|
|


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

|


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


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







 







<

>







 







|







 







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







 







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







 







|
|

|


|
|
|
|
|
|
|
|
|
|

|


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

|


|
|
|
|

|


|
|
|

|


|
|

|


|

|







 







>
|
|
|
|


|
|
|
|
|
|
|



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

|
|



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

|
|

|
|



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

|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
<
|
|
<
|


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







 







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







 







|


|




|
|
|







 







|

|


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

|
|
|
|
|
|
|
|
|

|




|

|
|


|





|





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


|


|





|





|


|
|
|

|
|

|

|
|



|





|
|

|
|

|
|

|
|

|
|

|
|

|


|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|

|
|
|
|
|
|
|
|

|


|


|
|

|
|

|
|

|

|
|


|
|
|

|
|

|
|
|

|

|


|

|


|

|


|


|
|


|
|

|

|
|
|

|

|


|
|

|

|


|
|
|

|
|
|
|
|
|

|

|


|


|


|




|


|


|
|

|

|
|


|

|
|


|
|

|

|
|


|

|


|

|
|


|
|
|



|
|


|
|

|
|

|
|

|
|

|
|

|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|

|


|
|
|

|
|
|

|
|
|
|

|

|
|


|

|
|


|
|
|

|
|

|
|

|
|

|
|

|
|

|

|
|


|

|
|
|


|
|

|
|

|
|

|
|

|
|

|
|
|

|
|
|

|
|

|
|

|
|

|
|
|
|

|
|
|

|



|


|





|


|
|

|


|



|

|


|

|
|


|

|


|
|
|
|



|

|
|


|



|
|
|
|



|
|
|
|
|
|
|
|
|

|
|
|

|
|
|

|


|
|
|
|

|
|
|
|


|

|
|


|

|
|


|

|
|


|

|
|


|
|

|
|


|

|
|


|

|
|


|

|
|
|
|
|



|
|


|

|
|
|
|

|

|
|


|

|
|
|
|
|

|

|


|

|
|
|
|
|

|

|
|


|


|
|
|
|
|



|
|


|

|

|
|

|

|



|

|
|
|
|

|

|


|

|
|


|

|
|


|


|
|


|
|
|

|
|

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






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


|


|
|

|




|


|

|



|
|
|

|
|

|
|

|
|
|

|
|

|
|

|
|

|


|
|

|


|
|
|
|


|

|
|
|
|


|
|

|
|

|
|

|
|

|
|

|

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



<
<
<
<
<
<
<
<
<
|
|

|
|

|

|







 







|







 







|
|
|
|
|
>
|
<
>

>
>







 







>
>







 







>







 







|







 







|




|







 







|







 







|
|
|







 







<







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
....
6095
6096
6097
6098
6099
6100
6101

6102
6103
6104
6105
6106
6107
6108
6109
6110
....
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
....
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
....
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
....
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
....
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
....
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
....
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
.....
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
.....
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
.....
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
.....
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
.....
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
.....
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
.....
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
.....
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
.....
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
.....
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
.....
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
.....
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
.....
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
.....
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
.....
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
.....
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
.....
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
.....
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
.....
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
.....
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
.....
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
.....
22144
22145
22146
22147
22148
22149
22150
22151
22152
22153
22154
22155
22156
22157
22158
22159
22160
22161
22162
22163
.....
22171
22172
22173
22174
22175
22176
22177
22178
22179
22180
22181
22182
22183
22184
22185
22186

22187
22188
22189
22190
22191
22192
22193
22194
22195
22196
22197
22198
22199
22200
22201
22202
22203
22204
22205
22206
22207
22208
22209
22210
22211
22212
22213
22214
22215
22216
22217
22218
.....
23516
23517
23518
23519
23520
23521
23522
23523
23524
23525
23526
23527

23528
23529
23530
23531
23532
23533
23534
23535
.....
25808
25809
25810
25811
25812
25813
25814
25815
25816
25817
25818
25819
25820
25821
25822
.....
27384
27385
27386
27387
27388
27389
27390
27391
27392
27393
27394
27395
27396
27397
27398
.....
27781
27782
27783
27784
27785
27786
27787
27788
27789
27790
27791
27792
27793
27794
27795
27796
27797
27798
27799
27800
27801
27802
27803
27804
27805
27806
27807
27808
27809
27810
27811
27812
27813

27814
27815

27816
27817
27818
27819
27820
27821










27822
27823
27824
27825
27826
27827
27828
.....
28303
28304
28305
28306
28307
28308
28309
28310
28311
28312
28313
28314
28315
28316
28317
.....
28627
28628
28629
28630
28631
28632
28633

28634
28635
28636

28637
28638
28639
28640
28641
28642
28643
.....
28892
28893
28894
28895
28896
28897
28898
28899
28900
28901
28902
28903
28904
28905
28906
.....
29004
29005
29006
29007
29008
29009
29010
29011
29012
29013
29014
29015
29016
29017
29018
.....
29888
29889
29890
29891
29892
29893
29894
29895
29896
29897
29898
29899
29900
29901
29902
.....
29968
29969
29970
29971
29972
29973
29974






29975
29976
29977
29978
29979
29980
29981
.....
31368
31369
31370
31371
31372
31373
31374
31375
31376
31377
31378
31379
31380
31381
31382
.....
33143
33144
33145
33146
33147
33148
33149
33150
33151
33152
33153
33154
33155
33156
33157
.....
33199
33200
33201
33202
33203
33204
33205
33206
33207
33208
33209
33210
33211
33212
33213
33214
33215
33216
33217
33218
33219
33220
33221
33222



33223
33224
33225
33226
33227
33228
33229
33230
33231
33232
33233
33234
33235

33236
33237
33238
33239
33240
33241
33242
33243
33244
33245
33246
33247
33248
33249
33250
33251
33252
33253
33254
33255
33256
33257
33258
33259
33260
33261
33262
33263
33264
33265
33266
33267
33268
33269
33270
33271
33272
33273
33274
33275
33276
33277
33278
33279
33280
33281
33282
33283
33284
33285
33286
33287
.....
33299
33300
33301
33302
33303
33304
33305
33306
33307
33308
33309
33310
33311
33312
33313
33314
33315
33316
33317
33318
33319
.....
33689
33690
33691
33692
33693
33694
33695
33696
33697
33698
33699
33700
33701
33702
33703
.....
33822
33823
33824
33825
33826
33827
33828
33829
33830
33831
33832
33833
33834
33835
33836
.....
34886
34887
34888
34889
34890
34891
34892
34893
34894
34895
34896
34897
34898
34899
34900
.....
34945
34946
34947
34948
34949
34950
34951
34952
34953
34954
34955
34956
34957
34958
34959
.....
34987
34988
34989
34990
34991
34992
34993
34994
34995
34996
34997
34998
34999
35000
35001
35002
35003
35004
35005
35006
35007
35008
35009
35010
35011
35012
35013
.....
36074
36075
36076
36077
36078
36079
36080
36081
36082
36083
36084
36085
36086
36087
36088
.....
36920
36921
36922
36923
36924
36925
36926
36927
36928
36929
36930
36931
36932
36933
36934
.....
37369
37370
37371
37372
37373
37374
37375
37376
37377
37378
37379
37380
37381
37382
37383
37384
37385
37386
37387
37388
.....
38237
38238
38239
38240
38241
38242
38243
38244
38245
38246
38247
38248
38249
38250
38251
.....
38544
38545
38546
38547
38548
38549
38550
38551
38552
38553
38554
38555
38556
38557
38558
38559
38560
38561
38562
38563
38564
38565
38566
38567
38568
38569
.....
40509
40510
40511
40512
40513
40514
40515
40516
40517
40518
40519
40520
40521
40522
40523
40524
40525
40526
40527
40528
40529
40530
40531
.....
43189
43190
43191
43192
43193
43194
43195
43196
43197
43198
43199
43200
43201
43202
43203
43204
43205
.....
44232
44233
44234
44235
44236
44237
44238
44239
44240
44241
44242
44243
44244
44245
44246
.....
44536
44537
44538
44539
44540
44541
44542
44543
44544
44545
44546
44547
44548
44549
44550
44551
44552
44553
44554
44555
44556
44557
44558
44559
44560
44561
44562
44563
44564
44565
44566
44567
44568
44569
.....
45279
45280
45281
45282
45283
45284
45285
45286
45287
45288
45289
45290
45291
45292
45293
.....
46166
46167
46168
46169
46170
46171
46172
46173
46174
46175
46176
46177
46178
46179
46180
46181
.....
46183
46184
46185
46186
46187
46188
46189
46190
46191
46192
46193
46194
46195
46196
46197
46198
.....
46287
46288
46289
46290
46291
46292
46293
46294
46295
46296
46297
46298
46299
46300
46301
.....
47918
47919
47920
47921
47922
47923
47924
47925
47926
47927
47928
47929
47930
47931
47932
.....
48406
48407
48408
48409
48410
48411
48412
48413
48414
48415
48416
48417
48418
48419
48420
48421
48422
48423
48424
48425
48426
48427
48428
48429
48430
48431
48432
48433
48434
48435
48436
48437
48438
48439
48440
48441
48442
.....
49270
49271
49272
49273
49274
49275
49276
49277
49278
49279
49280
49281
49282
49283
49284
.....
53687
53688
53689
53690
53691
53692
53693

53694



53695


53696
53697
53698
53699
53700
53701
53702
53703
53704
53705
53706
53707
53708
53709
53710
53711
53712
53713
53714
53715
53716
53717
53718
53719
53720
53721
53722
53723
53724
53725
53726
53727
53728
53729
53730
53731
53732
53733
53734
53735
53736
53737
53738
53739
53740
53741
53742
53743
53744
53745
53746
53747
53748
53749
53750
53751
53752
.....
54745
54746
54747
54748
54749
54750
54751
54752
54753
54754
54755
54756
54757
54758
54759
.....
54995
54996
54997
54998
54999
55000
55001
55002
55003
55004
55005
55006
55007
55008
55009
55010
55011
55012
55013
55014
55015
.....
56892
56893
56894
56895
56896
56897
56898
56899
56900
56901
56902
56903
56904
56905
56906
.....
57283
57284
57285
57286
57287
57288
57289
57290
57291
57292
57293
57294
57295
57296
57297
57298
57299
57300
57301
57302
57303
57304
57305
57306
57307
57308
57309
57310
57311
57312
57313
57314
.....
57406
57407
57408
57409
57410
57411
57412
57413
57414
57415
57416
57417
57418
57419
57420
57421

57422
57423
57424
57425
57426
57427
57428
.....
57538
57539
57540
57541
57542
57543
57544
57545
57546


57547
















57548
57549
57550
57551
57552
57553
57554
57555
57556
57557
.....
57592
57593
57594
57595
57596
57597
57598
57599
57600
57601
57602
57603
57604
57605
57606
.....
57754
57755
57756
57757
57758
57759
57760
57761
57762
57763
57764
57765
57766
57767
57768
.....
58874
58875
58876
58877
58878
58879
58880
58881
58882
58883
58884
58885
58886
58887
58888
.....
59376
59377
59378
59379
59380
59381
59382
59383
59384
59385
59386
59387
59388
59389
59390
.....
60204
60205
60206
60207
60208
60209
60210
60211
60212
60213
60214
60215
60216
60217
60218
.....
60784
60785
60786
60787
60788
60789
60790
60791
60792
60793
60794
60795
60796
60797
60798
.....
62055
62056
62057
62058
62059
62060
62061
62062
62063
62064
62065
62066
62067
62068
62069
.....
62371
62372
62373
62374
62375
62376
62377
62378
62379
62380
62381
62382
62383
62384
62385
.....
62499
62500
62501
62502
62503
62504
62505
62506
62507
62508
62509
62510
62511
62512
62513
.....
62530
62531
62532
62533
62534
62535
62536
62537
62538
62539
62540
62541
62542
62543
62544
.....
62868
62869
62870
62871
62872
62873
62874
62875
62876
62877
62878
62879
62880
62881
62882
.....
63887
63888
63889
63890
63891
63892
63893
63894
63895
63896
63897
63898
63899
63900
63901
63902
63903
63904
63905
63906
63907
63908
63909
63910
63911
63912
63913
63914
.....
65730
65731
65732
65733
65734
65735
65736
65737
65738
65739
65740
65741
65742
65743
65744
.....
66139
66140
66141
66142
66143
66144
66145
66146
66147
66148
66149
66150
66151
66152
66153
.....
66823
66824
66825
66826
66827
66828
66829
66830
66831
66832
66833
66834
66835
66836
66837
.....
68108
68109
68110
68111
68112
68113
68114
68115
68116
68117
68118
68119
68120
68121
68122
68123
68124
.....
72570
72571
72572
72573
72574
72575
72576
72577
72578
72579
72580
72581
72582
72583
72584
.....
72633
72634
72635
72636
72637
72638
72639

72640
72641
72642


72643
72644

72645
72646
72647
72648
72649
72650
72651
72652
72653
72654
72655
72656
72657
.....
73404
73405
73406
73407
73408
73409
73410
73411
73412
73413
73414
73415
73416
73417
73418
.....
74620
74621
74622
74623
74624
74625
74626
74627
74628
74629
74630
74631
74632
74633
74634
.....
74675
74676
74677
74678
74679
74680
74681
74682
74683
74684
74685
74686
74687
74688
74689
.....
76471
76472
76473
76474
76475
76476
76477
76478
76479
76480
76481
76482
76483
76484
76485
.....
79757
79758
79759
79760
79761
79762
79763
79764
79765
79766
79767
79768
79769
79770
79771
.....
79863
79864
79865
79866
79867
79868
79869
79870
79871
79872
79873
79874
79875
79876
79877
79878
.....
80610
80611
80612
80613
80614
80615
80616
80617
80618
80619
80620
80621
80622
80623
80624
.....
81249
81250
81251
81252
81253
81254
81255
81256
81257
81258
81259
81260
81261
81262
81263
.....
82519
82520
82521
82522
82523
82524
82525
82526
82527
82528
82529
82530
82531
82532
82533
82534
82535
82536
82537
82538
82539
82540
82541
82542
82543
82544
82545
82546
82547
82548
82549
82550
82551
82552
82553
82554
82555
82556
82557
82558
82559
82560
82561
82562
82563
82564
82565
82566
82567
82568
82569
82570
82571
82572
82573
82574
82575
82576
82577
82578
82579
82580
82581
.....
82584
82585
82586
82587
82588
82589
82590
82591
82592
82593
82594
82595
82596
82597
82598
82599
.....
84171
84172
84173
84174
84175
84176
84177
84178
84179
84180
84181
84182
84183
84184
84185
84186
84187
84188
84189
84190
84191
84192
84193
84194
84195
84196
84197
84198
84199
84200
84201
84202
84203
84204
84205
84206
84207
84208
84209
84210
84211
84212
.....
84257
84258
84259
84260
84261
84262
84263
84264
84265
84266
84267
84268
84269
84270
84271
84272
84273
84274
84275
84276
84277
84278
84279
84280
84281
84282
84283
84284
84285
84286
84287
84288
84289
84290
84291
84292
84293
84294
84295
84296
84297
84298
84299
84300
84301
84302
84303
84304
84305
84306
84307
84308
84309
84310
84311
84312
84313
84314
84315
84316
84317
84318
84319
84320
84321
84322
84323
84324
84325
84326
84327
84328
84329
84330
84331
84332
84333
84334
84335
84336
84337
84338
84339
84340
84341
84342
84343
84344
84345
84346
84347
84348
84349
84350
84351
84352
84353
84354
84355
84356
84357
84358
84359
84360
84361
84362
84363
84364
84365
84366
84367
84368
84369
84370
84371
84372
84373
84374
84375
84376
84377
84378
84379
84380
84381
84382
84383
84384
84385
84386
84387
84388
84389
84390
84391
84392
84393
84394
84395
84396
84397
84398
84399
84400
84401
84402
84403
84404
84405
84406
84407
84408
84409
84410
84411
84412
84413
84414
84415
84416
84417
84418
84419
84420
84421
84422
84423
84424
84425
84426
84427
84428
84429
84430
84431
84432
84433
84434
84435
84436
84437
84438
84439
84440
84441
84442
84443
84444
84445
84446
84447
84448
84449
84450
84451
84452
84453
84454
84455
84456
84457
84458
84459
84460
84461
84462
84463
84464
84465
84466
84467
84468
84469
84470
84471
84472
84473
84474
84475
84476
84477
84478
84479
84480
84481
84482
84483
84484
84485
84486
84487
84488
84489
84490
84491
84492
84493
84494
84495
84496
84497
84498
84499
84500
84501
84502
84503
84504
84505
84506
84507
84508
84509
84510
84511
84512
84513
84514
84515
84516
84517
84518
84519
84520
84521
84522
84523
84524
84525
84526
84527
84528
84529
84530
84531
84532
84533
84534
84535
84536
84537
84538
84539
84540
84541
84542
84543
84544
84545
84546
84547
84548
84549
84550
84551
84552
84553
84554
84555
84556
84557
84558
84559
84560
84561
84562
84563
84564
84565
84566
84567
84568
84569
84570
84571
84572
84573
84574
84575
84576
84577
84578
84579
84580
84581
84582
84583
84584
84585
84586
84587
84588
84589
84590
84591
84592
84593
84594
84595
84596
84597
84598
84599
84600
84601
84602
84603
84604
84605
84606
84607
84608
84609
84610
84611
84612
84613
84614
84615
84616
84617
84618
84619
84620
84621
84622
84623
84624
84625
84626
84627
84628
84629
84630
84631
84632
84633
84634
84635
84636
84637
84638
84639
84640
84641
84642
84643
84644
84645
84646
84647
84648
84649
84650
84651
84652
84653
84654
84655
84656
84657
84658
84659
84660
84661
84662
84663
84664
84665
84666
84667
84668
84669
84670
84671
84672
.....
84690
84691
84692
84693
84694
84695
84696

84697
84698
84699
84700
84701
84702
84703
84704
84705
.....
84894
84895
84896
84897
84898
84899
84900
84901
84902
84903
84904
84905
84906
84907
84908
.....
84928
84929
84930
84931
84932
84933
84934
84935
84936
84937
84938
84939
84940
84941
84942
84943
84944
84945
84946
84947
84948
84949
84950
84951
84952
84953
84954
84955
84956
84957
84958
84959
84960
84961
84962
84963
.....
84983
84984
84985
84986
84987
84988
84989
84990
84991
84992
84993
84994
84995
84996
84997
84998
84999
85000
85001
85002
85003
85004
85005
85006
85007
85008
85009
85010
85011
85012
85013
85014
85015
85016
85017
85018
85019
85020
85021
85022
85023
85024
85025
85026
85027
85028
85029
85030
85031
85032
85033
85034
85035
85036
85037
85038
85039
85040
85041
85042
85043
85044
85045
85046
85047
85048
85049
85050
85051
85052
85053
85054
85055
85056
85057
85058
85059
85060
85061
85062
85063
85064
85065
85066
85067
85068
85069
85070
85071
85072
85073
85074
85075
85076
85077
85078
85079
85080
85081
85082
85083
85084
85085
85086
85087
85088
85089
85090
85091
85092
85093
85094
85095
85096
85097
85098
85099
85100
85101
85102
85103
85104
85105
85106
85107
85108
85109
85110
85111
85112
85113
85114
85115
85116
85117
85118
85119
85120
85121
85122
85123
85124
85125
85126
85127
85128
85129
85130
85131
85132
85133
85134
85135
85136
85137
85138
85139
85140
85141
85142
85143
85144
85145
85146
85147
85148
85149
85150
85151
85152
85153
85154
85155
85156
85157
85158
85159
85160
85161
85162
85163
85164
85165
85166
85167
85168
85169
85170
85171
85172
85173
85174
85175
85176
85177
85178
85179
85180
85181
85182
85183
85184
85185
85186
85187
85188
85189
85190
85191
85192
85193
85194
85195
85196
85197
85198
85199
85200
85201
85202
85203
85204
85205
85206
85207
85208
85209
85210
85211
85212
85213
85214
85215
85216
85217
85218
85219
85220
85221
85222
85223
85224
85225
85226
85227
85228
85229
85230
85231
85232
85233
85234
85235
85236
85237
85238
85239
85240
85241
85242
85243
85244
85245
85246
85247
85248
85249
85250
85251
85252
85253
85254
.....
85319
85320
85321
85322
85323
85324
85325
85326
85327
85328
85329
85330
85331
85332
85333
85334
85335
85336
85337
85338
85339
85340
85341
85342
85343
85344
85345
85346
85347
85348
85349
85350
85351
85352
85353
85354
85355
85356
85357
85358
85359
85360
85361
85362
85363
85364
85365
85366
85367
85368
85369
85370
85371
85372
85373
85374
85375
85376
85377
85378
85379
85380
85381
85382
85383
85384
85385
85386
85387
85388
85389
85390
85391
85392
.....
85638
85639
85640
85641
85642
85643
85644
85645
85646
85647
85648
85649
85650
85651
85652
85653
85654
85655
85656
85657
85658
85659
85660
85661
85662
85663
85664
85665
85666
85667
85668
85669
85670
85671
85672
85673
85674
85675
85676
85677
85678
85679
85680
85681
85682
85683
85684
85685
85686
85687
85688
85689
85690
85691
85692
85693
85694
85695
85696
85697
85698
85699
85700
85701
85702
85703
85704
85705
85706
85707
85708
85709
85710
85711
85712
85713
85714
85715
85716
85717
85718
85719
85720
85721
85722
85723
85724
85725
85726
85727
85728
85729
85730
85731
85732
85733
85734
85735
85736
85737
85738
85739
85740
85741
85742
85743
85744
85745
85746
85747
85748
85749
85750
85751
85752
85753
85754
85755
85756
85757
85758
85759
85760
85761
85762
85763
85764
85765
85766
85767
85768
85769
85770
85771
85772
85773
85774
85775
85776
85777
85778
85779
85780
85781
85782
85783
85784
85785
85786
85787
85788
85789
85790
85791
85792
85793
85794
85795
85796
85797
85798
85799
85800
85801
85802
85803
85804
85805
85806
85807
85808
85809
85810
85811
85812
85813
85814
85815
85816
85817
85818
85819
85820
85821
85822
85823
85824
85825
85826
85827
85828
85829
85830
85831
85832
85833
85834
85835
85836
85837
85838
85839
85840
85841
85842
85843
85844
85845
85846
85847
85848
85849
85850
85851
85852
85853
85854
85855
85856
85857
85858
85859
85860
85861
85862
85863
85864
85865
85866
85867
85868
85869
85870
85871
85872
85873
85874
85875
85876
85877
85878
85879
85880

85881
85882

85883
85884
85885
85886
85887
85888
85889
85890
85891
85892
85893
85894
85895
85896
85897
85898
85899
85900
85901
85902
85903
85904
85905
85906
85907
.....
85960
85961
85962
85963
85964
85965
85966
85967
85968
85969
85970
85971
85972
85973
85974
85975
85976
85977
85978
85979
85980
85981
85982
85983
85984
85985
85986
85987
85988
85989
85990
85991
.....
85994
85995
85996
85997
85998
85999
86000
86001
86002
86003
86004
86005
86006
86007
86008
86009
86010
86011
86012
86013
86014
86015
86016
86017
86018
.....
86028
86029
86030
86031
86032
86033
86034
86035
86036
86037
86038
86039
86040
86041
86042
86043
86044
86045
86046
86047
86048
86049
86050
86051
86052
86053
86054
86055
86056
86057
86058
86059
86060
86061
86062
86063
86064
86065
86066
86067
86068
86069
86070
86071
86072
86073
86074
86075
86076
86077
86078
86079
86080
86081
86082
86083
86084
86085
86086
86087
86088
86089
86090
86091
86092
86093
86094
86095
86096
86097
86098
86099
86100
86101
86102
86103
86104
86105
86106
86107
86108
86109
86110
86111
86112
86113
86114
86115
86116
86117
86118
86119
86120
86121
86122
86123
86124
86125
86126
86127
86128
86129
86130
86131
86132
86133
86134
86135
86136
86137
86138
86139
86140
86141
86142
86143
86144
86145
86146
86147
86148
86149
86150
86151
86152
86153
86154
86155
86156
86157
86158
86159
86160
86161
86162
86163
86164
86165
86166
86167
86168
86169
86170
86171
86172
86173
86174
86175
86176
86177
86178
86179
86180
86181
86182
86183
86184
86185
86186
86187
86188
86189
86190
86191
86192
86193
86194
86195
86196
86197
86198
86199
86200
86201
86202
86203
86204
86205
86206
86207
86208
86209
86210
86211
86212
86213
86214
86215
86216
86217
86218
86219
86220
86221
86222
86223
86224
86225
86226
86227
86228
86229
86230
86231
86232
86233
86234
86235
86236
86237
86238
86239
86240
86241
86242
86243
86244
86245
86246
86247
86248
86249
86250
86251
86252
86253
86254
86255
86256
86257
86258
86259
86260
86261
86262
86263
86264
86265
86266
86267
86268
86269
86270
86271
86272
86273
86274
86275
86276
86277
86278
86279
86280
86281
86282
86283
86284
86285
86286
86287
86288
86289
86290
86291
86292
86293
86294
86295
86296
86297
86298
86299
86300
86301
86302
86303
86304
86305
86306
86307
86308
86309
86310
86311
86312
86313
86314
86315
86316
86317
86318
86319
86320
86321
86322
86323
86324
86325
86326
86327
86328
86329
86330
86331
86332
86333
86334
86335
86336
86337
86338
86339
86340
86341
86342
86343
86344
86345
86346
86347
86348
86349
86350
86351
86352
86353
86354
86355
86356
86357
86358
86359
86360
86361
86362
86363
86364
86365
86366
86367
86368
86369
86370
86371
86372
86373
86374
86375
86376
86377
86378
86379
86380
86381
86382
86383
86384
86385
86386
86387
86388
86389
86390
86391
86392
86393
86394
86395
86396
86397
86398
86399
86400
86401
86402
86403
86404
86405
86406
86407
86408
86409
86410
86411
86412
86413
86414
86415
86416
86417
86418
86419
86420
86421
86422
86423
86424
86425
86426
86427
86428
86429
86430
86431
86432
86433
86434
86435
86436
86437
86438
86439
86440
86441
86442
86443
86444
86445
86446
86447
86448
86449
86450
86451
86452
86453
86454
86455
86456
86457
86458
86459
86460
86461
86462
86463
86464
86465
86466
86467
86468
86469
86470
86471
86472
86473
86474
86475
86476
86477
86478
86479
86480
86481
86482
86483
86484
86485
86486
86487
86488
86489
86490
86491
86492
86493
86494
86495
86496
86497
86498
86499
86500
86501
86502
86503
86504
86505
86506
86507
86508
86509
86510
86511
86512
86513
86514
86515
86516
86517
86518
86519
86520
86521
86522
86523
86524
86525
86526
86527
86528
86529
86530
86531
86532
86533
86534
86535
86536
86537
86538
86539
86540
86541
86542
86543
86544
86545
86546
86547
86548
86549
86550
86551
86552
86553
86554
86555
86556
86557
86558
86559
86560
86561
86562
86563
86564
86565
86566
86567
86568
86569
86570
86571
86572
86573
86574
86575
86576
86577
86578
86579
86580
86581
86582
86583
86584
86585
86586
86587
86588
86589
86590
86591
86592
86593
86594
86595
86596
86597
86598
86599
86600
86601
86602
86603
86604
86605
86606
86607
86608
86609
86610
86611
86612
86613
86614
86615
86616
86617
86618
86619
86620
86621
86622
86623
86624
86625
86626
86627
86628
86629
86630
86631
86632
86633
86634
86635
86636
86637
86638
86639
86640
86641
86642
86643
86644
86645
86646
86647
86648
86649
86650
86651
86652
86653
86654
86655
86656
86657
86658
86659
86660
86661
86662
86663
86664
86665
86666
86667
86668
86669
86670
86671
86672
86673
86674
86675
86676
86677
86678
86679
86680
86681
86682
86683
86684
86685
86686
86687
86688
86689
86690
86691
86692
86693
86694
86695
86696
86697
86698
86699
86700
86701
86702
86703
86704
86705
86706
86707
86708
86709
86710
86711
86712
86713
86714
86715
86716
86717
86718
86719
86720
86721
86722
86723
86724
86725
86726
86727
86728
86729
86730
86731
86732
86733
86734
86735
86736
86737
86738
86739
86740
86741
86742
86743
86744
86745
86746
86747
86748
86749
86750
86751
86752
86753
86754
86755
86756
86757
86758
86759
86760
86761
86762
86763
86764
86765
86766
86767
86768
86769
86770
86771
86772
86773
86774
86775












86776
86777
86778
86779
86780
86781
86782
86783
86784
86785
86786
86787
86788
86789
86790
86791
86792
86793
86794
86795
86796
86797
86798
86799
86800
86801
86802
86803
86804
86805
86806
86807
86808
86809
86810
86811
86812
86813
86814
86815
86816
86817
86818
86819
86820
86821
86822
86823
86824
86825
86826
86827
86828
86829
86830
86831
86832
86833
86834
86835
86836
86837
86838
86839
86840
86841
86842
86843
86844
86845
86846
86847
86848
86849
86850
86851
86852
86853
86854
86855
86856
86857
86858
86859
86860
86861
86862
86863
86864
86865
86866
86867
86868
86869
86870
86871
86872
86873
86874
86875
86876
86877
86878
86879









86880
86881
86882
86883
86884
86885
86886
86887
86888
86889
86890
86891
86892
86893
86894
86895
.....
87143
87144
87145
87146
87147
87148
87149
87150
87151
87152
87153
87154
87155
87156
87157
.....
87747
87748
87749
87750
87751
87752
87753
87754
87755
87756
87757
87758
87759
87760

87761
87762
87763
87764
87765
87766
87767
87768
87769
87770
87771
.....
87777
87778
87779
87780
87781
87782
87783
87784
87785
87786
87787
87788
87789
87790
87791
87792
.....
87833
87834
87835
87836
87837
87838
87839
87840
87841
87842
87843
87844
87845
87846
87847
.....
88183
88184
88185
88186
88187
88188
88189
88190
88191
88192
88193
88194
88195
88196
88197
.....
88660
88661
88662
88663
88664
88665
88666
88667
88668
88669
88670
88671
88672
88673
88674
88675
88676
88677
88678
88679
.....
90451
90452
90453
90454
90455
90456
90457
90458
90459
90460
90461
90462
90463
90464
90465
.....
90666
90667
90668
90669
90670
90671
90672
90673
90674
90675
90676
90677
90678
90679
90680
90681
90682
.....
90743
90744
90745
90746
90747
90748
90749

90750
90751
90752
90753
90754
90755
90756
** the "sqlite3.h" header file at hand, you will find a copy in the first
** 5487 lines past this header comment.)  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.
**
** This amalgamation was generated on 2009-03-31 13:00:09 UTC.
*/
#define SQLITE_CORE 1
#define SQLITE_AMALGAMATION 1
#ifndef SQLITE_PRIVATE
# define SQLITE_PRIVATE static
#endif
#ifndef SQLITE_API
................................................................................
**    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.
**
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.848 2009/03/25 16:51:43 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_

/*
** Include the configuration header output by 'configure' if we're using the
** autoconf-based build
................................................................................
#define TK_EXCLUSIVE                       9
#define TK_COMMIT                         10
#define TK_END                            11
#define TK_ROLLBACK                       12
#define TK_SAVEPOINT                      13
#define TK_RELEASE                        14
#define TK_TO                             15

#define TK_TABLE                          16
#define TK_CREATE                         17
#define TK_IF                             18
#define TK_NOT                            19
#define TK_EXISTS                         20
#define TK_TEMP                           21
#define TK_LP                             22
#define TK_RP                             23
#define TK_AS                             24
................................................................................
#define LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))
#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)

/* 
** Round up a number to the next larger multiple of 8.  This is used
** to force 8-byte alignment on 64-bit architectures.
*/
#define ROUND8(x)     (((x)+7)&~7)

/*
** Round down to the nearest multiple of 8
*/
#define ROUNDDOWN8(x) ((x)&~7)

/*
** An instance of the following structure is used to store the busy-handler
** callback for a given sqlite handle. 
**
** The sqlite.busyHandler member of the sqlite struct contains the busy
** callback for the database handle. Each pager opened via the sqlite
................................................................................
** (approx 10%) by avoiding numerous malloc/free requests while parsing
** SQL statements.
**
** The Lookaside structure holds configuration information about the
** lookaside malloc subsystem.  Each available memory allocation in
** the lookaside subsystem is stored on a linked list of LookasideSlot
** objects.
**
** Lookaside allocations are only allowed for objects that are associated
** with a particular database connection.  Hence, schema information cannot
** be stored in lookaside because in shared cache mode the schema information
** is shared by multiple database connections.  Therefore, while parsing
** schema information, the Lookaside.bEnabled flag is cleared so that
** lookaside allocations are not used to construct the schema objects.
*/
struct Lookaside {
  u16 sz;                 /* Size of each buffer in bytes */
  u8 bEnabled;            /* False to disable new lookaside allocations */
  u8 bMalloced;           /* True if pStart obtained from sqlite3_malloc() */
  int nOut;               /* Number of buffers currently checked out */
  int mxOut;              /* Highwater mark for nOut */
  LookasideSlot *pFree;   /* List of available buffers */
  void *pStart;           /* First byte of available memory space */
  void *pEnd;             /* First byte past end of available space */
};
................................................................................
** when the VDBE cursor to the table is closed.  In this case Table.tnum 
** refers VDBE cursor number that holds the table open, not to the root
** page number.  Transient tables are used to hold the results of a
** sub-query that appears instead of a real table name in the FROM clause 
** of a SELECT statement.
*/
struct Table {
  sqlite3 *dbMem;      /* DB connection used for lookaside allocations. */
  char *zName;         /* Name of the table or view */
  int iPKey;           /* If not negative, use aCol[iPKey] as the primary key */
  int nCol;            /* Number of columns in this table */
  Column *aCol;        /* Information about each column */
  Index *pIndex;       /* List of SQL indexes on this table. */
  int tnum;            /* Root BTree node for this table (see note above) */
  Select *pSelect;     /* NULL for tables.  Points to definition if a view. */
................................................................................
** If the EP_TokenOnly flag is set in Expr.flags, then only EXPR_TOKENONLYSIZE
** bytes of space are allocated for the expression structure. This is enough
** space to store all fields up to and including the "Token token;" field.
*/
struct Expr {
  u8 op;                 /* Operation performed by this node */
  char affinity;         /* The affinity of the column or 0 if not a column */
  VVA_ONLY(u8 vvaFlags;) /* Flags used for VV&A only.  EVVA_* below. */
  u16 flags;             /* Various flags.  EP_* See below */
  Token token;           /* An operand token */

  /* If the EP_TokenOnly flag is set in the Expr.flags mask, then no
  ** space is allocated for the fields below this point. An attempt to
  ** access them will result in a segfault or malfunction. 
  *********************************************************************/

................................................................................
#define EP_IntValue   0x0800  /* Integer value contained in iTable */
#define EP_xIsSelect  0x1000  /* x.pSelect is valid (otherwise x.pList is) */

#define EP_Reduced    0x2000  /* Expr struct is EXPR_REDUCEDSIZE bytes only */
#define EP_TokenOnly  0x4000  /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
#define EP_SpanOnly   0x8000  /* Expr struct is EXPR_SPANONLYSIZE bytes only */

/*
** The following are the meanings of bits in the Expr.vvaFlags field.
** This information is only used when SQLite is compiled with
** SQLITE_DEBUG defined.
*/
#ifndef NDEBUG
#define EVVA_ReadOnlyToken  0x01  /* Expr.token.z is read-only */
#endif

/*
** These macros can be used to test, set, or clear bits in the 
** Expr.flags field.
*/
#define ExprHasProperty(E,P)     (((E)->flags&(P))==(P))
#define ExprHasAnyProperty(E,P)  (((E)->flags&(P))!=0)
#define ExprSetProperty(E,P)     (E)->flags|=(P)
................................................................................
#if defined(SQLITE_TEST)
SQLITE_PRIVATE   void *sqlite3TestTextToPtr(const char*);
#endif
SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*, ...);
SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...);
SQLITE_PRIVATE void sqlite3ErrorClear(Parse*);
SQLITE_PRIVATE void sqlite3Dequote(char*);
SQLITE_PRIVATE void sqlite3DequoteExpr(Expr*);
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int);
SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*, char **);
SQLITE_PRIVATE void sqlite3FinishCoding(Parse*);
SQLITE_PRIVATE int sqlite3GetTempReg(Parse*);
SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse*,int);
SQLITE_PRIVATE int sqlite3GetTempRange(Parse*,int);
SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse*,int,int);
................................................................................
SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int);
SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
                                     int*,int,int,int,int);
SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);
SQLITE_PRIVATE void sqlite3TokenCopy(sqlite3*,Token*,const Token*);
SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);
SQLITE_PRIVATE void sqlite3FuncDefInsert(FuncDefHash*, FuncDef*);
SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,int);
SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(sqlite3*);
................................................................................
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file contains OS interface code that is common to all
** architectures.
**
** $Id: os.c,v 1.126 2009/03/25 14:24:42 drh Exp $
*/
#define _SQLITE_OS_C_ 1
#undef _SQLITE_OS_C_

/*
** The default SQLite sqlite3_vfs implementations do not allocate
** memory (actually, os_unix.c allocates a small amount of memory
................................................................................
SQLITE_PRIVATE int sqlite3OsOpen(
  sqlite3_vfs *pVfs, 
  const char *zPath, 
  sqlite3_file *pFile, 
  int flags, 
  int *pFlagsOut
){
  int rc;
  DO_OS_MALLOC_TEST;
  rc = pVfs->xOpen(pVfs, zPath, pFile, flags, pFlagsOut);
  assert( rc==SQLITE_OK || pFile->pMethods==0 );
  return rc;
}
SQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
  return pVfs->xDelete(pVfs, zPath, dirSync);
}
SQLITE_PRIVATE int sqlite3OsAccess(
  sqlite3_vfs *pVfs, 
  const char *zPath, 
................................................................................
** This file contains low-level memory allocation drivers for when
** SQLite will use the standard C-library malloc/realloc/free interface
** to obtain the memory it needs.
**
** This file contains implementations of the low-level memory allocation
** routines specified in the sqlite3_mem_methods object.
**
** $Id: mem1.c,v 1.30 2009/03/23 04:33:33 danielk1977 Exp $
*/

/*
** This version of the memory allocator is the default.  It is
** used when no other memory allocator is specified using compile-time
** macros.
*/
................................................................................
** For this low-level routine, we are guaranteed that nByte>0 because
** cases of nByte<=0 will be intercepted and dealt with by higher level
** routines.
*/
static void *sqlite3MemMalloc(int nByte){
  sqlite3_int64 *p;
  assert( nByte>0 );
  nByte = ROUND8(nByte);
  p = malloc( nByte+8 );
  if( p ){
    p[0] = nByte;
    p++;
  }
  return (void *)p;
}
................................................................................
** redirected to xMalloc.  Similarly, we know that nByte>0 becauses
** cases where nByte<=0 will have been intercepted by higher-level
** routines and redirected to xFree.
*/
static void *sqlite3MemRealloc(void *pPrior, int nByte){
  sqlite3_int64 *p = (sqlite3_int64*)pPrior;
  assert( pPrior!=0 && nByte>0 );
  nByte = ROUND8(nByte);
  p = (sqlite3_int64*)pPrior;
  p--;
  p = realloc(p, nByte+8 );
  if( p ){
    p[0] = nByte;
    p++;
  }
................................................................................
  return (int)p[0];
}

/*
** Round up a request size to the next valid allocation size.
*/
static int sqlite3MemRoundup(int n){
  return ROUND8(n);
}

/*
** Initialize this module.
*/
static int sqlite3MemInit(void *NotUsed){
  UNUSED_PARAMETER(NotUsed);
................................................................................
** to obtain the memory it needs while adding lots of additional debugging
** information to each allocation in order to help detect and fix memory
** leaks and memory usage errors.
**
** This file contains implementations of the low-level memory allocation
** routines specified in the sqlite3_mem_methods object.
**
** $Id: mem2.c,v 1.45 2009/03/23 04:33:33 danielk1977 Exp $
*/

/*
** This version of the memory allocator is used only if the
** SQLITE_MEMDEBUG macro is defined
*/
#ifdef SQLITE_MEMDEBUG
................................................................................
} mem;


/*
** Adjust memory usage statistics
*/
static void adjustStats(int iSize, int increment){
  int i = ROUND8(iSize)/8;
  if( i>NCSIZE-1 ){
    i = NCSIZE - 1;
  }
  if( increment>0 ){
    mem.nAlloc[i]++;
    mem.nCurrent[i]++;
    if( mem.nCurrent[i]>mem.mxCurrent[i] ){
................................................................................
  int *pInt;
  u8 *pU8;
  int nReserve;

  p = (struct MemBlockHdr*)pAllocation;
  p--;
  assert( p->iForeGuard==(int)FOREGUARD );
  nReserve = ROUND8(p->iSize);
  pInt = (int*)pAllocation;
  pU8 = (u8*)pAllocation;
  assert( pInt[nReserve/sizeof(int)]==(int)REARGUARD );
  /* This checks any of the "extra" bytes allocated due
  ** to rounding up to an 8 byte boundary to ensure 
  ** they haven't been overwritten.
  */
................................................................................
  mem.mutex = 0;
}

/*
** Round up a request size to the next valid allocation size.
*/
static int sqlite3MemRoundup(int n){
  return ROUND8(n);
}

/*
** Allocate nByte bytes of memory.
*/
static void *sqlite3MemMalloc(int nByte){
  struct MemBlockHdr *pHdr;
................................................................................
  char *z;
  int *pInt;
  void *p = 0;
  int totalSize;
  int nReserve;
  sqlite3_mutex_enter(mem.mutex);
  assert( mem.disallow==0 );
  nReserve = ROUND8(nByte);
  totalSize = nReserve + sizeof(*pHdr) + sizeof(int) +
               mem.nBacktrace*sizeof(void*) + mem.nTitle;
  p = malloc(totalSize);
  if( p ){
    z = p;
    pBt = (void**)&z[mem.nTitle];
    pHdr = (struct MemBlockHdr*)&pBt[mem.nBacktrace];
................................................................................
*/
SQLITE_PRIVATE void sqlite3MemdebugSettitle(const char *zTitle){
  unsigned int n = sqlite3Strlen30(zTitle) + 1;
  sqlite3_mutex_enter(mem.mutex);
  if( n>=sizeof(mem.zTitle) ) n = sizeof(mem.zTitle)-1;
  memcpy(mem.zTitle, zTitle, n);
  mem.zTitle[n] = 0;
  mem.nTitle = ROUND8(n);
  sqlite3_mutex_leave(mem.mutex);
}

SQLITE_PRIVATE void sqlite3MemdebugSync(){
  struct MemBlockHdr *pHdr;
  for(pHdr=mem.pFirst; pHdr; pHdr=pHdr->pNext){
    void **pBt = (void**)pHdr;
................................................................................
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** Memory allocation functions used throughout sqlite.
**
** $Id: malloc.c,v 1.61 2009/03/24 15:08:10 drh Exp $
*/

/*
** This routine runs when the memory allocator sees that the
** total memory allocation is about to exceed the soft heap
** limit.
*/
................................................................................
  memset(&mem0, 0, sizeof(mem0));
  if( sqlite3GlobalConfig.bCoreMutex ){
    mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
  }
  if( sqlite3GlobalConfig.pScratch && sqlite3GlobalConfig.szScratch>=100
      && sqlite3GlobalConfig.nScratch>=0 ){
    int i;
    sqlite3GlobalConfig.szScratch = ROUNDDOWN8(sqlite3GlobalConfig.szScratch-4);
    mem0.aScratchFree = (u32*)&((char*)sqlite3GlobalConfig.pScratch)
                  [sqlite3GlobalConfig.szScratch*sqlite3GlobalConfig.nScratch];
    for(i=0; i<sqlite3GlobalConfig.nScratch; i++){ mem0.aScratchFree[i] = i; }
    mem0.nScratchFree = sqlite3GlobalConfig.nScratch;
  }else{
    sqlite3GlobalConfig.pScratch = 0;
    sqlite3GlobalConfig.szScratch = 0;
  }
  if( sqlite3GlobalConfig.pPage && sqlite3GlobalConfig.szPage>=512
      && sqlite3GlobalConfig.nPage>=1 ){
    int i;
    int overhead;
    int sz = ROUNDDOWN8(sqlite3GlobalConfig.szPage);
    int n = sqlite3GlobalConfig.nPage;
    overhead = (4*n + sz - 1)/sz;
    sqlite3GlobalConfig.nPage -= overhead;
    mem0.aPageFree = (u32*)&((char*)sqlite3GlobalConfig.pPage)
                  [sqlite3GlobalConfig.szPage*sqlite3GlobalConfig.nPage];
    for(i=0; i<sqlite3GlobalConfig.nPage; i++){ mem0.aPageFree[i] = i; }
    mem0.nPageFree = sqlite3GlobalConfig.nPage;
................................................................................
** Return the size of a memory allocation previously obtained from
** sqlite3Malloc() or sqlite3_malloc().
*/
SQLITE_PRIVATE int sqlite3MallocSize(void *p){
  return sqlite3GlobalConfig.m.xSize(p);
}
SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){
  assert( db==0 || sqlite3_mutex_held(db->mutex) );
  if( p==0 ){
    return 0;
  }else if( isLookaside(db, p) ){
    return db->lookaside.sz;
  }else{
    return sqlite3GlobalConfig.m.xSize(p);
  }
................................................................................
}

/*
** Free memory that might be associated with a particular database
** connection.
*/
SQLITE_PRIVATE void sqlite3DbFree(sqlite3 *db, void *p){
  assert( db==0 || sqlite3_mutex_held(db->mutex) );
  if( isLookaside(db, p) ){
    LookasideSlot *pBuf = (LookasideSlot*)p;
    pBuf->pNext = db->lookaside.pFree;
    db->lookaside.pFree = pBuf;
    db->lookaside.nOut--;
  }else{
    sqlite3_free(p);
................................................................................
**         if( b ) a[10] = 9;
**
** In other words, if a subsequent malloc (ex: "b") worked, it is assumed
** that all prior mallocs (ex: "a") worked too.
*/
SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3 *db, int n){
  void *p;
  assert( db==0 || sqlite3_mutex_held(db->mutex) );
#ifndef SQLITE_OMIT_LOOKASIDE
  if( db ){
    LookasideSlot *pBuf;
    if( db->mallocFailed ){
      return 0;
    }
    if( db->lookaside.bEnabled && n<=db->lookaside.sz
................................................................................

/*
** Resize the block of memory pointed to by p to n bytes. If the
** resize fails, set the mallocFailed flag in the connection object.
*/
SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, int n){
  void *pNew = 0;
  assert( db!=0 );
  assert( sqlite3_mutex_held(db->mutex) );
  if( db->mallocFailed==0 ){
    if( p==0 ){
      return sqlite3DbMallocRaw(db, n);
    }
    if( isLookaside(db, p) ){
      if( n<=db->lookaside.sz ){
        return p;
................................................................................
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains routines used to translate between UTF-8, 
** UTF-16, UTF-16BE, and UTF-16LE.
**
** $Id: utf.c,v 1.71 2009/03/31 03:41:57 shane Exp $
**
** Notes on UTF-8:
**
**   Byte-0    Byte-1    Byte-2    Byte-3    Value
**  0xxxxxxx                                 00000000 00000000 0xxxxxxx
**  110yyyyy  10xxxxxx                       00000000 00000yyy yyxxxxxx
**  1110zzzz  10yyyyyy  10xxxxxx             00000000 zzzzyyyy yyxxxxxx
................................................................................
  while( zIn[0] ){
    c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn);
    if( c!=0xfffd ){
      WRITE_UTF8(zOut, c);
    }
  }
  *zOut = 0;
  return (int)(zOut - zStart);
}
#endif

#ifndef SQLITE_OMIT_UTF16
/*
** Convert a UTF-16 string in the native encoding into a UTF-8 string.
** Memory to hold the UTF-8 string is obtained from sqlite3_malloc and must
................................................................................
**   *  Definitions of sqlite3_io_methods objects for all locking
**      methods plus "finder" functions for each locking method.
**   *  sqlite3_vfs method implementations.
**   *  Locking primitives for the proxy uber-locking-method. (MacOSX only)
**   *  Definitions of sqlite3_vfs objects for all locking methods
**      plus implementations of sqlite3_os_init() and sqlite3_os_end().
**
** $Id: os_unix.c,v 1.248 2009/03/30 07:39:35 danielk1977 Exp $
*/
#if SQLITE_OS_UNIX              /* This file is used on unix only */

/*
** There are various methods for file locking used for concurrency
** control:
**
................................................................................
      pLock->locktype = SHARED_LOCK;
    }else{
      int tErrno = errno;
      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);
      if( IS_LOCK_ERROR(rc) ){
        pFile->lastErrno = tErrno;
      }
      goto end_unlock;
    }
  }
  if( locktype==NO_LOCK ){
    struct unixOpenCnt *pOpen;
    int rc2 = SQLITE_OK;

    /* Decrement the shared lock counter.  Release the lock using an
    ** OS call only when all threads in this same process have released
    ** the lock.
    */
    pLock->cnt--;
    if( pLock->cnt==0 ){
................................................................................
        pLock->locktype = NO_LOCK;
      }else{
        int tErrno = errno;
        rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);
        if( IS_LOCK_ERROR(rc) ){
          pFile->lastErrno = tErrno;
        }
        pLock->locktype = NO_LOCK;
        pFile->locktype = NO_LOCK;
      }
    }

    /* Decrement the count of locks against this same file.  When the
    ** count reaches zero, close any other file descriptors whose close
    ** was deferred because of outstanding locks.
    */

    pOpen = pFile->pOpen;
    pOpen->nLock--;
    assert( pOpen->nLock>=0 );
    if( pOpen->nLock==0 && pOpen->nPending>0 ){
      int i;
      for(i=0; i<pOpen->nPending; i++){
        /* close pending fds, but if closing fails don't free the array
        ** assign -1 to the successfully closed descriptors and record the
        ** error.  The next attempt to unlock will try again. */
        if( pOpen->aPending[i] < 0 ) continue;
        if( close(pOpen->aPending[i]) ){
          pFile->lastErrno = errno;
          rc2 = SQLITE_IOERR_CLOSE;
        }else{
          pOpen->aPending[i] = -1;
        }
      }
      if( rc2==SQLITE_OK ){
        sqlite3_free(pOpen->aPending);
        pOpen->nPending = 0;
        pOpen->aPending = 0;
      }
    }
    if( rc==SQLITE_OK ){
      rc = rc2;
    }
  }
	
end_unlock:
  unixLeaveMutex();
  if( rc==SQLITE_OK ) pFile->locktype = locktype;
  return rc;
................................................................................
** that syncs and fullsyncs are occurring at the right times.
*/
SQLITE_API int sqlite3_sync_count = 0;
SQLITE_API int sqlite3_fullsync_count = 0;
#endif

/*
** We do not trust systems to provide a working fdatasync().  Some do.
** Others do no.  To be safe, we will stick with the (slower) fsync().
** If you know that your system does support fdatasync() correctly,
** then simply compile with -Dfdatasync=fdatasync
*/

#if !defined(fdatasync) && !defined(__linux__)
# define fdatasync fsync
#endif

/*
** Define HAVE_FULLFSYNC to 0 or 1 depending on whether or not
** the F_FULLFSYNC macro is defined.  F_FULLFSYNC is currently
** only available on Mac OS X.  But that could change.
................................................................................
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file contains code that is specific to windows.
**
** $Id: os_win.c,v 1.153 2009/03/31 03:41:57 shane Exp $
*/
#if SQLITE_OS_WIN               /* This file is used for windows only */


/*
** A Note About Memory Allocation:
**
................................................................................
       NULL
    );
#endif
  }
  if( h==INVALID_HANDLE_VALUE ){
    free(zConverted);
    if( flags & SQLITE_OPEN_READWRITE ){
      return winOpen(pVfs, zName, id, 
             ((flags|SQLITE_OPEN_READONLY)&~SQLITE_OPEN_READWRITE), pOutFlags);
    }else{
      return SQLITE_CANTOPEN;
    }
  }
  if( pOutFlags ){
    if( flags & SQLITE_OPEN_READWRITE ){
................................................................................
** return 0.  Return 1 if the time and date cannot be found.
*/
int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){
  FILETIME ft;
  /* FILETIME structure is a 64-bit value representing the number of 
     100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). 
  */
  sqlite3_int64 timeW;   /* Whole days */
  sqlite3_int64 timeF;   /* Fractional Days */

  /* Number of 100-nanosecond intervals in a single day */
  static const sqlite3_int64 ntuPerDay = 
      10000000*(sqlite3_int64)86400;

  /* Number of 100-nanosecond intervals in half of a day */
  static const sqlite3_int64 ntuPerHalfDay = 
      10000000*(sqlite3_int64)43200;

  /* 2^32 - to avoid use of LL and warnings in gcc */
  static const sqlite3_int64 max32BitValue = 
      (sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 + (sqlite3_int64)294967296;

#if SQLITE_OS_WINCE
  SYSTEMTIME time;
  GetSystemTime(&time);
  /* if SystemTimeToFileTime() fails, it returns zero. */
  if (!SystemTimeToFileTime(&time,&ft)){
    return 1;
  }
#else
  GetSystemTimeAsFileTime( &ft );
#endif
  UNUSED_PARAMETER(pVfs);

  timeW = (((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + (sqlite3_int64)ft.dwLowDateTime;
  timeF = timeW % ntuPerDay;          /* fractional days (100-nanoseconds) */

  timeW = timeW / ntuPerDay;          /* whole days */
  timeW = timeW + 2305813;            /* add whole days (from 2305813.5) */
  timeF = timeF + ntuPerHalfDay;      /* add half a day (from 2305813.5) */
  timeW = timeW + (timeF/ntuPerDay);  /* add whole day if half day made one */
  timeF = timeF % ntuPerDay;          /* compute new fractional days */
  *prNow = (double)timeW + ((double)timeF / (double)ntuPerDay);










#ifdef SQLITE_TEST
  if( sqlite3_current_time ){
    *prNow = ((double)sqlite3_current_time + (double)43200) / (double)86400 + (double)2440587;
  }
#endif
  return 0;
}
................................................................................
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file implements that page cache.
**
** @(#) $Id: pcache.c,v 1.44 2009/03/31 01:32:18 drh Exp $
*/

/*
** A complete page cache is an instance of this structure.
*/
struct PCache {
  PgHdr *pDirty, *pDirtyTail;         /* List of dirty pages in LRU order */
................................................................................
}

/*
** Make sure the page is marked as dirty. If it isn't dirty already,
** make it so.
*/
SQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr *p){

  p->flags &= ~PGHDR_DONT_WRITE;
  assert( p->nRef>0 );
  if( 0==(p->flags & PGHDR_DIRTY) ){

    p->flags |= PGHDR_DIRTY;
    pcacheAddToDirtyList( p);
  }
}

/*
** Make sure the page is marked as clean. If it isn't clean already,
................................................................................
**
** This file implements the default page cache implementation (the
** sqlite3_pcache interface). It also contains part of the implementation
** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features.
** If the default page cache implementation is overriden, then neither of
** these two features are available.
**
** @(#) $Id: pcache1.c,v 1.10 2009/03/23 04:33:33 danielk1977 Exp $
*/


typedef struct PCache1 PCache1;
typedef struct PgHdr1 PgHdr1;
typedef struct PgFreeslot PgFreeslot;

................................................................................
** This function is called during initialization if a static buffer is 
** supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE
** verb to sqlite3_config(). Parameter pBuf points to an allocation large
** enough to contain 'n' buffers of 'sz' bytes each.
*/
SQLITE_PRIVATE void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){
  PgFreeslot *p;
  sz = ROUNDDOWN8(sz);
  pcache1.szSlot = sz;
  pcache1.pStart = pBuf;
  pcache1.pFree = 0;
  while( n-- ){
    p = (PgFreeslot*)pBuf;
    p->pNext = pcache1.pFree;
    pcache1.pFree = p;
................................................................................
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.576 2009/03/31 02:54:40 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO

/*
** Macros for troubleshooting.  Normally turned off
*/
#if 0
................................................................................
*/
#define PAGER_UNLOCK      0
#define PAGER_SHARED      1   /* same as SHARED_LOCK */
#define PAGER_RESERVED    2   /* same as RESERVED_LOCK */
#define PAGER_EXCLUSIVE   4   /* same as EXCLUSIVE_LOCK */
#define PAGER_SYNCED      5







/*
** A macro used for invoking the codec if there is one
*/
#ifdef SQLITE_HAS_CODEC
# define CODEC1(P,D,N,X) if( P->xCodec!=0 ){ P->xCodec(P->pCodecArg,D,N,X); }
# define CODEC2(P,D,N,X) ((char*)(P->xCodec!=0?P->xCodec(P->pCodecArg,D,N,X):D))
#else
................................................................................
  ** the page is marked as needSync==0.
  **
  ** 2008-04-14:  When attempting to vacuum a corrupt database file, it
  ** is possible to fail a statement on a database that does not yet exist.
  ** Do not attempt to write if database file has never been opened.
  */
  pPg = pager_lookup(pPager, pgno);
  assert( pPg || !MEMDB );
  PAGERTRACE(("PLAYBACK %d page %d hash(%08x) %s\n",
               PAGERID(pPager), pgno, pager_datahash(pPager->pageSize, aData),
               (isMainJrnl?"main-journal":"sub-journal")
  ));
  if( (pPager->state>=PAGER_EXCLUSIVE)
   && (pPg==0 || 0==(pPg->flags&PGHDR_NEED_SYNC))
   && isOpen(pPager->fd)
................................................................................
    assert( !pPager->pTmpSpace );
    sqlite3OsClose(pPager->fd);
    sqlite3_free(pPager);
    return rc;
  }

  /* Initialize the PCache object. */
  nExtra = ROUND8(nExtra);
  sqlite3PcacheOpen(szPageDflt, nExtra, !memDb,
                    !memDb?pagerStress:0, (void *)pPager, pPager->pPCache);

  PAGERTRACE(("OPEN %d %s\n", FILEHANDLEID(pPager->fd), pPager->zFilename));
  IOTRACE(("OPEN %p %s\n", pPager, pPager->zFilename))

  pPager->useJournal = (u8)useJournal;
................................................................................


/*
** This function is called after transitioning from PAGER_UNLOCK to
** PAGER_SHARED state. It tests if there is a hot journal present in
** the file-system for the given pager. A hot journal is one that 
** needs to be played back. According to this function, a hot-journal
** file exists if the following criteria are met:
**
**   * The journal file exists in the file system, and
**   * No process holds a RESERVED or greater lock on the database file, and
**   * The database file itself is greater than 0 bytes in size, and
**   * The first byte of the journal file exists and is not 0x00.
**
** If the current size of the database file is 0 but a journal file
** exists, that is probably an old journal left over from a prior
** database with the same name. In this case the journal file is
** just deleted using OsDelete, *pExists is set to 0 and SQLITE_OK
** is returned.
**
** This routine does not check if there is a master journal filename
** at the end of the file. If there is, and that master journal file
** does not exist, then the journal file is not really hot. In this
** case this routine will return a false-positive. The pager_playback()



** routine will discover that the journal file is not really hot and 
** will not roll it back. 
**
** If a hot-journal file is found to exist, *pExists is set to 1 and 
** SQLITE_OK returned. If no hot-journal file is present, *pExists is
** set to 0 and SQLITE_OK returned. If an IO error occurs while trying
** to determine whether or not a hot-journal file exists, the IO error
** code is returned and the value of *pExists is undefined.
*/
static int hasHotJournal(Pager *pPager, int *pExists){
  sqlite3_vfs * const pVfs = pPager->pVfs;
  int rc;                       /* Return code */
  int exists;                   /* True if a journal file is present */


  assert( pPager!=0 );
  assert( pPager->useJournal );
  assert( isOpen(pPager->fd) );
  assert( !isOpen(pPager->jfd) );

  *pExists = 0;
  rc = sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &exists);
  if( rc==SQLITE_OK && exists ){
    int locked;                 /* True if some process holds a RESERVED lock */
    rc = sqlite3OsCheckReservedLock(pPager->fd, &locked);
    if( rc==SQLITE_OK && !locked ){
      int nPage;

      /* Check the size of the database file. If it consists of 0 pages,
      ** then delete the journal file. See the header comment above for 
      ** the reasoning here.
      */
      rc = sqlite3PagerPagecount(pPager, &nPage);
      if( rc==SQLITE_OK ){
        if( nPage==0 ){
          rc = sqlite3OsDelete(pVfs, pPager->zJournal, 0);
        }else{
          /* The journal file exists and no other connection has a reserved
          ** or greater lock on the database file. Now check that there is
          ** at least one non-zero bytes at the start of the journal file.
          ** If there is, then we consider this journal to be hot. If not, 
          ** it can be ignored.
          */
          int f = SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL;
          rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &f);
          if( rc==SQLITE_OK ){
            u8 first = 0;
            rc = sqlite3OsRead(pPager->jfd, (void *)&first, 1, 0);
            if( rc==SQLITE_IOERR_SHORT_READ ){
              rc = SQLITE_OK;
            }
            sqlite3OsClose(pPager->jfd);
            *pExists = (first!=0);
          }
        }
      }
    }
  }

  return rc;
}

/*
** Read the content for page pPg out of the database file and into 
** pPg->pData. A shared lock or greater must be held on the database
** file before this function is called.
................................................................................
  i64 iOffset;                 /* Byte offset of file to read from */

  assert( pPager->state>=PAGER_SHARED && !MEMDB );

  if( !isOpen(pPager->fd) ){
    assert( pPager->tempFile );
    memset(pPg->pData, 0, pPager->pageSize);
    return SQLITE_OK;
  }
  iOffset = (pgno-1)*(i64)pPager->pageSize;
  rc = sqlite3OsRead(pPager->fd, pPg->pData, pPager->pageSize, iOffset);
  if( rc==SQLITE_IOERR_SHORT_READ ){
    rc = SQLITE_OK;
  }
  if( pgno==1 ){
    u8 *dbFileVers = &((u8*)pPg->pData)[24];
    memcpy(&pPager->dbFileVers, dbFileVers, sizeof(pPager->dbFileVers));
  }
  CODEC1(pPager, pPg->pData, pgno, 3);

  PAGER_INCR(sqlite3_pager_readdb_count);
................................................................................
      }else{
        memset(pPg->pData, 0, pPager->pageSize);
      }
      IOTRACE(("ZERO %p %d\n", pPager, pgno));
    }else{
      assert( pPg->pPager==pPager );
      rc = readDbPage(pPg);
      if( rc!=SQLITE_OK ){
        pagerDropPage(pPg);
        return rc;
      }
    }
#ifdef SQLITE_CHECK_PAGES
    pPg->pageHash = pager_pagehash(pPg);
#endif
................................................................................

  /* Open the journal file if it is not already open. */
  if( !isOpen(pPager->jfd) ){
    if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ){
      sqlite3MemJournalOpen(pPager->jfd);
    }else{
      const int flags =                   /* VFS flags to open journal file */
        SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|
        (pPager->tempFile ? 
          (SQLITE_OPEN_DELETEONCLOSE|SQLITE_OPEN_TEMP_JOURNAL):
          (SQLITE_OPEN_MAIN_JOURNAL)
        );
#ifdef SQLITE_ENABLE_ATOMIC_WRITE
      rc = sqlite3JournalOpen(
          pVfs, pPager->zJournal, pPager->jfd, flags, jrnlBufferSize(pPager)
................................................................................
** This function may return SQLITE_NOMEM or an IO error code if an error
** occurs. Otherwise, it returns SQLITE_OK.
*/
SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){
  PgHdr *pPgOld;               /* The page being overwritten. */
  Pgno needSyncPgno = 0;       /* Old value of pPg->pgno, if sync is required */
  int rc;                      /* Return code */
  Pgno origPgno;               /* The original page number */

  assert( pPg->nRef>0 );

  /* If the page being moved is dirty and has not been saved by the latest
  ** savepoint, then save the current contents of the page into the 
  ** sub-journal now. This is required to handle the following scenario:
  **
................................................................................
  pPg->flags &= ~PGHDR_NEED_SYNC;
  pPgOld = pager_lookup(pPager, pgno);
  assert( !pPgOld || pPgOld->nRef==1 );
  if( pPgOld ){
    pPg->flags |= (pPgOld->flags&PGHDR_NEED_SYNC);
  }

  origPgno = pPg->pgno;
  sqlite3PcacheMove(pPg, pgno);
  if( pPgOld ){
    sqlite3PcacheDrop(pPgOld);
  }

  sqlite3PcacheMakeDirty(pPg);
  pPager->dbModified = 1;
................................................................................
    }
    pPager->needSync = 1;
    assert( pPager->noSync==0 && !MEMDB );
    pPgHdr->flags |= PGHDR_NEED_SYNC;
    sqlite3PcacheMakeDirty(pPgHdr);
    sqlite3PagerUnref(pPgHdr);
  }

  /*
  ** For an in-memory database, make sure the original page continues
  ** to exist, in case the transaction needs to roll back.  We allocate
  ** the page now, instead of at rollback, because we can better deal
  ** with an out-of-memory error now.  Ticket #3761.
  */
  if( MEMDB ){
    DbPage *pNew;
    rc = sqlite3PagerAcquire(pPager, origPgno, &pNew, 1);
    if( rc!=SQLITE_OK ) return rc;
    sqlite3PagerUnref(pNew);
  }

  return SQLITE_OK;
}
#endif

/*
** Return a pointer to the data for the specified page.
................................................................................
** 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.
**
*************************************************************************
** $Id: btree.c,v 1.582 2009/03/30 18:50:05 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
** Including a description of file format and an overview of operation.
*/

/*
................................................................................
**
** Return the index into pPage->aData[] of the first byte of
** the new allocation.  The caller guarantees that there is enough
** space.  This routine will never fail.
**
** If the page contains nBytes of free space but does not contain
** nBytes of contiguous free space, then this routine automatically
** calls defragmentPage() to consolidate all free space before 
** allocating the new chunk.
*/
static int allocateSpace(MemPage *pPage, int nByte){
  int addr, pc, hdr;
  int size;
  int nFrag;
  int top;
................................................................................
static void pageReinit(DbPage *pData){
  MemPage *pPage;
  pPage = (MemPage *)sqlite3PagerGetExtra(pData);
  if( pPage->isInit ){
    assert( sqlite3_mutex_held(pPage->pBt->mutex) );
    pPage->isInit = 0;
    if( sqlite3PagerPageRefcount(pData)>0 ){
      /* pPage might not be a btree page;  it might be an overflow page
      ** or ptrmap page or a free page.  In those cases, the following
      ** call to sqlite3BtreeInitPage() will likely return SQLITE_CORRUPT.
      ** But no harm is done by this.  And it is very important that
      ** sqlite3BtreeInitPage() be called on every btree page so we make
      ** the call for every page that comes in for re-initing. */
      sqlite3BtreeInitPage(pPage);
    }
  }
}

/*
** Invoke the busy handler for a btree.
................................................................................
    if( p->inTrans>pBt->inTransaction ){
      pBt->inTransaction = p->inTrans;
    }
#ifndef SQLITE_OMIT_SHARED_CACHE
    if( wrflag ){
      assert( !pBt->pWriter );
      pBt->pWriter = p;
      pBt->isExclusive = (u8)(wrflag>1);
    }
#endif
  }


trans_begun:
  if( rc==SQLITE_OK && wrflag ){
................................................................................
      }
    }
  }

  if( nFin==0 ){
    iLastPg--;
    while( iLastPg==PENDING_BYTE_PAGE(pBt)||PTRMAP_ISPAGE(pBt, iLastPg) ){
      if( PTRMAP_ISPAGE(pBt, iLastPg) ){
        MemPage *pPg;
        int rc = sqlite3BtreeGetPage(pBt, iLastPg, &pPg, 0);
        if( rc!=SQLITE_OK ){
          return rc;
        }
        rc = sqlite3PagerWrite(pPg->pDbPage);
        releasePage(pPg);
        if( rc!=SQLITE_OK ){
          return rc;
        }
      }
      iLastPg--;
    }
    sqlite3PagerTruncateImage(pBt->pPager, iLastPg);
  }
  return SQLITE_OK;
}

................................................................................

#ifndef SQLITE_OMIT_AUTOVACUUM
    if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt, *pPgno) ){
      /* If *pPgno refers to a pointer-map page, allocate two new pages
      ** at the end of the file instead of one. The first allocated page
      ** becomes a new pointer-map page, the second is used by the caller.
      */
      MemPage *pPg = 0;
      TRACE(("ALLOCATE: %d from end of file (pointer-map page)\n", *pPgno));
      assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
      rc = sqlite3BtreeGetPage(pBt, *pPgno, &pPg, 0);
      if( rc==SQLITE_OK ){
        rc = sqlite3PagerWrite(pPg->pDbPage);
        releasePage(pPg);
      }
      if( rc ) return rc;
      (*pPgno)++;
      if( *pPgno==PENDING_BYTE_PAGE(pBt) ){ (*pPgno)++; }
    }
#endif

    assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
    rc = sqlite3BtreeGetPage(pBt, *pPgno, ppPage, 0);
................................................................................
    sqlite3_snprintf(sizeof(zContext), zContext,
             "On tree page %d cell %d: ", iPage, i);
    pCell = findCell(pPage,i);
    sqlite3BtreeParseCellPtr(pPage, pCell, &info);
    sz = info.nData;
    if( !pPage->intKey ) sz += (int)info.nKey;
    assert( sz==info.nPayload );
    if( (sz>info.nLocal) 
     && (&pCell[info.iOverflow]<=&pPage->aData[pBt->usableSize])
    ){
      int nPage = (sz - info.nLocal + usableSize - 5)/(usableSize - 4);
      Pgno pgnoOvfl = get4byte(&pCell[info.iOverflow]);
#ifndef SQLITE_OMIT_AUTOVACUUM
      if( pBt->autoVacuum ){
        checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage, zContext);
      }
#endif
................................................................................
*************************************************************************
**
** This file contains code use to manipulate "Mem" structure.  A "Mem"
** stores a single value in the VDBE.  Mem is an opaque structure visible
** only within the VDBE.  Interface routines refer to a Mem using the
** name sqlite_value
**
** $Id: vdbemem.c,v 1.139 2009/03/29 15:12:10 drh Exp $
*/

/*
** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem*)
** P if required.
*/
#define expandBlob(P) (((P)->flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0)
................................................................................
  */
  static const i64 maxInt = LARGEST_INT64;
  static const i64 minInt = SMALLEST_INT64;

  if( r<(double)minInt ){
    return minInt;
  }else if( r>(double)maxInt ){
    /* minInt is correct here - not maxInt.  It turns out that assigning
    ** a very large positive number to an integer results in a very large
    ** negative integer.  This makes no sense, but it is what x86 hardware
    ** does so for compatibility we will do the same in software. */
    return minInt;
  }else{
    return (i64)r;
  }
}

/*
** Return some kind of integer value which is the best we can do
** at representing the value that *pMem describes as an integer.
** If pMem is an integer, then the value is exact.  If pMem is
** a floating-point then the value returned is the integer part.
** If pMem is a string or blob, then we make an attempt to convert
** it into a integer and return that.  If pMem represents an
** an SQL-NULL value, return 0.
**
** If pMem represents a string value, its encoding might be changed.
*/
SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
  int flags;
  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
  flags = pMem->flags;
  if( flags & MEM_Int ){
    return pMem->u.i;
................................................................................
**
*************************************************************************
** This file contains code used for creating, destroying, and populating
** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.)  Prior
** to version 2.8.7, all this code was combined into the vdbe.c source file.
** But that file was getting too big so this subroutines were split out.
**
** $Id: vdbeaux.c,v 1.446 2009/03/25 15:43:09 danielk1977 Exp $
*/



/*
** When debugging the code generator in a symbolic debugger, one can
** set the sqlite3VdbeAddopTrace to 1 and all opcodes will be printed
................................................................................
      pMem->flags = MEM_Int;
      pMem->u.i = pOp->p3;                          /* P3 */
      pMem->type = SQLITE_INTEGER;
      pMem++;
    }

    if( sqlite3VdbeMemGrow(pMem, 32, 0) ){            /* P4 */
      assert( p->db->mallocFailed );
      return SQLITE_ERROR;
    }
    pMem->flags = MEM_Dyn|MEM_Str|MEM_Term;
    z = displayP4(pOp, pMem->z, 32);
    if( z!=pMem->z ){
      sqlite3VdbeMemSetStr(pMem, z, -1, SQLITE_UTF8, 0);
    }else{
      assert( pMem->z!=0 );
................................................................................
      pMem->enc = SQLITE_UTF8;
    }
    pMem->type = SQLITE_TEXT;
    pMem++;

    if( p->explain==1 ){
      if( sqlite3VdbeMemGrow(pMem, 4, 0) ){
        assert( p->db->mallocFailed );
        return SQLITE_ERROR;
      }
      pMem->flags = MEM_Dyn|MEM_Str|MEM_Term;
      pMem->n = 2;
      sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5);   /* P5 */
      pMem->type = SQLITE_TEXT;
      pMem->enc = SQLITE_UTF8;
      pMem++;
................................................................................
  char *pp,            /* IN/OUT: Set *pp to point to allocated buffer */
  int nByte,           /* Number of bytes to allocate */
  u8 **ppFrom,         /* IN/OUT: Allocate from *ppFrom */
  u8 *pEnd,            /* Pointer to 1 byte past the end of *ppFrom buffer */
  int *pnByte          /* If allocation cannot be made, increment *pnByte */
){
  if( (*(void**)pp)==0 ){
    nByte = ROUND8(nByte);
    if( (pEnd - *ppFrom)>=nByte ){
      *(void**)pp = (void *)*ppFrom;
      *ppFrom += nByte;
    }else{
      *pnByte += nByte;
    }
  }
................................................................................
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains code use to implement APIs that are part of the
** VDBE.
**
** $Id: vdbeapi.c,v 1.156 2009/03/25 15:43:09 danielk1977 Exp $
*/

#if 0 && defined(SQLITE_ENABLE_MEMORY_MANAGEMENT)
/*
** The following structure contains pointers to the end points of a
** doubly-linked list of all compiled SQL statements that may be holding
** buffers eligible for release when the sqlite3_release_memory() interface is
................................................................................
    elapseTime = (u64)((rNow - (int)rNow)*3600.0*24.0*1000000000.0);
    elapseTime -= p->startTime;
    db->xProfile(db->pProfileArg, p->zSql, elapseTime);
  }
#endif

  db->errCode = rc;
  if( SQLITE_NOMEM==sqlite3ApiExit(p->db, p->rc) ){
    p->rc = SQLITE_NOMEM;
  }
end_of_step:
  /* At this point local variable rc holds the value that should be 
  ** returned if this statement was compiled using the legacy 
  ** sqlite3_prepare() interface. According to the docs, this can only
  ** be one of the values in the first assert() below. Variable p->rc 
  ** contains the value that would be returned if sqlite3_finalize() 
  ** were called on statement p.
  */
  assert( rc==SQLITE_ROW  || rc==SQLITE_DONE   || rc==SQLITE_ERROR 
       || rc==SQLITE_BUSY || rc==SQLITE_MISUSE
  );
  assert( p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE );
  if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){
    /* If this statement was prepared using sqlite3_prepare_v2(), and an
    ** error has occured, then return the error code in p->rc to the
    ** caller. Set the error code in the database handle to the same value.
    */ 
    rc = db->errCode = p->rc;
  }
  return (rc&db->errMask);
}

/*
** This is the top-level implementation of sqlite3_step().  Call
** sqlite3Step() to do most of the work.  If a schema error occurs,
** call sqlite3Reprepare() and try again.
*/
................................................................................
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** in this file for details.  If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.828 2009/03/23 17:11:27 danielk1977 Exp $
*/

/*
** The following global variable is incremented every time a cursor
** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes.  The test
** procedures use this information to make sure that indices are
** working correctly.  This variable has no function other than to
................................................................................
** is false, the SQLITE_MASTER table is only parsed if the rest of the
** schema is already loaded into the symbol table.
**
** This opcode invokes the parser to create a new virtual machine,
** then runs the new virtual machine.  It is thus a re-entrant opcode.
*/
case OP_ParseSchema: {

  int iDb = pOp->p1;



  assert( iDb>=0 && iDb<db->nDb );



  /* If pOp->p2 is 0, then this opcode is being executed to read a
  ** single row, for example the row corresponding to a new index
  ** created by this VDBE, from the sqlite_master table. It only
  ** does this if the corresponding in-memory schema is currently
  ** loaded. Otherwise, the new index definition can be loaded along
  ** with the rest of the schema when it is required.
  **
  ** Although the mutex on the BtShared object that corresponds to
  ** database iDb (the database containing the sqlite_master table
  ** read by this instruction) is currently held, it is necessary to
  ** obtain the mutexes on all attached databases before checking if
  ** the schema of iDb is loaded. This is because, at the start of
  ** the sqlite3_exec() call below, SQLite will invoke 
  ** sqlite3BtreeEnterAll(). If all mutexes are not already held, the
  ** iDb mutex may be temporarily released to avoid deadlock. If 
  ** this happens, then some other thread may delete the in-memory 
  ** schema of database iDb before the SQL statement runs. The schema
  ** will not be reloaded becuase the db->init.busy flag is set. This
  ** can result in a "no such table: sqlite_master" or "malformed
  ** database schema" error being returned to the user.
  */
  assert( sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );
  sqlite3BtreeEnterAll(db);
  if( pOp->p2 || DbHasProperty(db, iDb, DB_SchemaLoaded) ){
    const char *zMaster = SCHEMA_TABLE(iDb);
    char *zSql;
    InitData initData;
    initData.db = db;
    initData.iDb = pOp->p1;
    initData.pzErrMsg = &p->zErrMsg;
    zSql = sqlite3MPrintf(db,
       "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s",
       db->aDb[iDb].zName, zMaster, pOp->p4.z);
    if( zSql==0 ){
      rc = SQLITE_NOMEM;
    }else{
      (void)sqlite3SafetyOff(db);
      assert( db->init.busy==0 );
      db->init.busy = 1;
      initData.rc = SQLITE_OK;
      assert( !db->mallocFailed );
      rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);
      if( rc==SQLITE_OK ) rc = initData.rc;
      sqlite3DbFree(db, zSql);
      db->init.busy = 0;
      (void)sqlite3SafetyOn(db);
    }
  }
  sqlite3BtreeLeaveAll(db);
  if( rc==SQLITE_NOMEM ){
    goto no_mem;
  }
  break;  
}

#if !defined(SQLITE_OMIT_ANALYZE) && !defined(SQLITE_OMIT_PARSER)
................................................................................
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains code used to implement incremental BLOB I/O.
**
** $Id: vdbeblob.c,v 1.31 2009/03/24 15:08:10 drh Exp $
*/


#ifndef SQLITE_OMIT_INCRBLOB

/*
** Valid sqlite3_blob* handles point to Incrblob structures.
................................................................................
/*
** Close a blob handle that was previously created using
** sqlite3_blob_open().
*/
SQLITE_API int sqlite3_blob_close(sqlite3_blob *pBlob){
  Incrblob *p = (Incrblob *)pBlob;
  int rc;
  sqlite3 *db;

  db = p->db;
  sqlite3_mutex_enter(db->mutex);
  rc = sqlite3_finalize(p->pStmt);
  sqlite3DbFree(db, p);
  sqlite3_mutex_leave(db->mutex);
  return rc;
}

/*
** Perform a read or write operation on a blob
*/
static int blobReadWrite(
................................................................................
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.424 2009/03/25 16:51:43 drh Exp $
*/

/*
** Return the 'affinity' of the expression pExpr if any.
**
** If pExpr is a column, a reference to a column via an 'AS' alias,
** or a sub-select with a column as the return value, then the 
................................................................................
  }
  pNew->op = (u8)op;
  pNew->pLeft = pLeft;
  pNew->pRight = pRight;
  pNew->iAgg = -1;
  pNew->span.z = (u8*)"";
  if( pToken ){
    int c;
    assert( pToken->dyn==0 );
    pNew->span = *pToken;
 
    /* The pToken->z value is read-only.  But the new expression
    ** node created here might be passed to sqlite3DequoteExpr() which
    ** will attempt to modify pNew->token.z.  Hence, if the token
    ** is quoted, make a copy now so that DequoteExpr() will change
    ** the copy rather than the original text.
    */
    if( pToken->n>=2 
         && ((c = pToken->z[0])=='\'' || c=='"' || c=='[' || c=='`') ){
      sqlite3TokenCopy(db, &pNew->token, pToken);
    }else{
      pNew->token = *pToken;
      pNew->flags |= EP_Dequoted;
      VVA_ONLY( pNew->vvaFlags |= EVVA_ReadOnlyToken; )
    }
  }else if( pLeft ){
    if( pRight ){
      if( pRight->span.dyn==0 && pLeft->span.dyn==0 ){
        sqlite3ExprSpan(pNew, &pLeft->span, &pRight->span);
      }
      if( pRight->flags & EP_ExpCollate ){
        pNew->flags |= EP_ExpCollate;
................................................................................
*/
SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse *pParse, ExprList *pList, Token *pToken){
  Expr *pNew;
  sqlite3 *db = pParse->db;
  assert( pToken );
  pNew = sqlite3DbMallocZero(db, sizeof(Expr) );
  if( pNew==0 ){
    sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */
    return 0;
  }
  pNew->op = TK_FUNCTION;
  pNew->x.pList = pList;
  assert( !ExprHasProperty(pNew, EP_xIsSelect) );
  assert( pToken->dyn==0 );
  pNew->span = *pToken;
  sqlite3TokenCopy(db, &pNew->token, pToken);

  sqlite3ExprSetHeight(pParse, pNew);
  return pNew;
}

/*
** Assign a variable number to an expression that encodes a wildcard
** in the original SQL statement.  
................................................................................
  sqlite3DbFree(db, p);
}

/*
** The Expr.token field might be a string literal that is quoted.
** If so, remove the quotation marks.
*/
SQLITE_PRIVATE void sqlite3DequoteExpr(Expr *p){
  if( !ExprHasAnyProperty(p, EP_Dequoted) ){


    ExprSetProperty(p, EP_Dequoted);
















    assert( (p->vvaFlags & EVVA_ReadOnlyToken)==0 );
    sqlite3Dequote((char*)p->token.z);
  }
}

/*
** Return the number of bytes allocated for the expression structure 
** passed as the first argument. This is always one of EXPR_FULLSIZE,
** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE.
*/
................................................................................
static int dupedExprNodeSize(Expr *p, int flags){
  int nByte = dupedExprStructSize(p, flags) + (p->token.z ? p->token.n + 1 : 0);
  if( (flags&EXPRDUP_DISTINCTSPAN)
   || (flags&EXPRDUP_SPAN && (p->token.z!=p->span.z || p->token.n!=p->span.n)) 
  ){
    nByte += p->span.n;
  }
  return ROUND8(nByte);
}

/*
** Return the number of bytes required to create a duplicate of the 
** expression passed as the first argument. The second argument is a
** mask containing EXPRDUP_XXX flags.
**
................................................................................
** If the EXPRDUP_REDUCE flag is set, then the structure returned is a
** truncated version of the usual Expr structure that will be stored as
** part of the in-memory representation of the database schema.
*/
SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3 *db, Expr *p, int flags){
  return exprDup(db, p, flags, 0);
}
SQLITE_PRIVATE void sqlite3TokenCopy(sqlite3 *db, Token *pTo, const Token *pFrom){
  if( pTo->dyn ) sqlite3DbFree(db, (char*)pTo->z);
  if( pFrom->z ){
    pTo->n = pFrom->n;
    pTo->z = (u8*)sqlite3DbStrNDup(db, (char*)pFrom->z, pFrom->n);
    pTo->dyn = 1;
  }else{
    pTo->z = 0;
................................................................................
      break;
    }
    case TK_FLOAT: {
      codeReal(v, (char*)pExpr->token.z, pExpr->token.n, 0, target);
      break;
    }
    case TK_STRING: {
      sqlite3DequoteExpr(pExpr);
      sqlite3VdbeAddOp4(v,OP_String8, 0, target, 0,
                        (char*)pExpr->token.z, pExpr->token.n);
      break;
    }
    case TK_NULL: {
      sqlite3VdbeAddOp2(v, OP_Null, 0, target);
      break;
................................................................................
                       "RAISE() may only be used within a trigger-program");
        return 0;
      }
      if( pExpr->affinity!=OE_Ignore ){
         assert( pExpr->affinity==OE_Rollback ||
                 pExpr->affinity == OE_Abort ||
                 pExpr->affinity == OE_Fail );
         sqlite3DequoteExpr(pExpr);
         sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CONSTRAINT, pExpr->affinity, 0,
                        (char*)pExpr->token.z, pExpr->token.n);
      } else {
         assert( pExpr->affinity == OE_Ignore );
         sqlite3VdbeAddOp2(v, OP_ContextPop, 0, 0);
         sqlite3VdbeAddOp2(v, OP_Goto, 0, pParse->trigStack->ignoreJump);
         VdbeComment((v, "raise(IGNORE)"));
................................................................................
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that used to generate VDBE code
** that implements the ALTER TABLE command.
**
** $Id: alter.c,v 1.55 2009/03/24 15:08:10 drh Exp $
*/

/*
** The code in this file only exists if we are not omitting the
** ALTER TABLE logic from the build.
*/
#ifndef SQLITE_OMIT_ALTERTABLE
................................................................................
  ** table because user table are not allowed to have the "sqlite_"
  ** prefix on their name.
  */
  pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));
  if( !pNew ) goto exit_begin_add_column;
  pParse->pNewTable = pNew;
  pNew->nRef = 1;
  pNew->dbMem = pTab->dbMem;
  pNew->nCol = pTab->nCol;
  assert( pNew->nCol>0 );
  nAlloc = (((pNew->nCol-1)/8)*8)+8;
  assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );
  pNew->aCol = (Column*)sqlite3DbMallocZero(db, sizeof(Column)*nAlloc);
  pNew->zName = sqlite3MPrintf(db, "sqlite_altertab_%s", pTab->zName);
  if( !pNew->aCol || !pNew->zName ){
................................................................................
**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**
** $Id: build.c,v 1.527 2009/03/31 03:41:57 shane Exp $
*/

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Initialize the pParse structure as needed.
*/
SQLITE_PRIVATE void sqlite3BeginParse(Parse *pParse, int explainFlag){
................................................................................
  return p;
}

/*
** Reclaim the memory used by an index
*/
static void freeIndex(Index *p){
  sqlite3 *db = p->pTable->dbMem;
  sqlite3DbFree(db, p->zColAff);
  sqlite3DbFree(db, p);
}

/*
** Remove the given index from the index hash table, and free
** its memory structures.
................................................................................

/*
** Clear the column names from a table or view.
*/
static void sqliteResetColumnNames(Table *pTable){
  int i;
  Column *pCol;
  sqlite3 *db = pTable->dbMem;
  assert( pTable!=0 );
  if( (pCol = pTable->aCol)!=0 ){
    for(i=0; i<pTable->nCol; i++, pCol++){
      sqlite3DbFree(db, pCol->zName);
      sqlite3ExprDelete(db, pCol->pDflt);
      sqlite3DbFree(db, pCol->zType);
      sqlite3DbFree(db, pCol->zColl);
................................................................................
*/
SQLITE_PRIVATE void sqlite3DeleteTable(Table *pTable){
  Index *pIndex, *pNext;
  FKey *pFKey, *pNextFKey;
  sqlite3 *db;

  if( pTable==0 ) return;
  db = pTable->dbMem;

  /* Do not delete the table until the reference count reaches zero. */
  pTable->nRef--;
  if( pTable->nRef>0 ){
    return;
  }
  assert( pTable->nRef==0 );
................................................................................
    pParse->nErr++;
    goto begin_table_error;
  }
  pTable->zName = zName;
  pTable->iPKey = -1;
  pTable->pSchema = db->aDb[iDb].pSchema;
  pTable->nRef = 1;
  pTable->dbMem = db->lookaside.bEnabled ? db : 0;
  if( pParse->pNewTable ) sqlite3DeleteTable(pParse->pNewTable);
  pParse->pNewTable = pTable;

  /* If this is the magic sqlite_sequence table used by autoincrement,
  ** then record a pointer to this table in the main database structure
  ** so that INSERT can find the table easily.
  */
................................................................................
  ** to the elements of the FROM clause.  But we do not want these changes
  ** to be permanent.  So the computation is done on a copy of the SELECT
  ** statement that defines the view.
  */
  assert( pTable->pSelect );
  pSel = sqlite3SelectDup(db, pTable->pSelect, 0);
  if( pSel ){
    u8 enableLookaside = db->lookaside.bEnabled;
    n = pParse->nTab;
    sqlite3SrcListAssignCursors(pParse, pSel->pSrc);
    pTable->nCol = -1;
    db->lookaside.bEnabled = 0;
#ifndef SQLITE_OMIT_AUTHORIZATION
    xAuth = db->xAuth;
    db->xAuth = 0;
    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
    db->xAuth = xAuth;
#else
    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
#endif
    db->lookaside.bEnabled = enableLookaside;
    pParse->nTab = n;
    if( pSelTab ){
      assert( pTable->aCol==0 );
      pTable->nCol = pSelTab->nCol;
      pTable->aCol = pSelTab->aCol;
      pSelTab->nCol = 0;
      pSelTab->aCol = 0;
................................................................................
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains functions used to access the internal hash tables
** of user defined functions and collation sequences.
**
** $Id: callback.c,v 1.37 2009/03/24 15:08:10 drh Exp $
*/


/*
** Invoke the 'collation needed' callback to request a collation sequence
** in the database text encoding of name zName, length nName.
** If the collation sequence
................................................................................
  for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){
    sqlite3DeleteTrigger(0, (Trigger*)sqliteHashData(pElem));
  }
  sqlite3HashClear(&temp2);
  sqlite3HashInit(&pSchema->tblHash, 0);
  for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){
    Table *pTab = sqliteHashData(pElem);
    assert( pTab->dbMem==0 );
    sqlite3DeleteTable(pTab);
  }
  sqlite3HashClear(&temp1);
  pSchema->pSeqTab = 0;
  pSchema->flags &= ~DB_SchemaLoaded;
}

................................................................................
** This file contains the C functions that implement various SQL
** functions of SQLite.  
**
** There is only one exported symbol in this file - the function
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: func.c,v 1.225 2009/03/27 15:26:03 danielk1977 Exp $
*/

/*
** Return the collating function associated with a function.
*/
static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){
  return context->pColl;
................................................................................
SQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive){
  struct compareInfo *pInfo;
  if( caseSensitive ){
    pInfo = (struct compareInfo*)&likeInfoAlt;
  }else{
    pInfo = (struct compareInfo*)&likeInfoNorm;
  }
  sqlite3CreateFunc(db, "like", 2, SQLITE_ANY, pInfo, likeFunc, 0, 0);
  sqlite3CreateFunc(db, "like", 3, SQLITE_ANY, pInfo, likeFunc, 0, 0);
  sqlite3CreateFunc(db, "glob", 2, SQLITE_ANY, 
      (struct compareInfo*)&globInfo, likeFunc, 0,0);
  setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE);
  setLikeOptFlag(db, "like", 
      caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE);
}

/*
................................................................................
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the implementation of the sqlite3_prepare()
** interface, and routines that contribute to loading the database schema
** from disk.
**
** $Id: prepare.c,v 1.114 2009/03/24 15:08:10 drh Exp $
*/

/*
** Fill the InitData structure with an error message that indicates
** that the database is corrupt.
*/
static void corruptSchema(
................................................................................
    /* Call the parser to process a CREATE TABLE, INDEX or VIEW.
    ** But because db->init.busy is set to 1, no VDBE code is generated
    ** or executed.  All the parser does is build the internal data
    ** structures that describe the table, index, or view.
    */
    char *zErr;
    int rc;

    assert( db->init.busy );
    db->init.iDb = iDb;
    db->init.newTnum = atoi(argv[1]);


    rc = sqlite3_exec(db, argv[2], 0, 0, &zErr);
    db->init.iDb = 0;

    assert( rc!=SQLITE_OK || zErr==0 );
    if( SQLITE_OK!=rc ){
      pData->rc = rc;
      if( rc==SQLITE_NOMEM ){
        db->mallocFailed = 1;
      }else if( rc!=SQLITE_INTERRUPT && (rc&0xff)!=SQLITE_LOCKED ){
        corruptSchema(pData, argv[0], zErr);
      }
      sqlite3DbFree(db, zErr);
    }
  }else if( argv[0]==0 ){
    corruptSchema(pData, 0, 0);
  }else{
................................................................................
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.506 2009/03/31 03:41:57 shane Exp $
*/


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
*/
................................................................................
** Add type and collation information to a column list based on
** a SELECT statement.
** 
** The column list presumably came from selectColumnNamesFromExprList().
** The column list has only names, not types or collations.  This
** routine goes through and adds the types and collations.
**
** This routine requires that all identifiers in the SELECT
** statement be resolved.
*/
static void selectAddColumnTypeAndCollation(
  Parse *pParse,        /* Parsing contexts */
  int nCol,             /* Number of columns */
  Column *aCol,         /* List of columns */
  Select *pSelect       /* SELECT used to determine types and collations */
................................................................................
  if( pParse->nErr ) return 0;
  while( pSelect->pPrior ) pSelect = pSelect->pPrior;
  db->flags = savedFlags;
  pTab = sqlite3DbMallocZero(db, sizeof(Table) );
  if( pTab==0 ){
    return 0;
  }
  pTab->dbMem = db->lookaside.bEnabled ? db : 0;
  pTab->nRef = 1;
  pTab->zName = 0;
  selectColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol);
  selectAddColumnTypeAndCollation(pParse, pTab->nCol, pTab->aCol, pSelect);
  pTab->iPKey = -1;
  if( db->mallocFailed ){
    sqlite3DeleteTable(pTab);
................................................................................
      Select *pSel = pFrom->pSelect;
      /* A sub-query in the FROM clause of a SELECT */
      assert( pSel!=0 );
      assert( pFrom->pTab==0 );
      sqlite3WalkSelect(pWalker, pSel);
      pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
      if( pTab==0 ) return WRC_Abort;
      pTab->dbMem = db->lookaside.bEnabled ? db : 0;
      pTab->nRef = 1;
      pTab->zName = sqlite3MPrintf(db, "sqlite_subquery_%p_", (void*)pTab);
      while( pSel->pPrior ){ pSel = pSel->pPrior; }
      selectColumnsFromExprList(pParse, pSel->pEList, &pTab->nCol, &pTab->aCol);
      pTab->iPKey = -1;
      pTab->tabFlags |= TF_Ephemeral;
#endif
................................................................................
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code used to help implement virtual tables.
**
** $Id: vtab.c,v 1.84 2009/03/24 15:08:10 drh Exp $
*/
#ifndef SQLITE_OMIT_VIRTUALTABLE

static int createModule(
  sqlite3 *db,                    /* Database in which module is registered */
  const char *zName,              /* Name assigned to this module */
  const sqlite3_module *pModule,  /* The definition of the module */
................................................................................
/*
** Clear any and all virtual-table information from the Table record.
** This routine is called, for example, just before deleting the Table
** record.
*/
SQLITE_PRIVATE void sqlite3VtabClear(Table *p){
  sqlite3_vtab *pVtab = p->pVtab;
  Schema *pSchema = p->pSchema;
  sqlite3 *db = pSchema ? pSchema->db : 0;
  if( pVtab ){
    assert( p->pMod && p->pMod->pModule );
    sqlite3VtabUnlock(db, pVtab);
    p->pVtab = 0;
  }
  if( p->azModuleArg ){
    int i;
................................................................................
** This module contains C code that generates VDBE code used to process
** the WHERE clause of SQL statements.  This module is responsible for
** generating the code that loops through a table looking for applicable
** rows.  Indices are selected and used to speed the search when doing
** so is applicable.  Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
** $Id: where.c,v 1.379 2009/03/29 00:15:54 drh Exp $
*/

/*
** Trace output macros
*/
#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
SQLITE_PRIVATE int sqlite3WhereTrace = 0;
................................................................................
    /* No collation is defined for the ROWID.  Use the default. */
    pColl = db->pDfltColl;
  }
  if( (pColl->type!=SQLITE_COLL_BINARY || *pnoCase) &&
      (pColl->type!=SQLITE_COLL_NOCASE || !*pnoCase) ){
    return 0;
  }
  sqlite3DequoteExpr(pRight);
  z = (char *)pRight->token.z;
  cnt = 0;
  if( z ){
    while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){ cnt++; }
  }
  if( cnt==0 || 255==(u8)z[cnt-1] ){
    return 0;
................................................................................

  /* Look at each index.
  */
  if( pSrc->pIndex ){
    pProbe = pSrc->pIndex;
  }
  for(; pProbe; pProbe=(pSrc->pIndex ? 0 : pProbe->pNext)){
    double inMultiplier = 1;  /* Number of equality look-ups needed */
    int inMultIsEst = 0;      /* True if inMultiplier is an estimate */

    WHERETRACE(("... index %s:\n", pProbe->zName));

    /* Count the number of columns in the index that are satisfied
    ** by x=EXPR constraints or x IN (...) constraints.  For a term
    ** of the form x=EXPR we only have to do a single binary search.
    ** But for x IN (...) we have to do a number of binary searched
    ** equal to the number of entries on the RHS of the IN operator.
    ** The inMultipler variable with try to estimate the number of
    ** binary searches needed.
    */
    wsFlags = 0;
    for(i=0; i<pProbe->nColumn; i++){
      int j = pProbe->aiColumn[i];
      pTerm = findTerm(pWC, iCur, j, notReady, eqTermMask, pProbe);
      if( pTerm==0 ) break;
      wsFlags |= WHERE_COLUMN_EQ;
      if( pTerm->eOperator & WO_IN ){
        Expr *pExpr = pTerm->pExpr;
        wsFlags |= WHERE_COLUMN_IN;
        if( ExprHasProperty(pExpr, EP_xIsSelect) ){
          inMultiplier *= 25;
          inMultIsEst = 1;
        }else if( pExpr->x.pList ){
          inMultiplier *= pExpr->x.pList->nExpr + 1;
        }
      }
    }
    nRow = pProbe->aiRowEst[i] * inMultiplier;
    /* If inMultiplier is an estimate and that estimate results in an
    ** nRow it that is more than half number of rows in the table,
    ** then reduce inMultipler */
    if( inMultIsEst && nRow*2 > pProbe->aiRowEst[0] ){
      nRow = pProbe->aiRowEst[0]/2;
      inMultiplier = nRow/pProbe->aiRowEst[i];
    }
    cost = nRow + inMultiplier*estLog(pProbe->aiRowEst[0]);
    nEq = i;
    if( pProbe->onError!=OE_None && (wsFlags & WHERE_COLUMN_IN)==0
         && nEq==pProbe->nColumn ){
      wsFlags |= WHERE_UNIQUE;
    }
    WHERETRACE(("...... nEq=%d inMult=%.9g nRow=%.9g cost=%.9g\n",
                nEq, inMultiplier, nRow, cost));

    /* Look for range constraints.  Assume that each range constraint
    ** makes the search space 1/3rd smaller.
    */
    if( nEq<pProbe->nColumn ){
      int j = pProbe->aiColumn[nEq];
      pTerm = findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE|WO_GT|WO_GE, pProbe);
      if( pTerm ){
        wsFlags |= WHERE_COLUMN_RANGE;
        if( findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE, pProbe) ){
................................................................................
          nRow /= 3;
        }
        if( findTerm(pWC, iCur, j, notReady, WO_GT|WO_GE, pProbe) ){
          wsFlags |= WHERE_BTM_LIMIT;
          cost /= 3;
          nRow /= 3;
        }
        WHERETRACE(("...... range reduces nRow to %.9g and cost to %.9g\n",
                    nRow, cost));
      }
    }

    /* Add the additional cost of sorting if that is a factor.
    */
    if( pOrderBy ){
      if( (wsFlags & WHERE_COLUMN_IN)==0 &&
................................................................................
**    sqlite3ParserARG_FETCH     Code to extract %extra_argument from yypParser
**    YYNSTATE           the combined number of states.
**    YYNRULE            the number of rules in the grammar
**    YYERRORSYMBOL      is the code number of the error symbol.  If not
**                       defined, then do no error processing.
*/
#define YYCODETYPE unsigned char
#define YYNOCODE 239
#define YYACTIONTYPE unsigned short int
#define YYWILDCARD 65
#define sqlite3ParserTOKENTYPE Token
typedef union {
  int yyinit;
  sqlite3ParserTOKENTYPE yy0;
  int yy60;
  struct TrigEvent yy62;
  struct {int value; int mask;} yy243;
  struct LikeOp yy258;
  ExprList* yy266;
  IdList* yy272;
  Select* yy331;
  struct LimitVal yy348;
  SrcList* yy427;
  Expr* yy454;
  TriggerStep* yy455;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
#endif
#define sqlite3ParserARG_SDECL Parse *pParse;
#define sqlite3ParserARG_PDECL ,Parse *pParse
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
#define YYNSTATE 549
#define YYNRULE 284
#define YYFALLBACK 1
#define YY_NO_ACTION      (YYNSTATE+YYNRULE+2)
#define YY_ACCEPT_ACTION  (YYNSTATE+YYNRULE+1)
#define YY_ERROR_ACTION   (YYNSTATE+YYNRULE)

/* The yyzerominor constant is used to initialize instances of
** YYMINORTYPE objects to zero. */
................................................................................
**  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.
*/
static const YYACTIONTYPE yy_action[] = {
 /*     0 */   273,  834,  155,  548,    2,  138,  192,  396,   21,   21,
 /*    10 */    21,   21,  143,   23,   23,   23,   23,   24,   24,   25,
 /*    20 */    25,   25,   26,  194,  370,  371,  190,  370,  371,  403,
 /*    30 */   409,   28,   23,   23,   23,   23,   24,   24,   25,   25,
 /*    40 */    25,   26,  194,   27,  440,   29,  122,   20,   19,  277,
 /*    50 */   413,  414,  410,  410,   22,   22,   21,   21,   21,   21,
 /*    60 */   393,   23,   23,   23,   23,   24,   24,   25,   25,   25,
 /*    70 */    26,  194,  273,  334,  280,  396,  425,  196,   42,   23,
 /*    80 */    23,   23,   23,   24,   24,   25,   25,   25,   26,  194,
 /*    90 */   483,  169,  373,  374,  144,  373,  374,  326,  329,  330,
 /*   100 */   280,  403,  409,  142,   27,   18,   29,  122,  331,   24,
 /*   110 */    24,   25,   25,   25,   26,  194,  138,  263,  396,   20,
 /*   120 */    19,  277,  413,  414,  410,  410,   22,   22,   21,   21,
 /*   130 */    21,   21,  142,   23,   23,   23,   23,   24,   24,   25,
 /*   140 */    25,   25,   26,  194,  273,  206,  427,  303,  178,  115,
 /*   150 */   452,  133,  120,  234,  324,  239,  325,  141,  275,  266,
 /*   160 */   297,  264,  144,  243,  243,  326,  329,  330,   55,  529,
 /*   170 */   171,  206,  396,  403,  409,  294,  331,  469,  120,  234,
 /*   180 */   324,  239,  325,  141,  392,   68,  396,  275,  429,  200,
 /*   190 */   243,   20,   19,  277,  413,  414,  410,  410,   22,   22,
 /*   200 */    21,   21,   21,   21,  393,   23,   23,   23,   23,   24,
 /*   210 */    24,   25,   25,   25,   26,  194,  273,  276,  470,  354,
 /*   220 */   260,  259,  398,  297,  396,  361,  311,  194,  290,  367,
 /*   230 */   192,  310,  387,  502,  191,  297,  113,  297,  294,  265,
 /*   240 */   396,  499,  189,  388,  192,  403,  409,  392,   68,  472,
 /*   250 */   294,  499,  294,  400,  400,  400,  360,  452,  389,  392,
 /*   260 */    69,  392,   75,   20,   19,  277,  413,  414,  410,  410,
 /*   270 */    22,   22,   21,   21,   21,   21,  393,   23,   23,   23,
 /*   280 */    23,   24,   24,   25,   25,   25,   26,  194,  273,  311,
 /*   290 */   530,  344,  396,    1,  321,  347,  461,  370,  371,  391,
 /*   300 */   359,  313,  199,  390,  297,  270,  297,  471,  427,  503,
 /*   310 */   178,  225,  456,   27,  170,   29,  122,  403,  409,  294,
 /*   320 */   192,  294,   25,   25,   25,   26,  194,  372,  392,   62,
 /*   330 */   392,   75,  353,   37,  529,   20,   19,  277,  413,  414,
 /*   340 */   410,  410,   22,   22,   21,   21,   21,   21,  393,   23,
 /*   350 */    23,   23,   23,   24,   24,   25,   25,   25,   26,  194,
 /*   360 */   273,  504,  242,  235,  465,  373,  374,  297,  512,  370,
 /*   370 */   371,  198,  386,   54,  236,  279,  372,  372,  297,  278,
 /*   380 */   420,  421,  294,   57,  354,  260,  259,  370,  371,  403,
 /*   390 */   409,  392,   68,  294,  505,  192,  168,  513,  524,  283,
 /*   400 */   365,  362,  392,   83,   14,   40,  162,   20,   19,  277,
 /*   410 */   413,  414,  410,  410,   22,   22,   21,   21,   21,   21,
 /*   420 */   219,   23,   23,   23,   23,   24,   24,   25,   25,   25,
 /*   430 */    26,  194,  273,  315,  504,  297,  468,  373,  374,  319,
 /*   440 */   447,  195,  218,  370,  371,  514,   54,  318,  288,  372,
 /*   450 */   294,  464,  308,  370,  371,  373,  374,  364,    2,  392,
 /*   460 */    83,  403,  409,  448,  144,   26,  194,  326,  329,  330,
 /*   470 */   302,  420,  421,  549,  365,  362,  434,  526,  331,   20,
 /*   480 */    19,  277,  413,  414,  410,  410,   22,   22,   21,   21,
 /*   490 */    21,   21,  435,   23,   23,   23,   23,   24,   24,   25,
 /*   500 */    25,   25,   26,  194,  273,  289,  445,  436,  485,  476,
 /*   510 */   123,  373,  374,  463,  320,  794,  511,  486,  158,  477,
 /*   520 */   447,  373,  374,  510,  446,  417,  456,  404,  405,  294,
 /*   530 */   187,  456,  195,  403,  409,  447,  212,  449,  392,    7,
 /*   540 */   300,  372,  416,  416,    4,  174,  372,  186,  407,  408,
 /*   550 */   426,   20,   19,  277,  413,  414,  410,  410,   22,   22,
 /*   560 */    21,   21,   21,   21,  393,   23,   23,   23,   23,   24,
 /*   570 */    24,   25,   25,   25,   26,  194,  273,  406,  297,  393,
 /*   580 */   246,  242,  300,  297,  416,  416,  297,  488,  352,  342,
 /*   590 */   123,  175,  125,  294,  287,  430,  372,  297,  294,  157,
 /*   600 */   165,  294,  392,   63,   53,  403,  409,  392,   58,  355,
 /*   610 */   392,   66,  294,  493,  300,  447,  416,  416,  207,  474,
 /*   620 */   475,  392,   85,   20,   19,  277,  413,  414,  410,  410,
 /*   630 */    22,   22,   21,   21,   21,   21,  297,   23,   23,   23,
 /*   640 */    23,   24,   24,   25,   25,   25,   26,  194,  273,  297,
 /*   650 */   442,  294,  242,  375,  376,  377,  297,  242,  491,  443,
 /*   660 */   392,   84,  527,  475,  294,  179,  125,  372,  297,  299,
 /*   670 */   226,  294,  372,  392,   89,  193,  338,  403,  409,  492,
 /*   680 */   392,   87,   15,  294,  300,  372,  416,  416,  300,  284,
 /*   690 */   416,  416,  392,   92,  285,   20,   19,  277,  413,  414,
 /*   700 */   410,  410,   22,   22,   21,   21,   21,   21,  297,   23,
 /*   710 */    23,   23,   23,   24,   24,   25,   25,   25,   26,  194,
 /*   720 */   273,  297,  254,  294,  434,  452,  242,  297,   36,  297,
 /*   730 */    38,  282,  392,   93,  423,  423,  294,  372,  480,  481,
 /*   740 */   435,  372,  294,  351,  294,  392,  114,  351,  411,  403,
 /*   750 */   409,  392,  116,  392,   52,  436,  494,  307,  372,  520,
 /*   760 */   341,  520,  372,  286,  230,  255,  384,   20,   30,  277,
 /*   770 */   413,  414,  410,  410,   22,   22,   21,   21,   21,   21,
 /*   780 */   297,   23,   23,   23,   23,   24,   24,   25,   25,   25,
 /*   790 */    26,  194,  273,  297,  164,  294,  254,  124,  522,  322,
 /*   800 */   297,  152,  521,  220,  392,   90,  397,  418,  294,   56,
 /*   810 */   211,  372,  372,  297,  208,  294,  343,  392,   67,  422,
 /*   820 */   316,  403,  409,  228,  392,   88,  391,  424,  294,  454,
 /*   830 */   390,  139,  180,  181,  182,  372,  188,  392,   59,  538,
 /*   840 */    19,  277,  413,  414,  410,  410,   22,   22,   21,   21,
 /*   850 */    21,   21,  297,   23,   23,   23,   23,   24,   24,   25,
 /*   860 */    25,   25,   26,  194,  273,  297,  227,  294,  254,  254,
 /*   870 */   393,  298,  297,  369,  172,  441,  392,   86,  490,  489,
 /*   880 */   294,  372,  305,  372,  372,  297,  372,  294,  372,  392,
 /*   890 */   117,  486,  381,  403,  409,  328,  392,  118,  497,  500,
 /*   900 */   294,  495,   44,  143,  187,  444,  248,  372,  393,  392,
 /*   910 */   119,  540,  541,  277,  413,  414,  410,  410,   22,   22,
 /*   920 */    21,   21,   21,   21,  237,   23,   23,   23,   23,   24,
 /*   930 */    24,   25,   25,   25,   26,  194,   32,  304,  393,    3,
 /*   940 */   297,  254,  297,  293,  371,  183,  382,  245,  252,  143,
 /*   950 */   250,   32,  304,  301,    3,  294,  372,  294,  293,  371,
 /*   960 */   254,  372,  352,  254,  392,   60,  392,   70,  301,  532,
 /*   970 */   297,  306,  333,  297,  143,  372,  496,  254,  372,  393,
 /*   980 */   452,  429,  498,  348,  542,  294,  306,  267,  294,  297,
 /*   990 */   383,  525,  372,  143,  392,   71,  429,  392,   61,  544,
 /*  1000 */   129,   35,   34,  209,  294,  372,  210,  297,  121,  399,
 /*  1010 */    33,  295,  296,  392,   72,  398,   35,   34,  462,  232,
 /*  1020 */   269,  184,  294,  372,  372,   33,  295,  296,  358,  309,
 /*  1030 */   398,  392,   73,  192,  368,   32,  304,  380,    3,  438,
 /*  1040 */     6,  451,  293,  371,  372,  455,  400,  400,  400,  401,
 /*  1050 */   402,    8,  301,   16,  372,  393,  372,  370,  371,  378,
 /*  1060 */   372,  400,  400,  400,  401,  402,    8,  176,  297,  457,
 /*  1070 */   306,  240,  213,  214,  215,  131,  217,  379,  291,  537,
 /*  1080 */   429,  297,  487,  294,  372,  130,  372,  241,  297,  506,
 /*  1090 */   394,  132,  392,   74,  292,  429,  294,  372,  221,   44,
 /*  1100 */    35,   34,  372,  294,  372,  392,   76,  297,  247,   33,
 /*  1110 */   295,  296,  392,   77,  398,  166,  167,  529,  314,  297,
 /*  1120 */   249,   43,  294,  372,  251,  470,  253,  258,  533,  398,
 /*  1130 */   139,  392,   78,  222,  294,  372,  312,  346,  349,  372,
 /*  1140 */    39,  372,  372,  392,   64,  400,  400,  400,  401,  402,
 /*  1150 */     8,  297,  372,  372,  223,  350,  297,  261,  224,  297,
 /*  1160 */   400,  400,  400,  534,  395,   51,  294,  357,  268,  259,
 /*  1170 */   372,  294,  372,  274,  294,  392,   65,  545,  192,   51,
 /*  1180 */   392,   79,  297,  392,   80,  297,   17,  262,  137,  197,
 /*  1190 */   439,  156,   45,  229,  317,  453,  231,  294,  323,  233,
 /*  1200 */   294,  459,  372,  473,  478,  460,  392,   81,  281,  392,
 /*  1210 */    82,  483,  238,   95,  479,  484,  482,  204,  507,  271,
 /*  1220 */   508,  203,  509,  335,  272,  501,  205,  515,  146,  147,
 /*  1230 */   339,  337,  148,   48,  185,  517,  256,  149,  518,  345,
 /*  1240 */   128,  528,  151,  104,  160,  356,  535,  105,  106,  107,
 /*  1250 */   108,  110,   91,  543,  366,  202,  216,  385,  177,   99,
 /*  1260 */   590,  591,  159,  592,  134,  135,  412,   31,  415,  419,
 /*  1270 */   428,  161,  431,  173,    5,  432,   10,  450,  433,  136,
 /*  1280 */   437,   41,   94,    9,  140,  126,  458,  466,  467,  201,
 /*  1290 */    46,   96,   97,  327,  244,   47,   98,  145,  332,  236,
 /*  1300 */   127,  336,  163,  516,  100,  340,  139,  257,  150,  102,
 /*  1310 */    13,  531,   49,   11,  103,  153,  154,  536,  101,  539,
 /*  1320 */   109,  111,   12,  519,  546,  112,  523,  363,  835,  547,
 /*  1330 */   835,  835,  835,  835,  835,  835,  835,  835,  835,  835,
 /*  1340 */   835,  835,  835,  835,  835,  835,   50,
};
static const YYCODETYPE yy_lookahead[] = {
 /*     0 */    19,  140,  141,  142,  143,   24,  116,   26,   75,   76,
 /*    10 */    77,   78,   25,   80,   81,   82,   83,   84,   85,   86,
 /*    20 */    87,   88,   89,   90,   26,   27,  158,   26,   27,   48,
 /*    30 */    49,   79,   80,   81,   82,   83,   84,   85,   86,   87,
 /*    40 */    88,   89,   90,  220,  221,  222,  223,   66,   67,   68,
 /*    50 */    69,   70,   71,   72,   73,   74,   75,   76,   77,   78,
 /*    60 */   192,   80,   81,   82,   83,   84,   85,   86,   87,   88,
 /*    70 */    89,   90,   19,   19,   19,   94,   84,   85,   25,   80,
 /*    80 */    81,   82,   83,   84,   85,   86,   87,   88,   89,   90,
 /*    90 */   103,   25,   94,   95,   96,   94,   95,   99,  100,  101,
 /*   100 */    19,   48,   49,   49,  220,   52,  222,  223,  110,   84,
 /*   110 */    85,   86,   87,   88,   89,   90,   24,   16,   26,   66,
 /*   120 */    67,   68,   69,   70,   71,   72,   73,   74,   75,   76,
 /*   130 */    77,   78,   49,   80,   81,   82,   83,   84,   85,   86,
 /*   140 */    87,   88,   89,   90,   19,   90,  164,  165,  166,   24,
 /*   150 */   164,   96,   97,   98,   99,  100,  101,  102,  104,   58,
 /*   160 */   148,   60,   96,  109,  109,   99,  100,  101,   22,   55,
 /*   170 */   158,   90,   26,   48,   49,  163,  110,  172,   97,   98,
 /*   180 */    99,  100,  101,  102,  172,  173,   94,  104,   64,  203,
 /*   190 */   109,   66,   67,   68,   69,   70,   71,   72,   73,   74,
 /*   200 */    75,   76,   77,   78,  192,   80,   81,   82,   83,   84,
 /*   210 */    85,   86,   87,   88,   89,   90,   19,  153,   94,  105,
 /*   220 */   106,  107,   98,  148,   26,   97,  214,   90,  144,  145,
 /*   230 */   116,  219,  170,  171,  150,  148,  152,  148,  163,  138,
 /*   240 */    94,  179,  158,  171,  116,   48,   49,  172,  173,  163,
 /*   250 */   163,  179,  163,  129,  130,  131,  128,  164,  172,  172,
 /*   260 */   173,  172,  173,   66,   67,   68,   69,   70,   71,   72,
 /*   270 */    73,   74,   75,   76,   77,   78,  192,   80,   81,   82,
 /*   280 */    83,   84,   85,   86,   87,   88,   89,   90,   19,  214,
 /*   290 */    11,  227,   94,   22,  219,  231,  203,   26,   27,  113,
 /*   300 */   216,  212,  213,  117,  148,  161,  148,  172,  164,  165,
 /*   310 */   166,  224,  148,  220,  158,  222,  223,   48,   49,  163,
 /*   320 */   116,  163,   86,   87,   88,   89,   90,  163,  172,  173,
 /*   330 */   172,  173,  128,  136,   55,   66,   67,   68,   69,   70,
 /*   340 */    71,   72,   73,   74,   75,   76,   77,   78,  192,   80,
 /*   350 */    81,   82,   83,   84,   85,   86,   87,   88,   89,   90,
 /*   360 */    19,  148,  148,   98,   23,   94,   95,  148,  184,   26,
 /*   370 */    27,  213,  159,  160,  109,  211,  163,  163,  148,  167,
 /*   380 */   168,  169,  163,   22,  105,  106,  107,   26,   27,   48,
 /*   390 */    49,  172,  173,  163,  184,  116,  183,  184,   21,  185,
 /*   400 */     1,    2,  172,  173,   22,  136,   24,   66,   67,   68,
 /*   410 */    69,   70,   71,   72,   73,   74,   75,   76,   77,   78,
 /*   420 */   193,   80,   81,   82,   83,   84,   85,   86,   87,   88,
 /*   430 */    89,   90,   19,  214,  148,  148,   23,   94,   95,   19,
 /*   440 */    25,  229,  156,   26,   27,  159,  160,   27,  218,  163,
 /*   450 */   163,   23,  189,   26,   27,   94,   95,  142,  143,  172,
 /*   460 */   173,   48,   49,  120,   96,   89,   90,   99,  100,  101,
 /*   470 */   167,  168,  169,    0,    1,    2,   12,  100,  110,   66,
 /*   480 */    67,   68,   69,   70,   71,   72,   73,   74,   75,   76,
 /*   490 */    77,   78,   28,   80,   81,   82,   83,   84,   85,   86,
 /*   500 */    87,   88,   89,   90,   19,  218,   25,   43,   23,   45,
 /*   510 */    95,   94,   95,   86,  148,  138,  179,  180,   23,   55,
 /*   520 */    25,   94,   95,  186,  206,   23,  148,   48,   49,  163,
 /*   530 */   158,  148,  229,   48,   49,  120,  146,  120,  172,  173,
 /*   540 */   112,  163,  114,  115,  194,  158,  163,  233,   69,   70,
 /*   550 */   164,   66,   67,   68,   69,   70,   71,   72,   73,   74,
 /*   560 */    75,   76,   77,   78,  192,   80,   81,   82,   83,   84,
 /*   570 */    85,   86,   87,   88,   89,   90,   19,   98,  148,  192,
 /*   580 */    23,  148,  112,  148,  114,  115,  148,  181,  216,  211,
 /*   590 */    95,  204,  205,  163,  211,   23,  163,  148,  163,   23,
 /*   600 */   119,  163,  172,  173,  232,   48,   49,  172,  173,  237,
 /*   610 */   172,  173,  163,  181,  112,  120,  114,  115,  185,  188,
 /*   620 */   189,  172,  173,   66,   67,   68,   69,   70,   71,   72,
 /*   630 */    73,   74,   75,   76,   77,   78,  148,   80,   81,   82,
 /*   640 */    83,   84,   85,   86,   87,   88,   89,   90,   19,  148,
 /*   650 */    31,  163,  148,    7,    8,    9,  148,  148,   35,   40,
 /*   660 */   172,  173,  188,  189,  163,  204,  205,  163,  148,   19,
 /*   670 */   148,  163,  163,  172,  173,  195,  234,   48,   49,   56,
 /*   680 */   172,  173,  202,  163,  112,  163,  114,  115,  112,  185,
 /*   690 */   114,  115,  172,  173,  185,   66,   67,   68,   69,   70,
 /*   700 */    71,   72,   73,   74,   75,   76,   77,   78,  148,   80,
 /*   710 */    81,   82,   83,   84,   85,   86,   87,   88,   89,   90,
 /*   720 */    19,  148,  148,  163,   12,  164,  148,  148,  135,  148,
 /*   730 */   137,  108,  172,  173,  129,  130,  163,  163,    7,    8,
 /*   740 */    28,  163,  163,  148,  163,  172,  173,  148,   98,   48,
 /*   750 */    49,  172,  173,  172,  173,   43,  181,   45,  163,  105,
 /*   760 */   106,  107,  163,  185,  203,  191,  151,   66,   67,   68,
 /*   770 */    69,   70,   71,   72,   73,   74,   75,   76,   77,   78,
 /*   780 */   148,   80,   81,   82,   83,   84,   85,   86,   87,   88,
 /*   790 */    89,   90,   19,  148,  194,  163,  148,  148,   29,   86,
 /*   800 */   148,   25,   33,  196,  172,  173,  164,   23,  163,   25,
 /*   810 */   215,  163,  163,  148,  215,  163,   47,  172,  173,  230,
 /*   820 */   148,   48,   49,  207,  172,  173,  113,  230,  163,   23,
 /*   830 */   117,   25,  105,  106,  107,  163,  158,  172,  173,  191,
 /*   840 */    67,   68,   69,   70,   71,   72,   73,   74,   75,   76,
 /*   850 */    77,   78,  148,   80,   81,   82,   83,   84,   85,   86,
 /*   860 */    87,   88,   89,   90,   19,  148,  148,  163,  148,  148,
 /*   870 */   192,  148,  148,  148,  158,  175,  172,  173,   97,   98,
 /*   880 */   163,  163,  226,  163,  163,  148,  163,  163,  163,  172,
 /*   890 */   173,  180,  148,   48,   49,  176,  172,  173,  164,  164,
 /*   900 */   163,   23,  126,   25,  158,  175,   16,  163,  192,  172,
 /*   910 */   173,  191,  191,   68,   69,   70,   71,   72,   73,   74,
 /*   920 */    75,   76,   77,   78,  175,   80,   81,   82,   83,   84,
 /*   930 */    85,   86,   87,   88,   89,   90,   19,   20,  192,   22,
 /*   940 */   148,  148,  148,   26,   27,  158,  148,   23,   58,   25,
 /*   950 */    60,   19,   20,   36,   22,  163,  163,  163,   26,   27,
 /*   960 */   148,  163,  216,  148,  172,  173,  172,  173,   36,  197,
 /*   970 */   148,   54,   23,  148,   25,  163,  175,  148,  163,  192,
 /*   980 */   164,   64,  175,  237,  191,  163,   54,  207,  163,  148,
 /*   990 */   148,   23,  163,   25,  172,  173,   64,  172,  173,  197,
 /*  1000 */     6,   84,   85,  191,  163,  163,  191,  148,  148,  148,
 /*  1010 */    93,   94,   95,  172,  173,   98,   84,   85,   86,  203,
 /*  1020 */   191,  158,  163,  163,  163,   93,   94,   95,  207,  148,
 /*  1030 */    98,  172,  173,  116,  147,   19,   20,   13,   22,  148,
 /*  1040 */    25,  148,   26,   27,  163,  148,  129,  130,  131,  132,
 /*  1050 */   133,  134,   36,   22,  163,  192,  163,   26,   27,  147,
 /*  1060 */   163,  129,  130,  131,  132,  133,  134,    5,  148,  148,
 /*  1070 */    54,  148,   10,   11,   12,   13,   14,  147,  147,   17,
 /*  1080 */    64,  148,  148,  163,  163,  149,  163,  148,  148,  148,
 /*  1090 */   192,  149,  172,  173,  157,   64,  163,  163,  197,  126,
 /*  1100 */    84,   85,  163,  163,  163,  172,  173,  148,  148,   93,
 /*  1110 */    94,   95,  172,  173,   98,   84,   85,   55,  123,  148,
 /*  1120 */   148,  124,  163,  163,  148,   94,  148,  148,   23,   98,
 /*  1130 */    25,  172,  173,  198,  163,  163,  122,  148,  148,  163,
 /*  1140 */   135,  163,  163,  172,  173,  129,  130,  131,  132,  133,
 /*  1150 */   134,  148,  163,  163,  199,  148,  148,  148,  200,  148,
 /*  1160 */   129,  130,  131,   23,  201,   25,  163,  105,  106,  107,
 /*  1170 */   163,  163,  163,  111,  163,  172,  173,   23,  116,   25,
 /*  1180 */   172,  173,  148,  172,  173,  148,  125,  148,  118,  225,
 /*  1190 */   155,  155,  104,  208,  121,  209,  208,  163,  104,  208,
 /*  1200 */   163,  209,  163,  174,  174,  209,  172,  173,   46,  172,
 /*  1210 */   173,  103,  174,   22,  182,  174,  176,   90,  174,  177,
 /*  1220 */   174,  228,  174,   18,  177,  182,  228,  155,  154,  154,
 /*  1230 */    44,  155,  154,  135,  155,  155,  235,  154,  236,  155,
 /*  1240 */    66,  187,  187,   22,  217,   18,  197,  190,  190,  190,
 /*  1250 */   190,  187,  162,  197,    1,  178,   15,   23,   22,  178,
 /*  1260 */   118,  118,  217,  118,  118,  118,   98,   22,  113,   23,
 /*  1270 */    23,   22,   11,   22,   34,   23,   34,  120,   23,   25,
 /*  1280 */    23,   25,   22,   25,   34,  118,   27,   23,   23,   50,
 /*  1290 */    22,   22,   22,   50,   23,   22,   22,  102,   50,  109,
 /*  1300 */    38,   19,   24,   20,  104,   42,   25,  138,  104,   22,
 /*  1310 */     5,    1,   74,   22,  108,  127,  119,    1,   51,   20,
 /*  1320 */   119,  108,   22,   57,  128,  127,   51,    3,  238,    4,
 /*  1330 */   238,  238,  238,  238,  238,  238,  238,  238,  238,  238,
 /*  1340 */   238,  238,  238,  238,  238,  238,   74,
};
#define YY_SHIFT_USE_DFLT (-111)
#define YY_SHIFT_MAX 363
static const short yy_shift_ofst[] = {
 /*     0 */   399,  917, 1062,  917, 1016, 1016,   -2,  -19, 1016, 1016,
 /*    10 */  1016, 1016, 1016,  114,    1,  932, 1016, 1016, 1016, 1016,
 /*    20 */  1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016,
 /*    30 */  1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016,
 /*    40 */  1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016,
 /*    50 */  1016, 1016,  -48,  279,  198,   -8,   -8, -110,   53,  125,
 /*    60 */   197,  269,  341,  413,  485,  557,  629,  701,  629,  629,
 /*    70 */   629,  629,  629,  629,  629,  629,  629,  629,  629,  629,
 /*    80 */   629,  629,  629,  629,  773,  845,  845,  -67,  -67,   -1,
 /*    90 */    -1,   55,   25,  236,    1,    1,    1,    1,    1,   54,
 /*   100 */     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 /*   110 */     1,    1,    1,  377,  376,  198,  137, -111, -111, -111,
 /*   120 */  1031,   81,  271,  343,  417,  361,  427,  464,  464,    1,
 /*   130 */     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 /*   140 */     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 /*   150 */     1,    1,    1,    1,    1,  473,   92,   92,   92,  128,
 /*   160 */   204, -110, -110, -110, -111, -111,  124,  124,   66,  368,
 /*   170 */   428,  502,  572,  712,  576,  495,  646,  713,  146,  415,
 /*   180 */   623,  623,  623,  470,  470,  769,  654,  470,  470,  470,
 /*   190 */   470,  382,  186,  481,  198,  605,  605,  593,  619,  619,
 /*   200 */   420,  619,   83,  619,  198,  619,  198,  -13,  776,  420,
 /*   210 */   420,  776,  994,  994,  994,  994, 1024, 1024, 1015, -110,
 /*   220 */   973,  995,  997, 1014, 1061, 1005, 1070, 1070, 1088, 1073,
 /*   230 */  1088, 1073, 1088, 1073, 1094, 1094, 1162, 1094, 1108, 1094,
 /*   240 */  1191, 1127, 1127, 1162, 1094, 1094, 1094, 1191, 1205, 1070,
 /*   250 */  1205, 1070, 1205, 1070, 1070, 1186, 1098, 1205, 1070, 1174,
 /*   260 */  1174, 1221,  973, 1227, 1227, 1227, 1227,  973, 1174, 1221,
 /*   270 */  -111, -111, -111,  479,  101,  727,  890,  650,  784,  806,
 /*   280 */   265,  731,  781,  878,  924,  949,  968, 1105, 1140, 1154,
 /*   290 */  1253, 1241, 1234, 1236, 1142, 1143, 1145, 1146, 1147, 1168,
 /*   300 */  1155, 1245, 1246, 1247, 1249, 1261, 1251, 1252, 1254, 1255,
 /*   310 */  1257, 1256, 1240, 1258, 1242, 1256, 1157, 1260, 1250, 1259,
 /*   320 */  1167, 1264, 1265, 1262, 1239, 1268, 1243, 1269, 1271, 1270,
 /*   330 */  1273, 1248, 1274, 1195, 1190, 1282, 1283, 1278, 1200, 1263,
 /*   340 */  1266, 1267, 1281, 1275, 1169, 1204, 1287, 1305, 1310, 1206,
 /*   350 */  1238, 1272, 1188, 1291, 1197, 1316, 1299, 1201, 1213, 1198,
 /*   360 */  1300, 1196, 1324, 1325,
};
#define YY_REDUCE_USE_DFLT (-178)
#define YY_REDUCE_MAX 272
static const short yy_reduce_ofst[] = {
 /*     0 */  -139,   12,   84,  156,   75,   89,  213,   93,   87,  158,
 /*    10 */   219,  230,  287,  372,  286,  366,  430,  435,  438,  449,
 /*    20 */   488,  501,  508,  520,  560,  573,  579,  581,  632,  645,
 /*    30 */   652,  665,  704,  717,  724,  737,  792,  794,  822,  825,
 /*    40 */   841,  859,  920,  933,  940,  959,  971, 1003, 1008, 1011,
 /*    50 */  1034, 1037, -177,  746,  144,  212,  303,  387, -116, -116,
 /*    60 */  -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
 /*    70 */  -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
 /*    80 */  -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
 /*    90 */  -116,   62, -116, -116,  164,  214,  433,  504,  509,  337,
 /*   100 */   574,  378,  578,  599,  383,  648,  720,  721,  793,  812,
 /*   110 */   815,  595,  829,   64, -116,  -18, -116, -116, -116, -116,
 /*   120 */    86,   72,  522,  649,  672,  718,  723,  431,  474,  725,
 /*   130 */   744,  798,  842,  860,  723,  861,  881,  891,  893,  897,
 /*   140 */   921,  923,  934,  939,  941,  960,  972,  976,  978,  979,
 /*   150 */   989,  990, 1007, 1009, 1039,  315,  -14,  561,  816, -132,
 /*   160 */   678,  716,  787,  863,  480,  461,    5,  135,  184,  210,
 /*   170 */   227,  227,  227,  263,  227,  318,  390,  350,  386,  318,
 /*   180 */   406,  432,  575,  227,  227,  314,  442,  227,  227,  227,
 /*   190 */   227,  615,  600,  607,  642,  589,  597,  656,  700,  730,
 /*   200 */   616,  749,  711,  801,  734,  807,  735,  719,  772,  780,
 /*   210 */   821,  802,  887,  912,  930,  931,  936,  942,  937,  898,
 /*   220 */   901,  935,  955,  958,  963,  964, 1035, 1036,  985,  986,
 /*   230 */   988,  992,  991,  996, 1029, 1030, 1032, 1038, 1040, 1041,
 /*   240 */  1042,  993,  998, 1043, 1044, 1046, 1048, 1047, 1074, 1072,
 /*   250 */  1075, 1076, 1078, 1079, 1080, 1001, 1002, 1083, 1084, 1054,
 /*   260 */  1055, 1027, 1049, 1057, 1058, 1059, 1060, 1056, 1064, 1045,
 /*   270 */  1090, 1077, 1081,
};
static const YYACTIONTYPE yy_default[] = {
 /*     0 */   554,  789,  833,  833,  789,  833,  833,  677,  787,  833,
 /*    10 */   833,  833,  833,  833,  833,  833,  833,  833,  833,  833,
 /*    20 */   833,  833,  833,  833,  833,  833,  833,  833,  833,  833,
 /*    30 */   833,  833,  833,  833,  833,  833,  833,  833,  833,  833,
 /*    40 */   833,  833,  833,  833,  833,  833,  833,  833,  833,  833,
 /*    50 */   833,  833,  761,  833,  593,  806,  806,  681,  712,  833,
 /*    60 */   833,  833,  833,  833,  833,  833,  713,  833,  791,  786,
 /*    70 */   782,  784,  783,  790,  714,  703,  710,  717,  692,  819,
 /*    80 */   719,  720,  726,  727,  749,  748,  767,  751,  773,  750,
 /*    90 */   760,  585,  752,  753,  833,  833,  833,  833,  833,  646,
 /*   100 */   833,  833,  833,  833,  833,  833,  833,  833,  833,  833,
 /*   110 */   833,  833,  833,  580,  754,  833,  755,  768,  769,  770,
 /*   120 */   833,  833,  833,  833,  833,  833,  833,  833,  833,  560,
 /*   130 */   833,  833,  833,  833,  833,  833,  833,  833,  833,  833,
 /*   140 */   833,  833,  833,  833,  833,  833,  833,  833,  833,  833,
 /*   150 */   833,  833,  833,  833,  833,  554,  677,  677,  677,  833,
 /*   160 */   833,  833,  833,  833,  671,  681,  833,  833,  637,  833,
 /*   170 */   833,  833,  833,  833,  833,  833,  562,  669,  595,  679,
 /*   180 */   833,  833,  833,  582,  658,  812,  833,  826,  824,  660,
 /*   190 */   722,  833,  669,  678,  833,  833,  833,  785,  706,  706,
 /*   200 */   694,  706,  616,  706,  833,  706,  833,  619,  716,  694,
 /*   210 */   694,  716,  559,  559,  559,  559,  570,  570,  636,  833,
 /*   220 */   716,  707,  709,  699,  711,  833,  685,  685,  693,  698,
 /*   230 */   693,  698,  693,  698,  648,  648,  633,  648,  619,  648,
 /*   240 */   795,  799,  799,  633,  648,  648,  648,  795,  577,  685,
 /*   250 */   577,  685,  577,  685,  685,  816,  818,  577,  685,  650,
 /*   260 */   650,  728,  716,  657,  657,  657,  657,  716,  650,  728,
 /*   270 */   603,  621,  621,  833,  833,  833,  833,  833,  833,  833,
 /*   280 */   833,  833,  833,  833,  833,  833,  833,  833,  833,  833,
 /*   290 */   833,  568,  833,  587,  735,  740,  736,  833,  737,  833,
 /*   300 */   663,  833,  833,  833,  833,  833,  833,  833,  833,  833,
 /*   310 */   833,  788,  833,  700,  833,  708,  833,  833,  833,  833,
 /*   320 */   833,  833,  833,  833,  833,  833,  833,  833,  833,  833,
 /*   330 */   833,  833,  833,  833,  833,  833,  833,  833,  833,  833,
 /*   340 */   833,  814,  815,  833,  833,  833,  833,  833,  833,  833,
 /*   350 */   833,  833,  833,  833,  833,  833,  833,  833,  833,  833,
 /*   360 */   833,  833,  555,  833,  550,  552,  553,  557,  558,  561,
 /*   370 */   587,  588,  590,  591,  592,  563,  564,  565,  566,  567,
 /*   380 */   569,  573,  571,  572,  574,  581,  583,  602,  604,  606,
 /*   390 */   667,  668,  732,  661,  662,  666,  589,  743,  734,  738,
 /*   400 */   739,  741,  742,  756,  757,  759,  765,  772,  775,  758,
 /*   410 */   763,  764,  766,  771,  774,  664,  665,  778,  596,  597,
 /*   420 */   600,  601,  802,  804,  803,  805,  599,  598,  744,  747,
 /*   430 */   780,  781,  827,  828,  829,  830,  831,  776,  686,  779,
 /*   440 */   762,  701,  704,  705,  702,  670,  680,  688,  689,  690,
 /*   450 */   691,  675,  676,  682,  697,  730,  731,  695,  696,  683,
 /*   460 */   684,  672,  673,  674,  777,  733,  745,  746,  607,  608,
 /*   470 */   740,  609,  610,  611,  649,  652,  653,  654,  612,  631,
 /*   480 */   634,  635,  613,  620,  614,  615,  622,  623,  624,  627,
 /*   490 */   628,  629,  630,  625,  626,  796,  797,  800,  798,  617,
 /*   500 */   618,  632,  605,  594,  586,  638,  641,  642,  643,  644,
 /*   510 */   645,  647,  639,  640,  584,  575,  578,  687,  808,  817,
 /*   520 */   813,  809,  810,  811,  579,  792,  793,  651,  724,  725,
 /*   530 */   807,  820,  822,  729,  823,  825,  821,  576,  655,  656,
 /*   540 */   659,  801,  832,  715,  718,  721,  723,  556,  551,
};
#define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))

/* The next table maps tokens into fallback tokens.  If a construct
** like the following:
** 
**      %fallback ID X Y Z.
................................................................................
   26,  /*  EXCLUSIVE => ID */
    0,  /*     COMMIT => nothing */
   26,  /*        END => ID */
   26,  /*   ROLLBACK => ID */
   26,  /*  SAVEPOINT => ID */
   26,  /*    RELEASE => ID */
    0,  /*         TO => nothing */

    0,  /*      TABLE => nothing */
    0,  /*     CREATE => nothing */
   26,  /*         IF => ID */
    0,  /*        NOT => nothing */
    0,  /*     EXISTS => nothing */
   26,  /*       TEMP => ID */
    0,  /*         LP => nothing */
    0,  /*         RP => nothing */
    0,  /*         AS => nothing */
................................................................................
/* For tracing shifts, the names of all terminals and nonterminals
** are required.  The following table supplies these names */
static const char *const yyTokenName[] = { 
  "$",             "SEMI",          "EXPLAIN",       "QUERY",       
  "PLAN",          "BEGIN",         "TRANSACTION",   "DEFERRED",    
  "IMMEDIATE",     "EXCLUSIVE",     "COMMIT",        "END",         
  "ROLLBACK",      "SAVEPOINT",     "RELEASE",       "TO",          
  "TABLE",         "CREATE",        "IF",            "NOT",         
  "EXISTS",        "TEMP",          "LP",            "RP",          
  "AS",            "COMMA",         "ID",            "INDEXED",     
  "ABORT",         "AFTER",         "ANALYZE",       "ASC",         
  "ATTACH",        "BEFORE",        "BY",            "CASCADE",     
  "CAST",          "COLUMNKW",      "CONFLICT",      "DATABASE",    
  "DESC",          "DETACH",        "EACH",          "FAIL",        
  "FOR",           "IGNORE",        "INITIALLY",     "INSTEAD",     
................................................................................
  "HAVING",        "LIMIT",         "WHERE",         "INTO",        
  "VALUES",        "INTEGER",       "FLOAT",         "BLOB",        
  "REGISTER",      "VARIABLE",      "CASE",          "WHEN",        
  "THEN",          "ELSE",          "INDEX",         "error",       
  "input",         "cmdlist",       "ecmd",          "explain",     
  "cmdx",          "cmd",           "transtype",     "trans_opt",   
  "nm",            "savepoint_opt",  "create_table",  "create_table_args",
  "createkw",      "temp",          "ifnotexists",   "dbnm",        
  "columnlist",    "conslist_opt",  "select",        "column",      
  "columnid",      "type",          "carglist",      "id",          
  "ids",           "typetoken",     "typename",      "signed",      
  "plus_num",      "minus_num",     "carg",          "ccons",       
  "term",          "expr",          "onconf",        "sortorder",   
  "autoinc",       "idxlist_opt",   "refargs",       "defer_subclause",
  "refarg",        "refact",        "init_deferred_pred_opt",  "conslist",    
  "tcons",         "idxlist",       "defer_subclause_opt",  "orconf",      
  "resolvetype",   "raisetype",     "ifexists",      "fullname",    
  "oneselect",     "multiselect_op",  "distinct",      "selcollist",  
  "from",          "where_opt",     "groupby_opt",   "having_opt",  
  "orderby_opt",   "limit_opt",     "sclp",          "as",          
  "seltablist",    "stl_prefix",    "joinop",        "indexed_opt", 
  "on_opt",        "using_opt",     "joinop2",       "inscollist",  
  "sortlist",      "sortitem",      "nexprlist",     "setlist",     
  "insert_cmd",    "inscollist_opt",  "itemlist",      "exprlist",    
  "likeop",        "escape",        "between_op",    "in_op",       
  "case_operand",  "case_exprlist",  "case_else",     "uniqueflag",  
  "collate",       "plus_opt",      "number",        "trigger_decl",
  "trigger_cmd_list",  "trigger_time",  "trigger_event",  "foreach_clause",
  "when_clause",   "trigger_cmd", 
};
#endif /* NDEBUG */

#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
*/
static const char *const yyRuleName[] = {
................................................................................
 /*  19 */ "cmd ::= ROLLBACK trans_opt",
 /*  20 */ "savepoint_opt ::= SAVEPOINT",
 /*  21 */ "savepoint_opt ::=",
 /*  22 */ "cmd ::= SAVEPOINT nm",
 /*  23 */ "cmd ::= RELEASE savepoint_opt nm",
 /*  24 */ "cmd ::= ROLLBACK trans_opt TO savepoint_opt nm",
 /*  25 */ "cmd ::= create_table create_table_args",
 /*  26 */ "create_table ::= createkw temp TABLE ifnotexists nm dbnm",
 /*  27 */ "createkw ::= CREATE",
 /*  28 */ "ifnotexists ::=",
 /*  29 */ "ifnotexists ::= IF NOT EXISTS",
 /*  30 */ "temp ::= TEMP",
 /*  31 */ "temp ::=",
 /*  32 */ "create_table_args ::= LP columnlist conslist_opt RP",
 /*  33 */ "create_table_args ::= AS select",
 /*  34 */ "columnlist ::= columnlist COMMA column",
 /*  35 */ "columnlist ::= column",
 /*  36 */ "column ::= columnid type carglist",
 /*  37 */ "columnid ::= nm",
 /*  38 */ "id ::= ID",
 /*  39 */ "id ::= INDEXED",
 /*  40 */ "ids ::= ID|STRING",
 /*  41 */ "nm ::= id",
 /*  42 */ "nm ::= STRING",
 /*  43 */ "nm ::= JOIN_KW",
 /*  44 */ "type ::=",
 /*  45 */ "type ::= typetoken",
 /*  46 */ "typetoken ::= typename",
 /*  47 */ "typetoken ::= typename LP signed RP",
 /*  48 */ "typetoken ::= typename LP signed COMMA signed RP",
 /*  49 */ "typename ::= ids",
 /*  50 */ "typename ::= typename ids",
 /*  51 */ "signed ::= plus_num",
 /*  52 */ "signed ::= minus_num",
 /*  53 */ "carglist ::= carglist carg",
 /*  54 */ "carglist ::=",
 /*  55 */ "carg ::= CONSTRAINT nm ccons",
 /*  56 */ "carg ::= ccons",
 /*  57 */ "ccons ::= DEFAULT term",
 /*  58 */ "ccons ::= DEFAULT LP expr RP",
 /*  59 */ "ccons ::= DEFAULT PLUS term",
 /*  60 */ "ccons ::= DEFAULT MINUS term",
 /*  61 */ "ccons ::= DEFAULT id",
 /*  62 */ "ccons ::= NULL onconf",
 /*  63 */ "ccons ::= NOT NULL onconf",
 /*  64 */ "ccons ::= PRIMARY KEY sortorder onconf autoinc",
 /*  65 */ "ccons ::= UNIQUE onconf",
 /*  66 */ "ccons ::= CHECK LP expr RP",
 /*  67 */ "ccons ::= REFERENCES nm idxlist_opt refargs",
 /*  68 */ "ccons ::= defer_subclause",
 /*  69 */ "ccons ::= COLLATE ids",
 /*  70 */ "autoinc ::=",
 /*  71 */ "autoinc ::= AUTOINCR",
 /*  72 */ "refargs ::=",
 /*  73 */ "refargs ::= refargs refarg",
 /*  74 */ "refarg ::= MATCH nm",
 /*  75 */ "refarg ::= ON DELETE refact",
 /*  76 */ "refarg ::= ON UPDATE refact",
 /*  77 */ "refarg ::= ON INSERT refact",
 /*  78 */ "refact ::= SET NULL",
 /*  79 */ "refact ::= SET DEFAULT",
 /*  80 */ "refact ::= CASCADE",
 /*  81 */ "refact ::= RESTRICT",
 /*  82 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
 /*  83 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
 /*  84 */ "init_deferred_pred_opt ::=",
 /*  85 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
 /*  86 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
 /*  87 */ "conslist_opt ::=",
 /*  88 */ "conslist_opt ::= COMMA conslist",
 /*  89 */ "conslist ::= conslist COMMA tcons",
 /*  90 */ "conslist ::= conslist tcons",
 /*  91 */ "conslist ::= tcons",
 /*  92 */ "tcons ::= CONSTRAINT nm",
 /*  93 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
 /*  94 */ "tcons ::= UNIQUE LP idxlist RP onconf",
 /*  95 */ "tcons ::= CHECK LP expr RP onconf",
 /*  96 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
 /*  97 */ "defer_subclause_opt ::=",
 /*  98 */ "defer_subclause_opt ::= defer_subclause",
 /*  99 */ "onconf ::=",
 /* 100 */ "onconf ::= ON CONFLICT resolvetype",
 /* 101 */ "orconf ::=",
 /* 102 */ "orconf ::= OR resolvetype",
 /* 103 */ "resolvetype ::= raisetype",
 /* 104 */ "resolvetype ::= IGNORE",
 /* 105 */ "resolvetype ::= REPLACE",
 /* 106 */ "cmd ::= DROP TABLE ifexists fullname",
 /* 107 */ "ifexists ::= IF EXISTS",
 /* 108 */ "ifexists ::=",
 /* 109 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
 /* 110 */ "cmd ::= DROP VIEW ifexists fullname",
 /* 111 */ "cmd ::= select",
 /* 112 */ "select ::= oneselect",
 /* 113 */ "select ::= select multiselect_op oneselect",
 /* 114 */ "multiselect_op ::= UNION",
 /* 115 */ "multiselect_op ::= UNION ALL",
 /* 116 */ "multiselect_op ::= EXCEPT|INTERSECT",
 /* 117 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
 /* 118 */ "distinct ::= DISTINCT",
 /* 119 */ "distinct ::= ALL",
 /* 120 */ "distinct ::=",
 /* 121 */ "sclp ::= selcollist COMMA",
 /* 122 */ "sclp ::=",
 /* 123 */ "selcollist ::= sclp expr as",
 /* 124 */ "selcollist ::= sclp STAR",
 /* 125 */ "selcollist ::= sclp nm DOT STAR",
 /* 126 */ "as ::= AS nm",
 /* 127 */ "as ::= ids",
 /* 128 */ "as ::=",
 /* 129 */ "from ::=",
 /* 130 */ "from ::= FROM seltablist",
 /* 131 */ "stl_prefix ::= seltablist joinop",
 /* 132 */ "stl_prefix ::=",
 /* 133 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
 /* 134 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
 /* 135 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
 /* 136 */ "dbnm ::=",
 /* 137 */ "dbnm ::= DOT nm",
 /* 138 */ "fullname ::= nm dbnm",
 /* 139 */ "joinop ::= COMMA|JOIN",
 /* 140 */ "joinop ::= JOIN_KW JOIN",
 /* 141 */ "joinop ::= JOIN_KW nm JOIN",
 /* 142 */ "joinop ::= JOIN_KW nm nm JOIN",
 /* 143 */ "on_opt ::= ON expr",
 /* 144 */ "on_opt ::=",
 /* 145 */ "indexed_opt ::=",
 /* 146 */ "indexed_opt ::= INDEXED BY nm",
 /* 147 */ "indexed_opt ::= NOT INDEXED",
 /* 148 */ "using_opt ::= USING LP inscollist RP",
 /* 149 */ "using_opt ::=",
 /* 150 */ "orderby_opt ::=",
 /* 151 */ "orderby_opt ::= ORDER BY sortlist",
 /* 152 */ "sortlist ::= sortlist COMMA sortitem sortorder",
 /* 153 */ "sortlist ::= sortitem sortorder",
 /* 154 */ "sortitem ::= expr",
 /* 155 */ "sortorder ::= ASC",
 /* 156 */ "sortorder ::= DESC",
 /* 157 */ "sortorder ::=",
 /* 158 */ "groupby_opt ::=",
 /* 159 */ "groupby_opt ::= GROUP BY nexprlist",
 /* 160 */ "having_opt ::=",
 /* 161 */ "having_opt ::= HAVING expr",
 /* 162 */ "limit_opt ::=",
 /* 163 */ "limit_opt ::= LIMIT expr",
 /* 164 */ "limit_opt ::= LIMIT expr OFFSET expr",
 /* 165 */ "limit_opt ::= LIMIT expr COMMA expr",
 /* 166 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
 /* 167 */ "where_opt ::=",
 /* 168 */ "where_opt ::= WHERE expr",
 /* 169 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
 /* 170 */ "setlist ::= setlist COMMA nm EQ expr",
 /* 171 */ "setlist ::= nm EQ expr",
 /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP",
 /* 173 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
 /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
 /* 175 */ "insert_cmd ::= INSERT orconf",
 /* 176 */ "insert_cmd ::= REPLACE",
 /* 177 */ "itemlist ::= itemlist COMMA expr",
 /* 178 */ "itemlist ::= expr",
 /* 179 */ "inscollist_opt ::=",
 /* 180 */ "inscollist_opt ::= LP inscollist RP",
 /* 181 */ "inscollist ::= inscollist COMMA nm",
 /* 182 */ "inscollist ::= nm",
 /* 183 */ "expr ::= term",
 /* 184 */ "expr ::= LP expr RP",
 /* 185 */ "term ::= NULL",
 /* 186 */ "expr ::= id",
 /* 187 */ "expr ::= JOIN_KW",
 /* 188 */ "expr ::= nm DOT nm",
 /* 189 */ "expr ::= nm DOT nm DOT nm",
 /* 190 */ "term ::= INTEGER|FLOAT|BLOB",
 /* 191 */ "term ::= STRING",
 /* 192 */ "expr ::= REGISTER",
 /* 193 */ "expr ::= VARIABLE",
 /* 194 */ "expr ::= expr COLLATE ids",
 /* 195 */ "expr ::= CAST LP expr AS typetoken RP",
 /* 196 */ "expr ::= ID LP distinct exprlist RP",
 /* 197 */ "expr ::= ID LP STAR RP",
 /* 198 */ "term ::= CTIME_KW",
 /* 199 */ "expr ::= expr AND expr",
 /* 200 */ "expr ::= expr OR expr",
 /* 201 */ "expr ::= expr LT|GT|GE|LE expr",
 /* 202 */ "expr ::= expr EQ|NE expr",
 /* 203 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
 /* 204 */ "expr ::= expr PLUS|MINUS expr",
 /* 205 */ "expr ::= expr STAR|SLASH|REM expr",
 /* 206 */ "expr ::= expr CONCAT expr",
 /* 207 */ "likeop ::= LIKE_KW",
 /* 208 */ "likeop ::= NOT LIKE_KW",
 /* 209 */ "likeop ::= MATCH",
 /* 210 */ "likeop ::= NOT MATCH",
 /* 211 */ "escape ::= ESCAPE expr",
 /* 212 */ "escape ::=",
 /* 213 */ "expr ::= expr likeop expr escape",
 /* 214 */ "expr ::= expr ISNULL|NOTNULL",
 /* 215 */ "expr ::= expr IS NULL",
 /* 216 */ "expr ::= expr NOT NULL",
 /* 217 */ "expr ::= expr IS NOT NULL",
 /* 218 */ "expr ::= NOT expr",
 /* 219 */ "expr ::= BITNOT expr",
 /* 220 */ "expr ::= MINUS expr",
 /* 221 */ "expr ::= PLUS expr",
 /* 222 */ "between_op ::= BETWEEN",
 /* 223 */ "between_op ::= NOT BETWEEN",
 /* 224 */ "expr ::= expr between_op expr AND expr",
 /* 225 */ "in_op ::= IN",
 /* 226 */ "in_op ::= NOT IN",
 /* 227 */ "expr ::= expr in_op LP exprlist RP",
 /* 228 */ "expr ::= LP select RP",
 /* 229 */ "expr ::= expr in_op LP select RP",
 /* 230 */ "expr ::= expr in_op nm dbnm",
 /* 231 */ "expr ::= EXISTS LP select RP",
 /* 232 */ "expr ::= CASE case_operand case_exprlist case_else END",
 /* 233 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
 /* 234 */ "case_exprlist ::= WHEN expr THEN expr",
 /* 235 */ "case_else ::= ELSE expr",
 /* 236 */ "case_else ::=",
 /* 237 */ "case_operand ::= expr",
 /* 238 */ "case_operand ::=",
 /* 239 */ "exprlist ::= nexprlist",
 /* 240 */ "exprlist ::=",
 /* 241 */ "nexprlist ::= nexprlist COMMA expr",
 /* 242 */ "nexprlist ::= expr",
 /* 243 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
 /* 244 */ "uniqueflag ::= UNIQUE",
 /* 245 */ "uniqueflag ::=",
 /* 246 */ "idxlist_opt ::=",
 /* 247 */ "idxlist_opt ::= LP idxlist RP",
 /* 248 */ "idxlist ::= idxlist COMMA nm collate sortorder",
 /* 249 */ "idxlist ::= nm collate sortorder",
 /* 250 */ "collate ::=",
 /* 251 */ "collate ::= COLLATE ids",
 /* 252 */ "cmd ::= DROP INDEX ifexists fullname",
 /* 253 */ "plus_num ::= plus_opt number",
 /* 254 */ "minus_num ::= MINUS number",
 /* 255 */ "number ::= INTEGER|FLOAT",
 /* 256 */ "plus_opt ::= PLUS",
 /* 257 */ "plus_opt ::=",
 /* 258 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
 /* 259 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
 /* 260 */ "trigger_time ::= BEFORE",
 /* 261 */ "trigger_time ::= AFTER",
 /* 262 */ "trigger_time ::= INSTEAD OF",
 /* 263 */ "trigger_time ::=",
 /* 264 */ "trigger_event ::= DELETE|INSERT",
 /* 265 */ "trigger_event ::= UPDATE",
 /* 266 */ "trigger_event ::= UPDATE OF inscollist",
 /* 267 */ "foreach_clause ::=",
 /* 268 */ "foreach_clause ::= FOR EACH ROW",
 /* 269 */ "when_clause ::=",
 /* 270 */ "when_clause ::= WHEN expr",
 /* 271 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
 /* 272 */ "trigger_cmd_list ::= trigger_cmd SEMI",
 /* 273 */ "trigger_cmd ::= UPDATE orconf nm SET setlist where_opt",
 /* 274 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP",
 /* 275 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt select",
 /* 276 */ "trigger_cmd ::= DELETE FROM nm where_opt",
 /* 277 */ "trigger_cmd ::= select",
 /* 278 */ "expr ::= RAISE LP IGNORE RP",
 /* 279 */ "expr ::= RAISE LP raisetype COMMA nm RP",
 /* 280 */ "raisetype ::= ROLLBACK",
 /* 281 */ "raisetype ::= ABORT",
 /* 282 */ "raisetype ::= FAIL",
 /* 283 */ "cmd ::= DROP TRIGGER ifexists fullname",
};
#endif /* NDEBUG */


#if YYSTACKDEPTH<=0
/*
** Try to increase the size of the parser stack.
................................................................................
    ** reduce or during error processing or when a parser is 
    ** being destroyed before it is finished parsing.
    **
    ** Note: during a reduce, the only symbols destroyed are those
    ** which appear on the RHS of the rule, but which are not used
    ** inside the C code.
    */
    case 158: /* select */
    case 192: /* oneselect */
{
sqlite3SelectDelete(pParse->db, (yypminor->yy331));
}
      break;
    case 172: /* term */
    case 173: /* expr */
    case 197: /* where_opt */
    case 199: /* having_opt */
    case 208: /* on_opt */
    case 213: /* sortitem */
    case 221: /* escape */
    case 224: /* case_operand */
    case 226: /* case_else */
    case 236: /* when_clause */
{
sqlite3ExprDelete(pParse->db, (yypminor->yy454));
}
      break;
    case 177: /* idxlist_opt */
    case 185: /* idxlist */
    case 195: /* selcollist */
    case 198: /* groupby_opt */
    case 200: /* orderby_opt */
    case 202: /* sclp */
    case 212: /* sortlist */
    case 214: /* nexprlist */
    case 215: /* setlist */
    case 218: /* itemlist */
    case 219: /* exprlist */
    case 225: /* case_exprlist */
{
sqlite3ExprListDelete(pParse->db, (yypminor->yy266));
}
      break;
    case 191: /* fullname */
    case 196: /* from */
    case 204: /* seltablist */
    case 205: /* stl_prefix */
{
sqlite3SrcListDelete(pParse->db, (yypminor->yy427));
}
      break;
    case 209: /* using_opt */
    case 211: /* inscollist */
    case 217: /* inscollist_opt */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy272));
}
      break;
    case 232: /* trigger_cmd_list */
    case 237: /* trigger_cmd */
{
sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy455));
}
      break;
    case 234: /* trigger_event */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy62).b);
}
      break;
    default:  break;   /* If no destructor action specified: do nothing */
  }
}

/*
................................................................................
  { 149, 1 },
  { 149, 0 },
  { 145, 2 },
  { 145, 3 },
  { 145, 5 },
  { 145, 2 },
  { 150, 6 },
  { 152, 1 },
  { 154, 0 },
  { 154, 3 },
  { 153, 1 },
  { 153, 0 },
  { 151, 4 },
  { 151, 2 },
  { 156, 3 },
  { 156, 1 },
  { 159, 3 },
  { 160, 1 },
  { 163, 1 },
  { 163, 1 },
  { 164, 1 },
  { 148, 1 },
  { 148, 1 },
  { 148, 1 },
  { 161, 0 },
  { 161, 1 },
  { 165, 1 },
  { 165, 4 },
  { 165, 6 },
  { 166, 1 },
  { 166, 2 },
  { 167, 1 },
  { 167, 1 },
  { 162, 2 },
  { 162, 0 },
  { 170, 3 },
  { 170, 1 },
  { 171, 2 },
  { 171, 4 },
  { 171, 3 },
  { 171, 3 },
  { 171, 2 },
  { 171, 2 },
  { 171, 3 },
  { 171, 5 },
  { 171, 2 },
  { 171, 4 },
  { 171, 4 },
  { 171, 1 },
  { 171, 2 },
  { 176, 0 },
  { 176, 1 },
  { 178, 0 },
  { 178, 2 },
  { 180, 2 },
  { 180, 3 },
  { 180, 3 },
  { 180, 3 },
  { 181, 2 },
  { 181, 2 },
  { 181, 1 },
  { 181, 1 },
  { 179, 3 },
  { 179, 2 },
  { 182, 0 },
  { 182, 2 },
  { 182, 2 },
  { 157, 0 },
  { 157, 2 },
  { 183, 3 },
  { 183, 2 },
  { 183, 1 },
  { 184, 2 },
  { 184, 7 },
  { 184, 5 },
  { 184, 5 },
  { 184, 10 },
  { 186, 0 },
  { 186, 1 },
  { 174, 0 },
  { 174, 3 },
  { 187, 0 },
  { 187, 2 },
  { 188, 1 },
  { 188, 1 },
  { 188, 1 },
  { 145, 4 },
  { 190, 2 },
  { 190, 0 },
  { 145, 8 },
  { 145, 4 },
  { 145, 1 },
  { 158, 1 },
  { 158, 3 },
  { 193, 1 },
  { 193, 2 },
  { 193, 1 },
  { 192, 9 },
  { 194, 1 },
  { 194, 1 },
  { 194, 0 },
  { 202, 2 },
  { 202, 0 },
  { 195, 3 },
  { 195, 2 },
  { 195, 4 },
  { 203, 2 },
  { 203, 1 },
  { 203, 0 },
  { 196, 0 },
  { 196, 2 },
  { 205, 2 },
  { 205, 0 },
  { 204, 7 },
  { 204, 7 },
  { 204, 7 },
  { 155, 0 },
  { 155, 2 },
  { 191, 2 },
  { 206, 1 },
  { 206, 2 },
  { 206, 3 },
  { 206, 4 },
  { 208, 2 },
  { 208, 0 },
  { 207, 0 },
  { 207, 3 },
  { 207, 2 },
  { 209, 4 },
  { 209, 0 },
  { 200, 0 },
  { 200, 3 },
  { 212, 4 },
  { 212, 2 },
  { 213, 1 },
  { 175, 1 },
  { 175, 1 },
  { 175, 0 },
  { 198, 0 },
  { 198, 3 },
  { 199, 0 },
  { 199, 2 },
  { 201, 0 },
  { 201, 2 },
  { 201, 4 },
  { 201, 4 },
  { 145, 5 },
  { 197, 0 },
  { 197, 2 },
  { 145, 7 },
  { 215, 5 },
  { 215, 3 },
  { 145, 8 },
  { 145, 5 },
  { 145, 6 },
  { 216, 2 },
  { 216, 1 },
  { 218, 3 },
  { 218, 1 },
  { 217, 0 },
  { 217, 3 },
  { 211, 3 },
  { 211, 1 },
  { 173, 1 },
  { 173, 3 },
  { 172, 1 },
  { 173, 1 },
  { 173, 1 },
  { 173, 3 },
  { 173, 5 },
  { 172, 1 },
  { 172, 1 },
  { 173, 1 },
  { 173, 1 },
  { 173, 3 },
  { 173, 6 },
  { 173, 5 },
  { 173, 4 },
  { 172, 1 },
  { 173, 3 },
  { 173, 3 },
  { 173, 3 },
  { 173, 3 },
  { 173, 3 },
  { 173, 3 },
  { 173, 3 },
  { 173, 3 },
  { 220, 1 },
  { 220, 2 },
  { 220, 1 },
  { 220, 2 },
  { 221, 2 },
  { 221, 0 },
  { 173, 4 },
  { 173, 2 },
  { 173, 3 },
  { 173, 3 },
  { 173, 4 },
  { 173, 2 },
  { 173, 2 },
  { 173, 2 },
  { 173, 2 },
  { 222, 1 },
  { 222, 2 },
  { 173, 5 },
  { 223, 1 },
  { 223, 2 },
  { 173, 5 },
  { 173, 3 },
  { 173, 5 },
  { 173, 4 },
  { 173, 4 },
  { 173, 5 },
  { 225, 5 },
  { 225, 4 },
  { 226, 2 },
  { 226, 0 },
  { 224, 1 },
  { 224, 0 },
  { 219, 1 },
  { 219, 0 },
  { 214, 3 },
  { 214, 1 },
  { 145, 11 },
  { 227, 1 },
  { 227, 0 },
  { 177, 0 },
  { 177, 3 },
  { 185, 5 },
  { 185, 3 },
  { 228, 0 },
  { 228, 2 },
  { 145, 4 },
  { 168, 2 },
  { 169, 2 },
  { 230, 1 },
  { 229, 1 },
  { 229, 0 },
  { 145, 5 },
  { 231, 11 },
  { 233, 1 },
  { 233, 1 },
  { 233, 2 },

  { 233, 0 },
  { 234, 1 },

  { 234, 1 },
  { 234, 3 },
  { 235, 0 },
  { 235, 3 },
  { 236, 0 },
  { 236, 2 },
  { 232, 3 },
  { 232, 2 },
  { 237, 6 },
  { 237, 8 },
  { 237, 5 },
  { 237, 4 },
  { 237, 1 },
  { 173, 4 },
  { 173, 6 },
  { 189, 1 },
  { 189, 1 },
  { 189, 1 },
  { 145, 4 },
};

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

/*
** Perform a reduce action and the shift that must immediately
................................................................................
      case 4: /* ecmd ::= explain cmdx SEMI */
      case 10: /* trans_opt ::= */
      case 11: /* trans_opt ::= TRANSACTION */
      case 12: /* trans_opt ::= TRANSACTION nm */
      case 20: /* savepoint_opt ::= SAVEPOINT */
      case 21: /* savepoint_opt ::= */
      case 25: /* cmd ::= create_table create_table_args */
      case 34: /* columnlist ::= columnlist COMMA column */
      case 35: /* columnlist ::= column */
      case 44: /* type ::= */
      case 51: /* signed ::= plus_num */
      case 52: /* signed ::= minus_num */
      case 53: /* carglist ::= carglist carg */
      case 54: /* carglist ::= */
      case 55: /* carg ::= CONSTRAINT nm ccons */
      case 56: /* carg ::= ccons */
      case 62: /* ccons ::= NULL onconf */
      case 89: /* conslist ::= conslist COMMA tcons */
      case 90: /* conslist ::= conslist tcons */
      case 91: /* conslist ::= tcons */
      case 92: /* tcons ::= CONSTRAINT nm */
      case 256: /* plus_opt ::= PLUS */
      case 257: /* plus_opt ::= */
      case 267: /* foreach_clause ::= */
      case 268: /* foreach_clause ::= FOR EACH ROW */
{
}
        break;
      case 5: /* explain ::= */
{ sqlite3BeginParse(pParse, 0); }
        break;
      case 6: /* explain ::= EXPLAIN */
................................................................................
      case 7: /* explain ::= EXPLAIN QUERY PLAN */
{ sqlite3BeginParse(pParse, 2); }
        break;
      case 8: /* cmdx ::= cmd */
{ sqlite3FinishCoding(pParse); }
        break;
      case 9: /* cmd ::= BEGIN transtype trans_opt */
{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy60);}
        break;
      case 13: /* transtype ::= */
{yygotominor.yy60 = TK_DEFERRED;}
        break;
      case 14: /* transtype ::= DEFERRED */
      case 15: /* transtype ::= IMMEDIATE */
      case 16: /* transtype ::= EXCLUSIVE */
      case 114: /* multiselect_op ::= UNION */
      case 116: /* multiselect_op ::= EXCEPT|INTERSECT */
{yygotominor.yy60 = yymsp[0].major;}
        break;
      case 17: /* cmd ::= COMMIT trans_opt */
      case 18: /* cmd ::= END trans_opt */
{sqlite3CommitTransaction(pParse);}
        break;
      case 19: /* cmd ::= ROLLBACK trans_opt */
{sqlite3RollbackTransaction(pParse);}
................................................................................
}
        break;
      case 24: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
{
  sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
}
        break;
      case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
{
   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy60,0,0,yymsp[-2].minor.yy60);
}
        break;
      case 27: /* createkw ::= CREATE */
{
  pParse->db->lookaside.bEnabled = 0;
  yygotominor.yy0 = yymsp[0].minor.yy0;
}
        break;
      case 28: /* ifnotexists ::= */
      case 31: /* temp ::= */
      case 70: /* autoinc ::= */
      case 84: /* init_deferred_pred_opt ::= */
      case 86: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
      case 97: /* defer_subclause_opt ::= */
      case 108: /* ifexists ::= */
      case 119: /* distinct ::= ALL */
      case 120: /* distinct ::= */
      case 222: /* between_op ::= BETWEEN */
      case 225: /* in_op ::= IN */
{yygotominor.yy60 = 0;}
        break;
      case 29: /* ifnotexists ::= IF NOT EXISTS */
      case 30: /* temp ::= TEMP */
      case 71: /* autoinc ::= AUTOINCR */
      case 85: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
      case 107: /* ifexists ::= IF EXISTS */
      case 118: /* distinct ::= DISTINCT */
      case 223: /* between_op ::= NOT BETWEEN */
      case 226: /* in_op ::= NOT IN */
{yygotominor.yy60 = 1;}
        break;
      case 32: /* create_table_args ::= LP columnlist conslist_opt RP */
{
  sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0);
}
        break;
      case 33: /* create_table_args ::= AS select */
{
  sqlite3EndTable(pParse,0,0,yymsp[0].minor.yy331);
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy331);
}
        break;
      case 36: /* column ::= columnid type carglist */
{
  yygotominor.yy0.z = yymsp[-2].minor.yy0.z;
  yygotominor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-2].minor.yy0.z) + pParse->sLastToken.n;
}
        break;
      case 37: /* columnid ::= nm */
{
  sqlite3AddColumn(pParse,&yymsp[0].minor.yy0);
  yygotominor.yy0 = yymsp[0].minor.yy0;
}
        break;
      case 38: /* id ::= ID */
      case 39: /* id ::= INDEXED */
      case 40: /* ids ::= ID|STRING */
      case 41: /* nm ::= id */
      case 42: /* nm ::= STRING */
      case 43: /* nm ::= JOIN_KW */
      case 46: /* typetoken ::= typename */
      case 49: /* typename ::= ids */
      case 126: /* as ::= AS nm */
      case 127: /* as ::= ids */
      case 137: /* dbnm ::= DOT nm */
      case 146: /* indexed_opt ::= INDEXED BY nm */
      case 251: /* collate ::= COLLATE ids */
      case 253: /* plus_num ::= plus_opt number */
      case 254: /* minus_num ::= MINUS number */
      case 255: /* number ::= INTEGER|FLOAT */
{yygotominor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 45: /* type ::= typetoken */
{sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
        break;
      case 47: /* typetoken ::= typename LP signed RP */
{
  yygotominor.yy0.z = yymsp[-3].minor.yy0.z;
  yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);
}
        break;
      case 48: /* typetoken ::= typename LP signed COMMA signed RP */
{
  yygotominor.yy0.z = yymsp[-5].minor.yy0.z;
  yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);
}
        break;
      case 50: /* typename ::= typename ids */
{yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
        break;
      case 57: /* ccons ::= DEFAULT term */
      case 59: /* ccons ::= DEFAULT PLUS term */
{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy454);}
        break;
      case 58: /* ccons ::= DEFAULT LP expr RP */
{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy454);}
        break;
      case 60: /* ccons ::= DEFAULT MINUS term */
{
  Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy454, 0, 0);
  sqlite3ExprSpan(p,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy454->span);
  sqlite3AddDefaultValue(pParse,p);
}
        break;
      case 61: /* ccons ::= DEFAULT id */
{
  Expr *p = sqlite3PExpr(pParse, TK_STRING, 0, 0, &yymsp[0].minor.yy0);
  sqlite3AddDefaultValue(pParse,p);
}
        break;
      case 63: /* ccons ::= NOT NULL onconf */
{sqlite3AddNotNull(pParse, yymsp[0].minor.yy60);}
        break;
      case 64: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy60,yymsp[0].minor.yy60,yymsp[-2].minor.yy60);}
        break;
      case 65: /* ccons ::= UNIQUE onconf */
{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy60,0,0,0,0);}
        break;
      case 66: /* ccons ::= CHECK LP expr RP */
{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy454);}
        break;
      case 67: /* ccons ::= REFERENCES nm idxlist_opt refargs */
{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy266,yymsp[0].minor.yy60);}
        break;
      case 68: /* ccons ::= defer_subclause */
{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy60);}
        break;
      case 69: /* ccons ::= COLLATE ids */
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
        break;
      case 72: /* refargs ::= */
{ yygotominor.yy60 = OE_Restrict * 0x010101; }
        break;
      case 73: /* refargs ::= refargs refarg */
{ yygotominor.yy60 = (yymsp[-1].minor.yy60 & ~yymsp[0].minor.yy243.mask) | yymsp[0].minor.yy243.value; }
        break;
      case 74: /* refarg ::= MATCH nm */
{ yygotominor.yy243.value = 0;     yygotominor.yy243.mask = 0x000000; }
        break;
      case 75: /* refarg ::= ON DELETE refact */
{ yygotominor.yy243.value = yymsp[0].minor.yy60;     yygotominor.yy243.mask = 0x0000ff; }
        break;
      case 76: /* refarg ::= ON UPDATE refact */
{ yygotominor.yy243.value = yymsp[0].minor.yy60<<8;  yygotominor.yy243.mask = 0x00ff00; }
        break;
      case 77: /* refarg ::= ON INSERT refact */
{ yygotominor.yy243.value = yymsp[0].minor.yy60<<16; yygotominor.yy243.mask = 0xff0000; }
        break;
      case 78: /* refact ::= SET NULL */
{ yygotominor.yy60 = OE_SetNull; }
        break;
      case 79: /* refact ::= SET DEFAULT */
{ yygotominor.yy60 = OE_SetDflt; }
        break;
      case 80: /* refact ::= CASCADE */
{ yygotominor.yy60 = OE_Cascade; }
        break;
      case 81: /* refact ::= RESTRICT */
{ yygotominor.yy60 = OE_Restrict; }
        break;
      case 82: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
      case 83: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
      case 98: /* defer_subclause_opt ::= defer_subclause */
      case 100: /* onconf ::= ON CONFLICT resolvetype */
      case 102: /* orconf ::= OR resolvetype */
      case 103: /* resolvetype ::= raisetype */
      case 175: /* insert_cmd ::= INSERT orconf */
{yygotominor.yy60 = yymsp[0].minor.yy60;}
        break;
      case 87: /* conslist_opt ::= */
{yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}
        break;
      case 88: /* conslist_opt ::= COMMA conslist */
{yygotominor.yy0 = yymsp[-1].minor.yy0;}
        break;
      case 93: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy266,yymsp[0].minor.yy60,yymsp[-2].minor.yy60,0);}
        break;
      case 94: /* tcons ::= UNIQUE LP idxlist RP onconf */
{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy266,yymsp[0].minor.yy60,0,0,0,0);}
        break;
      case 95: /* tcons ::= CHECK LP expr RP onconf */
{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy454);}
        break;
      case 96: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
{
    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy266, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy266, yymsp[-1].minor.yy60);
    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy60);
}
        break;
      case 99: /* onconf ::= */
      case 101: /* orconf ::= */
{yygotominor.yy60 = OE_Default;}
        break;
      case 104: /* resolvetype ::= IGNORE */
{yygotominor.yy60 = OE_Ignore;}
        break;
      case 105: /* resolvetype ::= REPLACE */
      case 176: /* insert_cmd ::= REPLACE */
{yygotominor.yy60 = OE_Replace;}
        break;
      case 106: /* cmd ::= DROP TABLE ifexists fullname */
{
  sqlite3DropTable(pParse, yymsp[0].minor.yy427, 0, yymsp[-1].minor.yy60);
}
        break;
      case 109: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
{
  sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy331, yymsp[-6].minor.yy60, yymsp[-4].minor.yy60);
}
        break;
      case 110: /* cmd ::= DROP VIEW ifexists fullname */
{
  sqlite3DropTable(pParse, yymsp[0].minor.yy427, 1, yymsp[-1].minor.yy60);
}
        break;
      case 111: /* cmd ::= select */
{
  SelectDest dest = {SRT_Output, 0, 0, 0, 0};
  sqlite3Select(pParse, yymsp[0].minor.yy331, &dest);
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy331);
}
        break;
      case 112: /* select ::= oneselect */
{yygotominor.yy331 = yymsp[0].minor.yy331;}
        break;
      case 113: /* select ::= select multiselect_op oneselect */
{
  if( yymsp[0].minor.yy331 ){
    yymsp[0].minor.yy331->op = (u8)yymsp[-1].minor.yy60;
    yymsp[0].minor.yy331->pPrior = yymsp[-2].minor.yy331;
  }else{
    sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy331);
  }
  yygotominor.yy331 = yymsp[0].minor.yy331;
}
        break;
      case 115: /* multiselect_op ::= UNION ALL */
{yygotominor.yy60 = TK_ALL;}
        break;
      case 117: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
{
  yygotominor.yy331 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy266,yymsp[-5].minor.yy427,yymsp[-4].minor.yy454,yymsp[-3].minor.yy266,yymsp[-2].minor.yy454,yymsp[-1].minor.yy266,yymsp[-7].minor.yy60,yymsp[0].minor.yy348.pLimit,yymsp[0].minor.yy348.pOffset);
}
        break;
      case 121: /* sclp ::= selcollist COMMA */
      case 247: /* idxlist_opt ::= LP idxlist RP */
{yygotominor.yy266 = yymsp[-1].minor.yy266;}
        break;
      case 122: /* sclp ::= */
      case 150: /* orderby_opt ::= */
      case 158: /* groupby_opt ::= */
      case 240: /* exprlist ::= */
      case 246: /* idxlist_opt ::= */
{yygotominor.yy266 = 0;}
        break;
      case 123: /* selcollist ::= sclp expr as */
{
   yygotominor.yy266 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy266,yymsp[-1].minor.yy454,yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
}
        break;
      case 124: /* selcollist ::= sclp STAR */
{
  Expr *p = sqlite3PExpr(pParse, TK_ALL, 0, 0, 0);
  yygotominor.yy266 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy266, p, 0);
}
        break;
      case 125: /* selcollist ::= sclp nm DOT STAR */
{
  Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);
  Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
  Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
  yygotominor.yy266 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy266, pDot, 0);
}
        break;
      case 128: /* as ::= */
{yygotominor.yy0.n = 0;}
        break;
      case 129: /* from ::= */
{yygotominor.yy427 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy427));}
        break;
      case 130: /* from ::= FROM seltablist */
{
  yygotominor.yy427 = yymsp[0].minor.yy427;
  sqlite3SrcListShiftJoinType(yygotominor.yy427);
}
        break;
      case 131: /* stl_prefix ::= seltablist joinop */
{
   yygotominor.yy427 = yymsp[-1].minor.yy427;
   if( yygotominor.yy427 && yygotominor.yy427->nSrc>0 ) yygotominor.yy427->a[yygotominor.yy427->nSrc-1].jointype = (u8)yymsp[0].minor.yy60;
}
        break;
      case 132: /* stl_prefix ::= */
{yygotominor.yy427 = 0;}
        break;
      case 133: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
{
  yygotominor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy454,yymsp[0].minor.yy272);
  sqlite3SrcListIndexedBy(pParse, yygotominor.yy427, &yymsp[-2].minor.yy0);
}
        break;
      case 134: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
{
    yygotominor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy331,yymsp[-1].minor.yy454,yymsp[0].minor.yy272);
  }
        break;
      case 135: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
{
    if( yymsp[-6].minor.yy427==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy454==0 && yymsp[0].minor.yy272==0 ){
      yygotominor.yy427 = yymsp[-4].minor.yy427;
    }else{
      Select *pSubquery;
      sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy427);
      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy427,0,0,0,0,0,0,0);
      yygotominor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy454,yymsp[0].minor.yy272);
    }
  }
        break;
      case 136: /* dbnm ::= */
      case 145: /* indexed_opt ::= */
{yygotominor.yy0.z=0; yygotominor.yy0.n=0;}
        break;
      case 138: /* fullname ::= nm dbnm */
{yygotominor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
        break;
      case 139: /* joinop ::= COMMA|JOIN */
{ yygotominor.yy60 = JT_INNER; }
        break;
      case 140: /* joinop ::= JOIN_KW JOIN */
{ yygotominor.yy60 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
        break;
      case 141: /* joinop ::= JOIN_KW nm JOIN */
{ yygotominor.yy60 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
        break;
      case 142: /* joinop ::= JOIN_KW nm nm JOIN */
{ yygotominor.yy60 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
        break;
      case 143: /* on_opt ::= ON expr */
      case 154: /* sortitem ::= expr */
      case 161: /* having_opt ::= HAVING expr */
      case 168: /* where_opt ::= WHERE expr */
      case 183: /* expr ::= term */
      case 211: /* escape ::= ESCAPE expr */
      case 235: /* case_else ::= ELSE expr */
      case 237: /* case_operand ::= expr */
{yygotominor.yy454 = yymsp[0].minor.yy454;}
        break;
      case 144: /* on_opt ::= */
      case 160: /* having_opt ::= */
      case 167: /* where_opt ::= */
      case 212: /* escape ::= */
      case 236: /* case_else ::= */
      case 238: /* case_operand ::= */
{yygotominor.yy454 = 0;}
        break;
      case 147: /* indexed_opt ::= NOT INDEXED */
{yygotominor.yy0.z=0; yygotominor.yy0.n=1;}
        break;
      case 148: /* using_opt ::= USING LP inscollist RP */
      case 180: /* inscollist_opt ::= LP inscollist RP */
{yygotominor.yy272 = yymsp[-1].minor.yy272;}
        break;
      case 149: /* using_opt ::= */
      case 179: /* inscollist_opt ::= */
{yygotominor.yy272 = 0;}
        break;
      case 151: /* orderby_opt ::= ORDER BY sortlist */
      case 159: /* groupby_opt ::= GROUP BY nexprlist */
      case 239: /* exprlist ::= nexprlist */
{yygotominor.yy266 = yymsp[0].minor.yy266;}
        break;
      case 152: /* sortlist ::= sortlist COMMA sortitem sortorder */
{
  yygotominor.yy266 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy266,yymsp[-1].minor.yy454,0);
  if( yygotominor.yy266 ) yygotominor.yy266->a[yygotominor.yy266->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy60;
}
        break;
      case 153: /* sortlist ::= sortitem sortorder */
{
  yygotominor.yy266 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy454,0);
  if( yygotominor.yy266 && yygotominor.yy266->a ) yygotominor.yy266->a[0].sortOrder = (u8)yymsp[0].minor.yy60;
}
        break;
      case 155: /* sortorder ::= ASC */
      case 157: /* sortorder ::= */
{yygotominor.yy60 = SQLITE_SO_ASC;}
        break;
      case 156: /* sortorder ::= DESC */
{yygotominor.yy60 = SQLITE_SO_DESC;}
        break;
      case 162: /* limit_opt ::= */
{yygotominor.yy348.pLimit = 0; yygotominor.yy348.pOffset = 0;}
        break;
      case 163: /* limit_opt ::= LIMIT expr */
{yygotominor.yy348.pLimit = yymsp[0].minor.yy454; yygotominor.yy348.pOffset = 0;}
        break;
      case 164: /* limit_opt ::= LIMIT expr OFFSET expr */
{yygotominor.yy348.pLimit = yymsp[-2].minor.yy454; yygotominor.yy348.pOffset = yymsp[0].minor.yy454;}
        break;
      case 165: /* limit_opt ::= LIMIT expr COMMA expr */
{yygotominor.yy348.pOffset = yymsp[-2].minor.yy454; yygotominor.yy348.pLimit = yymsp[0].minor.yy454;}
        break;
      case 166: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
{
  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy427, &yymsp[-1].minor.yy0);
  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy427,yymsp[0].minor.yy454);
}
        break;
      case 169: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
{
  sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy427, &yymsp[-3].minor.yy0);
  sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy266,"set list"); 
  sqlite3Update(pParse,yymsp[-4].minor.yy427,yymsp[-1].minor.yy266,yymsp[0].minor.yy454,yymsp[-5].minor.yy60);
}
        break;
      case 170: /* setlist ::= setlist COMMA nm EQ expr */
{yygotominor.yy266 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy266,yymsp[0].minor.yy454,&yymsp[-2].minor.yy0);}
        break;
      case 171: /* setlist ::= nm EQ expr */
{yygotominor.yy266 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy454,&yymsp[-2].minor.yy0);}
        break;
      case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */
{sqlite3Insert(pParse, yymsp[-5].minor.yy427, yymsp[-1].minor.yy266, 0, yymsp[-4].minor.yy272, yymsp[-7].minor.yy60);}
        break;
      case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
{sqlite3Insert(pParse, yymsp[-2].minor.yy427, 0, yymsp[0].minor.yy331, yymsp[-1].minor.yy272, yymsp[-4].minor.yy60);}
        break;
      case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
{sqlite3Insert(pParse, yymsp[-3].minor.yy427, 0, 0, yymsp[-2].minor.yy272, yymsp[-5].minor.yy60);}
        break;
      case 177: /* itemlist ::= itemlist COMMA expr */
      case 241: /* nexprlist ::= nexprlist COMMA expr */
{yygotominor.yy266 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy266,yymsp[0].minor.yy454,0);}
        break;
      case 178: /* itemlist ::= expr */
      case 242: /* nexprlist ::= expr */
{yygotominor.yy266 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy454,0);}
        break;
      case 181: /* inscollist ::= inscollist COMMA nm */
{yygotominor.yy272 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy272,&yymsp[0].minor.yy0);}
        break;
      case 182: /* inscollist ::= nm */
{yygotominor.yy272 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
        break;
      case 184: /* expr ::= LP expr RP */
{yygotominor.yy454 = yymsp[-1].minor.yy454; sqlite3ExprSpan(yygotominor.yy454,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); }
        break;
      case 185: /* term ::= NULL */
      case 190: /* term ::= INTEGER|FLOAT|BLOB */
      case 191: /* term ::= STRING */
{yygotominor.yy454 = sqlite3PExpr(pParse, yymsp[0].major, 0, 0, &yymsp[0].minor.yy0);}
        break;
      case 186: /* expr ::= id */
      case 187: /* expr ::= JOIN_KW */
{yygotominor.yy454 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);}
        break;
      case 188: /* expr ::= nm DOT nm */
{
  Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
  Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
  yygotominor.yy454 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
}
        break;
      case 189: /* expr ::= nm DOT nm DOT nm */
{
  Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
  Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
  Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
  Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
  yygotominor.yy454 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
}
        break;
      case 192: /* expr ::= REGISTER */
{yygotominor.yy454 = sqlite3RegisterExpr(pParse, &yymsp[0].minor.yy0);}
        break;
      case 193: /* expr ::= VARIABLE */
{
  Token *pToken = &yymsp[0].minor.yy0;
  Expr *pExpr = yygotominor.yy454 = sqlite3PExpr(pParse, TK_VARIABLE, 0, 0, pToken);
  sqlite3ExprAssignVarNumber(pParse, pExpr);
}
        break;
      case 194: /* expr ::= expr COLLATE ids */
{
  yygotominor.yy454 = sqlite3ExprSetColl(pParse, yymsp[-2].minor.yy454, &yymsp[0].minor.yy0);
}
        break;
      case 195: /* expr ::= CAST LP expr AS typetoken RP */
{
  yygotominor.yy454 = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy454, 0, &yymsp[-1].minor.yy0);
  sqlite3ExprSpan(yygotominor.yy454,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);
}
        break;
      case 196: /* expr ::= ID LP distinct exprlist RP */
{
  if( yymsp[-1].minor.yy266 && yymsp[-1].minor.yy266->nExpr>SQLITE_MAX_FUNCTION_ARG ){
    sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
  }
  yygotominor.yy454 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy266, &yymsp[-4].minor.yy0);
  sqlite3ExprSpan(yygotominor.yy454,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
  if( yymsp[-2].minor.yy60 && yygotominor.yy454 ){
    yygotominor.yy454->flags |= EP_Distinct;
  }
}
        break;
      case 197: /* expr ::= ID LP STAR RP */
{
  yygotominor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
  sqlite3ExprSpan(yygotominor.yy454,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
}
        break;
      case 198: /* term ::= CTIME_KW */
{
  /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are
  ** treated as functions that return constants */
  yygotominor.yy454 = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
  if( yygotominor.yy454 ){
    yygotominor.yy454->op = TK_CONST_FUNC;  
    yygotominor.yy454->span = yymsp[0].minor.yy0;
  }
}
        break;
      case 199: /* expr ::= expr AND expr */
      case 200: /* expr ::= expr OR expr */
      case 201: /* expr ::= expr LT|GT|GE|LE expr */
      case 202: /* expr ::= expr EQ|NE expr */
      case 203: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
      case 204: /* expr ::= expr PLUS|MINUS expr */
      case 205: /* expr ::= expr STAR|SLASH|REM expr */
      case 206: /* expr ::= expr CONCAT expr */
{yygotominor.yy454 = sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy454,yymsp[0].minor.yy454,0);}
        break;
      case 207: /* likeop ::= LIKE_KW */
      case 209: /* likeop ::= MATCH */
{yygotominor.yy258.eOperator = yymsp[0].minor.yy0; yygotominor.yy258.not = 0;}
        break;
      case 208: /* likeop ::= NOT LIKE_KW */
      case 210: /* likeop ::= NOT MATCH */
{yygotominor.yy258.eOperator = yymsp[0].minor.yy0; yygotominor.yy258.not = 1;}
        break;
      case 213: /* expr ::= expr likeop expr escape */
{
  ExprList *pList;
  pList = sqlite3ExprListAppend(pParse,0, yymsp[-1].minor.yy454, 0);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-3].minor.yy454, 0);
  if( yymsp[0].minor.yy454 ){
    pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy454, 0);
  }
  yygotominor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-2].minor.yy258.eOperator);
  if( yymsp[-2].minor.yy258.not ) yygotominor.yy454 = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy454, 0, 0);
  sqlite3ExprSpan(yygotominor.yy454, &yymsp[-3].minor.yy454->span, &yymsp[-1].minor.yy454->span);
  if( yygotominor.yy454 ) yygotominor.yy454->flags |= EP_InfixFunc;
}
        break;
      case 214: /* expr ::= expr ISNULL|NOTNULL */
{
  yygotominor.yy454 = sqlite3PExpr(pParse, yymsp[0].major, yymsp[-1].minor.yy454, 0, 0);
  sqlite3ExprSpan(yygotominor.yy454,&yymsp[-1].minor.yy454->span,&yymsp[0].minor.yy0);
}
        break;
      case 215: /* expr ::= expr IS NULL */
{
  yygotominor.yy454 = sqlite3PExpr(pParse, TK_ISNULL, yymsp[-2].minor.yy454, 0, 0);
  sqlite3ExprSpan(yygotominor.yy454,&yymsp[-2].minor.yy454->span,&yymsp[0].minor.yy0);
}
        break;
      case 216: /* expr ::= expr NOT NULL */
{
  yygotominor.yy454 = sqlite3PExpr(pParse, TK_NOTNULL, yymsp[-2].minor.yy454, 0, 0);
  sqlite3ExprSpan(yygotominor.yy454,&yymsp[-2].minor.yy454->span,&yymsp[0].minor.yy0);
}
        break;
      case 217: /* expr ::= expr IS NOT NULL */
{
  yygotominor.yy454 = sqlite3PExpr(pParse, TK_NOTNULL, yymsp[-3].minor.yy454, 0, 0);
  sqlite3ExprSpan(yygotominor.yy454,&yymsp[-3].minor.yy454->span,&yymsp[0].minor.yy0);
}
        break;
      case 218: /* expr ::= NOT expr */
      case 219: /* expr ::= BITNOT expr */
{
  yygotominor.yy454 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy454, 0, 0);
  sqlite3ExprSpan(yygotominor.yy454,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy454->span);
}
        break;
      case 220: /* expr ::= MINUS expr */
{
  yygotominor.yy454 = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy454, 0, 0);
  sqlite3ExprSpan(yygotominor.yy454,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy454->span);
}
        break;
      case 221: /* expr ::= PLUS expr */
{
  yygotominor.yy454 = sqlite3PExpr(pParse, TK_UPLUS, yymsp[0].minor.yy454, 0, 0);
  sqlite3ExprSpan(yygotominor.yy454,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy454->span);
}
        break;
      case 224: /* expr ::= expr between_op expr AND expr */
{
  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454, 0);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy454, 0);
  yygotominor.yy454 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy454, 0, 0);
  if( yygotominor.yy454 ){
    yygotominor.yy454->x.pList = pList;
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  } 
  if( yymsp[-3].minor.yy60 ) yygotominor.yy454 = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy454, 0, 0);
  sqlite3ExprSpan(yygotominor.yy454,&yymsp[-4].minor.yy454->span,&yymsp[0].minor.yy454->span);
}
        break;
      case 227: /* expr ::= expr in_op LP exprlist RP */
{
    yygotominor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0, 0);
    if( yygotominor.yy454 ){
      yygotominor.yy454->x.pList = yymsp[-1].minor.yy266;
      sqlite3ExprSetHeight(pParse, yygotominor.yy454);
    }else{
      sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy266);
    }
    if( yymsp[-3].minor.yy60 ) yygotominor.yy454 = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy454, 0, 0);
    sqlite3ExprSpan(yygotominor.yy454,&yymsp[-4].minor.yy454->span,&yymsp[0].minor.yy0);
  }
        break;
      case 228: /* expr ::= LP select RP */
{
    yygotominor.yy454 = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
    if( yygotominor.yy454 ){
      yygotominor.yy454->x.pSelect = yymsp[-1].minor.yy331;
      ExprSetProperty(yygotominor.yy454, EP_xIsSelect);
      sqlite3ExprSetHeight(pParse, yygotominor.yy454);
    }else{
      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy331);
    }
    sqlite3ExprSpan(yygotominor.yy454,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
  }
        break;
      case 229: /* expr ::= expr in_op LP select RP */
{
    yygotominor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0, 0);
    if( yygotominor.yy454 ){
      yygotominor.yy454->x.pSelect = yymsp[-1].minor.yy331;
      ExprSetProperty(yygotominor.yy454, EP_xIsSelect);
      sqlite3ExprSetHeight(pParse, yygotominor.yy454);
    }else{
      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy331);
    }
    if( yymsp[-3].minor.yy60 ) yygotominor.yy454 = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy454, 0, 0);
    sqlite3ExprSpan(yygotominor.yy454,&yymsp[-4].minor.yy454->span,&yymsp[0].minor.yy0);
  }
        break;
      case 230: /* expr ::= expr in_op nm dbnm */
{
    SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
    yygotominor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy454, 0, 0);
    if( yygotominor.yy454 ){
      yygotominor.yy454->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
      ExprSetProperty(yygotominor.yy454, EP_xIsSelect);
      sqlite3ExprSetHeight(pParse, yygotominor.yy454);
    }else{
      sqlite3SrcListDelete(pParse->db, pSrc);
    }
    if( yymsp[-2].minor.yy60 ) yygotominor.yy454 = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy454, 0, 0);
    sqlite3ExprSpan(yygotominor.yy454,&yymsp[-3].minor.yy454->span,yymsp[0].minor.yy0.z?&yymsp[0].minor.yy0:&yymsp[-1].minor.yy0);
  }
        break;
      case 231: /* expr ::= EXISTS LP select RP */
{
    Expr *p = yygotominor.yy454 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
    if( p ){
      p->x.pSelect = yymsp[-1].minor.yy331;
      ExprSetProperty(yygotominor.yy454, EP_xIsSelect);
      sqlite3ExprSpan(p,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
      sqlite3ExprSetHeight(pParse, yygotominor.yy454);
    }else{
      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy331);
    }
  }
        break;
      case 232: /* expr ::= CASE case_operand case_exprlist case_else END */
{
  yygotominor.yy454 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy454, yymsp[-1].minor.yy454, 0);
  if( yygotominor.yy454 ){
    yygotominor.yy454->x.pList = yymsp[-2].minor.yy266;
    sqlite3ExprSetHeight(pParse, yygotominor.yy454);
  }else{
    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy266);
  }
  sqlite3ExprSpan(yygotominor.yy454, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0);
}
        break;
      case 233: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
  yygotominor.yy266 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy266, yymsp[-2].minor.yy454, 0);
  yygotominor.yy266 = sqlite3ExprListAppend(pParse,yygotominor.yy266, yymsp[0].minor.yy454, 0);
}
        break;
      case 234: /* case_exprlist ::= WHEN expr THEN expr */
{
  yygotominor.yy266 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454, 0);
  yygotominor.yy266 = sqlite3ExprListAppend(pParse,yygotominor.yy266, yymsp[0].minor.yy454, 0);
}
        break;
      case 243: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
{
  sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0, 
                     sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy266, yymsp[-9].minor.yy60,
                      &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy60);
}
        break;
      case 244: /* uniqueflag ::= UNIQUE */
      case 281: /* raisetype ::= ABORT */
{yygotominor.yy60 = OE_Abort;}
        break;
      case 245: /* uniqueflag ::= */
{yygotominor.yy60 = OE_None;}
        break;
      case 248: /* idxlist ::= idxlist COMMA nm collate sortorder */
{
  Expr *p = 0;
  if( yymsp[-1].minor.yy0.n>0 ){
    p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
    sqlite3ExprSetColl(pParse, p, &yymsp[-1].minor.yy0);
  }
  yygotominor.yy266 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy266, p, &yymsp[-2].minor.yy0);
  sqlite3ExprListCheckLength(pParse, yygotominor.yy266, "index");
  if( yygotominor.yy266 ) yygotominor.yy266->a[yygotominor.yy266->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy60;
}
        break;
      case 249: /* idxlist ::= nm collate sortorder */
{
  Expr *p = 0;
  if( yymsp[-1].minor.yy0.n>0 ){
    p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
    sqlite3ExprSetColl(pParse, p, &yymsp[-1].minor.yy0);
  }












  yygotominor.yy266 = sqlite3ExprListAppend(pParse,0, p, &yymsp[-2].minor.yy0);
  sqlite3ExprListCheckLength(pParse, yygotominor.yy266, "index");
  if( yygotominor.yy266 ) yygotominor.yy266->a[yygotominor.yy266->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy60;
}
        break;
      case 250: /* collate ::= */
{yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}
        break;
      case 252: /* cmd ::= DROP INDEX ifexists fullname */
{sqlite3DropIndex(pParse, yymsp[0].minor.yy427, yymsp[-1].minor.yy60);}
        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.yy455, &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.yy60, yymsp[-4].minor.yy62.a, yymsp[-4].minor.yy62.b, yymsp[-2].minor.yy427, yymsp[0].minor.yy454, yymsp[-10].minor.yy60, yymsp[-8].minor.yy60);
  yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
}
        break;
      case 260: /* trigger_time ::= BEFORE */
      case 263: /* trigger_time ::= */
{ yygotominor.yy60 = TK_BEFORE; }
        break;
      case 261: /* trigger_time ::= AFTER */
{ yygotominor.yy60 = TK_AFTER;  }
        break;
      case 262: /* trigger_time ::= INSTEAD OF */
{ yygotominor.yy60 = TK_INSTEAD;}
        break;
      case 264: /* trigger_event ::= DELETE|INSERT */
      case 265: /* trigger_event ::= UPDATE */
{yygotominor.yy62.a = yymsp[0].major; yygotominor.yy62.b = 0;}
        break;
      case 266: /* trigger_event ::= UPDATE OF inscollist */
{yygotominor.yy62.a = TK_UPDATE; yygotominor.yy62.b = yymsp[0].minor.yy272;}
        break;
      case 269: /* when_clause ::= */
{ yygotominor.yy454 = 0; }
        break;
      case 270: /* when_clause ::= WHEN expr */
{ yygotominor.yy454 = yymsp[0].minor.yy454; }
        break;
      case 271: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
/*
  if( yymsp[-2].minor.yy455 ){
    yymsp[-2].minor.yy455->pLast->pNext = yymsp[-1].minor.yy455;
  }else{
    yymsp[-2].minor.yy455 = yymsp[-1].minor.yy455;
  }
*/
  assert( yymsp[-2].minor.yy455!=0 );
  yymsp[-2].minor.yy455->pLast->pNext = yymsp[-1].minor.yy455;
  yymsp[-2].minor.yy455->pLast = yymsp[-1].minor.yy455;
  yygotominor.yy455 = yymsp[-2].minor.yy455;
}
        break;
      case 272: /* trigger_cmd_list ::= trigger_cmd SEMI */
{ 
  /* if( yymsp[-1].minor.yy455 ) */
  assert( yymsp[-1].minor.yy455!=0 );
  yymsp[-1].minor.yy455->pLast = yymsp[-1].minor.yy455;
  yygotominor.yy455 = yymsp[-1].minor.yy455;
}
        break;
      case 273: /* trigger_cmd ::= UPDATE orconf nm SET setlist where_opt */
{ yygotominor.yy455 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy266, yymsp[0].minor.yy454, yymsp[-4].minor.yy60); }
        break;
      case 274: /* trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP */
{yygotominor.yy455 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy272, yymsp[-1].minor.yy266, 0, yymsp[-7].minor.yy60);}
        break;
      case 275: /* trigger_cmd ::= insert_cmd INTO nm inscollist_opt select */
{yygotominor.yy455 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy272, 0, yymsp[0].minor.yy331, yymsp[-4].minor.yy60);}
        break;
      case 276: /* trigger_cmd ::= DELETE FROM nm where_opt */
{yygotominor.yy455 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-1].minor.yy0, yymsp[0].minor.yy454);}
        break;
      case 277: /* trigger_cmd ::= select */
{yygotominor.yy455 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy331); }
        break;
      case 278: /* expr ::= RAISE LP IGNORE RP */
{
  yygotominor.yy454 = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); 
  if( yygotominor.yy454 ){
    yygotominor.yy454->affinity = OE_Ignore;
    sqlite3ExprSpan(yygotominor.yy454, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0);
  }
}
        break;
      case 279: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
  yygotominor.yy454 = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); 
  if( yygotominor.yy454 ) {
    yygotominor.yy454->affinity = (char)yymsp[-3].minor.yy60;
    sqlite3ExprSpan(yygotominor.yy454, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0);
  }
}
        break;









      case 280: /* raisetype ::= ROLLBACK */
{yygotominor.yy60 = OE_Rollback;}
        break;
      case 282: /* raisetype ::= FAIL */
{yygotominor.yy60 = OE_Fail;}
        break;
      case 283: /* cmd ::= DROP TRIGGER ifexists fullname */
{
  sqlite3DropTrigger(pParse,yymsp[0].minor.yy427,yymsp[-1].minor.yy60);
}
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
................................................................................
*************************************************************************
** An tokenizer for SQL
**
** This file contains C code that splits an SQL input string up into
** individual tokens and sends those tokens one-by-one over to the
** parser for analysis.
**
** $Id: tokenize.c,v 1.155 2009/03/31 03:41:57 shane Exp $
*/

/*
** The charMap() macro maps alphabetic characters into their
** lower-case ASCII equivalent.  On ASCII machines, this is just
** an upper-to-lower case map.  On EBCDIC machines we also need
** to adjust the encoding.  Only alphabetic characters and underscores
................................................................................
** Run the parser on the given SQL string.  The parser structure is
** passed in.  An SQLITE_ status code is returned.  If an error occurs
** then an and attempt is made to write an error message into 
** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that
** error message.
*/
SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
  int nErr = 0;                   /* Number of errors encountered */
  int i;                          /* Loop counter */
  void *pEngine;                  /* The LEMON-generated LALR(1) parser */
  int tokenType;                  /* type of the next token */
  int lastTokenParsed = -1;       /* type of the previous token */
  u8 enableLookaside;             /* Saved value of db->lookaside.bEnabled */
  sqlite3 *db = pParse->db;       /* The database connection */

  int mxSqlLen;                   /* Max length of an SQL string */


  mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
  if( db->activeVdbeCnt==0 ){
    db->u1.isInterrupted = 0;
  }
  pParse->rc = SQLITE_OK;
  pParse->zTail = pParse->zSql = zSql;
  i = 0;
  assert( pzErrMsg!=0 );
................................................................................
  assert( pParse->sLastToken.dyn==0 );
  assert( pParse->pNewTable==0 );
  assert( pParse->pNewTrigger==0 );
  assert( pParse->nVar==0 );
  assert( pParse->nVarExpr==0 );
  assert( pParse->nVarExprAlloc==0 );
  assert( pParse->apVarExpr==0 );
  enableLookaside = db->lookaside.bEnabled;
  if( db->lookaside.pStart ) db->lookaside.bEnabled = 1;
  while( !db->mallocFailed && zSql[i]!=0 ){
    assert( i>=0 );
    pParse->sLastToken.z = (u8*)&zSql[i];
    assert( pParse->sLastToken.dyn==0 );
    pParse->sLastToken.n = sqlite3GetToken((unsigned char*)&zSql[i],&tokenType);
    i += pParse->sLastToken.n;
    if( i>mxSqlLen ){
................................................................................
  }
#ifdef YYTRACKMAXSTACKDEPTH
  sqlite3StatusSet(SQLITE_STATUS_PARSER_STACK,
      sqlite3ParserStackPeak(pEngine)
  );
#endif /* YYDEBUG */
  sqlite3ParserFree(pEngine, sqlite3_free);
  db->lookaside.bEnabled = enableLookaside;
  if( db->mallocFailed ){
    pParse->rc = SQLITE_NOMEM;
  }
  if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){
    sqlite3SetString(&pParse->zErrMsg, db, "%s", sqlite3ErrStr(pParse->rc));
  }
  if( pParse->zErrMsg ){
................................................................................
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.534 2009/03/23 04:33:32 danielk1977 Exp $
*/

#ifdef SQLITE_ENABLE_FTS3
/************** Include fts3.h in the middle of main.c ***********************/
/************** Begin file fts3.h ********************************************/
/*
** 2006 Oct 10
................................................................................
  */
  if( sz<=(int)sizeof(LookasideSlot*) ) sz = 0;
  if( cnt<0 ) cnt = 0;
  if( sz==0 || cnt==0 ){
    sz = 0;
    pStart = 0;
  }else if( pBuf==0 ){
    sz = ROUND8(sz);
    sqlite3BeginBenignMalloc();
    pStart = sqlite3Malloc( sz*cnt );
    sqlite3EndBenignMalloc();
  }else{
    sz = ROUNDDOWN8(sz);
    pStart = pBuf;
  }
  db->lookaside.pStart = pStart;
  db->lookaside.pFree = 0;
  db->lookaside.sz = (u16)sz;
  if( pStart ){
    int i;
................................................................................
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains the implementation of the sqlite3_unlock_notify()
** API method and its associated functionality.
**
** $Id: notify.c,v 1.2 2009/03/25 16:51:43 drh Exp $
*/

/* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY

/*
** Public interfaces:
................................................................................
      if( p->xUnlockNotify!=xUnlockNotify && nArg!=0 ){
        xUnlockNotify(aArg, nArg);
        nArg = 0;
      }

      sqlite3BeginBenignMalloc();
      assert( aArg==aDyn || (aDyn==0 && aArg==aStatic) );
      assert( nArg<=(int)ArraySize(aStatic) || aArg==aDyn );
      if( (!aDyn && nArg==(int)ArraySize(aStatic))
       || (aDyn && nArg==(int)(sqlite3DbMallocSize(db, aDyn)/sizeof(void*)))
      ){
        /* The aArg[] array needs to grow. */
        void **pNew = (void **)sqlite3Malloc(nArg*sizeof(void *)*2);
        if( pNew ){
          memcpy(pNew, aArg, nArg*sizeof(void *));
          sqlite3_free(aDyn);
          aDyn = aArg = pNew;
................................................................................
  sqlite3ConnectionUnlocked(db);
  enterMutex();
  removeFromBlockedList(db);
  checkListProperties(db);
  leaveMutex();
}
#endif


/************** End of notify.c **********************************************/
/************** Begin file fts3.c ********************************************/
/*
** 2006 Oct 10
**
** The author disclaims copyright to this source code.  In place of