Fossil SCM

Merge from trunk

george 2021-06-15 21:37 UTC wcontent-subsets merge
Commit cea36e6c866da8baa31359787482af4d0408c4b7f115c8094b0a12973a2e9b66
77 files changed +1 -1 +5 -1 +2 -2 +2 -2 +11 -7 +2 -2 +8 -1 +1 -1 +2 -2 +1 -1 +5 +9 -1 +2 -2 +324 -51 +8 +7 -1 +10 -10 +19 -4 +11 -16 +39 -6 +39 -6 +24 +2 -2 +8 -4 +20 +17 -2 +14 -3 +9 -6 +3 -1 +18 -9 +1 +1 +33 +38 -14 +60 +42 -1 +1 -1 +59 -11 +19 -3 +14 -2 +1 -1 +5 -5 +887 -58 +1 +3241 -2435 +95 -21 +15 -1 +4 +3 -3 +147 -40 +12 -2 +19 -8 +23 -2 +7 -2 +8 -2 +8 -2 -6 +59 +5 -1 +2 +2 +4 +6 -6 +37 -4 +37 -4 +1 -70 +2 -2 +14 -1 +14 -1 +1 +1 +1 -1 +2 -1 +1 +60 +231
+1 -1
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1
-2.15
1
+2.16
22
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1 2.15
2
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1 2.16
2
--- skins/ardoise/css.txt
+++ skins/ardoise/css.txt
@@ -959,11 +959,11 @@
959959
span.timelineSelected {
960960
border-radius: 5px;
961961
border: solid #ff8000;
962962
vertical-align: top;
963963
text-align: left;
964
- background: #442800
964
+ background-color: #442800;
965965
}
966966
.timelineSelected {
967967
box-shadow: none;
968968
}
969969
.timelineSecondary {}
@@ -1410,6 +1410,10 @@
14101410
.capsumRead {
14111411
background-color: #262;
14121412
}
14131413
.capsumWrite {
14141414
background-color: #662;
1415
+}
1416
+body.branch .brlist > table > tbody > tr:hover:not(.selected),
1417
+body.branch .brlist > table > tbody > tr.selected {
1418
+ background-color: #442800;
14151419
}
14161420
--- skins/ardoise/css.txt
+++ skins/ardoise/css.txt
@@ -959,11 +959,11 @@
959 span.timelineSelected {
960 border-radius: 5px;
961 border: solid #ff8000;
962 vertical-align: top;
963 text-align: left;
964 background: #442800
965 }
966 .timelineSelected {
967 box-shadow: none;
968 }
969 .timelineSecondary {}
@@ -1410,6 +1410,10 @@
1410 .capsumRead {
1411 background-color: #262;
1412 }
1413 .capsumWrite {
1414 background-color: #662;
 
 
 
 
1415 }
1416
--- skins/ardoise/css.txt
+++ skins/ardoise/css.txt
@@ -959,11 +959,11 @@
959 span.timelineSelected {
960 border-radius: 5px;
961 border: solid #ff8000;
962 vertical-align: top;
963 text-align: left;
964 background-color: #442800;
965 }
966 .timelineSelected {
967 box-shadow: none;
968 }
969 .timelineSecondary {}
@@ -1410,6 +1410,10 @@
1410 .capsumRead {
1411 background-color: #262;
1412 }
1413 .capsumWrite {
1414 background-color: #662;
1415 }
1416 body.branch .brlist > table > tbody > tr:hover:not(.selected),
1417 body.branch .brlist > table > tbody > tr.selected {
1418 background-color: #442800;
1419 }
1420
--- skins/ardoise/header.txt
+++ skins/ardoise/header.txt
@@ -26,12 +26,12 @@
2626
html "<li><a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776;</a></li>\n"
2727
builtin_request_js hbmenu.js
2828
set once 1
2929
foreach {name url expr class} $mainmenu {
3030
if {![capexpr $expr]} continue
31
- if {$once && [string match /$current_page* $url]} {
32
- lappend class active
31
+ if {$once && [string match $url\[/?#\]* /$current_page/]} {
32
+ set class "$class active"
3333
set once 0
3434
}
3535
html "<li class='$class'>"
3636
if {[string match /* $url]} {set url $home$url}
3737
html "<a href='$url'>$name</a></li>\n"
3838
--- skins/ardoise/header.txt
+++ skins/ardoise/header.txt
@@ -26,12 +26,12 @@
26 html "<li><a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776;</a></li>\n"
27 builtin_request_js hbmenu.js
28 set once 1
29 foreach {name url expr class} $mainmenu {
30 if {![capexpr $expr]} continue
31 if {$once && [string match /$current_page* $url]} {
32 lappend class active
33 set once 0
34 }
35 html "<li class='$class'>"
36 if {[string match /* $url]} {set url $home$url}
37 html "<a href='$url'>$name</a></li>\n"
38
--- skins/ardoise/header.txt
+++ skins/ardoise/header.txt
@@ -26,12 +26,12 @@
26 html "<li><a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776;</a></li>\n"
27 builtin_request_js hbmenu.js
28 set once 1
29 foreach {name url expr class} $mainmenu {
30 if {![capexpr $expr]} continue
31 if {$once && [string match $url\[/?#\]* /$current_page/]} {
32 set class "$class active"
33 set once 0
34 }
35 html "<li class='$class'>"
36 if {[string match /* $url]} {set url $home$url}
37 html "<a href='$url'>$name</a></li>\n"
38
--- skins/blitz/header.txt
+++ skins/blitz/header.txt
@@ -27,12 +27,12 @@
2727
html "<li><a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776;</a></li>\n"
2828
builtin_request_js hbmenu.js
2929
set once 1
3030
foreach {name url expr class} $mainmenu {
3131
if {![capexpr $expr]} continue
32
- if {$once && [string match /$current_page* $url]} {
33
- lappend class active
32
+ if {$once && [string match $url\[/?#\]* /$current_page/]} {
33
+ set class "active $class"
3434
set once 0
3535
}
3636
html "<li class='$class'>"
3737
if {[string match /* $url]} {set url $home$url}
3838
html "<a href='$url'>$name</a></li>\n"
3939
--- skins/blitz/header.txt
+++ skins/blitz/header.txt
@@ -27,12 +27,12 @@
27 html "<li><a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776;</a></li>\n"
28 builtin_request_js hbmenu.js
29 set once 1
30 foreach {name url expr class} $mainmenu {
31 if {![capexpr $expr]} continue
32 if {$once && [string match /$current_page* $url]} {
33 lappend class active
34 set once 0
35 }
36 html "<li class='$class'>"
37 if {[string match /* $url]} {set url $home$url}
38 html "<a href='$url'>$name</a></li>\n"
39
--- skins/blitz/header.txt
+++ skins/blitz/header.txt
@@ -27,12 +27,12 @@
27 html "<li><a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776;</a></li>\n"
28 builtin_request_js hbmenu.js
29 set once 1
30 foreach {name url expr class} $mainmenu {
31 if {![capexpr $expr]} continue
32 if {$once && [string match $url\[/?#\]* /$current_page/]} {
33 set class "active $class"
34 set once 0
35 }
36 html "<li class='$class'>"
37 if {[string match /* $url]} {set url $home$url}
38 html "<a href='$url'>$name</a></li>\n"
39
--- skins/bootstrap/css.txt
+++ skins/bootstrap/css.txt
cannot compute difference between binary files
11
--- skins/bootstrap/css.txt
+++ skins/bootstrap/css.txt
0 annot compute difference between binary files
1
--- skins/bootstrap/css.txt
+++ skins/bootstrap/css.txt
0 annot compute difference between binary files
1
--- skins/bootstrap/footer.txt
+++ skins/bootstrap/footer.txt
@@ -8,20 +8,24 @@
88
</div>
99
<footer id="footer">
1010
<p>&#169; Copyright $<project_name>. All right reserved. Fossil $release_version &#183; <a href="$home/timeline.rss">RSS</a></p>
1111
</footer>
1212
<script nonce="$<nonce>">
13
+window.addEventListener( 'load', function() {
14
+var i;
1315
var tables = document.querySelectorAll('table');
14
-for (var i = 0; i < tables.length; i++) {
15
- if (tables[i].id !== "timelineTable")
16
- tables[i].classList.add('table');
16
+for(i = 0; i < tables.length; i++) {
17
+ if (tables[i].id !== "timelineTable"){
18
+ tables[i].classList.add('table');
19
+ }
1720
};
1821
var submenus = document.querySelectorAll('.submenu');
19
-for (var i = 0; i < submenus.length; i++) {
22
+var labels, j;
23
+for (i = 0; i < submenus.length; i++) {
2024
submenus[i].classList.add('btn-group');
21
- var labels = submenus[i].querySelectorAll('.label');
22
- for (var j = 0; j < labels.length; j++) {
25
+ labels = submenus[i].querySelectorAll('.label');
26
+ for (j = 0; j < labels.length; j++) {
2327
labels[j].classList.remove('label');
2428
labels[j].classList.add('btn');
2529
labels[j].classList.add('btn-default');
2630
labels[j].classList.add('btn-sm');
2731
}
@@ -33,6 +37,6 @@
3337
collapse.getAttribute('data-target')
3438
);
3539
target.classList.toggle('collapse');
3640
target.classList.toggle('collapsed');
3741
};
38
-</script>
42
+});</script>
3943
--- skins/bootstrap/footer.txt
+++ skins/bootstrap/footer.txt
@@ -8,20 +8,24 @@
8 </div>
9 <footer id="footer">
10 <p>&#169; Copyright $<project_name>. All right reserved. Fossil $release_version &#183; <a href="$home/timeline.rss">RSS</a></p>
11 </footer>
12 <script nonce="$<nonce>">
 
 
13 var tables = document.querySelectorAll('table');
14 for (var i = 0; i < tables.length; i++) {
15 if (tables[i].id !== "timelineTable")
16 tables[i].classList.add('table');
 
17 };
18 var submenus = document.querySelectorAll('.submenu');
19 for (var i = 0; i < submenus.length; i++) {
 
20 submenus[i].classList.add('btn-group');
21 var labels = submenus[i].querySelectorAll('.label');
22 for (var j = 0; j < labels.length; j++) {
23 labels[j].classList.remove('label');
24 labels[j].classList.add('btn');
25 labels[j].classList.add('btn-default');
26 labels[j].classList.add('btn-sm');
27 }
@@ -33,6 +37,6 @@
33 collapse.getAttribute('data-target')
34 );
35 target.classList.toggle('collapse');
36 target.classList.toggle('collapsed');
37 };
38 </script>
39
--- skins/bootstrap/footer.txt
+++ skins/bootstrap/footer.txt
@@ -8,20 +8,24 @@
8 </div>
9 <footer id="footer">
10 <p>&#169; Copyright $<project_name>. All right reserved. Fossil $release_version &#183; <a href="$home/timeline.rss">RSS</a></p>
11 </footer>
12 <script nonce="$<nonce>">
13 window.addEventListener( 'load', function() {
14 var i;
15 var tables = document.querySelectorAll('table');
16 for(i = 0; i < tables.length; i++) {
17 if (tables[i].id !== "timelineTable"){
18 tables[i].classList.add('table');
19 }
20 };
21 var submenus = document.querySelectorAll('.submenu');
22 var labels, j;
23 for (i = 0; i < submenus.length; i++) {
24 submenus[i].classList.add('btn-group');
25 labels = submenus[i].querySelectorAll('.label');
26 for (j = 0; j < labels.length; j++) {
27 labels[j].classList.remove('label');
28 labels[j].classList.add('btn');
29 labels[j].classList.add('btn-default');
30 labels[j].classList.add('btn-sm');
31 }
@@ -33,6 +37,6 @@
37 collapse.getAttribute('data-target')
38 );
39 target.classList.toggle('collapse');
40 target.classList.toggle('collapsed');
41 };
42 });</script>
43
--- skins/bootstrap/header.txt
+++ skins/bootstrap/header.txt
@@ -45,12 +45,12 @@
4545
set sitemap 0
4646
set is_index [expr [string compare [string range $current_page 0 4] "index"]==0]
4747
set is_home [expr [string compare [string range $current_page 0 [expr [string length $index_page]-1] ] $index_page]==0]
4848
foreach {name url expr class} $mainmenu {
4949
if {![capexpr $expr]} continue
50
- if {$once && [string match /$current_page* $url]} {
51
- lappend class active
50
+ if {$once && [string match $url\[/?#\]* /$current_page/]} {
51
+ set class "active $class"
5252
set once 0
5353
}
5454
html "<li class='$class'>"
5555
if {[string match /* $url]} {set url $home$url}
5656
if {[string match *sitemap* $url]} {set sitemap 1}
5757
--- skins/bootstrap/header.txt
+++ skins/bootstrap/header.txt
@@ -45,12 +45,12 @@
45 set sitemap 0
46 set is_index [expr [string compare [string range $current_page 0 4] "index"]==0]
47 set is_home [expr [string compare [string range $current_page 0 [expr [string length $index_page]-1] ] $index_page]==0]
48 foreach {name url expr class} $mainmenu {
49 if {![capexpr $expr]} continue
50 if {$once && [string match /$current_page* $url]} {
51 lappend class active
52 set once 0
53 }
54 html "<li class='$class'>"
55 if {[string match /* $url]} {set url $home$url}
56 if {[string match *sitemap* $url]} {set sitemap 1}
57
--- skins/bootstrap/header.txt
+++ skins/bootstrap/header.txt
@@ -45,12 +45,12 @@
45 set sitemap 0
46 set is_index [expr [string compare [string range $current_page 0 4] "index"]==0]
47 set is_home [expr [string compare [string range $current_page 0 [expr [string length $index_page]-1] ] $index_page]==0]
48 foreach {name url expr class} $mainmenu {
49 if {![capexpr $expr]} continue
50 if {$once && [string match $url\[/?#\]* /$current_page/]} {
51 set class "active $class"
52 set once 0
53 }
54 html "<li class='$class'>"
55 if {[string match /* $url]} {set url $home$url}
56 if {[string match *sitemap* $url]} {set sitemap 1}
57
--- skins/darkmode/css.txt
+++ skins/darkmode/css.txt
@@ -85,11 +85,13 @@
8585
div.mainmenu a, div.submenu a,
8686
div.sectionmenu>a.button, div.submenu label,
8787
div.footer a {
8888
padding: 0.15em 0.5em;
8989
}
90
-/* div.mainmenu a.active, FIXME: setting of .active is broken for some URIs */
90
+div.mainmenu a.active {
91
+ border-bottom: 1px solid #FF4500f0;
92
+}
9193
a:hover,
9294
a:visited:hover {
9395
background-color: #FF4500f0;
9496
color: rgba(24,24,24,0.8);
9597
border-radius: 0.1em;
@@ -553,5 +555,10 @@
553555
554556
body.report table.report tr td { color: black }
555557
body.report table.report a { color: blue }
556558
body.tkt td.tktDspValue { color: black }
557559
body.tkt td.tktDspValue a { color: blue }
560
+
561
+body.branch .brlist > table > tbody > tr:hover:not(.selected),
562
+body.branch .brlist > table > tbody > tr.selected {
563
+ background-color: #442800;
564
+}
558565
--- skins/darkmode/css.txt
+++ skins/darkmode/css.txt
@@ -85,11 +85,13 @@
85 div.mainmenu a, div.submenu a,
86 div.sectionmenu>a.button, div.submenu label,
87 div.footer a {
88 padding: 0.15em 0.5em;
89 }
90 /* div.mainmenu a.active, FIXME: setting of .active is broken for some URIs */
 
 
91 a:hover,
92 a:visited:hover {
93 background-color: #FF4500f0;
94 color: rgba(24,24,24,0.8);
95 border-radius: 0.1em;
@@ -553,5 +555,10 @@
553
554 body.report table.report tr td { color: black }
555 body.report table.report a { color: blue }
556 body.tkt td.tktDspValue { color: black }
557 body.tkt td.tktDspValue a { color: blue }
 
 
 
 
 
558
--- skins/darkmode/css.txt
+++ skins/darkmode/css.txt
@@ -85,11 +85,13 @@
85 div.mainmenu a, div.submenu a,
86 div.sectionmenu>a.button, div.submenu label,
87 div.footer a {
88 padding: 0.15em 0.5em;
89 }
90 div.mainmenu a.active {
91 border-bottom: 1px solid #FF4500f0;
92 }
93 a:hover,
94 a:visited:hover {
95 background-color: #FF4500f0;
96 color: rgba(24,24,24,0.8);
97 border-radius: 0.1em;
@@ -553,5 +555,10 @@
555
556 body.report table.report tr td { color: black }
557 body.report table.report a { color: blue }
558 body.tkt td.tktDspValue { color: black }
559 body.tkt td.tktDspValue a { color: blue }
560
561 body.branch .brlist > table > tbody > tr:hover:not(.selected),
562 body.branch .brlist > table > tbody > tr.selected {
563 background-color: #442800;
564 }
565
--- skins/darkmode/header.txt
+++ skins/darkmode/header.txt
@@ -17,11 +17,11 @@
1717
html "<a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776;</a>"
1818
builtin_request_js hbmenu.js
1919
foreach {name url expr class} $mainmenu {
2020
if {![capexpr $expr]} continue
2121
if {[string match /* $url]} {
22
- if {[string match /$current_page* $url]} {
22
+ if {[string match $url\[/?#\]* /$current_page/]} {
2323
set class "active $class"
2424
}
2525
set url $home$url
2626
}
2727
html "<a href='$url' class='$class'>$name</a>\n"
2828
--- skins/darkmode/header.txt
+++ skins/darkmode/header.txt
@@ -17,11 +17,11 @@
17 html "<a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776;</a>"
18 builtin_request_js hbmenu.js
19 foreach {name url expr class} $mainmenu {
20 if {![capexpr $expr]} continue
21 if {[string match /* $url]} {
22 if {[string match /$current_page* $url]} {
23 set class "active $class"
24 }
25 set url $home$url
26 }
27 html "<a href='$url' class='$class'>$name</a>\n"
28
--- skins/darkmode/header.txt
+++ skins/darkmode/header.txt
@@ -17,11 +17,11 @@
17 html "<a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776;</a>"
18 builtin_request_js hbmenu.js
19 foreach {name url expr class} $mainmenu {
20 if {![capexpr $expr]} continue
21 if {[string match /* $url]} {
22 if {[string match $url\[/?#\]* /$current_page/]} {
23 set class "active $class"
24 }
25 set url $home$url
26 }
27 html "<a href='$url' class='$class'>$name</a>\n"
28
--- skins/default/css.txt
+++ skins/default/css.txt
@@ -267,11 +267,11 @@
267267
padding-top: 0px;
268268
padding-bottom: 0px;
269269
}
270270
.status {padding-top: 0px;}
271271
.mainmenu a {
272
- padding: 10px 10px;
272
+ padding: 8px 10px;
273273
}
274274
.mainmenu {
275275
padding: 10px;
276276
}
277277
}
@@ -285,11 +285,11 @@
285285
padding-top: 10px;
286286
padding-bottom: 10px;
287287
}
288288
.status {padding-top: 30px;}
289289
.mainmenu a {
290
- padding: 10px 20px;
290
+ padding: 8px 20px;
291291
}
292292
.mainmenu {
293293
padding: 10px;
294294
}
295295
}
296296
--- skins/default/css.txt
+++ skins/default/css.txt
@@ -267,11 +267,11 @@
267 padding-top: 0px;
268 padding-bottom: 0px;
269 }
270 .status {padding-top: 0px;}
271 .mainmenu a {
272 padding: 10px 10px;
273 }
274 .mainmenu {
275 padding: 10px;
276 }
277 }
@@ -285,11 +285,11 @@
285 padding-top: 10px;
286 padding-bottom: 10px;
287 }
288 .status {padding-top: 30px;}
289 .mainmenu a {
290 padding: 10px 20px;
291 }
292 .mainmenu {
293 padding: 10px;
294 }
295 }
296
--- skins/default/css.txt
+++ skins/default/css.txt
@@ -267,11 +267,11 @@
267 padding-top: 0px;
268 padding-bottom: 0px;
269 }
270 .status {padding-top: 0px;}
271 .mainmenu a {
272 padding: 8px 10px;
273 }
274 .mainmenu {
275 padding: 10px;
276 }
277 }
@@ -285,11 +285,11 @@
285 padding-top: 10px;
286 padding-bottom: 10px;
287 }
288 .status {padding-top: 30px;}
289 .mainmenu a {
290 padding: 8px 20px;
291 }
292 .mainmenu {
293 padding: 10px;
294 }
295 }
296
--- skins/default/header.txt
+++ skins/default/header.txt
@@ -13,11 +13,11 @@
1313
html "<a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776;</a>"
1414
builtin_request_js hbmenu.js
1515
foreach {name url expr class} $mainmenu {
1616
if {![capexpr $expr]} continue
1717
if {[string match /* $url]} {
18
- if {[string match /$current_page* $url]} {
18
+ if {[string match $url\[/?#\]* /$current_page/]} {
1919
set class "active $class"
2020
}
2121
set url $home$url
2222
}
2323
html "<a href='$url' class='$class'>$name</a>\n"
2424
--- skins/default/header.txt
+++ skins/default/header.txt
@@ -13,11 +13,11 @@
13 html "<a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776;</a>"
14 builtin_request_js hbmenu.js
15 foreach {name url expr class} $mainmenu {
16 if {![capexpr $expr]} continue
17 if {[string match /* $url]} {
18 if {[string match /$current_page* $url]} {
19 set class "active $class"
20 }
21 set url $home$url
22 }
23 html "<a href='$url' class='$class'>$name</a>\n"
24
--- skins/default/header.txt
+++ skins/default/header.txt
@@ -13,11 +13,11 @@
13 html "<a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776;</a>"
14 builtin_request_js hbmenu.js
15 foreach {name url expr class} $mainmenu {
16 if {![capexpr $expr]} continue
17 if {[string match /* $url]} {
18 if {[string match $url\[/?#\]* /$current_page/]} {
19 set class "active $class"
20 }
21 set url $home$url
22 }
23 html "<a href='$url' class='$class'>$name</a>\n"
24
--- skins/eagle/css.txt
+++ skins/eagle/css.txt
@@ -433,5 +433,10 @@
433433
background-color: #006d00;
434434
}
435435
.capsumWrite {
436436
background-color: #e5e500;
437437
}
438
+
439
+body.branch .brlist > table > tbody > tr:hover:not(.selected),
440
+body.branch .brlist > table > tbody > tr.selected {
441
+ background-color: #7EA2D9;
442
+}
438443
--- skins/eagle/css.txt
+++ skins/eagle/css.txt
@@ -433,5 +433,10 @@
433 background-color: #006d00;
434 }
435 .capsumWrite {
436 background-color: #e5e500;
437 }
 
 
 
 
 
438
--- skins/eagle/css.txt
+++ skins/eagle/css.txt
@@ -433,5 +433,10 @@
433 background-color: #006d00;
434 }
435 .capsumWrite {
436 background-color: #e5e500;
437 }
438
439 body.branch .brlist > table > tbody > tr:hover:not(.selected),
440 body.branch .brlist > table > tbody > tr.selected {
441 background-color: #7EA2D9;
442 }
443
--- skins/xekri/css.txt
+++ skins/xekri/css.txt
@@ -1124,11 +1124,14 @@
11241124
.fossil-PopupWidget,
11251125
.fossil-tooltip.help-buttonlet-content {
11261126
background-color: #111;
11271127
border: 1px solid rgba(255,255,255,0.5);
11281128
}
1129
-
1129
+.fossil-PopupWidget a,
1130
+.fossil-PopupWidget a:visited {
1131
+ color: white;
1132
+}
11301133
div.forumSel {
11311134
background-color: #663399;
11321135
}
11331136
div.forumPostBody blockquote {
11341137
border-width: 1pt;
@@ -1138,5 +1141,10 @@
11381141
}
11391142
11401143
.debug {
11411144
color: black;
11421145
}
1146
+
1147
+body.branch .brlist > table > tbody > tr:hover:not(.selected),
1148
+body.branch .brlist > table > tbody > tr.selected {
1149
+ background-color: #444;
1150
+}
11431151
--- skins/xekri/css.txt
+++ skins/xekri/css.txt
@@ -1124,11 +1124,14 @@
1124 .fossil-PopupWidget,
1125 .fossil-tooltip.help-buttonlet-content {
1126 background-color: #111;
1127 border: 1px solid rgba(255,255,255,0.5);
1128 }
1129
 
 
 
1130 div.forumSel {
1131 background-color: #663399;
1132 }
1133 div.forumPostBody blockquote {
1134 border-width: 1pt;
@@ -1138,5 +1141,10 @@
1138 }
1139
1140 .debug {
1141 color: black;
1142 }
 
 
 
 
 
1143
--- skins/xekri/css.txt
+++ skins/xekri/css.txt
@@ -1124,11 +1124,14 @@
1124 .fossil-PopupWidget,
1125 .fossil-tooltip.help-buttonlet-content {
1126 background-color: #111;
1127 border: 1px solid rgba(255,255,255,0.5);
1128 }
1129 .fossil-PopupWidget a,
1130 .fossil-PopupWidget a:visited {
1131 color: white;
1132 }
1133 div.forumSel {
1134 background-color: #663399;
1135 }
1136 div.forumPostBody blockquote {
1137 border-width: 1pt;
@@ -1138,5 +1141,10 @@
1141 }
1142
1143 .debug {
1144 color: black;
1145 }
1146
1147 body.branch .brlist > table > tbody > tr:hover:not(.selected),
1148 body.branch .brlist > table > tbody > tr.selected {
1149 background-color: #444;
1150 }
1151
--- skins/xekri/header.txt
+++ skins/xekri/header.txt
@@ -94,12 +94,12 @@
9494
<div class="mainmenu"><th1>
9595
set sitemap 0
9696
foreach {name url expr class} $mainmenu {
9797
if {![capexpr $expr]} continue
9898
if {[string match /* $url]} {
99
- if {[string match /$current_page* $url]} {
100
- lappend class active
99
+ if {[string match $url\[/?#\]* /$current_page/]} {
100
+ set class "active $class"
101101
}
102102
set url $home$url
103103
}
104104
html "<a href='$url' class='$class'>$name</a>\n"
105105
if {[string match */sitemap $url]} {set sitemap 1}
106106
--- skins/xekri/header.txt
+++ skins/xekri/header.txt
@@ -94,12 +94,12 @@
94 <div class="mainmenu"><th1>
95 set sitemap 0
96 foreach {name url expr class} $mainmenu {
97 if {![capexpr $expr]} continue
98 if {[string match /* $url]} {
99 if {[string match /$current_page* $url]} {
100 lappend class active
101 }
102 set url $home$url
103 }
104 html "<a href='$url' class='$class'>$name</a>\n"
105 if {[string match */sitemap $url]} {set sitemap 1}
106
--- skins/xekri/header.txt
+++ skins/xekri/header.txt
@@ -94,12 +94,12 @@
94 <div class="mainmenu"><th1>
95 set sitemap 0
96 foreach {name url expr class} $mainmenu {
97 if {![capexpr $expr]} continue
98 if {[string match /* $url]} {
99 if {[string match $url\[/?#\]* /$current_page/]} {
100 set class "active $class"
101 }
102 set url $home$url
103 }
104 html "<a href='$url' class='$class'>$name</a>\n"
105 if {[string match */sitemap $url]} {set sitemap 1}
106
+324 -51
--- src/alerts.c
+++ src/alerts.c
@@ -13,11 +13,11 @@
1313
** [email protected]
1414
** http://www.hwaci.com/drh/
1515
**
1616
*******************************************************************************
1717
**
18
-** Logic for email notification, also known as "alerts".
18
+** Logic for email notification, also known as "alerts" or "subscriptions".
1919
**
2020
** Are you looking for the code that reads and writes the internet
2121
** email protocol? That is not here. See the "smtp.c" file instead.
2222
** Yes, the choice of source code filenames is not the greatest, but
2323
** it is not so bad that changing them seems justified.
@@ -64,11 +64,12 @@
6464
@ sdonotcall BOOLEAN, -- true for Do Not Call
6565
@ sdigest BOOLEAN, -- true for daily digests only
6666
@ ssub TEXT, -- baseline subscriptions
6767
@ sctime INTDATE, -- When this entry was created. unixtime
6868
@ mtime INTDATE, -- Last change. unixtime
69
-@ smip TEXT -- IP address of last change
69
+@ smip TEXT, -- IP address of last change
70
+@ lastContact INT -- Last contact. days since 1970
7071
@ );
7172
@ CREATE INDEX repository.subscriberUname
7273
@ ON subscriber(suname) WHERE suname IS NOT NULL;
7374
@
7475
@ DROP TABLE IF EXISTS repository.pending_alert;
@@ -83,28 +84,33 @@
8384
@ sentSep BOOLEAN DEFAULT false, -- individual alert sent
8485
@ sentDigest BOOLEAN DEFAULT false, -- digest alert sent
8586
@ sentMod BOOLEAN DEFAULT false -- pending moderation alert sent
8687
@ ) WITHOUT ROWID;
8788
@
89
+@ -- Obsolete table. No longer used.
8890
@ DROP TABLE IF EXISTS repository.alert_bounce;
89
-@ -- Record bounced emails. If too many bounces are received within
90
-@ -- some defined time range, then cancel the subscription. Older
91
-@ -- entries are periodically purged.
92
-@ --
93
-@ CREATE TABLE repository.alert_bounce(
94
-@ subscriberId INTEGER, -- to whom the email was sent.
95
-@ sendTime INTEGER, -- seconds since 1970 when email was sent
96
-@ rcvdTime INTEGER -- seconds since 1970 when bounce was received
97
-@ );
9891
;
9992
10093
/*
10194
** Return true if the email notification tables exist.
10295
*/
10396
int alert_tables_exist(void){
10497
return db_table_exists("repository", "subscriber");
10598
}
99
+
100
+/*
101
+** Record the fact that user zUser has made contact with the repository.
102
+** This resets the subscription timeout on that user.
103
+*/
104
+void alert_user_contact(const char *zUser){
105
+ if( db_table_has_column("repository","subscriber","lastContact") ){
106
+ db_multi_exec(
107
+ "UPDATE subscriber SET lastContact=now()/86400 WHERE suname=%Q",
108
+ zUser
109
+ );
110
+ }
111
+}
106112
107113
/*
108114
** Make sure the table needed for email notification exist in the repository.
109115
**
110116
** If the bOnlyIfEnabled option is true, then tables are only created
@@ -116,16 +122,27 @@
116122
&& fossil_strcmp(db_get("email-send-method",0),"off")==0
117123
){
118124
return; /* Don't create table for disabled email */
119125
}
120126
db_exec_sql(zAlertInit);
121
- }else if( !db_table_has_column("repository","pending_alert","sentMod") ){
122
- db_multi_exec(
123
- "ALTER TABLE repository.pending_alert"
124
- " ADD COLUMN sentMod BOOLEAN DEFAULT false;"
125
- );
127
+ return;
126128
}
129
+ if( db_table_has_column("repository","subscriber","lastContact") ){
130
+ return;
131
+ }
132
+ db_multi_exec(
133
+ "DROP TABLE IF EXISTS repository.alert_bounde;\n"
134
+ "ALTER TABLE repository.subscriber ADD COLUMN lastContact INT;\n"
135
+ "UPDATE subscriber SET lastContact=mtime/86400;"
136
+ );
137
+ if( db_table_has_column("repository","pending_alert","sentMod") ){
138
+ return;
139
+ }
140
+ db_multi_exec(
141
+ "ALTER TABLE repository.pending_alert"
142
+ " ADD COLUMN sentMod BOOLEAN DEFAULT false;"
143
+ );
127144
}
128145
129146
/*
130147
** Enable triggers that automatically populate the pending_alert
131148
** table.
@@ -270,10 +287,24 @@
270287
@ This is short name used to identifies the repository in the
271288
@ Subject: line of email alerts. Traditionally this name is
272289
@ included in square brackets. Examples: "[fossil-src]", "[sqlite-src]".
273290
@ (Property: "email-subname")</p>
274291
@ <hr>
292
+
293
+ entry_attribute("Subscription Renewal Interval In Days", 8,
294
+ "email-renew-interval", "eri", "", 0);
295
+ @ <p>
296
+ @ If this value is a integer N greater than or equal to 14, then email
297
+ @ notification subscriptions will be suspended N days after the last known
298
+ @ interaction with the user. This prevents sending notifications
299
+ @ to abandoned accounts. If a subscription comes within 7 days of expiring,
300
+ @ a separate email goes out with the daily digest that prompts the
301
+ @ subscriber to click on a link to the "/renew" webpage in order to
302
+ @ extend their subscription. Subscriptions never expire if this setting
303
+ @ is less than 14 or is an empty string.
304
+ @ (Property: "email-renew-interval")</p>
305
+ @ <hr>
275306
276307
multiple_choice_attribute("Email Send Method", "email-send-method", "esm",
277308
"off", count(azSendMethods)/2, azSendMethods);
278309
@ <p>How to send email. Requires auxiliary information from the fields
279310
@ that follow. Hint: Use the <a href="%R/announce">/announce</a> page
@@ -938,10 +969,38 @@
938969
** SETTING: email-subname width=16
939970
** This is a short name used to identifies the repository in the Subject:
940971
** line of email alerts. Traditionally this name is included in square
941972
** brackets. Examples: "[fossil-src]", "[sqlite-src]".
942973
*/
974
+/*
975
+** SETTING: email-renew-interval width=16
976
+** If this setting as an integer N that is 14 or greater then email
977
+** notification is suspected for subscriptions that have a "last contact
978
+** time" of more than N days ago. The "last contact time" is recorded
979
+** in the SUBSCRIBER.LASTCONTACT entry of the database. Logging in,
980
+** sending a forum post, editing a wiki page, changing subscription settings
981
+** at /alerts, or visiting /renew all update the last contact time.
982
+** If this setting is not an integer value or is less than 14 or undefined,
983
+** then subscriptions never expire.
984
+*/
985
+/* X-VARIABLE: email-renew-warning
986
+** X-VARIABLE: email-renew-cutoff
987
+**
988
+** These CONFIG table entries are not considered "settings" since their
989
+** values are computed and updated automatically.
990
+**
991
+** email-renew-cutoff is the lastContact cutoff for subscription. It
992
+** is measured in days since 1970-01-01. If The lastContact time for
993
+** a subscription is less than email-renew-cutoff, then now new emails
994
+** are sent to the subscriber.
995
+**
996
+** email-renew-warning is the time (in days since 1970-01-01) when the
997
+** last batch of "your subscription is about to expire" emails were
998
+** sent out.
999
+**
1000
+** email-renew-cutoff is normally 7 days behind email-renew-warning.
1001
+*/
9431002
/*
9441003
** SETTING: email-send-method width=5 default=off sensitive
9451004
** Determine the method used to send email. Allowed values are
9461005
** "off", "relay", "pipe", "dir", "db", and "stdout". The "off" value
9471006
** means no email is ever sent. The "relay" value means emails are sent
@@ -1002,29 +1061,32 @@
10021061
** a cron-job to make sure alerts are sent
10031062
** in a timely manner.
10041063
** Options:
10051064
**
10061065
** --digest Send digests
1066
+** --renewal Send subscription renewal
1067
+** notices
10071068
** --test Write to standard output
10081069
**
10091070
** settings [NAME VALUE] With no arguments, list all email settings.
10101071
** Or change the value of a single email setting.
10111072
**
10121073
** status Report on the status of the email alert
10131074
** subsystem
10141075
**
1015
-** subscribers [PATTERN] List all subscribers matching PATTERN.
1076
+** subscribers [PATTERN] List all subscribers matching PATTERN. Either
1077
+** LIKE or GLOB wildcards can be used in PATTERN.
10161078
**
10171079
** test-message TO [OPTS] Send a single email message using whatever
10181080
** email sending mechanism is currently configured.
10191081
** Use this for testing the email notification
10201082
** configuration. Options:
10211083
**
1022
-** --body FILENAME
1023
-** --smtp-trace
1024
-** --stdout
1025
-** -S|--subject SUBJECT
1084
+** --body FILENAME Content from FILENAME
1085
+** --smtp-trace Trace SMTP processing
1086
+** --stdout Send msg to stdout
1087
+** -S|--subject SUBJECT Message "subject:"
10261088
**
10271089
** unsubscribe EMAIL Remove a single subscriber with the given EMAIL.
10281090
*/
10291091
void alert_cmd(void){
10301092
const char *zCmd;
@@ -1078,10 +1140,11 @@
10781140
}
10791141
}else
10801142
if( strncmp(zCmd, "send", nCmd)==0 ){
10811143
u32 eFlags = 0;
10821144
if( find_option("digest",0,0)!=0 ) eFlags |= SENDALERT_DIGEST;
1145
+ if( find_option("renewal",0,0)!=0 ) eFlags |= SENDALERT_RENEWAL;
10831146
if( find_option("test",0,0)!=0 ){
10841147
eFlags |= SENDALERT_PRESERVE|SENDALERT_STDOUT;
10851148
}
10861149
verify_all_options();
10871150
alert_send_alerts(eFlags);
@@ -1107,10 +1170,12 @@
11071170
if( strncmp(pSetting->name,"email-",6)!=0 ) continue;
11081171
print_setting(pSetting);
11091172
}
11101173
}else
11111174
if( strncmp(zCmd, "status", nCmd)==0 ){
1175
+ Stmt q;
1176
+ int iCutoff;
11121177
int nSetting, n;
11131178
static const char *zFmt = "%-29s %d\n";
11141179
const Setting *pSetting = setting_info(&nSetting);
11151180
db_open_config(1, 0);
11161181
verify_all_options();
@@ -1122,14 +1187,32 @@
11221187
}
11231188
n = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep");
11241189
fossil_print(zFmt/*works-like:"%s%d"*/, "pending-alerts", n);
11251190
n = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentDigest");
11261191
fossil_print(zFmt/*works-like:"%s%d"*/, "pending-digest-alerts", n);
1192
+ db_prepare(&q,
1193
+ "SELECT"
1194
+ " name,"
1195
+ " value,"
1196
+ " now()/86400-value,"
1197
+ " date(value*86400,'unixepoch')"
1198
+ " FROM repository.config"
1199
+ " WHERE name in ('email-renew-warning','email-renew-cutoff');");
1200
+ while( db_step(&q)==SQLITE_ROW ){
1201
+ fossil_print("%-29s %-6d (%d days ago on %s)\n",
1202
+ db_column_text(&q, 0),
1203
+ db_column_int(&q, 1),
1204
+ db_column_int(&q, 2),
1205
+ db_column_text(&q, 3));
1206
+ }
1207
+ db_finalize(&q);
11271208
n = db_int(0,"SELECT count(*) FROM subscriber");
11281209
fossil_print(zFmt/*works-like:"%s%d"*/, "total-subscribers", n);
1210
+ iCutoff = db_get_int("email-renew-cutoff", 0);
11291211
n = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified"
1130
- " AND NOT sdonotcall AND length(ssub)>1");
1212
+ " AND NOT sdonotcall AND length(ssub)>1"
1213
+ " AND lastContact>=%d", iCutoff);
11311214
fossil_print(zFmt/*works-like:"%s%d"*/, "active-subscribers", n);
11321215
}else
11331216
if( strncmp(zCmd, "subscribers", nCmd)==0 ){
11341217
Stmt q;
11351218
verify_all_options();
@@ -1391,12 +1474,12 @@
13911474
if( g.perm.RdWiki && PB("sw") ) ssub[nsub++] = 'w';
13921475
if( g.perm.RdForum && PB("sx") ) ssub[nsub++] = 'x';
13931476
ssub[nsub] = 0;
13941477
zCode = db_text(0,
13951478
"INSERT INTO subscriber(semail,suname,"
1396
- " sverified,sdonotcall,sdigest,ssub,sctime,mtime,smip)"
1397
- "VALUES(%Q,%Q,%d,0,%d,%Q,now(),now(),%Q)"
1479
+ " sverified,sdonotcall,sdigest,ssub,sctime,mtime,smip,lastContact)"
1480
+ "VALUES(%Q,%Q,%d,0,%d,%Q,now(),now(),%Q,now()/86400)"
13981481
"RETURNING hex(subscriberCode);",
13991482
/* semail */ zEAddr,
14001483
/* suname */ suname,
14011484
/* sverified */ needCaptcha==0,
14021485
/* sdigest */ PB("di"),
@@ -1582,12 +1665,13 @@
15821665
15831666
db_multi_exec(
15841667
"DELETE FROM subscriber WHERE subscriberId=%d", sid
15851668
);
15861669
style_header("Unsubscribed");
1587
- @ <p>The "%h(zEmail)" email address has been unsubscribed and the
1588
- @ corresponding row in the subscriber table has been deleted.<p>
1670
+ @ <p>The "%h(zEmail)" email address has been unsubscribed from all
1671
+ @ notifications. All subscription records for "%h(zEmail)" have
1672
+ @ been purged. No further emails will be sent to "%h(zEmail)".</p>
15891673
if( uid && g.perm.Admin ){
15901674
@ <p>You may also want to
15911675
@ <a href="%R/setup_uedit?id=%d(uid)">edit or delete
15921676
@ the corresponding user "%h(zLogin)"</a></p>
15931677
}
@@ -1640,10 +1724,11 @@
16401724
int eErr = 0; /* Type of error */
16411725
char *zErr = 0; /* Error message text */
16421726
int sid = 0; /* Subscriber ID */
16431727
int nName; /* Length of zName in bytes */
16441728
char *zHalfCode; /* prefix of subscriberCode */
1729
+ int keepAlive = 0; /* True to update the last contact time */
16451730
16461731
db_begin_transaction();
16471732
if( alert_webpages_disabled() ){
16481733
db_commit_transaction();
16491734
return;
@@ -1664,10 +1749,11 @@
16641749
sid = db_int(0,
16651750
"SELECT CASE WHEN hex(subscriberCode) LIKE (%Q||'%%')"
16661751
" THEN subscriberId ELSE 0 END"
16671752
" FROM subscriber WHERE subscriberCode>=hextoblob(%Q)"
16681753
" LIMIT 1", zName, zName);
1754
+ if( sid ) keepAlive = 1;
16691755
}
16701756
if( sid==0 && isLogin ){
16711757
sid = db_int(0, "SELECT subscriberId FROM subscriber"
16721758
" WHERE suname=%Q", g.zLogin);
16731759
}
@@ -1696,11 +1782,12 @@
16961782
blob_init(&update, "UPDATE subscriber SET", -1);
16971783
blob_append_sql(&update,
16981784
" sdonotcall=%d,"
16991785
" sdigest=%d,"
17001786
" ssub=%Q,"
1701
- " mtime=strftime('%%s','now'),"
1787
+ " mtime=now(),"
1788
+ " lastContact=now()/86400,"
17021789
" smip=%Q",
17031790
sdonotcall,
17041791
sdigest,
17051792
ssub,
17061793
g.zIpAddr
@@ -1726,10 +1813,15 @@
17261813
if( eErr==0 ){
17271814
db_exec_sql(blob_str(&update));
17281815
ssub = 0;
17291816
}
17301817
blob_reset(&update);
1818
+ }else if( keepAlive ){
1819
+ db_multi_exec(
1820
+ "UPDATE subscriber SET lastContact=now()/86400"
1821
+ " WHERE subscriberId=%d", sid
1822
+ );
17311823
}
17321824
if( P("delete")!=0 && cgi_csrf_safe(1) ){
17331825
if( !PB("dodelete") ){
17341826
eErr = 9;
17351827
zErr = mprintf("Select this checkbox and press \"Unsubscribe\" again to"
@@ -1751,11 +1843,13 @@
17511843
" ssub," /* 4 */
17521844
" smip," /* 5 */
17531845
" suname," /* 6 */
17541846
" datetime(mtime,'unixepoch')," /* 7 */
17551847
" datetime(sctime,'unixepoch')," /* 8 */
1756
- " hex(subscriberCode)" /* 9 */
1848
+ " hex(subscriberCode)," /* 9 */
1849
+ " date(coalesce(lastContact*86400,mtime),'unixepoch')," /* 10 */
1850
+ " now()/86400 - coalesce(lastContact,mtime/86400)" /* 11 */
17571851
" FROM subscriber WHERE subscriberId=%d", sid);
17581852
if( db_step(&q)!=SQLITE_ROW ){
17591853
db_finalize(&q);
17601854
db_commit_transaction();
17611855
cgi_redirect("subscribe");
@@ -1850,10 +1944,15 @@
18501944
@ </tr>
18511945
@ <tr>
18521946
@ <td class='form_label'>Subscriber&nbsp;Code:</td>
18531947
@ <td>%h(db_column_text(&q,9))</td>
18541948
@ <tr>
1949
+ @ <tr>
1950
+ @ <td class='form_label'>Last Contact:</td>
1951
+ @ <td>%h(db_column_text(&q,10)) &larr; \
1952
+ @ %,d(db_column_int(&q,11)) days ago</td>
1953
+ @ </tr>
18551954
@ <td class="form_label">User:</td>
18561955
@ <td><input type="text" name="suname" value="%h(suname?suname:"")" \
18571956
@ size="30">\
18581957
uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", suname);
18591958
if( uid ){
@@ -1920,10 +2019,61 @@
19202019
db_finalize(&q);
19212020
style_finish_page();
19222021
db_commit_transaction();
19232022
return;
19242023
}
2024
+
2025
+/*
2026
+** WEBPAGE: renew
2027
+**
2028
+** Users visit this page to update the last-contact date on their
2029
+** subscription. The last-contact date is the day that the subscriber
2030
+** last interacted with the repository. If the name= query parameter
2031
+** (or POST parameter) contains a valid subscriber code, then the last-contact
2032
+** subscription associated with that subscriber code is updated to be the
2033
+** current date.
2034
+*/
2035
+void renewal_page(void){
2036
+ const char *zName = P("name");
2037
+ int iInterval = db_get_int("email-renew-interval", 0);
2038
+ Stmt s;
2039
+ int rc;
2040
+
2041
+ style_header("Subscription Renewal");
2042
+ if( zName==0 || strlen(zName)<4 ){
2043
+ @ <p>No subscription specified</p>
2044
+ style_finish_page();
2045
+ return;
2046
+ }
2047
+
2048
+ if( !db_table_has_column("repository","subscriber","lastContact")
2049
+ || iInterval<1
2050
+ ){
2051
+ @ <p>This repository does not expire email notification subscriptions.
2052
+ @ No renewals are necessary.</p>
2053
+ style_finish_page();
2054
+ return;
2055
+ }
2056
+
2057
+ db_prepare(&s,
2058
+ "UPDATE subscriber"
2059
+ " SET lastContact=now()/86400"
2060
+ " WHERE subscriberCode=hextoblob(%Q)"
2061
+ " RETURNING semail, date('now','+%d days');",
2062
+ zName, iInterval+1
2063
+ );
2064
+ rc = db_step(&s);
2065
+ if( rc==SQLITE_ROW ){
2066
+ @ <p>The email notification subscription for %h(db_column_text(&s,0))
2067
+ @ has been extended until %h(db_column_text(&s,1)) UTC.
2068
+ }else{
2069
+ @ <p>No such subscriber-id: %h(zName)</p>
2070
+ }
2071
+ db_finalize(&s);
2072
+ style_finish_page();
2073
+}
2074
+
19252075
19262076
/* This is the message that gets sent to describe how to change
19272077
** or modify a subscription
19282078
*/
19292079
static const char zUnsubMsg[] =
@@ -2094,10 +2244,14 @@
20942244
Stmt q;
20952245
sqlite3_int64 iNow;
20962246
int nTotal;
20972247
int nPending;
20982248
int nDel = 0;
2249
+ int iCutoff = db_get_int("email-renew-cutoff",0);
2250
+ int iWarning = db_get_int("email-renew-warning",0);
2251
+ char zCutoffClr[8];
2252
+ char zWarnClr[8];
20992253
if( alert_webpages_disabled() ) return;
21002254
login_check_credentials();
21012255
if( !g.perm.Admin ){
21022256
login_needed(0);
21032257
return;
@@ -2110,11 +2264,11 @@
21102264
nPending = db_int(0, "SELECT count(*) FROM subscriber WHERE NOT sverified");
21112265
if( nPending>0 && P("purge") && cgi_csrf_safe(0) ){
21122266
int nNewPending;
21132267
db_multi_exec(
21142268
"DELETE FROM subscriber"
2115
- " WHERE NOT sverified AND mtime<0+strftime('%%s','now','-1 day')"
2269
+ " WHERE NOT sverified AND mtime<now()-86400"
21162270
);
21172271
nNewPending = db_int(0, "SELECT count(*) FROM subscriber"
21182272
" WHERE NOT sverified");
21192273
nDel = nPending - nNewPending;
21202274
nPending = nNewPending;
@@ -2121,11 +2275,11 @@
21212275
nTotal -= nDel;
21222276
}
21232277
if( nPending>0 ){
21242278
@ <h1>%,d(nTotal) Subscribers, %,d(nPending) Pending</h1>
21252279
if( nDel==0 && 0<db_int(0,"SELECT count(*) FROM subscriber"
2126
- " WHERE NOT sverified AND mtime<0+strftime('%%s','now','-1 day')")
2280
+ " WHERE NOT sverified AND mtime<now()-86400")
21272281
){
21282282
style_submenu_element("Purge Pending","subscribers?purge");
21292283
}
21302284
}else{
21312285
@ <h1>%,d(nTotal) Subscribers</h1>
@@ -2141,38 +2295,44 @@
21412295
" suname," /* 3 */
21422296
" sverified," /* 4 */
21432297
" sdigest," /* 5 */
21442298
" mtime," /* 6 */
21452299
" date(sctime,'unixepoch')," /* 7 */
2146
- " (SELECT uid FROM user WHERE login=subscriber.suname)" /* 8 */
2300
+ " (SELECT uid FROM user WHERE login=subscriber.suname)," /* 8 */
2301
+ " coalesce(lastContact,mtime/86400)" /* 9 */
21472302
" FROM subscriber"
21482303
);
21492304
if( P("only")!=0 ){
21502305
blob_append_sql(&sql, " WHERE ssub LIKE '%%%q%%'", P("only"));
21512306
style_submenu_element("Show All","%R/subscribers");
21522307
}
21532308
blob_append_sql(&sql," ORDER BY mtime DESC");
21542309
db_prepare_blob(&q, &sql);
21552310
iNow = time(0);
2311
+ memcpy(zCutoffClr, hash_color("A"), sizeof(zCutoffClr));
2312
+ memcpy(zWarnClr, hash_color("HIJ"), sizeof(zWarnClr));
21562313
@ <table border='1' class='sortable' \
2157
- @ data-init-sort='6' data-column-types='tttttKt'>
2314
+ @ data-init-sort='6' data-column-types='tttttKKt'>
21582315
@ <thead>
21592316
@ <tr>
21602317
@ <th>Email
21612318
@ <th>Events
21622319
@ <th>Digest-Only?
21632320
@ <th>User
21642321
@ <th>Verified?
21652322
@ <th>Last change
2323
+ @ <th>Last contact
21662324
@ <th>Created
21672325
@ </tr>
21682326
@ </thead><tbody>
21692327
while( db_step(&q)==SQLITE_ROW ){
21702328
sqlite3_int64 iMtime = db_column_int64(&q, 6);
21712329
double rAge = (iNow - iMtime)/86400.0;
21722330
int uid = db_column_int(&q, 8);
21732331
const char *zUname = db_column_text(&q, 3);
2332
+ sqlite3_int64 iContact = db_column_int64(&q, 9);
2333
+ double rContact = (iNow/86400) - iContact;
21742334
@ <tr>
21752335
@ <td><a href='%R/alerts?sid=%d(db_column_int(&q,0))'>\
21762336
@ %h(db_column_text(&q,1))</a></td>
21772337
@ <td>%h(db_column_text(&q,2))</td>
21782338
@ <td>%s(db_column_int(&q,5)?"digest":"")</td>
@@ -2181,10 +2341,19 @@
21812341
}else{
21822342
@ <td>%h(zUname)</td>
21832343
}
21842344
@ <td>%s(db_column_int(&q,4)?"yes":"pending")</td>
21852345
@ <td data-sortkey='%010llx(iMtime)'>%z(human_readable_age(rAge))</td>
2346
+ @ <td data-sortkey='%010llx(iContact)'>\
2347
+ if( iContact>iWarning ){
2348
+ @ <span>\
2349
+ }else if( iContact>iCutoff ){
2350
+ @ <span style='background-color:%s(zWarnClr);'>\
2351
+ }else{
2352
+ @ <span style='background-color:%s(zCutoffClr);'>\
2353
+ }
2354
+ @ %z(human_readable_age(rContact))</td>
21862355
@ <td>%h(db_column_text(&q,7))</td>
21872356
@ </tr>
21882357
}
21892358
@ </tbody></table>
21902359
db_finalize(&q);
@@ -2420,31 +2589,30 @@
24202589
"on Fossil repository %s (%s/timeline)\n",
24212590
db_get("email-subname","(unknown)"),
24222591
db_get("email-url","http://localhost:8080"));
24232592
}
24242593
2425
-/*
2426
-** Append the "unsubscribe" notification and other footer text to
2427
-** the end of an email alert being assemblied in pOut.
2428
-*/
2429
-void alert_footer(Blob *pOut){
2430
- blob_appendf(pOut, "\n-- \nTo unsubscribe: %s/unsubscribe\n",
2431
- db_get("email-url","http://localhost:8080"));
2432
-}
2433
-
24342594
/*
24352595
** COMMAND: test-alert
24362596
**
24372597
** Usage: %fossil test-alert EVENTID ...
24382598
**
24392599
** Generate the text of an email alert for all of the EVENTIDs
24402600
** listed on the command-line. Or if no events are listed on the
24412601
** command line, generate text for all events named in the
2442
-** pending_alert table.
2602
+** pending_alert table. The text of the email alerts appears on
2603
+** standard output.
2604
+**
2605
+** This command is intended for testing and debugging Fossil itself,
2606
+** for example when enhancing the email alert system or fixing bugs
2607
+** in the email alert system. If you are not making changes to the
2608
+** Fossil source code, this command is probably not useful to you.
24432609
**
2444
-** This command is intended for testing and debugging the logic
2445
-** that generates email alert text.
2610
+** EVENTIDs are text. The first character is 'c', 'f', 't', or 'w'
2611
+** for check-in, forum, ticket, or wiki. The remaining text is a
2612
+** integer that references the EVENT.OBJID value for the event.
2613
+** Run /timeline?showid to see these OBJID values.
24462614
**
24472615
** Options:
24482616
**
24492617
** --digest Generate digest alert text
24502618
** --needmod Assume all events are pending moderator approval
@@ -2484,11 +2652,10 @@
24842652
blob_append(&out, "\n", 1);
24852653
}
24862654
blob_append(&out, blob_buffer(&p->txt), blob_size(&p->txt));
24872655
}
24882656
alert_free_eventlist(pEvent);
2489
- alert_footer(&out);
24902657
fossil_print("%s", blob_str(&out));
24912658
blob_reset(&out);
24922659
db_end_transaction(0);
24932660
}
24942661
@@ -2539,19 +2706,66 @@
25392706
db_end_transaction(0);
25402707
if( doAuto ){
25412708
alert_backoffice(SENDALERT_TRACE|mFlags);
25422709
}
25432710
}
2711
+
2712
+/*
2713
+** Minimum number of days between renewal messages
2714
+*/
2715
+#define ALERT_RENEWAL_MSG_FREQUENCY 7 /* Do renewals at most once/week */
2716
+
2717
+/*
2718
+** Construct the header and body for an email message that will alert
2719
+** a subscriber that their subscriptions are about to expire.
2720
+*/
2721
+static void alert_renewal_msg(
2722
+ Blob *pHdr, /* Write email header here */
2723
+ Blob *pBody, /* Write email body here */
2724
+ const char *zCode, /* The subscriber code */
2725
+ int lastContact, /* Last contact (days since 1970) */
2726
+ const char *zEAddr, /* Subscriber email address. Send to this. */
2727
+ const char *zSub, /* Subscription codes */
2728
+ const char *zRepoName, /* Name of the sending Fossil repostory */
2729
+ const char *zUrl /* URL for the sending Fossil repostory */
2730
+){
2731
+ blob_appendf(pHdr,"To: <%s>\r\n", zEAddr);
2732
+ blob_appendf(pHdr,"Subject: %s Subscription to %s expires soon\r\n",
2733
+ zRepoName, zUrl);
2734
+ blob_appendf(pBody,
2735
+ "\nTo renew your subscription, click the following link:\n"
2736
+ "\n %s/renew/%s\n\n",
2737
+ zUrl, zCode
2738
+ );
2739
+ blob_appendf(pBody,
2740
+ "You are currently receiving email notification for the following events\n"
2741
+ "on the %s Fossil repository at %s:\n\n",
2742
+ zRepoName, zUrl
2743
+ );
2744
+ if( strchr(zSub, 'a') ) blob_appendf(pBody, " * Announcements\n");
2745
+ if( strchr(zSub, 'c') ) blob_appendf(pBody, " * Check-ins\n");
2746
+ if( strchr(zSub, 'f') ) blob_appendf(pBody, " * Forum posts\n");
2747
+ if( strchr(zSub, 't') ) blob_appendf(pBody, " * Ticket changes\n");
2748
+ if( strchr(zSub, 'w') ) blob_appendf(pBody, " * Wiki changes\n");
2749
+ blob_appendf(pBody, "\n"
2750
+ "If you take no action, your subscription will expire and you will be\n"
2751
+ "unsubscribed in about %d days. To make other changes or to unsubscribe\n"
2752
+ "immediately, visit the following webpage:\n\n"
2753
+ " %s/alerts/%s\n\n",
2754
+ ALERT_RENEWAL_MSG_FREQUENCY, zUrl, zCode
2755
+ );
2756
+}
25442757
25452758
#if INTERFACE
25462759
/*
25472760
** Flags for alert_send_alerts()
25482761
*/
25492762
#define SENDALERT_DIGEST 0x0001 /* Send a digest */
25502763
#define SENDALERT_PRESERVE 0x0002 /* Do not mark the task as done */
25512764
#define SENDALERT_STDOUT 0x0004 /* Print emails instead of sending */
25522765
#define SENDALERT_TRACE 0x0008 /* Trace operation for debugging */
2766
+#define SENDALERT_RENEWAL 0x0010 /* Send renewal notices */
25532767
25542768
#endif /* INTERFACE */
25552769
25562770
/*
25572771
** Send alert emails to subscribers.
@@ -2598,14 +2812,15 @@
25982812
const char *zRepoName;
25992813
const char *zFrom;
26002814
const char *zDest = (flags & SENDALERT_STDOUT) ? "stdout" : 0;
26012815
AlertSender *pSender = 0;
26022816
u32 senderFlags = 0;
2817
+ int iInterval = 0; /* Subscription renewal interval */
26032818
26042819
if( g.fSqlTrace ) fossil_trace("-- BEGIN alert_send_alerts(%u)\n", flags);
26052820
alert_schema(0);
2606
- if( !alert_enabled() ) goto send_alert_done;
2821
+ if( !alert_enabled() && (flags & SENDALERT_STDOUT)==0 ) goto send_alert_done;
26072822
zUrl = db_get("email-url",0);
26082823
if( zUrl==0 ) goto send_alert_done;
26092824
zRepoName = db_get("email-subname",0);
26102825
if( zRepoName==0 ) goto send_alert_done;
26112826
zFrom = db_get("email-self",0);
@@ -2647,11 +2862,11 @@
26472862
26482863
/* Step 2: compute EmailEvent objects for every notification that
26492864
** needs sending.
26502865
*/
26512866
pEvents = alert_compute_event_text(&nEvent, (flags & SENDALERT_DIGEST)!=0);
2652
- if( nEvent==0 ) goto send_alert_done;
2867
+ if( nEvent==0 ) goto send_alert_expiration_warnings;
26532868
26542869
/* Step 4a: Update the pending_alerts table to designate the
26552870
** alerts as having all been sent. This is done *before* step (3)
26562871
** so that a crash will not cause alerts to be sent multiple times.
26572872
** Better a missed alert than being spammed with hundreds of alerts
@@ -2682,13 +2897,16 @@
26822897
" hex(subscriberCode)," /* 0 */
26832898
" semail," /* 1 */
26842899
" ssub," /* 2 */
26852900
" fullcap(user.cap)" /* 3 */
26862901
" FROM subscriber LEFT JOIN user ON (login=suname)"
2687
- " WHERE sverified AND NOT sdonotcall"
2688
- " AND sdigest IS %s",
2689
- zDigest/*safe-for-%s*/
2902
+ " WHERE sverified"
2903
+ " AND NOT sdonotcall"
2904
+ " AND sdigest IS %s"
2905
+ " AND coalesce(subscriber.lastContact,subscriber.mtime)>=%d",
2906
+ zDigest/*safe-for-%s*/,
2907
+ db_get_int("email-renew-cutoff",0)
26902908
);
26912909
while( db_step(&q)==SQLITE_ROW ){
26922910
const char *zCode = db_column_text(&q, 0);
26932911
const char *zSub = db_column_text(&q, 2);
26942912
const char *zEmail = db_column_text(&q, 1);
@@ -2753,10 +2971,13 @@
27532971
blob_append(&body, "\n", 1);
27542972
blob_append(&body, blob_buffer(&p->txt), blob_size(&p->txt));
27552973
}
27562974
}
27572975
if( nHit==0 ) continue;
2976
+ blob_appendf(&hdr, "List-Unsubscribe: <%s/unsubscribe/%s>\r\n",
2977
+ zUrl, zCode);
2978
+ blob_appendf(&hdr, "List-Unsubscribe-Post: List-Unsubscribe=One-Click\r\n");
27582979
blob_appendf(&body,"\n-- \nSubscription info: %s/alerts/%s\n",
27592980
zUrl, zCode);
27602981
alert_send(pSender,&hdr,&body,0);
27612982
nSent++;
27622983
blob_truncate(&hdr, 0);
@@ -2769,10 +2990,62 @@
27692990
27702991
/* Step 4b: Update the pending_alerts table to remove all of the
27712992
** alerts that have been completely sent.
27722993
*/
27732994
db_multi_exec("DELETE FROM pending_alert WHERE sentDigest AND sentSep;");
2995
+
2996
+ /* Send renewal messages to subscribers whose subscriptions are about
2997
+ ** to expire. Only do this if:
2998
+ **
2999
+ ** (1) email-renew-interval is 14 or greater (or in other words if
3000
+ ** subscription expiration is enabled).
3001
+ **
3002
+ ** (2) The SENDALERT_RENEWAL flag is set
3003
+ */
3004
+send_alert_expiration_warnings:
3005
+ if( (flags & SENDALERT_RENEWAL)!=0
3006
+ && (iInterval = db_get_int("email-renew-interval",0))>=14
3007
+ ){
3008
+ int iNow = (int)(time(0)/86400);
3009
+ int iOldWarn = db_get_int("email-renew-warning",0);
3010
+ int iNewWarn = iNow - iInterval + ALERT_RENEWAL_MSG_FREQUENCY;
3011
+ if( iNewWarn >= iOldWarn + ALERT_RENEWAL_MSG_FREQUENCY ){
3012
+ db_prepare(&q,
3013
+ "SELECT"
3014
+ " hex(subscriberCode)," /* 0 */
3015
+ " lastContact," /* 1 */
3016
+ " semail," /* 2 */
3017
+ " ssub" /* 3 */
3018
+ " FROM subscriber"
3019
+ " WHERE lastContact<=%d AND lastContact>%d"
3020
+ " AND NOT sdonotcall"
3021
+ " AND length(sdigest)>0",
3022
+ iNewWarn, iOldWarn
3023
+ );
3024
+ while( db_step(&q)==SQLITE_ROW ){
3025
+ Blob hdr, body;
3026
+ blob_init(&hdr, 0, 0);
3027
+ blob_init(&body, 0, 0);
3028
+ alert_renewal_msg(&hdr, &body,
3029
+ db_column_text(&q,0),
3030
+ db_column_int(&q,1),
3031
+ db_column_text(&q,2),
3032
+ db_column_text(&q,3),
3033
+ zRepoName, zUrl);
3034
+ alert_send(pSender,&hdr,&body,0);
3035
+ blob_reset(&hdr);
3036
+ blob_reset(&body);
3037
+ }
3038
+ db_finalize(&q);
3039
+ if( (flags & SENDALERT_PRESERVE)==0 ){
3040
+ if( iOldWarn>0 ){
3041
+ db_set_int("email-renew-cutoff", iOldWarn, 0);
3042
+ }
3043
+ db_set_int("email-renew-warning", iNewWarn, 0);
3044
+ }
3045
+ }
3046
+ }
27743047
27753048
send_alert_done:
27763049
alert_sender_free(pSender);
27773050
if( g.fSqlTrace ) fossil_trace("-- END alert_send_alerts(%u)\n", flags);
27783051
return nSent;
@@ -2795,11 +3068,11 @@
27953068
if( !alert_tables_exist() ) return 0;
27963069
nSent = alert_send_alerts(mFlags);
27973070
iJulianDay = db_int(0, "SELECT julianday('now')");
27983071
if( iJulianDay>db_get_int("email-last-digest",0) ){
27993072
db_set_int("email-last-digest",iJulianDay,0);
2800
- nSent += alert_send_alerts(SENDALERT_DIGEST|mFlags);
3073
+ nSent += alert_send_alerts(SENDALERT_DIGEST|SENDALERT_RENEWAL|mFlags);
28013074
}
28023075
return nSent;
28033076
}
28043077
28053078
/*
28063079
--- src/alerts.c
+++ src/alerts.c
@@ -13,11 +13,11 @@
13 ** [email protected]
14 ** http://www.hwaci.com/drh/
15 **
16 *******************************************************************************
17 **
18 ** Logic for email notification, also known as "alerts".
19 **
20 ** Are you looking for the code that reads and writes the internet
21 ** email protocol? That is not here. See the "smtp.c" file instead.
22 ** Yes, the choice of source code filenames is not the greatest, but
23 ** it is not so bad that changing them seems justified.
@@ -64,11 +64,12 @@
64 @ sdonotcall BOOLEAN, -- true for Do Not Call
65 @ sdigest BOOLEAN, -- true for daily digests only
66 @ ssub TEXT, -- baseline subscriptions
67 @ sctime INTDATE, -- When this entry was created. unixtime
68 @ mtime INTDATE, -- Last change. unixtime
69 @ smip TEXT -- IP address of last change
 
70 @ );
71 @ CREATE INDEX repository.subscriberUname
72 @ ON subscriber(suname) WHERE suname IS NOT NULL;
73 @
74 @ DROP TABLE IF EXISTS repository.pending_alert;
@@ -83,28 +84,33 @@
83 @ sentSep BOOLEAN DEFAULT false, -- individual alert sent
84 @ sentDigest BOOLEAN DEFAULT false, -- digest alert sent
85 @ sentMod BOOLEAN DEFAULT false -- pending moderation alert sent
86 @ ) WITHOUT ROWID;
87 @
 
88 @ DROP TABLE IF EXISTS repository.alert_bounce;
89 @ -- Record bounced emails. If too many bounces are received within
90 @ -- some defined time range, then cancel the subscription. Older
91 @ -- entries are periodically purged.
92 @ --
93 @ CREATE TABLE repository.alert_bounce(
94 @ subscriberId INTEGER, -- to whom the email was sent.
95 @ sendTime INTEGER, -- seconds since 1970 when email was sent
96 @ rcvdTime INTEGER -- seconds since 1970 when bounce was received
97 @ );
98 ;
99
100 /*
101 ** Return true if the email notification tables exist.
102 */
103 int alert_tables_exist(void){
104 return db_table_exists("repository", "subscriber");
105 }
 
 
 
 
 
 
 
 
 
 
 
 
 
106
107 /*
108 ** Make sure the table needed for email notification exist in the repository.
109 **
110 ** If the bOnlyIfEnabled option is true, then tables are only created
@@ -116,16 +122,27 @@
116 && fossil_strcmp(db_get("email-send-method",0),"off")==0
117 ){
118 return; /* Don't create table for disabled email */
119 }
120 db_exec_sql(zAlertInit);
121 }else if( !db_table_has_column("repository","pending_alert","sentMod") ){
122 db_multi_exec(
123 "ALTER TABLE repository.pending_alert"
124 " ADD COLUMN sentMod BOOLEAN DEFAULT false;"
125 );
126 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127 }
128
129 /*
130 ** Enable triggers that automatically populate the pending_alert
131 ** table.
@@ -270,10 +287,24 @@
270 @ This is short name used to identifies the repository in the
271 @ Subject: line of email alerts. Traditionally this name is
272 @ included in square brackets. Examples: "[fossil-src]", "[sqlite-src]".
273 @ (Property: "email-subname")</p>
274 @ <hr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
276 multiple_choice_attribute("Email Send Method", "email-send-method", "esm",
277 "off", count(azSendMethods)/2, azSendMethods);
278 @ <p>How to send email. Requires auxiliary information from the fields
279 @ that follow. Hint: Use the <a href="%R/announce">/announce</a> page
@@ -938,10 +969,38 @@
938 ** SETTING: email-subname width=16
939 ** This is a short name used to identifies the repository in the Subject:
940 ** line of email alerts. Traditionally this name is included in square
941 ** brackets. Examples: "[fossil-src]", "[sqlite-src]".
942 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
943 /*
944 ** SETTING: email-send-method width=5 default=off sensitive
945 ** Determine the method used to send email. Allowed values are
946 ** "off", "relay", "pipe", "dir", "db", and "stdout". The "off" value
947 ** means no email is ever sent. The "relay" value means emails are sent
@@ -1002,29 +1061,32 @@
1002 ** a cron-job to make sure alerts are sent
1003 ** in a timely manner.
1004 ** Options:
1005 **
1006 ** --digest Send digests
 
 
1007 ** --test Write to standard output
1008 **
1009 ** settings [NAME VALUE] With no arguments, list all email settings.
1010 ** Or change the value of a single email setting.
1011 **
1012 ** status Report on the status of the email alert
1013 ** subsystem
1014 **
1015 ** subscribers [PATTERN] List all subscribers matching PATTERN.
 
1016 **
1017 ** test-message TO [OPTS] Send a single email message using whatever
1018 ** email sending mechanism is currently configured.
1019 ** Use this for testing the email notification
1020 ** configuration. Options:
1021 **
1022 ** --body FILENAME
1023 ** --smtp-trace
1024 ** --stdout
1025 ** -S|--subject SUBJECT
1026 **
1027 ** unsubscribe EMAIL Remove a single subscriber with the given EMAIL.
1028 */
1029 void alert_cmd(void){
1030 const char *zCmd;
@@ -1078,10 +1140,11 @@
1078 }
1079 }else
1080 if( strncmp(zCmd, "send", nCmd)==0 ){
1081 u32 eFlags = 0;
1082 if( find_option("digest",0,0)!=0 ) eFlags |= SENDALERT_DIGEST;
 
1083 if( find_option("test",0,0)!=0 ){
1084 eFlags |= SENDALERT_PRESERVE|SENDALERT_STDOUT;
1085 }
1086 verify_all_options();
1087 alert_send_alerts(eFlags);
@@ -1107,10 +1170,12 @@
1107 if( strncmp(pSetting->name,"email-",6)!=0 ) continue;
1108 print_setting(pSetting);
1109 }
1110 }else
1111 if( strncmp(zCmd, "status", nCmd)==0 ){
 
 
1112 int nSetting, n;
1113 static const char *zFmt = "%-29s %d\n";
1114 const Setting *pSetting = setting_info(&nSetting);
1115 db_open_config(1, 0);
1116 verify_all_options();
@@ -1122,14 +1187,32 @@
1122 }
1123 n = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep");
1124 fossil_print(zFmt/*works-like:"%s%d"*/, "pending-alerts", n);
1125 n = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentDigest");
1126 fossil_print(zFmt/*works-like:"%s%d"*/, "pending-digest-alerts", n);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1127 n = db_int(0,"SELECT count(*) FROM subscriber");
1128 fossil_print(zFmt/*works-like:"%s%d"*/, "total-subscribers", n);
 
1129 n = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified"
1130 " AND NOT sdonotcall AND length(ssub)>1");
 
1131 fossil_print(zFmt/*works-like:"%s%d"*/, "active-subscribers", n);
1132 }else
1133 if( strncmp(zCmd, "subscribers", nCmd)==0 ){
1134 Stmt q;
1135 verify_all_options();
@@ -1391,12 +1474,12 @@
1391 if( g.perm.RdWiki && PB("sw") ) ssub[nsub++] = 'w';
1392 if( g.perm.RdForum && PB("sx") ) ssub[nsub++] = 'x';
1393 ssub[nsub] = 0;
1394 zCode = db_text(0,
1395 "INSERT INTO subscriber(semail,suname,"
1396 " sverified,sdonotcall,sdigest,ssub,sctime,mtime,smip)"
1397 "VALUES(%Q,%Q,%d,0,%d,%Q,now(),now(),%Q)"
1398 "RETURNING hex(subscriberCode);",
1399 /* semail */ zEAddr,
1400 /* suname */ suname,
1401 /* sverified */ needCaptcha==0,
1402 /* sdigest */ PB("di"),
@@ -1582,12 +1665,13 @@
1582
1583 db_multi_exec(
1584 "DELETE FROM subscriber WHERE subscriberId=%d", sid
1585 );
1586 style_header("Unsubscribed");
1587 @ <p>The "%h(zEmail)" email address has been unsubscribed and the
1588 @ corresponding row in the subscriber table has been deleted.<p>
 
1589 if( uid && g.perm.Admin ){
1590 @ <p>You may also want to
1591 @ <a href="%R/setup_uedit?id=%d(uid)">edit or delete
1592 @ the corresponding user "%h(zLogin)"</a></p>
1593 }
@@ -1640,10 +1724,11 @@
1640 int eErr = 0; /* Type of error */
1641 char *zErr = 0; /* Error message text */
1642 int sid = 0; /* Subscriber ID */
1643 int nName; /* Length of zName in bytes */
1644 char *zHalfCode; /* prefix of subscriberCode */
 
1645
1646 db_begin_transaction();
1647 if( alert_webpages_disabled() ){
1648 db_commit_transaction();
1649 return;
@@ -1664,10 +1749,11 @@
1664 sid = db_int(0,
1665 "SELECT CASE WHEN hex(subscriberCode) LIKE (%Q||'%%')"
1666 " THEN subscriberId ELSE 0 END"
1667 " FROM subscriber WHERE subscriberCode>=hextoblob(%Q)"
1668 " LIMIT 1", zName, zName);
 
1669 }
1670 if( sid==0 && isLogin ){
1671 sid = db_int(0, "SELECT subscriberId FROM subscriber"
1672 " WHERE suname=%Q", g.zLogin);
1673 }
@@ -1696,11 +1782,12 @@
1696 blob_init(&update, "UPDATE subscriber SET", -1);
1697 blob_append_sql(&update,
1698 " sdonotcall=%d,"
1699 " sdigest=%d,"
1700 " ssub=%Q,"
1701 " mtime=strftime('%%s','now'),"
 
1702 " smip=%Q",
1703 sdonotcall,
1704 sdigest,
1705 ssub,
1706 g.zIpAddr
@@ -1726,10 +1813,15 @@
1726 if( eErr==0 ){
1727 db_exec_sql(blob_str(&update));
1728 ssub = 0;
1729 }
1730 blob_reset(&update);
 
 
 
 
 
1731 }
1732 if( P("delete")!=0 && cgi_csrf_safe(1) ){
1733 if( !PB("dodelete") ){
1734 eErr = 9;
1735 zErr = mprintf("Select this checkbox and press \"Unsubscribe\" again to"
@@ -1751,11 +1843,13 @@
1751 " ssub," /* 4 */
1752 " smip," /* 5 */
1753 " suname," /* 6 */
1754 " datetime(mtime,'unixepoch')," /* 7 */
1755 " datetime(sctime,'unixepoch')," /* 8 */
1756 " hex(subscriberCode)" /* 9 */
 
 
1757 " FROM subscriber WHERE subscriberId=%d", sid);
1758 if( db_step(&q)!=SQLITE_ROW ){
1759 db_finalize(&q);
1760 db_commit_transaction();
1761 cgi_redirect("subscribe");
@@ -1850,10 +1944,15 @@
1850 @ </tr>
1851 @ <tr>
1852 @ <td class='form_label'>Subscriber&nbsp;Code:</td>
1853 @ <td>%h(db_column_text(&q,9))</td>
1854 @ <tr>
 
 
 
 
 
1855 @ <td class="form_label">User:</td>
1856 @ <td><input type="text" name="suname" value="%h(suname?suname:"")" \
1857 @ size="30">\
1858 uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", suname);
1859 if( uid ){
@@ -1920,10 +2019,61 @@
1920 db_finalize(&q);
1921 style_finish_page();
1922 db_commit_transaction();
1923 return;
1924 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1925
1926 /* This is the message that gets sent to describe how to change
1927 ** or modify a subscription
1928 */
1929 static const char zUnsubMsg[] =
@@ -2094,10 +2244,14 @@
2094 Stmt q;
2095 sqlite3_int64 iNow;
2096 int nTotal;
2097 int nPending;
2098 int nDel = 0;
 
 
 
 
2099 if( alert_webpages_disabled() ) return;
2100 login_check_credentials();
2101 if( !g.perm.Admin ){
2102 login_needed(0);
2103 return;
@@ -2110,11 +2264,11 @@
2110 nPending = db_int(0, "SELECT count(*) FROM subscriber WHERE NOT sverified");
2111 if( nPending>0 && P("purge") && cgi_csrf_safe(0) ){
2112 int nNewPending;
2113 db_multi_exec(
2114 "DELETE FROM subscriber"
2115 " WHERE NOT sverified AND mtime<0+strftime('%%s','now','-1 day')"
2116 );
2117 nNewPending = db_int(0, "SELECT count(*) FROM subscriber"
2118 " WHERE NOT sverified");
2119 nDel = nPending - nNewPending;
2120 nPending = nNewPending;
@@ -2121,11 +2275,11 @@
2121 nTotal -= nDel;
2122 }
2123 if( nPending>0 ){
2124 @ <h1>%,d(nTotal) Subscribers, %,d(nPending) Pending</h1>
2125 if( nDel==0 && 0<db_int(0,"SELECT count(*) FROM subscriber"
2126 " WHERE NOT sverified AND mtime<0+strftime('%%s','now','-1 day')")
2127 ){
2128 style_submenu_element("Purge Pending","subscribers?purge");
2129 }
2130 }else{
2131 @ <h1>%,d(nTotal) Subscribers</h1>
@@ -2141,38 +2295,44 @@
2141 " suname," /* 3 */
2142 " sverified," /* 4 */
2143 " sdigest," /* 5 */
2144 " mtime," /* 6 */
2145 " date(sctime,'unixepoch')," /* 7 */
2146 " (SELECT uid FROM user WHERE login=subscriber.suname)" /* 8 */
 
2147 " FROM subscriber"
2148 );
2149 if( P("only")!=0 ){
2150 blob_append_sql(&sql, " WHERE ssub LIKE '%%%q%%'", P("only"));
2151 style_submenu_element("Show All","%R/subscribers");
2152 }
2153 blob_append_sql(&sql," ORDER BY mtime DESC");
2154 db_prepare_blob(&q, &sql);
2155 iNow = time(0);
 
 
2156 @ <table border='1' class='sortable' \
2157 @ data-init-sort='6' data-column-types='tttttKt'>
2158 @ <thead>
2159 @ <tr>
2160 @ <th>Email
2161 @ <th>Events
2162 @ <th>Digest-Only?
2163 @ <th>User
2164 @ <th>Verified?
2165 @ <th>Last change
 
2166 @ <th>Created
2167 @ </tr>
2168 @ </thead><tbody>
2169 while( db_step(&q)==SQLITE_ROW ){
2170 sqlite3_int64 iMtime = db_column_int64(&q, 6);
2171 double rAge = (iNow - iMtime)/86400.0;
2172 int uid = db_column_int(&q, 8);
2173 const char *zUname = db_column_text(&q, 3);
 
 
2174 @ <tr>
2175 @ <td><a href='%R/alerts?sid=%d(db_column_int(&q,0))'>\
2176 @ %h(db_column_text(&q,1))</a></td>
2177 @ <td>%h(db_column_text(&q,2))</td>
2178 @ <td>%s(db_column_int(&q,5)?"digest":"")</td>
@@ -2181,10 +2341,19 @@
2181 }else{
2182 @ <td>%h(zUname)</td>
2183 }
2184 @ <td>%s(db_column_int(&q,4)?"yes":"pending")</td>
2185 @ <td data-sortkey='%010llx(iMtime)'>%z(human_readable_age(rAge))</td>
 
 
 
 
 
 
 
 
 
2186 @ <td>%h(db_column_text(&q,7))</td>
2187 @ </tr>
2188 }
2189 @ </tbody></table>
2190 db_finalize(&q);
@@ -2420,31 +2589,30 @@
2420 "on Fossil repository %s (%s/timeline)\n",
2421 db_get("email-subname","(unknown)"),
2422 db_get("email-url","http://localhost:8080"));
2423 }
2424
2425 /*
2426 ** Append the "unsubscribe" notification and other footer text to
2427 ** the end of an email alert being assemblied in pOut.
2428 */
2429 void alert_footer(Blob *pOut){
2430 blob_appendf(pOut, "\n-- \nTo unsubscribe: %s/unsubscribe\n",
2431 db_get("email-url","http://localhost:8080"));
2432 }
2433
2434 /*
2435 ** COMMAND: test-alert
2436 **
2437 ** Usage: %fossil test-alert EVENTID ...
2438 **
2439 ** Generate the text of an email alert for all of the EVENTIDs
2440 ** listed on the command-line. Or if no events are listed on the
2441 ** command line, generate text for all events named in the
2442 ** pending_alert table.
 
 
 
 
 
 
2443 **
2444 ** This command is intended for testing and debugging the logic
2445 ** that generates email alert text.
 
 
2446 **
2447 ** Options:
2448 **
2449 ** --digest Generate digest alert text
2450 ** --needmod Assume all events are pending moderator approval
@@ -2484,11 +2652,10 @@
2484 blob_append(&out, "\n", 1);
2485 }
2486 blob_append(&out, blob_buffer(&p->txt), blob_size(&p->txt));
2487 }
2488 alert_free_eventlist(pEvent);
2489 alert_footer(&out);
2490 fossil_print("%s", blob_str(&out));
2491 blob_reset(&out);
2492 db_end_transaction(0);
2493 }
2494
@@ -2539,19 +2706,66 @@
2539 db_end_transaction(0);
2540 if( doAuto ){
2541 alert_backoffice(SENDALERT_TRACE|mFlags);
2542 }
2543 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2544
2545 #if INTERFACE
2546 /*
2547 ** Flags for alert_send_alerts()
2548 */
2549 #define SENDALERT_DIGEST 0x0001 /* Send a digest */
2550 #define SENDALERT_PRESERVE 0x0002 /* Do not mark the task as done */
2551 #define SENDALERT_STDOUT 0x0004 /* Print emails instead of sending */
2552 #define SENDALERT_TRACE 0x0008 /* Trace operation for debugging */
 
2553
2554 #endif /* INTERFACE */
2555
2556 /*
2557 ** Send alert emails to subscribers.
@@ -2598,14 +2812,15 @@
2598 const char *zRepoName;
2599 const char *zFrom;
2600 const char *zDest = (flags & SENDALERT_STDOUT) ? "stdout" : 0;
2601 AlertSender *pSender = 0;
2602 u32 senderFlags = 0;
 
2603
2604 if( g.fSqlTrace ) fossil_trace("-- BEGIN alert_send_alerts(%u)\n", flags);
2605 alert_schema(0);
2606 if( !alert_enabled() ) goto send_alert_done;
2607 zUrl = db_get("email-url",0);
2608 if( zUrl==0 ) goto send_alert_done;
2609 zRepoName = db_get("email-subname",0);
2610 if( zRepoName==0 ) goto send_alert_done;
2611 zFrom = db_get("email-self",0);
@@ -2647,11 +2862,11 @@
2647
2648 /* Step 2: compute EmailEvent objects for every notification that
2649 ** needs sending.
2650 */
2651 pEvents = alert_compute_event_text(&nEvent, (flags & SENDALERT_DIGEST)!=0);
2652 if( nEvent==0 ) goto send_alert_done;
2653
2654 /* Step 4a: Update the pending_alerts table to designate the
2655 ** alerts as having all been sent. This is done *before* step (3)
2656 ** so that a crash will not cause alerts to be sent multiple times.
2657 ** Better a missed alert than being spammed with hundreds of alerts
@@ -2682,13 +2897,16 @@
2682 " hex(subscriberCode)," /* 0 */
2683 " semail," /* 1 */
2684 " ssub," /* 2 */
2685 " fullcap(user.cap)" /* 3 */
2686 " FROM subscriber LEFT JOIN user ON (login=suname)"
2687 " WHERE sverified AND NOT sdonotcall"
2688 " AND sdigest IS %s",
2689 zDigest/*safe-for-%s*/
 
 
 
2690 );
2691 while( db_step(&q)==SQLITE_ROW ){
2692 const char *zCode = db_column_text(&q, 0);
2693 const char *zSub = db_column_text(&q, 2);
2694 const char *zEmail = db_column_text(&q, 1);
@@ -2753,10 +2971,13 @@
2753 blob_append(&body, "\n", 1);
2754 blob_append(&body, blob_buffer(&p->txt), blob_size(&p->txt));
2755 }
2756 }
2757 if( nHit==0 ) continue;
 
 
 
2758 blob_appendf(&body,"\n-- \nSubscription info: %s/alerts/%s\n",
2759 zUrl, zCode);
2760 alert_send(pSender,&hdr,&body,0);
2761 nSent++;
2762 blob_truncate(&hdr, 0);
@@ -2769,10 +2990,62 @@
2769
2770 /* Step 4b: Update the pending_alerts table to remove all of the
2771 ** alerts that have been completely sent.
2772 */
2773 db_multi_exec("DELETE FROM pending_alert WHERE sentDigest AND sentSep;");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2774
2775 send_alert_done:
2776 alert_sender_free(pSender);
2777 if( g.fSqlTrace ) fossil_trace("-- END alert_send_alerts(%u)\n", flags);
2778 return nSent;
@@ -2795,11 +3068,11 @@
2795 if( !alert_tables_exist() ) return 0;
2796 nSent = alert_send_alerts(mFlags);
2797 iJulianDay = db_int(0, "SELECT julianday('now')");
2798 if( iJulianDay>db_get_int("email-last-digest",0) ){
2799 db_set_int("email-last-digest",iJulianDay,0);
2800 nSent += alert_send_alerts(SENDALERT_DIGEST|mFlags);
2801 }
2802 return nSent;
2803 }
2804
2805 /*
2806
--- src/alerts.c
+++ src/alerts.c
@@ -13,11 +13,11 @@
13 ** [email protected]
14 ** http://www.hwaci.com/drh/
15 **
16 *******************************************************************************
17 **
18 ** Logic for email notification, also known as "alerts" or "subscriptions".
19 **
20 ** Are you looking for the code that reads and writes the internet
21 ** email protocol? That is not here. See the "smtp.c" file instead.
22 ** Yes, the choice of source code filenames is not the greatest, but
23 ** it is not so bad that changing them seems justified.
@@ -64,11 +64,12 @@
64 @ sdonotcall BOOLEAN, -- true for Do Not Call
65 @ sdigest BOOLEAN, -- true for daily digests only
66 @ ssub TEXT, -- baseline subscriptions
67 @ sctime INTDATE, -- When this entry was created. unixtime
68 @ mtime INTDATE, -- Last change. unixtime
69 @ smip TEXT, -- IP address of last change
70 @ lastContact INT -- Last contact. days since 1970
71 @ );
72 @ CREATE INDEX repository.subscriberUname
73 @ ON subscriber(suname) WHERE suname IS NOT NULL;
74 @
75 @ DROP TABLE IF EXISTS repository.pending_alert;
@@ -83,28 +84,33 @@
84 @ sentSep BOOLEAN DEFAULT false, -- individual alert sent
85 @ sentDigest BOOLEAN DEFAULT false, -- digest alert sent
86 @ sentMod BOOLEAN DEFAULT false -- pending moderation alert sent
87 @ ) WITHOUT ROWID;
88 @
89 @ -- Obsolete table. No longer used.
90 @ DROP TABLE IF EXISTS repository.alert_bounce;
 
 
 
 
 
 
 
 
 
91 ;
92
93 /*
94 ** Return true if the email notification tables exist.
95 */
96 int alert_tables_exist(void){
97 return db_table_exists("repository", "subscriber");
98 }
99
100 /*
101 ** Record the fact that user zUser has made contact with the repository.
102 ** This resets the subscription timeout on that user.
103 */
104 void alert_user_contact(const char *zUser){
105 if( db_table_has_column("repository","subscriber","lastContact") ){
106 db_multi_exec(
107 "UPDATE subscriber SET lastContact=now()/86400 WHERE suname=%Q",
108 zUser
109 );
110 }
111 }
112
113 /*
114 ** Make sure the table needed for email notification exist in the repository.
115 **
116 ** If the bOnlyIfEnabled option is true, then tables are only created
@@ -116,16 +122,27 @@
122 && fossil_strcmp(db_get("email-send-method",0),"off")==0
123 ){
124 return; /* Don't create table for disabled email */
125 }
126 db_exec_sql(zAlertInit);
127 return;
 
 
 
 
128 }
129 if( db_table_has_column("repository","subscriber","lastContact") ){
130 return;
131 }
132 db_multi_exec(
133 "DROP TABLE IF EXISTS repository.alert_bounde;\n"
134 "ALTER TABLE repository.subscriber ADD COLUMN lastContact INT;\n"
135 "UPDATE subscriber SET lastContact=mtime/86400;"
136 );
137 if( db_table_has_column("repository","pending_alert","sentMod") ){
138 return;
139 }
140 db_multi_exec(
141 "ALTER TABLE repository.pending_alert"
142 " ADD COLUMN sentMod BOOLEAN DEFAULT false;"
143 );
144 }
145
146 /*
147 ** Enable triggers that automatically populate the pending_alert
148 ** table.
@@ -270,10 +287,24 @@
287 @ This is short name used to identifies the repository in the
288 @ Subject: line of email alerts. Traditionally this name is
289 @ included in square brackets. Examples: "[fossil-src]", "[sqlite-src]".
290 @ (Property: "email-subname")</p>
291 @ <hr>
292
293 entry_attribute("Subscription Renewal Interval In Days", 8,
294 "email-renew-interval", "eri", "", 0);
295 @ <p>
296 @ If this value is a integer N greater than or equal to 14, then email
297 @ notification subscriptions will be suspended N days after the last known
298 @ interaction with the user. This prevents sending notifications
299 @ to abandoned accounts. If a subscription comes within 7 days of expiring,
300 @ a separate email goes out with the daily digest that prompts the
301 @ subscriber to click on a link to the "/renew" webpage in order to
302 @ extend their subscription. Subscriptions never expire if this setting
303 @ is less than 14 or is an empty string.
304 @ (Property: "email-renew-interval")</p>
305 @ <hr>
306
307 multiple_choice_attribute("Email Send Method", "email-send-method", "esm",
308 "off", count(azSendMethods)/2, azSendMethods);
309 @ <p>How to send email. Requires auxiliary information from the fields
310 @ that follow. Hint: Use the <a href="%R/announce">/announce</a> page
@@ -938,10 +969,38 @@
969 ** SETTING: email-subname width=16
970 ** This is a short name used to identifies the repository in the Subject:
971 ** line of email alerts. Traditionally this name is included in square
972 ** brackets. Examples: "[fossil-src]", "[sqlite-src]".
973 */
974 /*
975 ** SETTING: email-renew-interval width=16
976 ** If this setting as an integer N that is 14 or greater then email
977 ** notification is suspected for subscriptions that have a "last contact
978 ** time" of more than N days ago. The "last contact time" is recorded
979 ** in the SUBSCRIBER.LASTCONTACT entry of the database. Logging in,
980 ** sending a forum post, editing a wiki page, changing subscription settings
981 ** at /alerts, or visiting /renew all update the last contact time.
982 ** If this setting is not an integer value or is less than 14 or undefined,
983 ** then subscriptions never expire.
984 */
985 /* X-VARIABLE: email-renew-warning
986 ** X-VARIABLE: email-renew-cutoff
987 **
988 ** These CONFIG table entries are not considered "settings" since their
989 ** values are computed and updated automatically.
990 **
991 ** email-renew-cutoff is the lastContact cutoff for subscription. It
992 ** is measured in days since 1970-01-01. If The lastContact time for
993 ** a subscription is less than email-renew-cutoff, then now new emails
994 ** are sent to the subscriber.
995 **
996 ** email-renew-warning is the time (in days since 1970-01-01) when the
997 ** last batch of "your subscription is about to expire" emails were
998 ** sent out.
999 **
1000 ** email-renew-cutoff is normally 7 days behind email-renew-warning.
1001 */
1002 /*
1003 ** SETTING: email-send-method width=5 default=off sensitive
1004 ** Determine the method used to send email. Allowed values are
1005 ** "off", "relay", "pipe", "dir", "db", and "stdout". The "off" value
1006 ** means no email is ever sent. The "relay" value means emails are sent
@@ -1002,29 +1061,32 @@
1061 ** a cron-job to make sure alerts are sent
1062 ** in a timely manner.
1063 ** Options:
1064 **
1065 ** --digest Send digests
1066 ** --renewal Send subscription renewal
1067 ** notices
1068 ** --test Write to standard output
1069 **
1070 ** settings [NAME VALUE] With no arguments, list all email settings.
1071 ** Or change the value of a single email setting.
1072 **
1073 ** status Report on the status of the email alert
1074 ** subsystem
1075 **
1076 ** subscribers [PATTERN] List all subscribers matching PATTERN. Either
1077 ** LIKE or GLOB wildcards can be used in PATTERN.
1078 **
1079 ** test-message TO [OPTS] Send a single email message using whatever
1080 ** email sending mechanism is currently configured.
1081 ** Use this for testing the email notification
1082 ** configuration. Options:
1083 **
1084 ** --body FILENAME Content from FILENAME
1085 ** --smtp-trace Trace SMTP processing
1086 ** --stdout Send msg to stdout
1087 ** -S|--subject SUBJECT Message "subject:"
1088 **
1089 ** unsubscribe EMAIL Remove a single subscriber with the given EMAIL.
1090 */
1091 void alert_cmd(void){
1092 const char *zCmd;
@@ -1078,10 +1140,11 @@
1140 }
1141 }else
1142 if( strncmp(zCmd, "send", nCmd)==0 ){
1143 u32 eFlags = 0;
1144 if( find_option("digest",0,0)!=0 ) eFlags |= SENDALERT_DIGEST;
1145 if( find_option("renewal",0,0)!=0 ) eFlags |= SENDALERT_RENEWAL;
1146 if( find_option("test",0,0)!=0 ){
1147 eFlags |= SENDALERT_PRESERVE|SENDALERT_STDOUT;
1148 }
1149 verify_all_options();
1150 alert_send_alerts(eFlags);
@@ -1107,10 +1170,12 @@
1170 if( strncmp(pSetting->name,"email-",6)!=0 ) continue;
1171 print_setting(pSetting);
1172 }
1173 }else
1174 if( strncmp(zCmd, "status", nCmd)==0 ){
1175 Stmt q;
1176 int iCutoff;
1177 int nSetting, n;
1178 static const char *zFmt = "%-29s %d\n";
1179 const Setting *pSetting = setting_info(&nSetting);
1180 db_open_config(1, 0);
1181 verify_all_options();
@@ -1122,14 +1187,32 @@
1187 }
1188 n = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep");
1189 fossil_print(zFmt/*works-like:"%s%d"*/, "pending-alerts", n);
1190 n = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentDigest");
1191 fossil_print(zFmt/*works-like:"%s%d"*/, "pending-digest-alerts", n);
1192 db_prepare(&q,
1193 "SELECT"
1194 " name,"
1195 " value,"
1196 " now()/86400-value,"
1197 " date(value*86400,'unixepoch')"
1198 " FROM repository.config"
1199 " WHERE name in ('email-renew-warning','email-renew-cutoff');");
1200 while( db_step(&q)==SQLITE_ROW ){
1201 fossil_print("%-29s %-6d (%d days ago on %s)\n",
1202 db_column_text(&q, 0),
1203 db_column_int(&q, 1),
1204 db_column_int(&q, 2),
1205 db_column_text(&q, 3));
1206 }
1207 db_finalize(&q);
1208 n = db_int(0,"SELECT count(*) FROM subscriber");
1209 fossil_print(zFmt/*works-like:"%s%d"*/, "total-subscribers", n);
1210 iCutoff = db_get_int("email-renew-cutoff", 0);
1211 n = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified"
1212 " AND NOT sdonotcall AND length(ssub)>1"
1213 " AND lastContact>=%d", iCutoff);
1214 fossil_print(zFmt/*works-like:"%s%d"*/, "active-subscribers", n);
1215 }else
1216 if( strncmp(zCmd, "subscribers", nCmd)==0 ){
1217 Stmt q;
1218 verify_all_options();
@@ -1391,12 +1474,12 @@
1474 if( g.perm.RdWiki && PB("sw") ) ssub[nsub++] = 'w';
1475 if( g.perm.RdForum && PB("sx") ) ssub[nsub++] = 'x';
1476 ssub[nsub] = 0;
1477 zCode = db_text(0,
1478 "INSERT INTO subscriber(semail,suname,"
1479 " sverified,sdonotcall,sdigest,ssub,sctime,mtime,smip,lastContact)"
1480 "VALUES(%Q,%Q,%d,0,%d,%Q,now(),now(),%Q,now()/86400)"
1481 "RETURNING hex(subscriberCode);",
1482 /* semail */ zEAddr,
1483 /* suname */ suname,
1484 /* sverified */ needCaptcha==0,
1485 /* sdigest */ PB("di"),
@@ -1582,12 +1665,13 @@
1665
1666 db_multi_exec(
1667 "DELETE FROM subscriber WHERE subscriberId=%d", sid
1668 );
1669 style_header("Unsubscribed");
1670 @ <p>The "%h(zEmail)" email address has been unsubscribed from all
1671 @ notifications. All subscription records for "%h(zEmail)" have
1672 @ been purged. No further emails will be sent to "%h(zEmail)".</p>
1673 if( uid && g.perm.Admin ){
1674 @ <p>You may also want to
1675 @ <a href="%R/setup_uedit?id=%d(uid)">edit or delete
1676 @ the corresponding user "%h(zLogin)"</a></p>
1677 }
@@ -1640,10 +1724,11 @@
1724 int eErr = 0; /* Type of error */
1725 char *zErr = 0; /* Error message text */
1726 int sid = 0; /* Subscriber ID */
1727 int nName; /* Length of zName in bytes */
1728 char *zHalfCode; /* prefix of subscriberCode */
1729 int keepAlive = 0; /* True to update the last contact time */
1730
1731 db_begin_transaction();
1732 if( alert_webpages_disabled() ){
1733 db_commit_transaction();
1734 return;
@@ -1664,10 +1749,11 @@
1749 sid = db_int(0,
1750 "SELECT CASE WHEN hex(subscriberCode) LIKE (%Q||'%%')"
1751 " THEN subscriberId ELSE 0 END"
1752 " FROM subscriber WHERE subscriberCode>=hextoblob(%Q)"
1753 " LIMIT 1", zName, zName);
1754 if( sid ) keepAlive = 1;
1755 }
1756 if( sid==0 && isLogin ){
1757 sid = db_int(0, "SELECT subscriberId FROM subscriber"
1758 " WHERE suname=%Q", g.zLogin);
1759 }
@@ -1696,11 +1782,12 @@
1782 blob_init(&update, "UPDATE subscriber SET", -1);
1783 blob_append_sql(&update,
1784 " sdonotcall=%d,"
1785 " sdigest=%d,"
1786 " ssub=%Q,"
1787 " mtime=now(),"
1788 " lastContact=now()/86400,"
1789 " smip=%Q",
1790 sdonotcall,
1791 sdigest,
1792 ssub,
1793 g.zIpAddr
@@ -1726,10 +1813,15 @@
1813 if( eErr==0 ){
1814 db_exec_sql(blob_str(&update));
1815 ssub = 0;
1816 }
1817 blob_reset(&update);
1818 }else if( keepAlive ){
1819 db_multi_exec(
1820 "UPDATE subscriber SET lastContact=now()/86400"
1821 " WHERE subscriberId=%d", sid
1822 );
1823 }
1824 if( P("delete")!=0 && cgi_csrf_safe(1) ){
1825 if( !PB("dodelete") ){
1826 eErr = 9;
1827 zErr = mprintf("Select this checkbox and press \"Unsubscribe\" again to"
@@ -1751,11 +1843,13 @@
1843 " ssub," /* 4 */
1844 " smip," /* 5 */
1845 " suname," /* 6 */
1846 " datetime(mtime,'unixepoch')," /* 7 */
1847 " datetime(sctime,'unixepoch')," /* 8 */
1848 " hex(subscriberCode)," /* 9 */
1849 " date(coalesce(lastContact*86400,mtime),'unixepoch')," /* 10 */
1850 " now()/86400 - coalesce(lastContact,mtime/86400)" /* 11 */
1851 " FROM subscriber WHERE subscriberId=%d", sid);
1852 if( db_step(&q)!=SQLITE_ROW ){
1853 db_finalize(&q);
1854 db_commit_transaction();
1855 cgi_redirect("subscribe");
@@ -1850,10 +1944,15 @@
1944 @ </tr>
1945 @ <tr>
1946 @ <td class='form_label'>Subscriber&nbsp;Code:</td>
1947 @ <td>%h(db_column_text(&q,9))</td>
1948 @ <tr>
1949 @ <tr>
1950 @ <td class='form_label'>Last Contact:</td>
1951 @ <td>%h(db_column_text(&q,10)) &larr; \
1952 @ %,d(db_column_int(&q,11)) days ago</td>
1953 @ </tr>
1954 @ <td class="form_label">User:</td>
1955 @ <td><input type="text" name="suname" value="%h(suname?suname:"")" \
1956 @ size="30">\
1957 uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", suname);
1958 if( uid ){
@@ -1920,10 +2019,61 @@
2019 db_finalize(&q);
2020 style_finish_page();
2021 db_commit_transaction();
2022 return;
2023 }
2024
2025 /*
2026 ** WEBPAGE: renew
2027 **
2028 ** Users visit this page to update the last-contact date on their
2029 ** subscription. The last-contact date is the day that the subscriber
2030 ** last interacted with the repository. If the name= query parameter
2031 ** (or POST parameter) contains a valid subscriber code, then the last-contact
2032 ** subscription associated with that subscriber code is updated to be the
2033 ** current date.
2034 */
2035 void renewal_page(void){
2036 const char *zName = P("name");
2037 int iInterval = db_get_int("email-renew-interval", 0);
2038 Stmt s;
2039 int rc;
2040
2041 style_header("Subscription Renewal");
2042 if( zName==0 || strlen(zName)<4 ){
2043 @ <p>No subscription specified</p>
2044 style_finish_page();
2045 return;
2046 }
2047
2048 if( !db_table_has_column("repository","subscriber","lastContact")
2049 || iInterval<1
2050 ){
2051 @ <p>This repository does not expire email notification subscriptions.
2052 @ No renewals are necessary.</p>
2053 style_finish_page();
2054 return;
2055 }
2056
2057 db_prepare(&s,
2058 "UPDATE subscriber"
2059 " SET lastContact=now()/86400"
2060 " WHERE subscriberCode=hextoblob(%Q)"
2061 " RETURNING semail, date('now','+%d days');",
2062 zName, iInterval+1
2063 );
2064 rc = db_step(&s);
2065 if( rc==SQLITE_ROW ){
2066 @ <p>The email notification subscription for %h(db_column_text(&s,0))
2067 @ has been extended until %h(db_column_text(&s,1)) UTC.
2068 }else{
2069 @ <p>No such subscriber-id: %h(zName)</p>
2070 }
2071 db_finalize(&s);
2072 style_finish_page();
2073 }
2074
2075
2076 /* This is the message that gets sent to describe how to change
2077 ** or modify a subscription
2078 */
2079 static const char zUnsubMsg[] =
@@ -2094,10 +2244,14 @@
2244 Stmt q;
2245 sqlite3_int64 iNow;
2246 int nTotal;
2247 int nPending;
2248 int nDel = 0;
2249 int iCutoff = db_get_int("email-renew-cutoff",0);
2250 int iWarning = db_get_int("email-renew-warning",0);
2251 char zCutoffClr[8];
2252 char zWarnClr[8];
2253 if( alert_webpages_disabled() ) return;
2254 login_check_credentials();
2255 if( !g.perm.Admin ){
2256 login_needed(0);
2257 return;
@@ -2110,11 +2264,11 @@
2264 nPending = db_int(0, "SELECT count(*) FROM subscriber WHERE NOT sverified");
2265 if( nPending>0 && P("purge") && cgi_csrf_safe(0) ){
2266 int nNewPending;
2267 db_multi_exec(
2268 "DELETE FROM subscriber"
2269 " WHERE NOT sverified AND mtime<now()-86400"
2270 );
2271 nNewPending = db_int(0, "SELECT count(*) FROM subscriber"
2272 " WHERE NOT sverified");
2273 nDel = nPending - nNewPending;
2274 nPending = nNewPending;
@@ -2121,11 +2275,11 @@
2275 nTotal -= nDel;
2276 }
2277 if( nPending>0 ){
2278 @ <h1>%,d(nTotal) Subscribers, %,d(nPending) Pending</h1>
2279 if( nDel==0 && 0<db_int(0,"SELECT count(*) FROM subscriber"
2280 " WHERE NOT sverified AND mtime<now()-86400")
2281 ){
2282 style_submenu_element("Purge Pending","subscribers?purge");
2283 }
2284 }else{
2285 @ <h1>%,d(nTotal) Subscribers</h1>
@@ -2141,38 +2295,44 @@
2295 " suname," /* 3 */
2296 " sverified," /* 4 */
2297 " sdigest," /* 5 */
2298 " mtime," /* 6 */
2299 " date(sctime,'unixepoch')," /* 7 */
2300 " (SELECT uid FROM user WHERE login=subscriber.suname)," /* 8 */
2301 " coalesce(lastContact,mtime/86400)" /* 9 */
2302 " FROM subscriber"
2303 );
2304 if( P("only")!=0 ){
2305 blob_append_sql(&sql, " WHERE ssub LIKE '%%%q%%'", P("only"));
2306 style_submenu_element("Show All","%R/subscribers");
2307 }
2308 blob_append_sql(&sql," ORDER BY mtime DESC");
2309 db_prepare_blob(&q, &sql);
2310 iNow = time(0);
2311 memcpy(zCutoffClr, hash_color("A"), sizeof(zCutoffClr));
2312 memcpy(zWarnClr, hash_color("HIJ"), sizeof(zWarnClr));
2313 @ <table border='1' class='sortable' \
2314 @ data-init-sort='6' data-column-types='tttttKKt'>
2315 @ <thead>
2316 @ <tr>
2317 @ <th>Email
2318 @ <th>Events
2319 @ <th>Digest-Only?
2320 @ <th>User
2321 @ <th>Verified?
2322 @ <th>Last change
2323 @ <th>Last contact
2324 @ <th>Created
2325 @ </tr>
2326 @ </thead><tbody>
2327 while( db_step(&q)==SQLITE_ROW ){
2328 sqlite3_int64 iMtime = db_column_int64(&q, 6);
2329 double rAge = (iNow - iMtime)/86400.0;
2330 int uid = db_column_int(&q, 8);
2331 const char *zUname = db_column_text(&q, 3);
2332 sqlite3_int64 iContact = db_column_int64(&q, 9);
2333 double rContact = (iNow/86400) - iContact;
2334 @ <tr>
2335 @ <td><a href='%R/alerts?sid=%d(db_column_int(&q,0))'>\
2336 @ %h(db_column_text(&q,1))</a></td>
2337 @ <td>%h(db_column_text(&q,2))</td>
2338 @ <td>%s(db_column_int(&q,5)?"digest":"")</td>
@@ -2181,10 +2341,19 @@
2341 }else{
2342 @ <td>%h(zUname)</td>
2343 }
2344 @ <td>%s(db_column_int(&q,4)?"yes":"pending")</td>
2345 @ <td data-sortkey='%010llx(iMtime)'>%z(human_readable_age(rAge))</td>
2346 @ <td data-sortkey='%010llx(iContact)'>\
2347 if( iContact>iWarning ){
2348 @ <span>\
2349 }else if( iContact>iCutoff ){
2350 @ <span style='background-color:%s(zWarnClr);'>\
2351 }else{
2352 @ <span style='background-color:%s(zCutoffClr);'>\
2353 }
2354 @ %z(human_readable_age(rContact))</td>
2355 @ <td>%h(db_column_text(&q,7))</td>
2356 @ </tr>
2357 }
2358 @ </tbody></table>
2359 db_finalize(&q);
@@ -2420,31 +2589,30 @@
2589 "on Fossil repository %s (%s/timeline)\n",
2590 db_get("email-subname","(unknown)"),
2591 db_get("email-url","http://localhost:8080"));
2592 }
2593
 
 
 
 
 
 
 
 
 
2594 /*
2595 ** COMMAND: test-alert
2596 **
2597 ** Usage: %fossil test-alert EVENTID ...
2598 **
2599 ** Generate the text of an email alert for all of the EVENTIDs
2600 ** listed on the command-line. Or if no events are listed on the
2601 ** command line, generate text for all events named in the
2602 ** pending_alert table. The text of the email alerts appears on
2603 ** standard output.
2604 **
2605 ** This command is intended for testing and debugging Fossil itself,
2606 ** for example when enhancing the email alert system or fixing bugs
2607 ** in the email alert system. If you are not making changes to the
2608 ** Fossil source code, this command is probably not useful to you.
2609 **
2610 ** EVENTIDs are text. The first character is 'c', 'f', 't', or 'w'
2611 ** for check-in, forum, ticket, or wiki. The remaining text is a
2612 ** integer that references the EVENT.OBJID value for the event.
2613 ** Run /timeline?showid to see these OBJID values.
2614 **
2615 ** Options:
2616 **
2617 ** --digest Generate digest alert text
2618 ** --needmod Assume all events are pending moderator approval
@@ -2484,11 +2652,10 @@
2652 blob_append(&out, "\n", 1);
2653 }
2654 blob_append(&out, blob_buffer(&p->txt), blob_size(&p->txt));
2655 }
2656 alert_free_eventlist(pEvent);
 
2657 fossil_print("%s", blob_str(&out));
2658 blob_reset(&out);
2659 db_end_transaction(0);
2660 }
2661
@@ -2539,19 +2706,66 @@
2706 db_end_transaction(0);
2707 if( doAuto ){
2708 alert_backoffice(SENDALERT_TRACE|mFlags);
2709 }
2710 }
2711
2712 /*
2713 ** Minimum number of days between renewal messages
2714 */
2715 #define ALERT_RENEWAL_MSG_FREQUENCY 7 /* Do renewals at most once/week */
2716
2717 /*
2718 ** Construct the header and body for an email message that will alert
2719 ** a subscriber that their subscriptions are about to expire.
2720 */
2721 static void alert_renewal_msg(
2722 Blob *pHdr, /* Write email header here */
2723 Blob *pBody, /* Write email body here */
2724 const char *zCode, /* The subscriber code */
2725 int lastContact, /* Last contact (days since 1970) */
2726 const char *zEAddr, /* Subscriber email address. Send to this. */
2727 const char *zSub, /* Subscription codes */
2728 const char *zRepoName, /* Name of the sending Fossil repostory */
2729 const char *zUrl /* URL for the sending Fossil repostory */
2730 ){
2731 blob_appendf(pHdr,"To: <%s>\r\n", zEAddr);
2732 blob_appendf(pHdr,"Subject: %s Subscription to %s expires soon\r\n",
2733 zRepoName, zUrl);
2734 blob_appendf(pBody,
2735 "\nTo renew your subscription, click the following link:\n"
2736 "\n %s/renew/%s\n\n",
2737 zUrl, zCode
2738 );
2739 blob_appendf(pBody,
2740 "You are currently receiving email notification for the following events\n"
2741 "on the %s Fossil repository at %s:\n\n",
2742 zRepoName, zUrl
2743 );
2744 if( strchr(zSub, 'a') ) blob_appendf(pBody, " * Announcements\n");
2745 if( strchr(zSub, 'c') ) blob_appendf(pBody, " * Check-ins\n");
2746 if( strchr(zSub, 'f') ) blob_appendf(pBody, " * Forum posts\n");
2747 if( strchr(zSub, 't') ) blob_appendf(pBody, " * Ticket changes\n");
2748 if( strchr(zSub, 'w') ) blob_appendf(pBody, " * Wiki changes\n");
2749 blob_appendf(pBody, "\n"
2750 "If you take no action, your subscription will expire and you will be\n"
2751 "unsubscribed in about %d days. To make other changes or to unsubscribe\n"
2752 "immediately, visit the following webpage:\n\n"
2753 " %s/alerts/%s\n\n",
2754 ALERT_RENEWAL_MSG_FREQUENCY, zUrl, zCode
2755 );
2756 }
2757
2758 #if INTERFACE
2759 /*
2760 ** Flags for alert_send_alerts()
2761 */
2762 #define SENDALERT_DIGEST 0x0001 /* Send a digest */
2763 #define SENDALERT_PRESERVE 0x0002 /* Do not mark the task as done */
2764 #define SENDALERT_STDOUT 0x0004 /* Print emails instead of sending */
2765 #define SENDALERT_TRACE 0x0008 /* Trace operation for debugging */
2766 #define SENDALERT_RENEWAL 0x0010 /* Send renewal notices */
2767
2768 #endif /* INTERFACE */
2769
2770 /*
2771 ** Send alert emails to subscribers.
@@ -2598,14 +2812,15 @@
2812 const char *zRepoName;
2813 const char *zFrom;
2814 const char *zDest = (flags & SENDALERT_STDOUT) ? "stdout" : 0;
2815 AlertSender *pSender = 0;
2816 u32 senderFlags = 0;
2817 int iInterval = 0; /* Subscription renewal interval */
2818
2819 if( g.fSqlTrace ) fossil_trace("-- BEGIN alert_send_alerts(%u)\n", flags);
2820 alert_schema(0);
2821 if( !alert_enabled() && (flags & SENDALERT_STDOUT)==0 ) goto send_alert_done;
2822 zUrl = db_get("email-url",0);
2823 if( zUrl==0 ) goto send_alert_done;
2824 zRepoName = db_get("email-subname",0);
2825 if( zRepoName==0 ) goto send_alert_done;
2826 zFrom = db_get("email-self",0);
@@ -2647,11 +2862,11 @@
2862
2863 /* Step 2: compute EmailEvent objects for every notification that
2864 ** needs sending.
2865 */
2866 pEvents = alert_compute_event_text(&nEvent, (flags & SENDALERT_DIGEST)!=0);
2867 if( nEvent==0 ) goto send_alert_expiration_warnings;
2868
2869 /* Step 4a: Update the pending_alerts table to designate the
2870 ** alerts as having all been sent. This is done *before* step (3)
2871 ** so that a crash will not cause alerts to be sent multiple times.
2872 ** Better a missed alert than being spammed with hundreds of alerts
@@ -2682,13 +2897,16 @@
2897 " hex(subscriberCode)," /* 0 */
2898 " semail," /* 1 */
2899 " ssub," /* 2 */
2900 " fullcap(user.cap)" /* 3 */
2901 " FROM subscriber LEFT JOIN user ON (login=suname)"
2902 " WHERE sverified"
2903 " AND NOT sdonotcall"
2904 " AND sdigest IS %s"
2905 " AND coalesce(subscriber.lastContact,subscriber.mtime)>=%d",
2906 zDigest/*safe-for-%s*/,
2907 db_get_int("email-renew-cutoff",0)
2908 );
2909 while( db_step(&q)==SQLITE_ROW ){
2910 const char *zCode = db_column_text(&q, 0);
2911 const char *zSub = db_column_text(&q, 2);
2912 const char *zEmail = db_column_text(&q, 1);
@@ -2753,10 +2971,13 @@
2971 blob_append(&body, "\n", 1);
2972 blob_append(&body, blob_buffer(&p->txt), blob_size(&p->txt));
2973 }
2974 }
2975 if( nHit==0 ) continue;
2976 blob_appendf(&hdr, "List-Unsubscribe: <%s/unsubscribe/%s>\r\n",
2977 zUrl, zCode);
2978 blob_appendf(&hdr, "List-Unsubscribe-Post: List-Unsubscribe=One-Click\r\n");
2979 blob_appendf(&body,"\n-- \nSubscription info: %s/alerts/%s\n",
2980 zUrl, zCode);
2981 alert_send(pSender,&hdr,&body,0);
2982 nSent++;
2983 blob_truncate(&hdr, 0);
@@ -2769,10 +2990,62 @@
2990
2991 /* Step 4b: Update the pending_alerts table to remove all of the
2992 ** alerts that have been completely sent.
2993 */
2994 db_multi_exec("DELETE FROM pending_alert WHERE sentDigest AND sentSep;");
2995
2996 /* Send renewal messages to subscribers whose subscriptions are about
2997 ** to expire. Only do this if:
2998 **
2999 ** (1) email-renew-interval is 14 or greater (or in other words if
3000 ** subscription expiration is enabled).
3001 **
3002 ** (2) The SENDALERT_RENEWAL flag is set
3003 */
3004 send_alert_expiration_warnings:
3005 if( (flags & SENDALERT_RENEWAL)!=0
3006 && (iInterval = db_get_int("email-renew-interval",0))>=14
3007 ){
3008 int iNow = (int)(time(0)/86400);
3009 int iOldWarn = db_get_int("email-renew-warning",0);
3010 int iNewWarn = iNow - iInterval + ALERT_RENEWAL_MSG_FREQUENCY;
3011 if( iNewWarn >= iOldWarn + ALERT_RENEWAL_MSG_FREQUENCY ){
3012 db_prepare(&q,
3013 "SELECT"
3014 " hex(subscriberCode)," /* 0 */
3015 " lastContact," /* 1 */
3016 " semail," /* 2 */
3017 " ssub" /* 3 */
3018 " FROM subscriber"
3019 " WHERE lastContact<=%d AND lastContact>%d"
3020 " AND NOT sdonotcall"
3021 " AND length(sdigest)>0",
3022 iNewWarn, iOldWarn
3023 );
3024 while( db_step(&q)==SQLITE_ROW ){
3025 Blob hdr, body;
3026 blob_init(&hdr, 0, 0);
3027 blob_init(&body, 0, 0);
3028 alert_renewal_msg(&hdr, &body,
3029 db_column_text(&q,0),
3030 db_column_int(&q,1),
3031 db_column_text(&q,2),
3032 db_column_text(&q,3),
3033 zRepoName, zUrl);
3034 alert_send(pSender,&hdr,&body,0);
3035 blob_reset(&hdr);
3036 blob_reset(&body);
3037 }
3038 db_finalize(&q);
3039 if( (flags & SENDALERT_PRESERVE)==0 ){
3040 if( iOldWarn>0 ){
3041 db_set_int("email-renew-cutoff", iOldWarn, 0);
3042 }
3043 db_set_int("email-renew-warning", iNewWarn, 0);
3044 }
3045 }
3046 }
3047
3048 send_alert_done:
3049 alert_sender_free(pSender);
3050 if( g.fSqlTrace ) fossil_trace("-- END alert_send_alerts(%u)\n", flags);
3051 return nSent;
@@ -2795,11 +3068,11 @@
3068 if( !alert_tables_exist() ) return 0;
3069 nSent = alert_send_alerts(mFlags);
3070 iJulianDay = db_int(0, "SELECT julianday('now')");
3071 if( iJulianDay>db_get_int("email-last-digest",0) ){
3072 db_set_int("email-last-digest",iJulianDay,0);
3073 nSent += alert_send_alerts(SENDALERT_DIGEST|SENDALERT_RENEWAL|mFlags);
3074 }
3075 return nSent;
3076 }
3077
3078 /*
3079
--- src/backlink.c
+++ src/backlink.c
@@ -143,10 +143,18 @@
143143
}
144144
case BKLNK_WIKI: {
145145
const char *zName = db_column_text(&q, 4);
146146
@ <td><a href="%R/wiki?name=%h(zName)&p">wiki-%d(srcid)</a>
147147
break;
148
+ }
149
+ case BKLNK_EVENT: {
150
+ @ <td><a href="%R/info?name=rid:%d(srcid)">tecknote-%d(srcid)</a>
151
+ break;
152
+ }
153
+ case BKLNK_FORUM: {
154
+ @ <td><a href="%R/info?name=rid:%d(srcid)">forum-%d(srcid)</a>
155
+ break;
148156
}
149157
default: {
150158
@ <td>unknown(%d(srctype)) - %d(srcid)
151159
break;
152160
}
153161
--- src/backlink.c
+++ src/backlink.c
@@ -143,10 +143,18 @@
143 }
144 case BKLNK_WIKI: {
145 const char *zName = db_column_text(&q, 4);
146 @ <td><a href="%R/wiki?name=%h(zName)&p">wiki-%d(srcid)</a>
147 break;
 
 
 
 
 
 
 
 
148 }
149 default: {
150 @ <td>unknown(%d(srctype)) - %d(srcid)
151 break;
152 }
153
--- src/backlink.c
+++ src/backlink.c
@@ -143,10 +143,18 @@
143 }
144 case BKLNK_WIKI: {
145 const char *zName = db_column_text(&q, 4);
146 @ <td><a href="%R/wiki?name=%h(zName)&p">wiki-%d(srcid)</a>
147 break;
148 }
149 case BKLNK_EVENT: {
150 @ <td><a href="%R/info?name=rid:%d(srcid)">tecknote-%d(srcid)</a>
151 break;
152 }
153 case BKLNK_FORUM: {
154 @ <td><a href="%R/info?name=rid:%d(srcid)">forum-%d(srcid)</a>
155 break;
156 }
157 default: {
158 @ <td>unknown(%d(srctype)) - %d(srcid)
159 break;
160 }
161
+7 -1
--- src/branch.c
+++ src/branch.c
@@ -363,10 +363,12 @@
363363
** List all branches. Options:
364364
** -a|--all List all branches. Default show only open branches
365365
** -c|--closed List closed branches.
366366
** -r Reverse the sort order
367367
** -t Show recently changed branches first
368
+**
369
+** The current branch is marked with an asterisk.
368370
**
369371
** If GLOB is given, show only branches matching the pattern.
370372
**
371373
** > fossil branch new BRANCH-NAME BASIS ?OPTIONS?
372374
**
@@ -472,10 +474,12 @@
472474
login_anonymous_available();
473475
474476
brlist_create_temp_table();
475477
db_prepare(&q, "SELECT * FROM tmp_brlist ORDER BY mtime DESC");
476478
rNow = db_double(0.0, "SELECT julianday('now')");
479
+ @ <script id="brlist-data" type="application/json">\
480
+ @ {"timelineUrl":"%R/timeline"}</script>
477481
@ <div class="brlist">
478482
@ <table class='sortable' data-column-types='tkNtt' data-init-sort='2'>
479483
@ <thead><tr>
480484
@ <th>Branch Name</th>
481485
@ <th>Last Change</th>
@@ -504,11 +508,12 @@
504508
if( zBgClr && zBgClr[0] && show_colors ){
505509
@ <tr style="background-color:%s(zBgClr)">
506510
}else{
507511
@ <tr>
508512
}
509
- @ <td>%z(href("%R/timeline?r=%T",zBranch))%h(zBranch)</a></td>
513
+ @ <td>%z(href("%R/timeline?r=%T",zBranch))%h(zBranch)</a><input
514
+ @ type="checkbox" disabled="disabled"/></td>
510515
@ <td data-sortkey="%016llx(iMtime)">%s(zAge)</td>
511516
@ <td>%d(nCkin)</td>
512517
fossil_free(zAge);
513518
@ <td>%s(isClosed?"closed":"")</td>
514519
if( zMergeTo ){
@@ -519,10 +524,11 @@
519524
}
520525
@ </tr>
521526
}
522527
@ </tbody></table></div>
523528
db_finalize(&q);
529
+ builtin_request_js("fossil.page.brlist.js");
524530
style_table_sorter();
525531
style_finish_page();
526532
}
527533
528534
/*
529535
--- src/branch.c
+++ src/branch.c
@@ -363,10 +363,12 @@
363 ** List all branches. Options:
364 ** -a|--all List all branches. Default show only open branches
365 ** -c|--closed List closed branches.
366 ** -r Reverse the sort order
367 ** -t Show recently changed branches first
 
 
368 **
369 ** If GLOB is given, show only branches matching the pattern.
370 **
371 ** > fossil branch new BRANCH-NAME BASIS ?OPTIONS?
372 **
@@ -472,10 +474,12 @@
472 login_anonymous_available();
473
474 brlist_create_temp_table();
475 db_prepare(&q, "SELECT * FROM tmp_brlist ORDER BY mtime DESC");
476 rNow = db_double(0.0, "SELECT julianday('now')");
 
 
477 @ <div class="brlist">
478 @ <table class='sortable' data-column-types='tkNtt' data-init-sort='2'>
479 @ <thead><tr>
480 @ <th>Branch Name</th>
481 @ <th>Last Change</th>
@@ -504,11 +508,12 @@
504 if( zBgClr && zBgClr[0] && show_colors ){
505 @ <tr style="background-color:%s(zBgClr)">
506 }else{
507 @ <tr>
508 }
509 @ <td>%z(href("%R/timeline?r=%T",zBranch))%h(zBranch)</a></td>
 
510 @ <td data-sortkey="%016llx(iMtime)">%s(zAge)</td>
511 @ <td>%d(nCkin)</td>
512 fossil_free(zAge);
513 @ <td>%s(isClosed?"closed":"")</td>
514 if( zMergeTo ){
@@ -519,10 +524,11 @@
519 }
520 @ </tr>
521 }
522 @ </tbody></table></div>
523 db_finalize(&q);
 
524 style_table_sorter();
525 style_finish_page();
526 }
527
528 /*
529
--- src/branch.c
+++ src/branch.c
@@ -363,10 +363,12 @@
363 ** List all branches. Options:
364 ** -a|--all List all branches. Default show only open branches
365 ** -c|--closed List closed branches.
366 ** -r Reverse the sort order
367 ** -t Show recently changed branches first
368 **
369 ** The current branch is marked with an asterisk.
370 **
371 ** If GLOB is given, show only branches matching the pattern.
372 **
373 ** > fossil branch new BRANCH-NAME BASIS ?OPTIONS?
374 **
@@ -472,10 +474,12 @@
474 login_anonymous_available();
475
476 brlist_create_temp_table();
477 db_prepare(&q, "SELECT * FROM tmp_brlist ORDER BY mtime DESC");
478 rNow = db_double(0.0, "SELECT julianday('now')");
479 @ <script id="brlist-data" type="application/json">\
480 @ {"timelineUrl":"%R/timeline"}</script>
481 @ <div class="brlist">
482 @ <table class='sortable' data-column-types='tkNtt' data-init-sort='2'>
483 @ <thead><tr>
484 @ <th>Branch Name</th>
485 @ <th>Last Change</th>
@@ -504,11 +508,12 @@
508 if( zBgClr && zBgClr[0] && show_colors ){
509 @ <tr style="background-color:%s(zBgClr)">
510 }else{
511 @ <tr>
512 }
513 @ <td>%z(href("%R/timeline?r=%T",zBranch))%h(zBranch)</a><input
514 @ type="checkbox" disabled="disabled"/></td>
515 @ <td data-sortkey="%016llx(iMtime)">%s(zAge)</td>
516 @ <td>%d(nCkin)</td>
517 fossil_free(zAge);
518 @ <td>%s(isClosed?"closed":"")</td>
519 if( zMergeTo ){
@@ -519,10 +524,11 @@
524 }
525 @ </tr>
526 }
527 @ </tbody></table></div>
528 db_finalize(&q);
529 builtin_request_js("fossil.page.brlist.js");
530 style_table_sorter();
531 style_finish_page();
532 }
533
534 /*
535
+10 -10
--- src/chat.c
+++ src/chat.c
@@ -213,18 +213,18 @@
213213
/* Definition of repository tables used by chat
214214
*/
215215
static const char zChatSchema1[] =
216216
@ CREATE TABLE repository.chat(
217217
@ msgid INTEGER PRIMARY KEY AUTOINCREMENT,
218
-@ mtime JULIANDAY, -- Time for this entry - Julianday Zulu
219
-@ lmtime TEXT, -- Localtime when message originally sent
220
-@ xfrom TEXT, -- Login of the sender
221
-@ xmsg TEXT, -- Raw, unformatted text of the message
222
-@ fname TEXT, -- Filename of the uploaded file, or NULL
223
-@ fmime TEXT, -- MIMEType of the upload file, or NULL
224
-@ mdel INT, -- msgid of another message to delete
225
-@ file BLOB -- Text of the uploaded file, or NULL
218
+@ mtime JULIANDAY, -- Time for this entry - Julianday Zulu
219
+@ lmtime TEXT, -- Client YYYY-MM-DDZHH:MM:SS when message originally sent
220
+@ xfrom TEXT, -- Login of the sender
221
+@ xmsg TEXT, -- Raw, unformatted text of the message
222
+@ fname TEXT, -- Filename of the uploaded file, or NULL
223
+@ fmime TEXT, -- MIMEType of the upload file, or NULL
224
+@ mdel INT, -- msgid of another message to delete
225
+@ file BLOB -- Text of the uploaded file, or NULL
226226
@ );
227227
;
228228
229229
230230
/*
@@ -483,12 +483,12 @@
483483
**
484484
** | {
485485
** | "msgs":[
486486
** | {
487487
** | "msgid": integer // message id
488
-** | "mtime": text // When sent: YYYY-MM-DD HH:MM:SS UTC
489
-** | "lmtime: text // Localtime where the message was sent from
488
+** | "mtime": text // When sent: YYYY-MM-DDTHH:MM:SSZ
489
+** | "lmtime: text // Sender's client-side YYYY-MM-DDTHH:MM:SS
490490
** | "xfrom": text // Login name of sender
491491
** | "uclr": text // Color string associated with the user
492492
** | "xmsg": text // HTML text of the message
493493
** | "fsize": integer // file attachment size in bytes
494494
** | "fname": text // Name of file attachment
495495
--- src/chat.c
+++ src/chat.c
@@ -213,18 +213,18 @@
213 /* Definition of repository tables used by chat
214 */
215 static const char zChatSchema1[] =
216 @ CREATE TABLE repository.chat(
217 @ msgid INTEGER PRIMARY KEY AUTOINCREMENT,
218 @ mtime JULIANDAY, -- Time for this entry - Julianday Zulu
219 @ lmtime TEXT, -- Localtime when message originally sent
220 @ xfrom TEXT, -- Login of the sender
221 @ xmsg TEXT, -- Raw, unformatted text of the message
222 @ fname TEXT, -- Filename of the uploaded file, or NULL
223 @ fmime TEXT, -- MIMEType of the upload file, or NULL
224 @ mdel INT, -- msgid of another message to delete
225 @ file BLOB -- Text of the uploaded file, or NULL
226 @ );
227 ;
228
229
230 /*
@@ -483,12 +483,12 @@
483 **
484 ** | {
485 ** | "msgs":[
486 ** | {
487 ** | "msgid": integer // message id
488 ** | "mtime": text // When sent: YYYY-MM-DD HH:MM:SS UTC
489 ** | "lmtime: text // Localtime where the message was sent from
490 ** | "xfrom": text // Login name of sender
491 ** | "uclr": text // Color string associated with the user
492 ** | "xmsg": text // HTML text of the message
493 ** | "fsize": integer // file attachment size in bytes
494 ** | "fname": text // Name of file attachment
495
--- src/chat.c
+++ src/chat.c
@@ -213,18 +213,18 @@
213 /* Definition of repository tables used by chat
214 */
215 static const char zChatSchema1[] =
216 @ CREATE TABLE repository.chat(
217 @ msgid INTEGER PRIMARY KEY AUTOINCREMENT,
218 @ mtime JULIANDAY, -- Time for this entry - Julianday Zulu
219 @ lmtime TEXT, -- Client YYYY-MM-DDZHH:MM:SS when message originally sent
220 @ xfrom TEXT, -- Login of the sender
221 @ xmsg TEXT, -- Raw, unformatted text of the message
222 @ fname TEXT, -- Filename of the uploaded file, or NULL
223 @ fmime TEXT, -- MIMEType of the upload file, or NULL
224 @ mdel INT, -- msgid of another message to delete
225 @ file BLOB -- Text of the uploaded file, or NULL
226 @ );
227 ;
228
229
230 /*
@@ -483,12 +483,12 @@
483 **
484 ** | {
485 ** | "msgs":[
486 ** | {
487 ** | "msgid": integer // message id
488 ** | "mtime": text // When sent: YYYY-MM-DDTHH:MM:SSZ
489 ** | "lmtime: text // Sender's client-side YYYY-MM-DDTHH:MM:SS
490 ** | "xfrom": text // Login name of sender
491 ** | "uclr": text // Color string associated with the user
492 ** | "xmsg": text // HTML text of the message
493 ** | "fsize": integer // file attachment size in bytes
494 ** | "fname": text // Name of file attachment
495
+19 -4
--- src/chat.js
+++ src/chat.js
@@ -94,10 +94,12 @@
9494
return resized;
9595
})();
9696
fossil.FRK = ForceResizeKludge/*for debugging*/;
9797
const Chat = (function(){
9898
const cs = {
99
+ verboseErrors: false /* if true then certain, mostly extraneous,
100
+ error messages may be sent to the console. */,
99101
e:{/*map of certain DOM elements.*/
100102
messageInjectPoint: E1('#message-inject-point'),
101103
pageTitle: E1('head title'),
102104
loadOlderToolbar: undefined /* the load-posts toolbar (dynamically created) */,
103105
inputWrapper: E1("#chat-input-area"),
@@ -226,13 +228,13 @@
226228
}else{
227229
eMsg.scrollIntoView(false);
228230
}
229231
return this;
230232
},
231
- /* Injects element e as a new row in the chat, at the oldest end
232
- of the list if atEnd is truthy, else at the newest end of the
233
- list. */
233
+ /* Injects DOM element e as a new row in the chat, at the oldest
234
+ end of the list if atEnd is truthy, else at the newest end of
235
+ the list. */
234236
injectMessageElem: function f(e, atEnd){
235237
const mip = atEnd ? this.e.loadOlderToolbar : this.e.messageInjectPoint,
236238
holder = this.e.messagesWrapper,
237239
prevMessage = this.e.newestMessage;
238240
if(atEnd){
@@ -736,10 +738,23 @@
736738
btnDeleteGlobal.addEventListener('click', function(){
737739
self.hide();
738740
Chat.deleteMessage(eMsg);
739741
});
740742
}
743
+ if(eMsg.dataset.xfrom){
744
+ /* Add a link to the /timeline filtered on this user. */
745
+ const toolbar2 = D.addClass(D.div(), 'toolbar');
746
+ D.append(this.e, toolbar2);
747
+ const timelineLink = D.attr(
748
+ D.a(F.repoUrl('timeline',{
749
+ u: eMsg.dataset.xfrom,
750
+ y: 'a'
751
+ }), "User's Timeline"),
752
+ 'target', '_blank'
753
+ );
754
+ D.append(toolbar2, timelineLink);
755
+ }
741756
}/*refresh()*/
742757
});
743758
f.popup.installHideHandlers();
744759
f.popup.hide = function(){
745760
delete this._eMsg;
@@ -1229,11 +1244,11 @@
12291244
// Disable the ajax start/end handling for this long-polling op:
12301245
beforesend: function(){},
12311246
aftersend: function(){},
12321247
onerror:function(err){
12331248
Chat._isBatchLoading = false;
1234
- console.error(err);
1249
+ if(Chat.verboseErrors) console.error(err);
12351250
/* ^^^ we don't use Chat.reportError() here b/c the polling
12361251
fails exepectedly when it times out, but is then immediately
12371252
resumed, and reportError() produces a loud error message. */
12381253
afterFetch();
12391254
},
12401255
--- src/chat.js
+++ src/chat.js
@@ -94,10 +94,12 @@
94 return resized;
95 })();
96 fossil.FRK = ForceResizeKludge/*for debugging*/;
97 const Chat = (function(){
98 const cs = {
 
 
99 e:{/*map of certain DOM elements.*/
100 messageInjectPoint: E1('#message-inject-point'),
101 pageTitle: E1('head title'),
102 loadOlderToolbar: undefined /* the load-posts toolbar (dynamically created) */,
103 inputWrapper: E1("#chat-input-area"),
@@ -226,13 +228,13 @@
226 }else{
227 eMsg.scrollIntoView(false);
228 }
229 return this;
230 },
231 /* Injects element e as a new row in the chat, at the oldest end
232 of the list if atEnd is truthy, else at the newest end of the
233 list. */
234 injectMessageElem: function f(e, atEnd){
235 const mip = atEnd ? this.e.loadOlderToolbar : this.e.messageInjectPoint,
236 holder = this.e.messagesWrapper,
237 prevMessage = this.e.newestMessage;
238 if(atEnd){
@@ -736,10 +738,23 @@
736 btnDeleteGlobal.addEventListener('click', function(){
737 self.hide();
738 Chat.deleteMessage(eMsg);
739 });
740 }
 
 
 
 
 
 
 
 
 
 
 
 
 
741 }/*refresh()*/
742 });
743 f.popup.installHideHandlers();
744 f.popup.hide = function(){
745 delete this._eMsg;
@@ -1229,11 +1244,11 @@
1229 // Disable the ajax start/end handling for this long-polling op:
1230 beforesend: function(){},
1231 aftersend: function(){},
1232 onerror:function(err){
1233 Chat._isBatchLoading = false;
1234 console.error(err);
1235 /* ^^^ we don't use Chat.reportError() here b/c the polling
1236 fails exepectedly when it times out, but is then immediately
1237 resumed, and reportError() produces a loud error message. */
1238 afterFetch();
1239 },
1240
--- src/chat.js
+++ src/chat.js
@@ -94,10 +94,12 @@
94 return resized;
95 })();
96 fossil.FRK = ForceResizeKludge/*for debugging*/;
97 const Chat = (function(){
98 const cs = {
99 verboseErrors: false /* if true then certain, mostly extraneous,
100 error messages may be sent to the console. */,
101 e:{/*map of certain DOM elements.*/
102 messageInjectPoint: E1('#message-inject-point'),
103 pageTitle: E1('head title'),
104 loadOlderToolbar: undefined /* the load-posts toolbar (dynamically created) */,
105 inputWrapper: E1("#chat-input-area"),
@@ -226,13 +228,13 @@
228 }else{
229 eMsg.scrollIntoView(false);
230 }
231 return this;
232 },
233 /* Injects DOM element e as a new row in the chat, at the oldest
234 end of the list if atEnd is truthy, else at the newest end of
235 the list. */
236 injectMessageElem: function f(e, atEnd){
237 const mip = atEnd ? this.e.loadOlderToolbar : this.e.messageInjectPoint,
238 holder = this.e.messagesWrapper,
239 prevMessage = this.e.newestMessage;
240 if(atEnd){
@@ -736,10 +738,23 @@
738 btnDeleteGlobal.addEventListener('click', function(){
739 self.hide();
740 Chat.deleteMessage(eMsg);
741 });
742 }
743 if(eMsg.dataset.xfrom){
744 /* Add a link to the /timeline filtered on this user. */
745 const toolbar2 = D.addClass(D.div(), 'toolbar');
746 D.append(this.e, toolbar2);
747 const timelineLink = D.attr(
748 D.a(F.repoUrl('timeline',{
749 u: eMsg.dataset.xfrom,
750 y: 'a'
751 }), "User's Timeline"),
752 'target', '_blank'
753 );
754 D.append(toolbar2, timelineLink);
755 }
756 }/*refresh()*/
757 });
758 f.popup.installHideHandlers();
759 f.popup.hide = function(){
760 delete this._eMsg;
@@ -1229,11 +1244,11 @@
1244 // Disable the ajax start/end handling for this long-polling op:
1245 beforesend: function(){},
1246 aftersend: function(){},
1247 onerror:function(err){
1248 Chat._isBatchLoading = false;
1249 if(Chat.verboseErrors) console.error(err);
1250 /* ^^^ we don't use Chat.reportError() here b/c the polling
1251 fails exepectedly when it times out, but is then immediately
1252 resumed, and reportError() produces a loud error message. */
1253 afterFetch();
1254 },
1255
+11 -16
--- src/clone.c
+++ src/clone.c
@@ -286,29 +286,24 @@
286286
fossil_print("\nproject-id: %s\n", db_get("project-code", 0));
287287
fossil_print("server-id: %s\n", db_get("server-code", 0));
288288
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
289289
fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
290290
if( zWorkDir!=0 && zWorkDir[0]!=0 && !noOpen ){
291
- char *azNew[7];
292
- int nargs = 5;
291
+ Blob cmd;
293292
fossil_print("opening the new %s repository in directory %s...\n",
294293
zRepo, zWorkDir);
295
- azNew[0] = g.argv[0];
296
- azNew[1] = "open";
297
- azNew[2] = (char*)zRepo;
298
- azNew[3] = "--workdir";
299
- azNew[4] = (char*)zWorkDir;
294
+ blob_init(&cmd, 0, 0);
295
+ blob_append_escaped_arg(&cmd, g.nameOfExe);
296
+ blob_append(&cmd, " open ", -1);
297
+ blob_append_escaped_arg(&cmd, zRepo);
298
+ blob_append(&cmd, " --workdir ", -1);
299
+ blob_append_escaped_arg(&cmd, zWorkDir);
300300
if( allowNested ){
301
- azNew[5] = "--nested";
302
- nargs++;
303
- }else{
304
- azNew[5] = 0;
305
- }
306
- azNew[6] = 0;
307
- g.argv = azNew;
308
- g.argc = nargs;
309
- cmd_open();
301
+ blob_append(&cmd, " --nested", -1);
302
+ }
303
+ fossil_system(blob_str(&cmd));
304
+ blob_reset(&cmd);
310305
}
311306
}
312307
313308
/*
314309
** If user chooses to use HTTP Authentication over unencrypted HTTP,
315310
--- src/clone.c
+++ src/clone.c
@@ -286,29 +286,24 @@
286 fossil_print("\nproject-id: %s\n", db_get("project-code", 0));
287 fossil_print("server-id: %s\n", db_get("server-code", 0));
288 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
289 fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
290 if( zWorkDir!=0 && zWorkDir[0]!=0 && !noOpen ){
291 char *azNew[7];
292 int nargs = 5;
293 fossil_print("opening the new %s repository in directory %s...\n",
294 zRepo, zWorkDir);
295 azNew[0] = g.argv[0];
296 azNew[1] = "open";
297 azNew[2] = (char*)zRepo;
298 azNew[3] = "--workdir";
299 azNew[4] = (char*)zWorkDir;
 
300 if( allowNested ){
301 azNew[5] = "--nested";
302 nargs++;
303 }else{
304 azNew[5] = 0;
305 }
306 azNew[6] = 0;
307 g.argv = azNew;
308 g.argc = nargs;
309 cmd_open();
310 }
311 }
312
313 /*
314 ** If user chooses to use HTTP Authentication over unencrypted HTTP,
315
--- src/clone.c
+++ src/clone.c
@@ -286,29 +286,24 @@
286 fossil_print("\nproject-id: %s\n", db_get("project-code", 0));
287 fossil_print("server-id: %s\n", db_get("server-code", 0));
288 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
289 fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
290 if( zWorkDir!=0 && zWorkDir[0]!=0 && !noOpen ){
291 Blob cmd;
 
292 fossil_print("opening the new %s repository in directory %s...\n",
293 zRepo, zWorkDir);
294 blob_init(&cmd, 0, 0);
295 blob_append_escaped_arg(&cmd, g.nameOfExe);
296 blob_append(&cmd, " open ", -1);
297 blob_append_escaped_arg(&cmd, zRepo);
298 blob_append(&cmd, " --workdir ", -1);
299 blob_append_escaped_arg(&cmd, zWorkDir);
300 if( allowNested ){
301 blob_append(&cmd, " --nested", -1);
302 }
303 fossil_system(blob_str(&cmd));
304 blob_reset(&cmd);
 
 
 
 
 
305 }
306 }
307
308 /*
309 ** If user chooses to use HTTP Authentication over unencrypted HTTP,
310
+39 -6
--- src/db.c
+++ src/db.c
@@ -864,23 +864,55 @@
864864
db_exec(&err);
865865
}
866866
867867
/*
868868
** COMMAND: test-db-prepare
869
-** Usage: %fossil test-db-prepare ?OPTIONS? SQL
869
+** Usage: %fossil test-db-prepare ?OPTIONS? SQL-STATEMENT
870
+**
871
+** Options:
872
+**
873
+** --auth-report Enable the ticket report query authorizer.
874
+** --auth-ticket Enable the ticket schema query authorizer.
870875
**
871876
** Invoke db_prepare() on the SQL input. Report any errors encountered.
872877
** This command is used to verify error detection logic in the db_prepare()
873878
** utility routine.
874879
*/
875880
void db_test_db_prepare(void){
881
+ const int fAuthReport = find_option("auth-report",0,0)!=0;
882
+ const int fAuthSchema = find_option("auth-ticket",0,0)!=0;
883
+ char * zReportErr = 0; /* auth-report error string. */
884
+ int nSchemaErr = 0; /* Number of auth-ticket errors. */
876885
Stmt err;
886
+
887
+ if(fAuthReport + fAuthSchema > 1){
888
+ fossil_fatal("Only one of --auth-report or --auth-ticket "
889
+ "may be used.");
890
+ }
877891
db_find_and_open_repository(0,0);
878892
verify_all_options();
879893
if( g.argc!=3 ) usage("?OPTIONS? SQL");
894
+ if(fAuthReport){
895
+ report_restrict_sql(&zReportErr);
896
+ }else if(fAuthSchema){
897
+ ticket_restrict_sql(&nSchemaErr);
898
+ }
880899
db_prepare(&err, "%s", g.argv[2]/*safe-for-%s*/);
881900
db_finalize(&err);
901
+ if(fAuthReport){
902
+ report_unrestrict_sql();
903
+ if(zReportErr){
904
+ fossil_warning("Report authorizer error: %s\n", zReportErr);
905
+ fossil_free(zReportErr);
906
+ }
907
+ }else if(fAuthSchema){
908
+ ticket_unrestrict_sql();
909
+ if(nSchemaErr){
910
+ fossil_warning("Ticket schema authorizer error count: %d\n",
911
+ nSchemaErr);
912
+ }
913
+ }
882914
}
883915
884916
/*
885917
** Print the output of one or more SQL queries on standard output.
886918
** This routine is used for debugging purposes only.
@@ -1711,15 +1743,16 @@
17111743
int iSlot = -1;
17121744
int rc;
17131745
Stmt q;
17141746
if( g.db==0 ) return iSlot;
17151747
rc = db_prepare_ignore_error(&q, "PRAGMA database_list");
1716
- if( rc!=SQLITE_OK ) return iSlot;
1717
- while( db_step(&q)==SQLITE_ROW ){
1718
- if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){
1719
- iSlot = db_column_int(&q, 0);
1720
- break;
1748
+ if( rc==SQLITE_OK ){
1749
+ while( db_step(&q)==SQLITE_ROW ){
1750
+ if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){
1751
+ iSlot = db_column_int(&q, 0);
1752
+ break;
1753
+ }
17211754
}
17221755
}
17231756
db_finalize(&q);
17241757
return iSlot;
17251758
}
17261759
--- src/db.c
+++ src/db.c
@@ -864,23 +864,55 @@
864 db_exec(&err);
865 }
866
867 /*
868 ** COMMAND: test-db-prepare
869 ** Usage: %fossil test-db-prepare ?OPTIONS? SQL
 
 
 
 
 
870 **
871 ** Invoke db_prepare() on the SQL input. Report any errors encountered.
872 ** This command is used to verify error detection logic in the db_prepare()
873 ** utility routine.
874 */
875 void db_test_db_prepare(void){
 
 
 
 
876 Stmt err;
 
 
 
 
 
877 db_find_and_open_repository(0,0);
878 verify_all_options();
879 if( g.argc!=3 ) usage("?OPTIONS? SQL");
 
 
 
 
 
880 db_prepare(&err, "%s", g.argv[2]/*safe-for-%s*/);
881 db_finalize(&err);
 
 
 
 
 
 
 
 
 
 
 
 
 
882 }
883
884 /*
885 ** Print the output of one or more SQL queries on standard output.
886 ** This routine is used for debugging purposes only.
@@ -1711,15 +1743,16 @@
1711 int iSlot = -1;
1712 int rc;
1713 Stmt q;
1714 if( g.db==0 ) return iSlot;
1715 rc = db_prepare_ignore_error(&q, "PRAGMA database_list");
1716 if( rc!=SQLITE_OK ) return iSlot;
1717 while( db_step(&q)==SQLITE_ROW ){
1718 if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){
1719 iSlot = db_column_int(&q, 0);
1720 break;
 
1721 }
1722 }
1723 db_finalize(&q);
1724 return iSlot;
1725 }
1726
--- src/db.c
+++ src/db.c
@@ -864,23 +864,55 @@
864 db_exec(&err);
865 }
866
867 /*
868 ** COMMAND: test-db-prepare
869 ** Usage: %fossil test-db-prepare ?OPTIONS? SQL-STATEMENT
870 **
871 ** Options:
872 **
873 ** --auth-report Enable the ticket report query authorizer.
874 ** --auth-ticket Enable the ticket schema query authorizer.
875 **
876 ** Invoke db_prepare() on the SQL input. Report any errors encountered.
877 ** This command is used to verify error detection logic in the db_prepare()
878 ** utility routine.
879 */
880 void db_test_db_prepare(void){
881 const int fAuthReport = find_option("auth-report",0,0)!=0;
882 const int fAuthSchema = find_option("auth-ticket",0,0)!=0;
883 char * zReportErr = 0; /* auth-report error string. */
884 int nSchemaErr = 0; /* Number of auth-ticket errors. */
885 Stmt err;
886
887 if(fAuthReport + fAuthSchema > 1){
888 fossil_fatal("Only one of --auth-report or --auth-ticket "
889 "may be used.");
890 }
891 db_find_and_open_repository(0,0);
892 verify_all_options();
893 if( g.argc!=3 ) usage("?OPTIONS? SQL");
894 if(fAuthReport){
895 report_restrict_sql(&zReportErr);
896 }else if(fAuthSchema){
897 ticket_restrict_sql(&nSchemaErr);
898 }
899 db_prepare(&err, "%s", g.argv[2]/*safe-for-%s*/);
900 db_finalize(&err);
901 if(fAuthReport){
902 report_unrestrict_sql();
903 if(zReportErr){
904 fossil_warning("Report authorizer error: %s\n", zReportErr);
905 fossil_free(zReportErr);
906 }
907 }else if(fAuthSchema){
908 ticket_unrestrict_sql();
909 if(nSchemaErr){
910 fossil_warning("Ticket schema authorizer error count: %d\n",
911 nSchemaErr);
912 }
913 }
914 }
915
916 /*
917 ** Print the output of one or more SQL queries on standard output.
918 ** This routine is used for debugging purposes only.
@@ -1711,15 +1743,16 @@
1743 int iSlot = -1;
1744 int rc;
1745 Stmt q;
1746 if( g.db==0 ) return iSlot;
1747 rc = db_prepare_ignore_error(&q, "PRAGMA database_list");
1748 if( rc==SQLITE_OK ){
1749 while( db_step(&q)==SQLITE_ROW ){
1750 if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){
1751 iSlot = db_column_int(&q, 0);
1752 break;
1753 }
1754 }
1755 }
1756 db_finalize(&q);
1757 return iSlot;
1758 }
1759
+39 -6
--- src/db.c
+++ src/db.c
@@ -864,23 +864,55 @@
864864
db_exec(&err);
865865
}
866866
867867
/*
868868
** COMMAND: test-db-prepare
869
-** Usage: %fossil test-db-prepare ?OPTIONS? SQL
869
+** Usage: %fossil test-db-prepare ?OPTIONS? SQL-STATEMENT
870
+**
871
+** Options:
872
+**
873
+** --auth-report Enable the ticket report query authorizer.
874
+** --auth-ticket Enable the ticket schema query authorizer.
870875
**
871876
** Invoke db_prepare() on the SQL input. Report any errors encountered.
872877
** This command is used to verify error detection logic in the db_prepare()
873878
** utility routine.
874879
*/
875880
void db_test_db_prepare(void){
881
+ const int fAuthReport = find_option("auth-report",0,0)!=0;
882
+ const int fAuthSchema = find_option("auth-ticket",0,0)!=0;
883
+ char * zReportErr = 0; /* auth-report error string. */
884
+ int nSchemaErr = 0; /* Number of auth-ticket errors. */
876885
Stmt err;
886
+
887
+ if(fAuthReport + fAuthSchema > 1){
888
+ fossil_fatal("Only one of --auth-report or --auth-ticket "
889
+ "may be used.");
890
+ }
877891
db_find_and_open_repository(0,0);
878892
verify_all_options();
879893
if( g.argc!=3 ) usage("?OPTIONS? SQL");
894
+ if(fAuthReport){
895
+ report_restrict_sql(&zReportErr);
896
+ }else if(fAuthSchema){
897
+ ticket_restrict_sql(&nSchemaErr);
898
+ }
880899
db_prepare(&err, "%s", g.argv[2]/*safe-for-%s*/);
881900
db_finalize(&err);
901
+ if(fAuthReport){
902
+ report_unrestrict_sql();
903
+ if(zReportErr){
904
+ fossil_warning("Report authorizer error: %s\n", zReportErr);
905
+ fossil_free(zReportErr);
906
+ }
907
+ }else if(fAuthSchema){
908
+ ticket_unrestrict_sql();
909
+ if(nSchemaErr){
910
+ fossil_warning("Ticket schema authorizer error count: %d\n",
911
+ nSchemaErr);
912
+ }
913
+ }
882914
}
883915
884916
/*
885917
** Print the output of one or more SQL queries on standard output.
886918
** This routine is used for debugging purposes only.
@@ -1711,15 +1743,16 @@
17111743
int iSlot = -1;
17121744
int rc;
17131745
Stmt q;
17141746
if( g.db==0 ) return iSlot;
17151747
rc = db_prepare_ignore_error(&q, "PRAGMA database_list");
1716
- if( rc!=SQLITE_OK ) return iSlot;
1717
- while( db_step(&q)==SQLITE_ROW ){
1718
- if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){
1719
- iSlot = db_column_int(&q, 0);
1720
- break;
1748
+ if( rc==SQLITE_OK ){
1749
+ while( db_step(&q)==SQLITE_ROW ){
1750
+ if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){
1751
+ iSlot = db_column_int(&q, 0);
1752
+ break;
1753
+ }
17211754
}
17221755
}
17231756
db_finalize(&q);
17241757
return iSlot;
17251758
}
17261759
--- src/db.c
+++ src/db.c
@@ -864,23 +864,55 @@
864 db_exec(&err);
865 }
866
867 /*
868 ** COMMAND: test-db-prepare
869 ** Usage: %fossil test-db-prepare ?OPTIONS? SQL
 
 
 
 
 
870 **
871 ** Invoke db_prepare() on the SQL input. Report any errors encountered.
872 ** This command is used to verify error detection logic in the db_prepare()
873 ** utility routine.
874 */
875 void db_test_db_prepare(void){
 
 
 
 
876 Stmt err;
 
 
 
 
 
877 db_find_and_open_repository(0,0);
878 verify_all_options();
879 if( g.argc!=3 ) usage("?OPTIONS? SQL");
 
 
 
 
 
880 db_prepare(&err, "%s", g.argv[2]/*safe-for-%s*/);
881 db_finalize(&err);
 
 
 
 
 
 
 
 
 
 
 
 
 
882 }
883
884 /*
885 ** Print the output of one or more SQL queries on standard output.
886 ** This routine is used for debugging purposes only.
@@ -1711,15 +1743,16 @@
1711 int iSlot = -1;
1712 int rc;
1713 Stmt q;
1714 if( g.db==0 ) return iSlot;
1715 rc = db_prepare_ignore_error(&q, "PRAGMA database_list");
1716 if( rc!=SQLITE_OK ) return iSlot;
1717 while( db_step(&q)==SQLITE_ROW ){
1718 if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){
1719 iSlot = db_column_int(&q, 0);
1720 break;
 
1721 }
1722 }
1723 db_finalize(&q);
1724 return iSlot;
1725 }
1726
--- src/db.c
+++ src/db.c
@@ -864,23 +864,55 @@
864 db_exec(&err);
865 }
866
867 /*
868 ** COMMAND: test-db-prepare
869 ** Usage: %fossil test-db-prepare ?OPTIONS? SQL-STATEMENT
870 **
871 ** Options:
872 **
873 ** --auth-report Enable the ticket report query authorizer.
874 ** --auth-ticket Enable the ticket schema query authorizer.
875 **
876 ** Invoke db_prepare() on the SQL input. Report any errors encountered.
877 ** This command is used to verify error detection logic in the db_prepare()
878 ** utility routine.
879 */
880 void db_test_db_prepare(void){
881 const int fAuthReport = find_option("auth-report",0,0)!=0;
882 const int fAuthSchema = find_option("auth-ticket",0,0)!=0;
883 char * zReportErr = 0; /* auth-report error string. */
884 int nSchemaErr = 0; /* Number of auth-ticket errors. */
885 Stmt err;
886
887 if(fAuthReport + fAuthSchema > 1){
888 fossil_fatal("Only one of --auth-report or --auth-ticket "
889 "may be used.");
890 }
891 db_find_and_open_repository(0,0);
892 verify_all_options();
893 if( g.argc!=3 ) usage("?OPTIONS? SQL");
894 if(fAuthReport){
895 report_restrict_sql(&zReportErr);
896 }else if(fAuthSchema){
897 ticket_restrict_sql(&nSchemaErr);
898 }
899 db_prepare(&err, "%s", g.argv[2]/*safe-for-%s*/);
900 db_finalize(&err);
901 if(fAuthReport){
902 report_unrestrict_sql();
903 if(zReportErr){
904 fossil_warning("Report authorizer error: %s\n", zReportErr);
905 fossil_free(zReportErr);
906 }
907 }else if(fAuthSchema){
908 ticket_unrestrict_sql();
909 if(nSchemaErr){
910 fossil_warning("Ticket schema authorizer error count: %d\n",
911 nSchemaErr);
912 }
913 }
914 }
915
916 /*
917 ** Print the output of one or more SQL queries on standard output.
918 ** This routine is used for debugging purposes only.
@@ -1711,15 +1743,16 @@
1743 int iSlot = -1;
1744 int rc;
1745 Stmt q;
1746 if( g.db==0 ) return iSlot;
1747 rc = db_prepare_ignore_error(&q, "PRAGMA database_list");
1748 if( rc==SQLITE_OK ){
1749 while( db_step(&q)==SQLITE_ROW ){
1750 if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){
1751 iSlot = db_column_int(&q, 0);
1752 break;
1753 }
1754 }
1755 }
1756 db_finalize(&q);
1757 return iSlot;
1758 }
1759
--- src/default.css
+++ src/default.css
@@ -1287,10 +1287,14 @@
12871287
/* problem: if we inherit the color it may either be
12881288
transparent or inherit translucency via the
12891289
skin, leaving it unreadable. Since we set the bg
12901290
color we must also set the fg color. */;
12911291
color: rgba(235, 235, 235, 0.9);
1292
+}
1293
+.fossil-PopupWidget a,
1294
+.fossil-PopupWidget a:visited {
1295
+ color: initial;
12921296
}
12931297
.fossil-toast-message.error,
12941298
.fossil-toast-message.warning {
12951299
background: yellow;
12961300
}
@@ -1772,10 +1776,30 @@
17721776
}
17731777
17741778
input[type="checkbox"].diff-toggle {
17751779
float: right;
17761780
}
1781
+
1782
+body.branch .brlist > table > tbody > tr:hover:not(.selected),
1783
+body.branch .brlist > table > tbody > tr.selected {
1784
+ background-color: #ffc;
1785
+}
1786
+body.branch .brlist > table > tbody td:first-child > input {
1787
+ cursor: pointer;
1788
+}
1789
+body.branch .brlist > table > tbody > tr > td:nth-child(1) {
1790
+ display: flex;
1791
+ flex-direction: row;
1792
+ justify-content: space-between;
1793
+}
1794
+body.branch .submenu > a.timeline-link {
1795
+ display: none;
1796
+}
1797
+body.branch .submenu > a.timeline-link.selected {
1798
+ display: inline;
1799
+}
1800
+
17771801
/* Objects in the "desktoponly" class are invisible on mobile */
17781802
@media screen and (max-width: 600px) {
17791803
.desktoponly {
17801804
display: none;
17811805
}
17821806
--- src/default.css
+++ src/default.css
@@ -1287,10 +1287,14 @@
1287 /* problem: if we inherit the color it may either be
1288 transparent or inherit translucency via the
1289 skin, leaving it unreadable. Since we set the bg
1290 color we must also set the fg color. */;
1291 color: rgba(235, 235, 235, 0.9);
 
 
 
 
1292 }
1293 .fossil-toast-message.error,
1294 .fossil-toast-message.warning {
1295 background: yellow;
1296 }
@@ -1772,10 +1776,30 @@
1772 }
1773
1774 input[type="checkbox"].diff-toggle {
1775 float: right;
1776 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1777 /* Objects in the "desktoponly" class are invisible on mobile */
1778 @media screen and (max-width: 600px) {
1779 .desktoponly {
1780 display: none;
1781 }
1782
--- src/default.css
+++ src/default.css
@@ -1287,10 +1287,14 @@
1287 /* problem: if we inherit the color it may either be
1288 transparent or inherit translucency via the
1289 skin, leaving it unreadable. Since we set the bg
1290 color we must also set the fg color. */;
1291 color: rgba(235, 235, 235, 0.9);
1292 }
1293 .fossil-PopupWidget a,
1294 .fossil-PopupWidget a:visited {
1295 color: initial;
1296 }
1297 .fossil-toast-message.error,
1298 .fossil-toast-message.warning {
1299 background: yellow;
1300 }
@@ -1772,10 +1776,30 @@
1776 }
1777
1778 input[type="checkbox"].diff-toggle {
1779 float: right;
1780 }
1781
1782 body.branch .brlist > table > tbody > tr:hover:not(.selected),
1783 body.branch .brlist > table > tbody > tr.selected {
1784 background-color: #ffc;
1785 }
1786 body.branch .brlist > table > tbody td:first-child > input {
1787 cursor: pointer;
1788 }
1789 body.branch .brlist > table > tbody > tr > td:nth-child(1) {
1790 display: flex;
1791 flex-direction: row;
1792 justify-content: space-between;
1793 }
1794 body.branch .submenu > a.timeline-link {
1795 display: none;
1796 }
1797 body.branch .submenu > a.timeline-link.selected {
1798 display: inline;
1799 }
1800
1801 /* Objects in the "desktoponly" class are invisible on mobile */
1802 @media screen and (max-width: 600px) {
1803 .desktoponly {
1804 display: none;
1805 }
1806
+2 -2
--- src/file.c
+++ src/file.c
@@ -2164,12 +2164,12 @@
21642164
#endif
21652165
return z;
21662166
}
21672167
21682168
/*
2169
-** Count the number of objects (files and subdirectores) in a given
2170
-** directory. Return the count. Return -1 of the object is not a
2169
+** Count the number of objects (files and subdirectories) in a given
2170
+** directory. Return the count. Return -1 if the object is not a
21712171
** directory.
21722172
*/
21732173
int file_directory_size(const char *zDir, const char *zGlob, int omitDotFiles){
21742174
void *zNative;
21752175
DIR *d;
21762176
--- src/file.c
+++ src/file.c
@@ -2164,12 +2164,12 @@
2164 #endif
2165 return z;
2166 }
2167
2168 /*
2169 ** Count the number of objects (files and subdirectores) in a given
2170 ** directory. Return the count. Return -1 of the object is not a
2171 ** directory.
2172 */
2173 int file_directory_size(const char *zDir, const char *zGlob, int omitDotFiles){
2174 void *zNative;
2175 DIR *d;
2176
--- src/file.c
+++ src/file.c
@@ -2164,12 +2164,12 @@
2164 #endif
2165 return z;
2166 }
2167
2168 /*
2169 ** Count the number of objects (files and subdirectories) in a given
2170 ** directory. Return the count. Return -1 if the object is not a
2171 ** directory.
2172 */
2173 int file_directory_size(const char *zDir, const char *zGlob, int omitDotFiles){
2174 void *zNative;
2175 DIR *d;
2176
+8 -4
--- src/forum.c
+++ src/forum.c
@@ -546,16 +546,16 @@
546546
@ .%0*d(fossil_num_digits(p->nEdit))(p->pEditNext->rev)</a>
547547
}
548548
549549
/* Provide a link to select the individual post. */
550550
if( !bSelect ){
551
- @ %z(href("%R/forumpost/%S?%s",p->zUuid,zQuery))[link]</a>
551
+ @ %z(href("%R/forumpost/%!S?%s",p->zUuid,zQuery))[link]</a>
552552
}
553553
554554
/* Provide a link to the raw source code. */
555555
if( !bUnf ){
556
- @ %z(href("%R/forumpost/%S?raw",p->zUuid))[source]</a>
556
+ @ %z(href("%R/forumpost/%!S?raw",p->zUuid))[source]</a>
557557
}
558558
@ </h3>
559559
}
560560
561561
/* Check if this post is approved, also if it's by the current user. */
@@ -1173,19 +1173,20 @@
11731173
Manifest *pRootPost = 0;
11741174
const char *zMimetype = 0;
11751175
const char *zContent = 0;
11761176
const char *zTitle = 0;
11771177
char *zDate = 0;
1178
+ const char *zFpid = PD("fpid","");
11781179
int isCsrfSafe;
11791180
int isDelete = 0;
11801181
11811182
login_check_credentials();
11821183
if( !g.perm.WrForum ){
11831184
login_needed(g.anon.WrForum);
11841185
return;
11851186
}
1186
- fpid = symbolic_name_to_rid(PD("fpid",""), "f");
1187
+ fpid = symbolic_name_to_rid(zFpid, "f");
11871188
if( fpid<=0 || (pPost = manifest_get(fpid, CFTYPE_FORUM, 0))==0 ){
11881189
webpage_error("Missing or invalid fpid query parameter");
11891190
}
11901191
froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid);
11911192
if( froot==0 || (pRootPost = manifest_get(froot, CFTYPE_FORUM, 0))==0 ){
@@ -1296,11 +1297,14 @@
12961297
zContent = PDT("content","");
12971298
style_header("Reply");
12981299
if( pRootPost->zThreadTitle ){
12991300
@ <h1>Thread: %h(pRootPost->zThreadTitle)</h1>
13001301
}
1301
- @ <h2>Replying To:</h2>
1302
+ @ <h2>Replying To:
1303
+ @ <a href="%R/forumpost/%!S(zFpid)" target="_blank">%S(zFpid)</a>
1304
+ @ <a href="%R/forumpost/%!S(zFpid)?raw" target="_blank">[source]</a>
1305
+ @ </h2>
13021306
zDate = db_text(0, "SELECT datetime(%.17g,toLocal())", pPost->rDate);
13031307
zDisplayName = display_name_from_login(pPost->zUser);
13041308
@ <h3 class='forumPostHdr'>By %s(zDisplayName) on %h(zDate)</h3>
13051309
fossil_free(zDisplayName);
13061310
fossil_free(zDate);
13071311
13081312
ADDED src/fossil.page.brlist.js
--- src/forum.c
+++ src/forum.c
@@ -546,16 +546,16 @@
546 @ .%0*d(fossil_num_digits(p->nEdit))(p->pEditNext->rev)</a>
547 }
548
549 /* Provide a link to select the individual post. */
550 if( !bSelect ){
551 @ %z(href("%R/forumpost/%S?%s",p->zUuid,zQuery))[link]</a>
552 }
553
554 /* Provide a link to the raw source code. */
555 if( !bUnf ){
556 @ %z(href("%R/forumpost/%S?raw",p->zUuid))[source]</a>
557 }
558 @ </h3>
559 }
560
561 /* Check if this post is approved, also if it's by the current user. */
@@ -1173,19 +1173,20 @@
1173 Manifest *pRootPost = 0;
1174 const char *zMimetype = 0;
1175 const char *zContent = 0;
1176 const char *zTitle = 0;
1177 char *zDate = 0;
 
1178 int isCsrfSafe;
1179 int isDelete = 0;
1180
1181 login_check_credentials();
1182 if( !g.perm.WrForum ){
1183 login_needed(g.anon.WrForum);
1184 return;
1185 }
1186 fpid = symbolic_name_to_rid(PD("fpid",""), "f");
1187 if( fpid<=0 || (pPost = manifest_get(fpid, CFTYPE_FORUM, 0))==0 ){
1188 webpage_error("Missing or invalid fpid query parameter");
1189 }
1190 froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid);
1191 if( froot==0 || (pRootPost = manifest_get(froot, CFTYPE_FORUM, 0))==0 ){
@@ -1296,11 +1297,14 @@
1296 zContent = PDT("content","");
1297 style_header("Reply");
1298 if( pRootPost->zThreadTitle ){
1299 @ <h1>Thread: %h(pRootPost->zThreadTitle)</h1>
1300 }
1301 @ <h2>Replying To:</h2>
 
 
 
1302 zDate = db_text(0, "SELECT datetime(%.17g,toLocal())", pPost->rDate);
1303 zDisplayName = display_name_from_login(pPost->zUser);
1304 @ <h3 class='forumPostHdr'>By %s(zDisplayName) on %h(zDate)</h3>
1305 fossil_free(zDisplayName);
1306 fossil_free(zDate);
1307
1308 DDED src/fossil.page.brlist.js
--- src/forum.c
+++ src/forum.c
@@ -546,16 +546,16 @@
546 @ .%0*d(fossil_num_digits(p->nEdit))(p->pEditNext->rev)</a>
547 }
548
549 /* Provide a link to select the individual post. */
550 if( !bSelect ){
551 @ %z(href("%R/forumpost/%!S?%s",p->zUuid,zQuery))[link]</a>
552 }
553
554 /* Provide a link to the raw source code. */
555 if( !bUnf ){
556 @ %z(href("%R/forumpost/%!S?raw",p->zUuid))[source]</a>
557 }
558 @ </h3>
559 }
560
561 /* Check if this post is approved, also if it's by the current user. */
@@ -1173,19 +1173,20 @@
1173 Manifest *pRootPost = 0;
1174 const char *zMimetype = 0;
1175 const char *zContent = 0;
1176 const char *zTitle = 0;
1177 char *zDate = 0;
1178 const char *zFpid = PD("fpid","");
1179 int isCsrfSafe;
1180 int isDelete = 0;
1181
1182 login_check_credentials();
1183 if( !g.perm.WrForum ){
1184 login_needed(g.anon.WrForum);
1185 return;
1186 }
1187 fpid = symbolic_name_to_rid(zFpid, "f");
1188 if( fpid<=0 || (pPost = manifest_get(fpid, CFTYPE_FORUM, 0))==0 ){
1189 webpage_error("Missing or invalid fpid query parameter");
1190 }
1191 froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid);
1192 if( froot==0 || (pRootPost = manifest_get(froot, CFTYPE_FORUM, 0))==0 ){
@@ -1296,11 +1297,14 @@
1297 zContent = PDT("content","");
1298 style_header("Reply");
1299 if( pRootPost->zThreadTitle ){
1300 @ <h1>Thread: %h(pRootPost->zThreadTitle)</h1>
1301 }
1302 @ <h2>Replying To:
1303 @ <a href="%R/forumpost/%!S(zFpid)" target="_blank">%S(zFpid)</a>
1304 @ <a href="%R/forumpost/%!S(zFpid)?raw" target="_blank">[source]</a>
1305 @ </h2>
1306 zDate = db_text(0, "SELECT datetime(%.17g,toLocal())", pPost->rDate);
1307 zDisplayName = display_name_from_login(pPost->zUser);
1308 @ <h3 class='forumPostHdr'>By %s(zDisplayName) on %h(zDate)</h3>
1309 fossil_free(zDisplayName);
1310 fossil_free(zDate);
1311
1312 DDED src/fossil.page.brlist.js
--- a/src/fossil.page.brlist.js
+++ b/src/fossil.page.brlist.js
@@ -0,0 +1,20 @@
1
+/*
2
+ * This script adds multiselect facility for the list of branches.
3
+ *
4
+ * Some info on 'const':
5
+ * https://caniuse.com/const
6
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const#browser_compatibility
7
+ *
8
+ * According to MDN 'const' requires Android's WebView 37,
9
+ * which may not be available.
10
+ * For the time being, continueing without 'const' and 'indexOf'
11
+ * (but that may be reconsidered later).
12
+*/
13
+window.addEventListener( 'load', function() {
14
+
15
+var submenu = document.querySelector("div.submenu");
16
+var anchor = document.createElement("A");
17
+var brlistDataObj = document.getElementById("brlist-data");
18
+var brlistDataTxt = brlistDataObj.textContent || brlistDataObj.innerText;
19
+var brlistData = JSON.parse(brlistDataTxt);
20
+anchor.classList.add("l
--- a/src/fossil.page.brlist.js
+++ b/src/fossil.page.brlist.js
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/src/fossil.page.brlist.js
+++ b/src/fossil.page.brlist.js
@@ -0,0 +1,20 @@
1 /*
2 * This script adds multiselect facility for the list of branches.
3 *
4 * Some info on 'const':
5 * https://caniuse.com/const
6 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const#browser_compatibility
7 *
8 * According to MDN 'const' requires Android's WebView 37,
9 * which may not be available.
10 * For the time being, continueing without 'const' and 'indexOf'
11 * (but that may be reconsidered later).
12 */
13 window.addEventListener( 'load', function() {
14
15 var submenu = document.querySelector("div.submenu");
16 var anchor = document.createElement("A");
17 var brlistDataObj = document.getElementById("brlist-data");
18 var brlistDataTxt = brlistDataObj.textContent || brlistDataObj.innerText;
19 var brlistData = JSON.parse(brlistDataTxt);
20 anchor.classList.add("l
+17 -2
--- src/graph.js
+++ src/graph.js
@@ -568,13 +568,28 @@
568568
selRow = null;
569569
this.className = this.className.replace(" sel", "");
570570
canvasDiv.className = canvasDiv.className.replace(" sel", "");
571571
}else{
572572
if( tx.fileDiff ){
573
- location.href=tx.baseUrl + "/fdiff?v1="+selRow.h+"&v2="+p.h
573
+ location.href=tx.baseUrl + "/fdiff?v1="+selRow.h+"&v2="+p.h;
574574
}else{
575
- location.href=tx.baseUrl + "/vdiff?from="+selRow.h+"&to="+p.h
575
+ var href = tx.baseUrl + "/vdiff?from="+selRow.h+"&to="+p.h;
576
+ let params = (new URL(document.location)).searchParams;
577
+ if(params && typeof params === "object"){
578
+ /* When called from /timeline page, If chng=str was specified in the
579
+ ** QueryString, specify glob=str on the /vdiff page */
580
+ let glob = params.get("chng");
581
+ if( !glob ){
582
+ /* When called from /vdiff page, keep the glob= QueryString if
583
+ ** present. */
584
+ glob = params.get("glob");
585
+ }
586
+ if( glob ){
587
+ href += "&glob=" + glob;
588
+ }
589
+ }
590
+ location.href = href;
576591
}
577592
}
578593
e.stopPropagation()
579594
}
580595
function dblclickOnNode(e){
581596
--- src/graph.js
+++ src/graph.js
@@ -568,13 +568,28 @@
568 selRow = null;
569 this.className = this.className.replace(" sel", "");
570 canvasDiv.className = canvasDiv.className.replace(" sel", "");
571 }else{
572 if( tx.fileDiff ){
573 location.href=tx.baseUrl + "/fdiff?v1="+selRow.h+"&v2="+p.h
574 }else{
575 location.href=tx.baseUrl + "/vdiff?from="+selRow.h+"&to="+p.h
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
576 }
577 }
578 e.stopPropagation()
579 }
580 function dblclickOnNode(e){
581
--- src/graph.js
+++ src/graph.js
@@ -568,13 +568,28 @@
568 selRow = null;
569 this.className = this.className.replace(" sel", "");
570 canvasDiv.className = canvasDiv.className.replace(" sel", "");
571 }else{
572 if( tx.fileDiff ){
573 location.href=tx.baseUrl + "/fdiff?v1="+selRow.h+"&v2="+p.h;
574 }else{
575 var href = tx.baseUrl + "/vdiff?from="+selRow.h+"&to="+p.h;
576 let params = (new URL(document.location)).searchParams;
577 if(params && typeof params === "object"){
578 /* When called from /timeline page, If chng=str was specified in the
579 ** QueryString, specify glob=str on the /vdiff page */
580 let glob = params.get("chng");
581 if( !glob ){
582 /* When called from /vdiff page, keep the glob= QueryString if
583 ** present. */
584 glob = params.get("glob");
585 }
586 if( glob ){
587 href += "&glob=" + glob;
588 }
589 }
590 location.href = href;
591 }
592 }
593 e.stopPropagation()
594 }
595 function dblclickOnNode(e){
596
+14 -3
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -252,10 +252,11 @@
252252
**
253253
** Return the number of errors.
254254
*/
255255
int ssl_open(UrlData *pUrlData){
256256
X509 *cert;
257
+ const char *zRemoteHost;
257258
258259
ssl_global_init();
259260
if( pUrlData->useProxy ){
260261
int rc;
261262
char *connStr = mprintf("%s:%d", g.url.name, pUrlData->port);
@@ -276,30 +277,40 @@
276277
277278
pUrlData->path = pUrlData->proxyUrlPath;
278279
279280
iBio = BIO_new_ssl(sslCtx, 1);
280281
BIO_push(iBio, sBio);
282
+ zRemoteHost = pUrlData->hostname;
281283
}else{
282284
iBio = BIO_new_ssl_connect(sslCtx);
285
+ zRemoteHost = pUrlData->name;
283286
}
284287
if( iBio==NULL ) {
285288
ssl_set_errmsg("SSL: cannot open SSL (%s)",
286289
ERR_reason_error_string(ERR_get_error()));
287290
return 1;
288291
}
289292
BIO_get_ssl(iBio, &ssl);
290293
291294
#if (SSLEAY_VERSION_NUMBER >= 0x00908070) && !defined(OPENSSL_NO_TLSEXT)
292
- if( !SSL_set_tlsext_host_name(ssl,
293
- (pUrlData->useProxy?pUrlData->hostname:pUrlData->name))
294
- ){
295
+ if( !SSL_set_tlsext_host_name(ssl, zRemoteHost)){
295296
fossil_warning("WARNING: failed to set server name indication (SNI), "
296297
"continuing without it.\n");
297298
}
298299
#endif
299300
300301
SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
302
+#if OPENSSL_VERSION_NUMBER >= 0x010002000
303
+ if( !sslNoCertVerify ){
304
+ X509_VERIFY_PARAM *param = 0;
305
+ param = SSL_get0_param(ssl);
306
+ if( !X509_VERIFY_PARAM_set1_host(param, zRemoteHost, strlen(zRemoteHost)) ){
307
+ fossil_fatal("failed to set hostname.");
308
+ }
309
+ /* SSL_set_verify(ssl, SSL_VERIFY_PEER, 0); */
310
+ }
311
+#endif
301312
302313
if( !pUrlData->useProxy ){
303314
char *connStr = mprintf("%s:%d", pUrlData->name, pUrlData->port);
304315
BIO_set_conn_hostname(iBio, connStr);
305316
free(connStr);
306317
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -252,10 +252,11 @@
252 **
253 ** Return the number of errors.
254 */
255 int ssl_open(UrlData *pUrlData){
256 X509 *cert;
 
257
258 ssl_global_init();
259 if( pUrlData->useProxy ){
260 int rc;
261 char *connStr = mprintf("%s:%d", g.url.name, pUrlData->port);
@@ -276,30 +277,40 @@
276
277 pUrlData->path = pUrlData->proxyUrlPath;
278
279 iBio = BIO_new_ssl(sslCtx, 1);
280 BIO_push(iBio, sBio);
 
281 }else{
282 iBio = BIO_new_ssl_connect(sslCtx);
 
283 }
284 if( iBio==NULL ) {
285 ssl_set_errmsg("SSL: cannot open SSL (%s)",
286 ERR_reason_error_string(ERR_get_error()));
287 return 1;
288 }
289 BIO_get_ssl(iBio, &ssl);
290
291 #if (SSLEAY_VERSION_NUMBER >= 0x00908070) && !defined(OPENSSL_NO_TLSEXT)
292 if( !SSL_set_tlsext_host_name(ssl,
293 (pUrlData->useProxy?pUrlData->hostname:pUrlData->name))
294 ){
295 fossil_warning("WARNING: failed to set server name indication (SNI), "
296 "continuing without it.\n");
297 }
298 #endif
299
300 SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
 
 
 
 
 
 
 
 
 
 
301
302 if( !pUrlData->useProxy ){
303 char *connStr = mprintf("%s:%d", pUrlData->name, pUrlData->port);
304 BIO_set_conn_hostname(iBio, connStr);
305 free(connStr);
306
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -252,10 +252,11 @@
252 **
253 ** Return the number of errors.
254 */
255 int ssl_open(UrlData *pUrlData){
256 X509 *cert;
257 const char *zRemoteHost;
258
259 ssl_global_init();
260 if( pUrlData->useProxy ){
261 int rc;
262 char *connStr = mprintf("%s:%d", g.url.name, pUrlData->port);
@@ -276,30 +277,40 @@
277
278 pUrlData->path = pUrlData->proxyUrlPath;
279
280 iBio = BIO_new_ssl(sslCtx, 1);
281 BIO_push(iBio, sBio);
282 zRemoteHost = pUrlData->hostname;
283 }else{
284 iBio = BIO_new_ssl_connect(sslCtx);
285 zRemoteHost = pUrlData->name;
286 }
287 if( iBio==NULL ) {
288 ssl_set_errmsg("SSL: cannot open SSL (%s)",
289 ERR_reason_error_string(ERR_get_error()));
290 return 1;
291 }
292 BIO_get_ssl(iBio, &ssl);
293
294 #if (SSLEAY_VERSION_NUMBER >= 0x00908070) && !defined(OPENSSL_NO_TLSEXT)
295 if( !SSL_set_tlsext_host_name(ssl, zRemoteHost)){
 
 
296 fossil_warning("WARNING: failed to set server name indication (SNI), "
297 "continuing without it.\n");
298 }
299 #endif
300
301 SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
302 #if OPENSSL_VERSION_NUMBER >= 0x010002000
303 if( !sslNoCertVerify ){
304 X509_VERIFY_PARAM *param = 0;
305 param = SSL_get0_param(ssl);
306 if( !X509_VERIFY_PARAM_set1_host(param, zRemoteHost, strlen(zRemoteHost)) ){
307 fossil_fatal("failed to set hostname.");
308 }
309 /* SSL_set_verify(ssl, SSL_VERIFY_PEER, 0); */
310 }
311 #endif
312
313 if( !pUrlData->useProxy ){
314 char *connStr = mprintf("%s:%d", pUrlData->name, pUrlData->port);
315 BIO_set_conn_hostname(iBio, connStr);
316 free(connStr);
317
+9 -6
--- src/info.c
+++ src/info.c
@@ -496,10 +496,11 @@
496496
const char *zHash;
497497
int rid;
498498
Stmt q;
499499
int cnt = 0;
500500
Blob sql;
501
+ char const *zType;
501502
502503
login_check_credentials();
503504
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
504505
rid = name_to_rid_www("name");
505506
if( rid==0 ){
@@ -508,11 +509,13 @@
508509
style_finish_page();
509510
return;
510511
}
511512
zHash = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
512513
style_header("Tags and Properties");
513
- @ <h1>Tags and Properties for Check-In \
514
+ zType = whatis_rid_type_label(rid);
515
+ if(!zType) zType = "Artifact";
516
+ @ <h1>Tags and Properties for %s(zType) \
514517
@ %z(href("%R/ci/%!S",zHash))%S(zHash)</a></h1>
515518
db_prepare(&q,
516519
"SELECT tag.tagid, tagname, "
517520
" (SELECT uuid FROM blob WHERE rid=tagxref.srcid AND rid!=%d),"
518521
" value, datetime(tagxref.mtime,toLocal()), tagtype,"
@@ -2791,10 +2794,15 @@
27912794
winfo_page();
27922795
}else
27932796
if( db_exists("SELECT 1 FROM tagxref JOIN tag USING(tagid)"
27942797
" WHERE rid=%d AND tagname LIKE 'tkt-%%'", rid) ){
27952798
tinfo_page();
2799
+ }else
2800
+ if( db_table_exists("repository","forumpost")
2801
+ && db_exists("SELECT 1 FROM forumpost WHERE fpid=%d", rid)
2802
+ ){
2803
+ forumthread_page();
27962804
}else
27972805
if( db_exists("SELECT 1 FROM plink WHERE cid=%d", rid) ){
27982806
ci_page();
27992807
}else
28002808
if( db_exists("SELECT 1 FROM plink WHERE pid=%d", rid) ){
@@ -2801,15 +2809,10 @@
28012809
ci_page();
28022810
}else
28032811
if( db_exists("SELECT 1 FROM attachment WHERE attachid=%d", rid) ){
28042812
ainfo_page();
28052813
}else
2806
- if( db_table_exists("repository","forumpost")
2807
- && db_exists("SELECT 1 FROM forumpost WHERE fpid=%d", rid)
2808
- ){
2809
- forumthread_page();
2810
- }else
28112814
{
28122815
artifact_page();
28132816
}
28142817
}
28152818
28162819
--- src/info.c
+++ src/info.c
@@ -496,10 +496,11 @@
496 const char *zHash;
497 int rid;
498 Stmt q;
499 int cnt = 0;
500 Blob sql;
 
501
502 login_check_credentials();
503 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
504 rid = name_to_rid_www("name");
505 if( rid==0 ){
@@ -508,11 +509,13 @@
508 style_finish_page();
509 return;
510 }
511 zHash = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
512 style_header("Tags and Properties");
513 @ <h1>Tags and Properties for Check-In \
 
 
514 @ %z(href("%R/ci/%!S",zHash))%S(zHash)</a></h1>
515 db_prepare(&q,
516 "SELECT tag.tagid, tagname, "
517 " (SELECT uuid FROM blob WHERE rid=tagxref.srcid AND rid!=%d),"
518 " value, datetime(tagxref.mtime,toLocal()), tagtype,"
@@ -2791,10 +2794,15 @@
2791 winfo_page();
2792 }else
2793 if( db_exists("SELECT 1 FROM tagxref JOIN tag USING(tagid)"
2794 " WHERE rid=%d AND tagname LIKE 'tkt-%%'", rid) ){
2795 tinfo_page();
 
 
 
 
 
2796 }else
2797 if( db_exists("SELECT 1 FROM plink WHERE cid=%d", rid) ){
2798 ci_page();
2799 }else
2800 if( db_exists("SELECT 1 FROM plink WHERE pid=%d", rid) ){
@@ -2801,15 +2809,10 @@
2801 ci_page();
2802 }else
2803 if( db_exists("SELECT 1 FROM attachment WHERE attachid=%d", rid) ){
2804 ainfo_page();
2805 }else
2806 if( db_table_exists("repository","forumpost")
2807 && db_exists("SELECT 1 FROM forumpost WHERE fpid=%d", rid)
2808 ){
2809 forumthread_page();
2810 }else
2811 {
2812 artifact_page();
2813 }
2814 }
2815
2816
--- src/info.c
+++ src/info.c
@@ -496,10 +496,11 @@
496 const char *zHash;
497 int rid;
498 Stmt q;
499 int cnt = 0;
500 Blob sql;
501 char const *zType;
502
503 login_check_credentials();
504 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
505 rid = name_to_rid_www("name");
506 if( rid==0 ){
@@ -508,11 +509,13 @@
509 style_finish_page();
510 return;
511 }
512 zHash = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
513 style_header("Tags and Properties");
514 zType = whatis_rid_type_label(rid);
515 if(!zType) zType = "Artifact";
516 @ <h1>Tags and Properties for %s(zType) \
517 @ %z(href("%R/ci/%!S",zHash))%S(zHash)</a></h1>
518 db_prepare(&q,
519 "SELECT tag.tagid, tagname, "
520 " (SELECT uuid FROM blob WHERE rid=tagxref.srcid AND rid!=%d),"
521 " value, datetime(tagxref.mtime,toLocal()), tagtype,"
@@ -2791,10 +2794,15 @@
2794 winfo_page();
2795 }else
2796 if( db_exists("SELECT 1 FROM tagxref JOIN tag USING(tagid)"
2797 " WHERE rid=%d AND tagname LIKE 'tkt-%%'", rid) ){
2798 tinfo_page();
2799 }else
2800 if( db_table_exists("repository","forumpost")
2801 && db_exists("SELECT 1 FROM forumpost WHERE fpid=%d", rid)
2802 ){
2803 forumthread_page();
2804 }else
2805 if( db_exists("SELECT 1 FROM plink WHERE cid=%d", rid) ){
2806 ci_page();
2807 }else
2808 if( db_exists("SELECT 1 FROM plink WHERE pid=%d", rid) ){
@@ -2801,15 +2809,10 @@
2809 ci_page();
2810 }else
2811 if( db_exists("SELECT 1 FROM attachment WHERE attachid=%d", rid) ){
2812 ainfo_page();
2813 }else
 
 
 
 
 
2814 {
2815 artifact_page();
2816 }
2817 }
2818
2819
+3 -1
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -460,11 +460,13 @@
460460
return NULL;
461461
}
462462
blob_append(&sql,"SELECT"
463463
" DISTINCT substr(tagname,6) as name"
464464
" FROM tag JOIN tagxref USING('tagid')"
465
- " WHERE tagname GLOB 'wiki-*'",
465
+ " WHERE tagname GLOB 'wiki-*'"
466
+ " AND TYPEOF(tagxref.value+0)='integer'",
467
+ /* ^^^ elide wiki- tags which are not wiki pages */
466468
-1);
467469
zGlob = json_find_option_cstr("glob",NULL,"g");
468470
if(zGlob && *zGlob){
469471
blob_append_sql(&sql," AND name %s GLOB %Q",
470472
fInvert ? "NOT" : "", zGlob);
471473
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -460,11 +460,13 @@
460 return NULL;
461 }
462 blob_append(&sql,"SELECT"
463 " DISTINCT substr(tagname,6) as name"
464 " FROM tag JOIN tagxref USING('tagid')"
465 " WHERE tagname GLOB 'wiki-*'",
 
 
466 -1);
467 zGlob = json_find_option_cstr("glob",NULL,"g");
468 if(zGlob && *zGlob){
469 blob_append_sql(&sql," AND name %s GLOB %Q",
470 fInvert ? "NOT" : "", zGlob);
471
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -460,11 +460,13 @@
460 return NULL;
461 }
462 blob_append(&sql,"SELECT"
463 " DISTINCT substr(tagname,6) as name"
464 " FROM tag JOIN tagxref USING('tagid')"
465 " WHERE tagname GLOB 'wiki-*'"
466 " AND TYPEOF(tagxref.value+0)='integer'",
467 /* ^^^ elide wiki- tags which are not wiki pages */
468 -1);
469 zGlob = json_find_option_cstr("glob",NULL,"g");
470 if(zGlob && *zGlob){
471 blob_append_sql(&sql," AND name %s GLOB %Q",
472 fInvert ? "NOT" : "", zGlob);
473
+18 -9
--- src/login.c
+++ src/login.c
@@ -170,17 +170,21 @@
170170
static void record_login_attempt(
171171
const char *zUsername, /* Name of user logging in */
172172
const char *zIpAddr, /* IP address from which they logged in */
173173
int bSuccess /* True if the attempt was a success */
174174
){
175
- if( !db_get_boolean("access-log", 0) ) return;
176
- create_accesslog_table();
177
- db_multi_exec(
178
- "INSERT INTO accesslog(uname,ipaddr,success,mtime)"
179
- "VALUES(%Q,%Q,%d,julianday('now'));",
180
- zUsername, zIpAddr, bSuccess
181
- );
175
+ if( db_get_boolean("access-log", 0) ){
176
+ create_accesslog_table();
177
+ db_multi_exec(
178
+ "INSERT INTO accesslog(uname,ipaddr,success,mtime)"
179
+ "VALUES(%Q,%Q,%d,julianday('now'));",
180
+ zUsername, zIpAddr, bSuccess
181
+ );
182
+ }
183
+ if( bSuccess ){
184
+ alert_user_contact(zUsername);
185
+ }
182186
}
183187
184188
/*
185189
** Searches for the user ID matching the given name and password.
186190
** On success it returns a positive value. On error it returns 0.
@@ -794,10 +798,15 @@
794798
if( g.perm.EmailAlert && alert_enabled() ){
795799
@ <hr>
796800
@ <p>Configure <a href="%R/alerts">Email Alerts</a>
797801
@ for user <b>%h(g.zLogin)</b></p>
798802
}
803
+ if( db_table_exists("repository","forumpost") ){
804
+ @ <hr><p>
805
+ @ <a href="%R/timeline?ss=v&y=f&vfx&u=%t(g.zLogin)">Forum
806
+ @ post timeline</a> for user <b>%h(g.zLogin)</b></p>
807
+ }
799808
if( g.perm.Password ){
800809
char *zRPW = fossil_random_password(12);
801810
@ <hr>
802811
@ <p>Change Password for user <b>%h(g.zLogin)</b>:</p>
803812
form_begin(0, "%R/login");
@@ -1709,12 +1718,12 @@
17091718
ssub[nsub] = 0;
17101719
capability_free(pCap);
17111720
/* Also add the user to the subscriber table. */
17121721
zCode = db_text(0,
17131722
"INSERT INTO subscriber(semail,suname,"
1714
- " sverified,sdonotcall,sdigest,ssub,sctime,mtime,smip)"
1715
- " VALUES(%Q,%Q,%d,0,%d,%Q,now(),now(),%Q)"
1723
+ " sverified,sdonotcall,sdigest,ssub,sctime,mtime,smip,lastContact)"
1724
+ " VALUES(%Q,%Q,%d,0,%d,%Q,now(),now(),%Q,now()/86400)"
17161725
" ON CONFLICT(semail) DO UPDATE"
17171726
" SET suname=excluded.suname"
17181727
" RETURNING hex(subscriberCode);",
17191728
/* semail */ zEAddr,
17201729
/* suname */ zUserID,
17211730
--- src/login.c
+++ src/login.c
@@ -170,17 +170,21 @@
170 static void record_login_attempt(
171 const char *zUsername, /* Name of user logging in */
172 const char *zIpAddr, /* IP address from which they logged in */
173 int bSuccess /* True if the attempt was a success */
174 ){
175 if( !db_get_boolean("access-log", 0) ) return;
176 create_accesslog_table();
177 db_multi_exec(
178 "INSERT INTO accesslog(uname,ipaddr,success,mtime)"
179 "VALUES(%Q,%Q,%d,julianday('now'));",
180 zUsername, zIpAddr, bSuccess
181 );
 
 
 
 
182 }
183
184 /*
185 ** Searches for the user ID matching the given name and password.
186 ** On success it returns a positive value. On error it returns 0.
@@ -794,10 +798,15 @@
794 if( g.perm.EmailAlert && alert_enabled() ){
795 @ <hr>
796 @ <p>Configure <a href="%R/alerts">Email Alerts</a>
797 @ for user <b>%h(g.zLogin)</b></p>
798 }
 
 
 
 
 
799 if( g.perm.Password ){
800 char *zRPW = fossil_random_password(12);
801 @ <hr>
802 @ <p>Change Password for user <b>%h(g.zLogin)</b>:</p>
803 form_begin(0, "%R/login");
@@ -1709,12 +1718,12 @@
1709 ssub[nsub] = 0;
1710 capability_free(pCap);
1711 /* Also add the user to the subscriber table. */
1712 zCode = db_text(0,
1713 "INSERT INTO subscriber(semail,suname,"
1714 " sverified,sdonotcall,sdigest,ssub,sctime,mtime,smip)"
1715 " VALUES(%Q,%Q,%d,0,%d,%Q,now(),now(),%Q)"
1716 " ON CONFLICT(semail) DO UPDATE"
1717 " SET suname=excluded.suname"
1718 " RETURNING hex(subscriberCode);",
1719 /* semail */ zEAddr,
1720 /* suname */ zUserID,
1721
--- src/login.c
+++ src/login.c
@@ -170,17 +170,21 @@
170 static void record_login_attempt(
171 const char *zUsername, /* Name of user logging in */
172 const char *zIpAddr, /* IP address from which they logged in */
173 int bSuccess /* True if the attempt was a success */
174 ){
175 if( db_get_boolean("access-log", 0) ){
176 create_accesslog_table();
177 db_multi_exec(
178 "INSERT INTO accesslog(uname,ipaddr,success,mtime)"
179 "VALUES(%Q,%Q,%d,julianday('now'));",
180 zUsername, zIpAddr, bSuccess
181 );
182 }
183 if( bSuccess ){
184 alert_user_contact(zUsername);
185 }
186 }
187
188 /*
189 ** Searches for the user ID matching the given name and password.
190 ** On success it returns a positive value. On error it returns 0.
@@ -794,10 +798,15 @@
798 if( g.perm.EmailAlert && alert_enabled() ){
799 @ <hr>
800 @ <p>Configure <a href="%R/alerts">Email Alerts</a>
801 @ for user <b>%h(g.zLogin)</b></p>
802 }
803 if( db_table_exists("repository","forumpost") ){
804 @ <hr><p>
805 @ <a href="%R/timeline?ss=v&y=f&vfx&u=%t(g.zLogin)">Forum
806 @ post timeline</a> for user <b>%h(g.zLogin)</b></p>
807 }
808 if( g.perm.Password ){
809 char *zRPW = fossil_random_password(12);
810 @ <hr>
811 @ <p>Change Password for user <b>%h(g.zLogin)</b>:</p>
812 form_begin(0, "%R/login");
@@ -1709,12 +1718,12 @@
1718 ssub[nsub] = 0;
1719 capability_free(pCap);
1720 /* Also add the user to the subscriber table. */
1721 zCode = db_text(0,
1722 "INSERT INTO subscriber(semail,suname,"
1723 " sverified,sdonotcall,sdigest,ssub,sctime,mtime,smip,lastContact)"
1724 " VALUES(%Q,%Q,%d,0,%d,%Q,now(),now(),%Q,now()/86400)"
1725 " ON CONFLICT(semail) DO UPDATE"
1726 " SET suname=excluded.suname"
1727 " RETURNING hex(subscriberCode);",
1728 /* semail */ zEAddr,
1729 /* suname */ zUserID,
1730
--- src/main.mk
+++ src/main.mk
@@ -226,10 +226,11 @@
226226
$(SRCDIR)/fossil.copybutton.js \
227227
$(SRCDIR)/fossil.dom.js \
228228
$(SRCDIR)/fossil.fetch.js \
229229
$(SRCDIR)/fossil.info-diff.js \
230230
$(SRCDIR)/fossil.numbered-lines.js \
231
+ $(SRCDIR)/fossil.page.brlist.js \
231232
$(SRCDIR)/fossil.page.fileedit.js \
232233
$(SRCDIR)/fossil.page.forumpost.js \
233234
$(SRCDIR)/fossil.page.pikchrshow.js \
234235
$(SRCDIR)/fossil.page.wcontent.js \
235236
$(SRCDIR)/fossil.page.whistory.js \
236237
--- src/main.mk
+++ src/main.mk
@@ -226,10 +226,11 @@
226 $(SRCDIR)/fossil.copybutton.js \
227 $(SRCDIR)/fossil.dom.js \
228 $(SRCDIR)/fossil.fetch.js \
229 $(SRCDIR)/fossil.info-diff.js \
230 $(SRCDIR)/fossil.numbered-lines.js \
 
231 $(SRCDIR)/fossil.page.fileedit.js \
232 $(SRCDIR)/fossil.page.forumpost.js \
233 $(SRCDIR)/fossil.page.pikchrshow.js \
234 $(SRCDIR)/fossil.page.wcontent.js \
235 $(SRCDIR)/fossil.page.whistory.js \
236
--- src/main.mk
+++ src/main.mk
@@ -226,10 +226,11 @@
226 $(SRCDIR)/fossil.copybutton.js \
227 $(SRCDIR)/fossil.dom.js \
228 $(SRCDIR)/fossil.fetch.js \
229 $(SRCDIR)/fossil.info-diff.js \
230 $(SRCDIR)/fossil.numbered-lines.js \
231 $(SRCDIR)/fossil.page.brlist.js \
232 $(SRCDIR)/fossil.page.fileedit.js \
233 $(SRCDIR)/fossil.page.forumpost.js \
234 $(SRCDIR)/fossil.page.pikchrshow.js \
235 $(SRCDIR)/fossil.page.wcontent.js \
236 $(SRCDIR)/fossil.page.whistory.js \
237
--- src/main.mk
+++ src/main.mk
@@ -226,10 +226,11 @@
226226
$(SRCDIR)/fossil.copybutton.js \
227227
$(SRCDIR)/fossil.dom.js \
228228
$(SRCDIR)/fossil.fetch.js \
229229
$(SRCDIR)/fossil.info-diff.js \
230230
$(SRCDIR)/fossil.numbered-lines.js \
231
+ $(SRCDIR)/fossil.page.brlist.js \
231232
$(SRCDIR)/fossil.page.fileedit.js \
232233
$(SRCDIR)/fossil.page.forumpost.js \
233234
$(SRCDIR)/fossil.page.pikchrshow.js \
234235
$(SRCDIR)/fossil.page.wcontent.js \
235236
$(SRCDIR)/fossil.page.whistory.js \
236237
--- src/main.mk
+++ src/main.mk
@@ -226,10 +226,11 @@
226 $(SRCDIR)/fossil.copybutton.js \
227 $(SRCDIR)/fossil.dom.js \
228 $(SRCDIR)/fossil.fetch.js \
229 $(SRCDIR)/fossil.info-diff.js \
230 $(SRCDIR)/fossil.numbered-lines.js \
 
231 $(SRCDIR)/fossil.page.fileedit.js \
232 $(SRCDIR)/fossil.page.forumpost.js \
233 $(SRCDIR)/fossil.page.pikchrshow.js \
234 $(SRCDIR)/fossil.page.wcontent.js \
235 $(SRCDIR)/fossil.page.whistory.js \
236
--- src/main.mk
+++ src/main.mk
@@ -226,10 +226,11 @@
226 $(SRCDIR)/fossil.copybutton.js \
227 $(SRCDIR)/fossil.dom.js \
228 $(SRCDIR)/fossil.fetch.js \
229 $(SRCDIR)/fossil.info-diff.js \
230 $(SRCDIR)/fossil.numbered-lines.js \
231 $(SRCDIR)/fossil.page.brlist.js \
232 $(SRCDIR)/fossil.page.fileedit.js \
233 $(SRCDIR)/fossil.page.forumpost.js \
234 $(SRCDIR)/fossil.page.pikchrshow.js \
235 $(SRCDIR)/fossil.page.wcontent.js \
236 $(SRCDIR)/fossil.page.whistory.js \
237
--- src/manifest.c
+++ src/manifest.c
@@ -2250,10 +2250,38 @@
22502250
if( c==0 ){
22512251
c = fossil_strcmp(pA->zName, pB->zName);
22522252
}
22532253
return c;
22542254
}
2255
+
2256
+/*
2257
+** Inserts plink entries for FORUM, WIKI, and TECHNOTE manifests. May
2258
+** assert for other manifest types. If a parent entry exists, it also
2259
+** propagates any tags for that parent. This is a no-op if
2260
+** p->nParent==0.
2261
+*/
2262
+static void manifest_add_fwt_plink(int rid, Manifest *p){
2263
+ int i;
2264
+ int parentId = 0;
2265
+ assert(p->type==CFTYPE_WIKI ||
2266
+ p->type==CFTYPE_FORUM ||
2267
+ p->type==CFTYPE_EVENT);
2268
+ for(i=0; i<p->nParent; ++i){
2269
+ int const pid = uuid_to_rid(p->azParent[i], 1);
2270
+ if(0==i){
2271
+ parentId = pid;
2272
+ }
2273
+ db_multi_exec(
2274
+ "INSERT OR IGNORE INTO plink"
2275
+ "(pid, cid, isprim, mtime, baseid)"
2276
+ "VALUES(%d, %d, %d, %.17g, NULL)",
2277
+ pid, rid, i==0, p->rDate);
2278
+ }
2279
+ if(parentId){
2280
+ tag_propagate_all(parentId);
2281
+ }
2282
+}
22552283
22562284
/*
22572285
** Scan artifact rid/pContent to see if it is a control artifact of
22582286
** any type:
22592287
**
@@ -2416,10 +2444,14 @@
24162444
}
24172445
}
24182446
if( parentid ){
24192447
tag_propagate_all(parentid);
24202448
}
2449
+ }
2450
+ if(p->type==CFTYPE_WIKI || p->type==CFTYPE_FORUM
2451
+ || p->type==CFTYPE_EVENT){
2452
+ manifest_add_fwt_plink(rid, p);
24212453
}
24222454
if( p->type==CFTYPE_WIKI ){
24232455
char *zTag = mprintf("wiki-%s", p->zWikiTitle);
24242456
int prior = 0;
24252457
char cPrefix;
@@ -2814,10 +2846,11 @@
28142846
}
28152847
if( p->zWiki[0] ){
28162848
backlink_extract(p->zWiki, p->zMimetype, rid, BKLNK_FORUM, p->rDate, 1);
28172849
}
28182850
}
2851
+
28192852
db_end_transaction(0);
28202853
if( permitHooks ){
28212854
rc = xfer_run_common_script();
28222855
if( rc==TH_OK ){
28232856
rc = xfer_run_script(zScript, zUuid, 0);
28242857
--- src/manifest.c
+++ src/manifest.c
@@ -2250,10 +2250,38 @@
2250 if( c==0 ){
2251 c = fossil_strcmp(pA->zName, pB->zName);
2252 }
2253 return c;
2254 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2255
2256 /*
2257 ** Scan artifact rid/pContent to see if it is a control artifact of
2258 ** any type:
2259 **
@@ -2416,10 +2444,14 @@
2416 }
2417 }
2418 if( parentid ){
2419 tag_propagate_all(parentid);
2420 }
 
 
 
 
2421 }
2422 if( p->type==CFTYPE_WIKI ){
2423 char *zTag = mprintf("wiki-%s", p->zWikiTitle);
2424 int prior = 0;
2425 char cPrefix;
@@ -2814,10 +2846,11 @@
2814 }
2815 if( p->zWiki[0] ){
2816 backlink_extract(p->zWiki, p->zMimetype, rid, BKLNK_FORUM, p->rDate, 1);
2817 }
2818 }
 
2819 db_end_transaction(0);
2820 if( permitHooks ){
2821 rc = xfer_run_common_script();
2822 if( rc==TH_OK ){
2823 rc = xfer_run_script(zScript, zUuid, 0);
2824
--- src/manifest.c
+++ src/manifest.c
@@ -2250,10 +2250,38 @@
2250 if( c==0 ){
2251 c = fossil_strcmp(pA->zName, pB->zName);
2252 }
2253 return c;
2254 }
2255
2256 /*
2257 ** Inserts plink entries for FORUM, WIKI, and TECHNOTE manifests. May
2258 ** assert for other manifest types. If a parent entry exists, it also
2259 ** propagates any tags for that parent. This is a no-op if
2260 ** p->nParent==0.
2261 */
2262 static void manifest_add_fwt_plink(int rid, Manifest *p){
2263 int i;
2264 int parentId = 0;
2265 assert(p->type==CFTYPE_WIKI ||
2266 p->type==CFTYPE_FORUM ||
2267 p->type==CFTYPE_EVENT);
2268 for(i=0; i<p->nParent; ++i){
2269 int const pid = uuid_to_rid(p->azParent[i], 1);
2270 if(0==i){
2271 parentId = pid;
2272 }
2273 db_multi_exec(
2274 "INSERT OR IGNORE INTO plink"
2275 "(pid, cid, isprim, mtime, baseid)"
2276 "VALUES(%d, %d, %d, %.17g, NULL)",
2277 pid, rid, i==0, p->rDate);
2278 }
2279 if(parentId){
2280 tag_propagate_all(parentId);
2281 }
2282 }
2283
2284 /*
2285 ** Scan artifact rid/pContent to see if it is a control artifact of
2286 ** any type:
2287 **
@@ -2416,10 +2444,14 @@
2444 }
2445 }
2446 if( parentid ){
2447 tag_propagate_all(parentid);
2448 }
2449 }
2450 if(p->type==CFTYPE_WIKI || p->type==CFTYPE_FORUM
2451 || p->type==CFTYPE_EVENT){
2452 manifest_add_fwt_plink(rid, p);
2453 }
2454 if( p->type==CFTYPE_WIKI ){
2455 char *zTag = mprintf("wiki-%s", p->zWikiTitle);
2456 int prior = 0;
2457 char cPrefix;
@@ -2814,10 +2846,11 @@
2846 }
2847 if( p->zWiki[0] ){
2848 backlink_extract(p->zWiki, p->zMimetype, rid, BKLNK_FORUM, p->rDate, 1);
2849 }
2850 }
2851
2852 db_end_transaction(0);
2853 if( permitHooks ){
2854 rc = xfer_run_common_script();
2855 if( rc==TH_OK ){
2856 rc = xfer_run_script(zScript, zUuid, 0);
2857
+38 -14
--- src/merge.c
+++ src/merge.c
@@ -402,10 +402,13 @@
402402
if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
403403
vid = db_lget_int("checkout", 0);
404404
if( vid==0 ){
405405
fossil_fatal("nothing is checked out");
406406
}
407
+ if( forceFlag==0 && leaf_is_closed(vid) ){
408
+ fossil_fatal("cannot merge into a closed leaf. Use --force to override");
409
+ }
407410
if( !dryRunFlag ){
408411
if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag,
409412
db_get_int("autosync-tries", 1), 1) ){
410413
fossil_fatal("merge abandoned due to sync failure");
411414
}
@@ -618,28 +621,49 @@
618621
** to B and B is renamed to A.
619622
** The Fossil merge algorithm breaks down in those cases. It will need
620623
** to be completely rewritten to handle such complex cases. Such cases
621624
** appear to be rare, and also confusing to humans.
622625
*/
626
+ db_multi_exec(
627
+ "UPDATE OR IGNORE fv SET fnp=vfile.pathname FROM vfile"
628
+ " WHERE fnp IS NULL"
629
+ " AND vfile.pathname = fv.fnn"
630
+ " AND vfile.vid=%d;",
631
+ pid
632
+ );
623633
db_multi_exec(
624634
"UPDATE OR IGNORE fv SET fn=vfile.pathname FROM vfile"
625635
" WHERE fn IS NULL"
626
- " AND vfile.pathname IN (fv.fnm,fv.fnp,fv.fnn)"
636
+ " AND vfile.pathname = coalesce(fv.fnp,fv.fnn)"
627637
" AND vfile.vid=%d;",
628638
vid
639
+ );
640
+ db_multi_exec(
641
+ "UPDATE OR IGNORE fv SET fnm=vfile.pathname FROM vfile"
642
+ " WHERE fnm IS NULL"
643
+ " AND vfile.pathname = coalesce(fv.fnp,fv.fnn)"
644
+ " AND vfile.vid=%d;",
645
+ mid
629646
);
630647
db_multi_exec(
631648
"UPDATE OR IGNORE fv SET fnp=vfile.pathname FROM vfile"
632649
" WHERE fnp IS NULL"
633
- " AND vfile.pathname IN (fv.fn,fv.fnm,fv.fnn)"
650
+ " AND vfile.pathname IN (fv.fnm,fv.fn)"
634651
" AND vfile.vid=%d;",
635652
pid
653
+ );
654
+ db_multi_exec(
655
+ "UPDATE OR IGNORE fv SET fn=vfile.pathname FROM vfile"
656
+ " WHERE fn IS NULL"
657
+ " AND vfile.pathname = fv.fnm"
658
+ " AND vfile.vid=%d;",
659
+ vid
636660
);
637661
db_multi_exec(
638662
"UPDATE OR IGNORE fv SET fnm=vfile.pathname FROM vfile"
639663
" WHERE fnm IS NULL"
640
- " AND vfile.pathname IN (fv.fn,fv.fnp,fv.fnn)"
664
+ " AND vfile.pathname = fv.fn"
641665
" AND vfile.vid=%d;",
642666
mid
643667
);
644668
}
645669
if( debugFlag ){
@@ -702,25 +726,25 @@
702726
db_multi_exec(
703727
"UPDATE fv SET idp=idv, ridp=ridv WHERE ridv>0 AND chnged NOT IN (3,5)"
704728
);
705729
}else{
706730
db_multi_exec(
707
- "UPDATE fv SET"
708
- " idp=coalesce((SELECT id FROM vfile WHERE vid=%d AND fnp=pathname),0),"
709
- " ridp=coalesce((SELECT rid FROM vfile WHERE vid=%d AND fnp=pathname),0)",
710
- pid, pid
731
+ "UPDATE fv SET idp=coalesce(vfile.id,0), ridp=coalesce(vfile.rid,0)"
732
+ " FROM vfile"
733
+ " WHERE vfile.vid=%d AND fv.fnp=vfile.pathname",
734
+ pid
711735
);
712736
}
713737
db_multi_exec(
714738
"UPDATE fv SET"
715
- " idm=coalesce((SELECT id FROM vfile WHERE vid=%d AND fnm=pathname),0),"
716
- " ridm=coalesce((SELECT rid FROM vfile WHERE vid=%d AND fnm=pathname),0),"
717
- " islinkm=coalesce((SELECT islink FROM vfile"
718
- " WHERE vid=%d AND fnm=pathname),0),"
719
- " isexe=coalesce((SELECT isexe FROM vfile WHERE vid=%d AND fnm=pathname),"
720
- " isexe)",
721
- mid, mid, mid, mid
739
+ " idm=coalesce(vfile.id,0),"
740
+ " ridm=coalesce(vfile.rid,0),"
741
+ " islinkm=coalesce(vfile.islink,0),"
742
+ " isexe=coalesce(vfile.isexe,fv.isexe)"
743
+ " FROM vfile"
744
+ " WHERE vid=%d AND fnm=pathname",
745
+ mid
722746
);
723747
724748
/*
725749
** Update the execute bit on files where it's changed from P->M but not P->V
726750
*/
727751
--- src/merge.c
+++ src/merge.c
@@ -402,10 +402,13 @@
402 if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
403 vid = db_lget_int("checkout", 0);
404 if( vid==0 ){
405 fossil_fatal("nothing is checked out");
406 }
 
 
 
407 if( !dryRunFlag ){
408 if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag,
409 db_get_int("autosync-tries", 1), 1) ){
410 fossil_fatal("merge abandoned due to sync failure");
411 }
@@ -618,28 +621,49 @@
618 ** to B and B is renamed to A.
619 ** The Fossil merge algorithm breaks down in those cases. It will need
620 ** to be completely rewritten to handle such complex cases. Such cases
621 ** appear to be rare, and also confusing to humans.
622 */
 
 
 
 
 
 
 
623 db_multi_exec(
624 "UPDATE OR IGNORE fv SET fn=vfile.pathname FROM vfile"
625 " WHERE fn IS NULL"
626 " AND vfile.pathname IN (fv.fnm,fv.fnp,fv.fnn)"
627 " AND vfile.vid=%d;",
628 vid
 
 
 
 
 
 
 
629 );
630 db_multi_exec(
631 "UPDATE OR IGNORE fv SET fnp=vfile.pathname FROM vfile"
632 " WHERE fnp IS NULL"
633 " AND vfile.pathname IN (fv.fn,fv.fnm,fv.fnn)"
634 " AND vfile.vid=%d;",
635 pid
 
 
 
 
 
 
 
636 );
637 db_multi_exec(
638 "UPDATE OR IGNORE fv SET fnm=vfile.pathname FROM vfile"
639 " WHERE fnm IS NULL"
640 " AND vfile.pathname IN (fv.fn,fv.fnp,fv.fnn)"
641 " AND vfile.vid=%d;",
642 mid
643 );
644 }
645 if( debugFlag ){
@@ -702,25 +726,25 @@
702 db_multi_exec(
703 "UPDATE fv SET idp=idv, ridp=ridv WHERE ridv>0 AND chnged NOT IN (3,5)"
704 );
705 }else{
706 db_multi_exec(
707 "UPDATE fv SET"
708 " idp=coalesce((SELECT id FROM vfile WHERE vid=%d AND fnp=pathname),0),"
709 " ridp=coalesce((SELECT rid FROM vfile WHERE vid=%d AND fnp=pathname),0)",
710 pid, pid
711 );
712 }
713 db_multi_exec(
714 "UPDATE fv SET"
715 " idm=coalesce((SELECT id FROM vfile WHERE vid=%d AND fnm=pathname),0),"
716 " ridm=coalesce((SELECT rid FROM vfile WHERE vid=%d AND fnm=pathname),0),"
717 " islinkm=coalesce((SELECT islink FROM vfile"
718 " WHERE vid=%d AND fnm=pathname),0),"
719 " isexe=coalesce((SELECT isexe FROM vfile WHERE vid=%d AND fnm=pathname),"
720 " isexe)",
721 mid, mid, mid, mid
722 );
723
724 /*
725 ** Update the execute bit on files where it's changed from P->M but not P->V
726 */
727
--- src/merge.c
+++ src/merge.c
@@ -402,10 +402,13 @@
402 if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
403 vid = db_lget_int("checkout", 0);
404 if( vid==0 ){
405 fossil_fatal("nothing is checked out");
406 }
407 if( forceFlag==0 && leaf_is_closed(vid) ){
408 fossil_fatal("cannot merge into a closed leaf. Use --force to override");
409 }
410 if( !dryRunFlag ){
411 if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag,
412 db_get_int("autosync-tries", 1), 1) ){
413 fossil_fatal("merge abandoned due to sync failure");
414 }
@@ -618,28 +621,49 @@
621 ** to B and B is renamed to A.
622 ** The Fossil merge algorithm breaks down in those cases. It will need
623 ** to be completely rewritten to handle such complex cases. Such cases
624 ** appear to be rare, and also confusing to humans.
625 */
626 db_multi_exec(
627 "UPDATE OR IGNORE fv SET fnp=vfile.pathname FROM vfile"
628 " WHERE fnp IS NULL"
629 " AND vfile.pathname = fv.fnn"
630 " AND vfile.vid=%d;",
631 pid
632 );
633 db_multi_exec(
634 "UPDATE OR IGNORE fv SET fn=vfile.pathname FROM vfile"
635 " WHERE fn IS NULL"
636 " AND vfile.pathname = coalesce(fv.fnp,fv.fnn)"
637 " AND vfile.vid=%d;",
638 vid
639 );
640 db_multi_exec(
641 "UPDATE OR IGNORE fv SET fnm=vfile.pathname FROM vfile"
642 " WHERE fnm IS NULL"
643 " AND vfile.pathname = coalesce(fv.fnp,fv.fnn)"
644 " AND vfile.vid=%d;",
645 mid
646 );
647 db_multi_exec(
648 "UPDATE OR IGNORE fv SET fnp=vfile.pathname FROM vfile"
649 " WHERE fnp IS NULL"
650 " AND vfile.pathname IN (fv.fnm,fv.fn)"
651 " AND vfile.vid=%d;",
652 pid
653 );
654 db_multi_exec(
655 "UPDATE OR IGNORE fv SET fn=vfile.pathname FROM vfile"
656 " WHERE fn IS NULL"
657 " AND vfile.pathname = fv.fnm"
658 " AND vfile.vid=%d;",
659 vid
660 );
661 db_multi_exec(
662 "UPDATE OR IGNORE fv SET fnm=vfile.pathname FROM vfile"
663 " WHERE fnm IS NULL"
664 " AND vfile.pathname = fv.fn"
665 " AND vfile.vid=%d;",
666 mid
667 );
668 }
669 if( debugFlag ){
@@ -702,25 +726,25 @@
726 db_multi_exec(
727 "UPDATE fv SET idp=idv, ridp=ridv WHERE ridv>0 AND chnged NOT IN (3,5)"
728 );
729 }else{
730 db_multi_exec(
731 "UPDATE fv SET idp=coalesce(vfile.id,0), ridp=coalesce(vfile.rid,0)"
732 " FROM vfile"
733 " WHERE vfile.vid=%d AND fv.fnp=vfile.pathname",
734 pid
735 );
736 }
737 db_multi_exec(
738 "UPDATE fv SET"
739 " idm=coalesce(vfile.id,0),"
740 " ridm=coalesce(vfile.rid,0),"
741 " islinkm=coalesce(vfile.islink,0),"
742 " isexe=coalesce(vfile.isexe,fv.isexe)"
743 " FROM vfile"
744 " WHERE vid=%d AND fnm=pathname",
745 mid
746 );
747
748 /*
749 ** Update the execute bit on files where it's changed from P->M but not P->V
750 */
751
+60
--- src/name.c
+++ src/name.c
@@ -737,10 +737,69 @@
737737
cgi_redirectf("%R/ambiguous/%T?src=%t", zName, g.zPath);
738738
rid = 0;
739739
}
740740
return rid;
741741
}
742
+
743
+/*
744
+** Given an RID of a structural artifact, which is assumed to be
745
+** valid, this function returns one of the CFTYPE_xxx values
746
+** describing the record type, or 0 if the RID does not refer to an
747
+** artifact record (as determined by reading the event table).
748
+**
749
+** Note that this function never returns CFTYPE_ATTACHMENT or
750
+** CFTYPE_CLUSTER because those are not used in the event table. Thus
751
+** it cannot be used to distinguish those artifact types from
752
+** non-artifact file content.
753
+**
754
+** Potential TODO: if the rid is not found in the timeline, try to
755
+** match it to a client file and return a hypothetical new
756
+** CFTYPE_OPAQUE or CFTYPE_NONARTIFACT if a match is found.
757
+*/
758
+int whatis_rid_type(int rid){
759
+ Stmt q = empty_Stmt;
760
+ int type = 0;
761
+ /* Check for entries on the timeline that reference this object */
762
+ db_prepare(&q,
763
+ "SELECT type FROM event WHERE objid=%d", rid);
764
+ if( db_step(&q)==SQLITE_ROW ){
765
+ switch( db_column_text(&q,0)[0] ){
766
+ case 'c': type = CFTYPE_MANIFEST; break;
767
+ case 'w': type = CFTYPE_WIKI; break;
768
+ case 'e': type = CFTYPE_EVENT; break;
769
+ case 'f': type = CFTYPE_FORUM; break;
770
+ case 't': type = CFTYPE_TICKET; break;
771
+ case 'g': type = CFTYPE_CONTROL; break;
772
+ default: break;
773
+ }
774
+ }
775
+ db_finalize(&q);
776
+ return type;
777
+}
778
+
779
+/*
780
+** A proxy for whatis_rid_type() which returns a brief string (in
781
+** static memory) describing the record type. Returns NULL if rid does
782
+** not refer to an artifact record (as determined by reading the event
783
+** table). The returned string is intended to be used in headers which
784
+** can refer to different artifact types. It is not "definitive," in
785
+** that it does not distinguish between closely-related types like
786
+** wiki creation, edit, and removal.
787
+*/
788
+char const * whatis_rid_type_label(int rid){
789
+ char const * zType = 0;
790
+ switch( whatis_rid_type(rid) ){
791
+ case CFTYPE_MANIFEST: zType = "Check-in"; break;
792
+ case CFTYPE_WIKI: zType = "Wiki-edit"; break;
793
+ case CFTYPE_EVENT: zType = "Technote"; break;
794
+ case CFTYPE_FORUM: zType = "Forum-post"; break;
795
+ case CFTYPE_TICKET: zType = "Ticket-change"; break;
796
+ case CFTYPE_CONTROL: zType = "Tag-change"; break;
797
+ default: break;
798
+ }
799
+ return zType;
800
+}
742801
743802
/*
744803
** Generate a description of artifact "rid"
745804
*/
746805
void whatis_rid(int rid, int verboseFlag){
@@ -771,10 +830,11 @@
771830
/* Report any symbolic tags on this artifact */
772831
db_prepare(&q,
773832
"SELECT substr(tagname,5)"
774833
" FROM tag JOIN tagxref ON tag.tagid=tagxref.tagid"
775834
" WHERE tagxref.rid=%d"
835
+ " AND tagxref.tagtype<>0"
776836
" AND tagname GLOB 'sym-*'"
777837
" ORDER BY 1",
778838
rid
779839
);
780840
cnt = 0;
781841
--- src/name.c
+++ src/name.c
@@ -737,10 +737,69 @@
737 cgi_redirectf("%R/ambiguous/%T?src=%t", zName, g.zPath);
738 rid = 0;
739 }
740 return rid;
741 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
742
743 /*
744 ** Generate a description of artifact "rid"
745 */
746 void whatis_rid(int rid, int verboseFlag){
@@ -771,10 +830,11 @@
771 /* Report any symbolic tags on this artifact */
772 db_prepare(&q,
773 "SELECT substr(tagname,5)"
774 " FROM tag JOIN tagxref ON tag.tagid=tagxref.tagid"
775 " WHERE tagxref.rid=%d"
 
776 " AND tagname GLOB 'sym-*'"
777 " ORDER BY 1",
778 rid
779 );
780 cnt = 0;
781
--- src/name.c
+++ src/name.c
@@ -737,10 +737,69 @@
737 cgi_redirectf("%R/ambiguous/%T?src=%t", zName, g.zPath);
738 rid = 0;
739 }
740 return rid;
741 }
742
743 /*
744 ** Given an RID of a structural artifact, which is assumed to be
745 ** valid, this function returns one of the CFTYPE_xxx values
746 ** describing the record type, or 0 if the RID does not refer to an
747 ** artifact record (as determined by reading the event table).
748 **
749 ** Note that this function never returns CFTYPE_ATTACHMENT or
750 ** CFTYPE_CLUSTER because those are not used in the event table. Thus
751 ** it cannot be used to distinguish those artifact types from
752 ** non-artifact file content.
753 **
754 ** Potential TODO: if the rid is not found in the timeline, try to
755 ** match it to a client file and return a hypothetical new
756 ** CFTYPE_OPAQUE or CFTYPE_NONARTIFACT if a match is found.
757 */
758 int whatis_rid_type(int rid){
759 Stmt q = empty_Stmt;
760 int type = 0;
761 /* Check for entries on the timeline that reference this object */
762 db_prepare(&q,
763 "SELECT type FROM event WHERE objid=%d", rid);
764 if( db_step(&q)==SQLITE_ROW ){
765 switch( db_column_text(&q,0)[0] ){
766 case 'c': type = CFTYPE_MANIFEST; break;
767 case 'w': type = CFTYPE_WIKI; break;
768 case 'e': type = CFTYPE_EVENT; break;
769 case 'f': type = CFTYPE_FORUM; break;
770 case 't': type = CFTYPE_TICKET; break;
771 case 'g': type = CFTYPE_CONTROL; break;
772 default: break;
773 }
774 }
775 db_finalize(&q);
776 return type;
777 }
778
779 /*
780 ** A proxy for whatis_rid_type() which returns a brief string (in
781 ** static memory) describing the record type. Returns NULL if rid does
782 ** not refer to an artifact record (as determined by reading the event
783 ** table). The returned string is intended to be used in headers which
784 ** can refer to different artifact types. It is not "definitive," in
785 ** that it does not distinguish between closely-related types like
786 ** wiki creation, edit, and removal.
787 */
788 char const * whatis_rid_type_label(int rid){
789 char const * zType = 0;
790 switch( whatis_rid_type(rid) ){
791 case CFTYPE_MANIFEST: zType = "Check-in"; break;
792 case CFTYPE_WIKI: zType = "Wiki-edit"; break;
793 case CFTYPE_EVENT: zType = "Technote"; break;
794 case CFTYPE_FORUM: zType = "Forum-post"; break;
795 case CFTYPE_TICKET: zType = "Ticket-change"; break;
796 case CFTYPE_CONTROL: zType = "Tag-change"; break;
797 default: break;
798 }
799 return zType;
800 }
801
802 /*
803 ** Generate a description of artifact "rid"
804 */
805 void whatis_rid(int rid, int verboseFlag){
@@ -771,10 +830,11 @@
830 /* Report any symbolic tags on this artifact */
831 db_prepare(&q,
832 "SELECT substr(tagname,5)"
833 " FROM tag JOIN tagxref ON tag.tagid=tagxref.tagid"
834 " WHERE tagxref.rid=%d"
835 " AND tagxref.tagtype<>0"
836 " AND tagname GLOB 'sym-*'"
837 " ORDER BY 1",
838 rid
839 );
840 cnt = 0;
841
+42 -1
--- src/pikchr.c
+++ src/pikchr.c
@@ -7308,10 +7308,28 @@
73087308
}else{
73097309
pToken->eType = T_LT;
73107310
return 1;
73117311
}
73127312
}
7313
+ case 0xe2: {
7314
+ if( z[1]==0x86 ){
7315
+ if( z[2]==0x90 ){
7316
+ pToken->eType = T_LARROW; /* <- */
7317
+ return 3;
7318
+ }
7319
+ if( z[2]==0x92 ){
7320
+ pToken->eType = T_RARROW; /* -> */
7321
+ return 3;
7322
+ }
7323
+ if( z[2]==0x94 ){
7324
+ pToken->eType = T_LRARROW; /* <-> */
7325
+ return 3;
7326
+ }
7327
+ }
7328
+ pToken->eType = T_ERROR;
7329
+ return 1;
7330
+ }
73137331
case '{': {
73147332
int len, depth;
73157333
i = 1;
73167334
if( bAllowCodeBlock ){
73177335
depth = 1;
@@ -7332,10 +7350,33 @@
73327350
pToken->eType = T_ERROR;
73337351
return 1;
73347352
}
73357353
pToken->eType = T_CODEBLOCK;
73367354
return i;
7355
+ }
7356
+ case '&': {
7357
+ static const struct {
7358
+ int nByte; /* Number of bytes in zEntity */
7359
+ int eCode; /* Corresponding token code */
7360
+ const char *zEntity; /* Name of the HTML entity */
7361
+ } aEntity[] = {
7362
+ /* 123456789 1234567 */
7363
+ { 6, T_RARROW, "&rarr;" }, /* Same as -> */
7364
+ { 12, T_RARROW, "&rightarrow;" }, /* Same as -> */
7365
+ { 6, T_LARROW, "&larr;" }, /* Same as <- */
7366
+ { 11, T_LARROW, "&leftarrow;" }, /* Same as <- */
7367
+ { 16, T_LRARROW, "&leftrightarrow;" }, /* Same as <-> */
7368
+ };
7369
+ unsigned int i;
7370
+ for(i=0; i<sizeof(aEntity)/sizeof(aEntity[0]); i++){
7371
+ if( strncmp((const char*)z,aEntity[i].zEntity,aEntity[i].nByte)==0 ){
7372
+ pToken->eType = aEntity[i].eCode;
7373
+ return aEntity[i].nByte;
7374
+ }
7375
+ }
7376
+ pToken->eType = T_ERROR;
7377
+ return 1;
73377378
}
73387379
default: {
73397380
c = z[0];
73407381
if( c=='.' ){
73417382
unsigned char c1 = z[1];
@@ -7960,6 +8001,6 @@
79608001
79618002
79628003
#endif /* PIKCHR_TCL */
79638004
79648005
7965
-#line 7990 "pikchr.c"
8006
+#line 8031 "pikchr.c"
79668007
--- src/pikchr.c
+++ src/pikchr.c
@@ -7308,10 +7308,28 @@
7308 }else{
7309 pToken->eType = T_LT;
7310 return 1;
7311 }
7312 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7313 case '{': {
7314 int len, depth;
7315 i = 1;
7316 if( bAllowCodeBlock ){
7317 depth = 1;
@@ -7332,10 +7350,33 @@
7332 pToken->eType = T_ERROR;
7333 return 1;
7334 }
7335 pToken->eType = T_CODEBLOCK;
7336 return i;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7337 }
7338 default: {
7339 c = z[0];
7340 if( c=='.' ){
7341 unsigned char c1 = z[1];
@@ -7960,6 +8001,6 @@
7960
7961
7962 #endif /* PIKCHR_TCL */
7963
7964
7965 #line 7990 "pikchr.c"
7966
--- src/pikchr.c
+++ src/pikchr.c
@@ -7308,10 +7308,28 @@
7308 }else{
7309 pToken->eType = T_LT;
7310 return 1;
7311 }
7312 }
7313 case 0xe2: {
7314 if( z[1]==0x86 ){
7315 if( z[2]==0x90 ){
7316 pToken->eType = T_LARROW; /* <- */
7317 return 3;
7318 }
7319 if( z[2]==0x92 ){
7320 pToken->eType = T_RARROW; /* -> */
7321 return 3;
7322 }
7323 if( z[2]==0x94 ){
7324 pToken->eType = T_LRARROW; /* <-> */
7325 return 3;
7326 }
7327 }
7328 pToken->eType = T_ERROR;
7329 return 1;
7330 }
7331 case '{': {
7332 int len, depth;
7333 i = 1;
7334 if( bAllowCodeBlock ){
7335 depth = 1;
@@ -7332,10 +7350,33 @@
7350 pToken->eType = T_ERROR;
7351 return 1;
7352 }
7353 pToken->eType = T_CODEBLOCK;
7354 return i;
7355 }
7356 case '&': {
7357 static const struct {
7358 int nByte; /* Number of bytes in zEntity */
7359 int eCode; /* Corresponding token code */
7360 const char *zEntity; /* Name of the HTML entity */
7361 } aEntity[] = {
7362 /* 123456789 1234567 */
7363 { 6, T_RARROW, "&rarr;" }, /* Same as -> */
7364 { 12, T_RARROW, "&rightarrow;" }, /* Same as -> */
7365 { 6, T_LARROW, "&larr;" }, /* Same as <- */
7366 { 11, T_LARROW, "&leftarrow;" }, /* Same as <- */
7367 { 16, T_LRARROW, "&leftrightarrow;" }, /* Same as <-> */
7368 };
7369 unsigned int i;
7370 for(i=0; i<sizeof(aEntity)/sizeof(aEntity[0]); i++){
7371 if( strncmp((const char*)z,aEntity[i].zEntity,aEntity[i].nByte)==0 ){
7372 pToken->eType = aEntity[i].eCode;
7373 return aEntity[i].nByte;
7374 }
7375 }
7376 pToken->eType = T_ERROR;
7377 return 1;
7378 }
7379 default: {
7380 c = z[0];
7381 if( c=='.' ){
7382 unsigned char c1 = z[1];
@@ -7960,6 +8001,6 @@
8001
8002
8003 #endif /* PIKCHR_TCL */
8004
8005
8006 #line 8031 "pikchr.c"
8007
+1 -1
--- src/rebuild.c
+++ src/rebuild.c
@@ -397,11 +397,11 @@
397397
" WHERE type='table'"
398398
" AND name NOT IN ('admin_log', 'blob','delta','rcvfrom','user','alias',"
399399
"'config','shun','private','reportfmt',"
400400
"'concealed','accesslog','modreq',"
401401
"'purgeevent','purgeitem','unversioned',"
402
- "'subscriber','pending_alert','alert_bounce','chat')"
402
+ "'subscriber','pending_alert','chat')"
403403
" AND name NOT GLOB 'sqlite_*'"
404404
" AND name NOT GLOB 'fx_*'"
405405
);
406406
while( db_step(&q)==SQLITE_ROW ){
407407
blob_appendf(&sql, "DROP TABLE IF EXISTS \"%w\";\n", db_column_text(&q,0));
408408
--- src/rebuild.c
+++ src/rebuild.c
@@ -397,11 +397,11 @@
397 " WHERE type='table'"
398 " AND name NOT IN ('admin_log', 'blob','delta','rcvfrom','user','alias',"
399 "'config','shun','private','reportfmt',"
400 "'concealed','accesslog','modreq',"
401 "'purgeevent','purgeitem','unversioned',"
402 "'subscriber','pending_alert','alert_bounce','chat')"
403 " AND name NOT GLOB 'sqlite_*'"
404 " AND name NOT GLOB 'fx_*'"
405 );
406 while( db_step(&q)==SQLITE_ROW ){
407 blob_appendf(&sql, "DROP TABLE IF EXISTS \"%w\";\n", db_column_text(&q,0));
408
--- src/rebuild.c
+++ src/rebuild.c
@@ -397,11 +397,11 @@
397 " WHERE type='table'"
398 " AND name NOT IN ('admin_log', 'blob','delta','rcvfrom','user','alias',"
399 "'config','shun','private','reportfmt',"
400 "'concealed','accesslog','modreq',"
401 "'purgeevent','purgeitem','unversioned',"
402 "'subscriber','pending_alert','chat')"
403 " AND name NOT GLOB 'sqlite_*'"
404 " AND name NOT GLOB 'fx_*'"
405 );
406 while( db_step(&q)==SQLITE_ROW ){
407 blob_appendf(&sql, "DROP TABLE IF EXISTS \"%w\";\n", db_column_text(&q,0));
408
+59 -11
--- src/regexp.c
+++ src/regexp.c
@@ -11,16 +11,52 @@
1111
**
1212
** Author contact information:
1313
** [email protected]
1414
** http://www.hwaci.com/drh/
1515
**
16
-*******************************************************************************
16
+******************************************************************************
1717
**
1818
** This file was adapted from the ext/misc/regexp.c file in SQLite3. That
1919
** file is in the public domain.
2020
**
2121
** See ../www/grep.md for details of the algorithm and RE dialect.
22
+**
23
+**
24
+** The following regular expression syntax is supported:
25
+**
26
+** X* zero or more occurrences of X
27
+** X+ one or more occurrences of X
28
+** X? zero or one occurrences of X
29
+** X{p,q} between p and q occurrences of X
30
+** (X) match X
31
+** X|Y X or Y
32
+** ^X X occurring at the beginning of the string
33
+** X$ X occurring at the end of the string
34
+** . Match any single character
35
+** \c Character c where c is one of \{}()[]|*+?.
36
+** \c C-language escapes for c in afnrtv. ex: \t or \n
37
+** \uXXXX Where XXXX is exactly 4 hex digits, unicode value XXXX
38
+** \xXX Where XX is exactly 2 hex digits, unicode value XX
39
+** [abc] Any single character from the set abc
40
+** [^abc] Any single character not in the set abc
41
+** [a-z] Any single character in the range a-z
42
+** [^a-z] Any single character not in the range a-z
43
+** \b Word boundary
44
+** \w Word character. [A-Za-z0-9_]
45
+** \W Non-word character
46
+** \d Digit
47
+** \D Non-digit
48
+** \s Whitespace character
49
+** \S Non-whitespace character
50
+**
51
+** A nondeterministic finite automaton (NFA) is used for matching, so the
52
+** performance is bounded by O(N*M) where N is the size of the regular
53
+** expression and M is the size of the input string. The matcher never
54
+** exhibits exponential behavior. Note that the X{p,q} operator expands
55
+** to p copies of X following by q-p copies of X? and that the size of the
56
+** regular expression in the O(N*M) performance bound is computed after
57
+** this expansion.
2258
*/
2359
#include "config.h"
2460
#include "regexp.h"
2561
2662
/* The end-of-input character */
@@ -197,35 +233,35 @@
197233
case RE_OP_MATCH: {
198234
if( pRe->aArg[x]==c ) re_add_state(pNext, x+1);
199235
break;
200236
}
201237
case RE_OP_ANY: {
202
- re_add_state(pNext, x+1);
238
+ if( c!=0 ) re_add_state(pNext, x+1);
203239
break;
204240
}
205241
case RE_OP_WORD: {
206242
if( re_word_char(c) ) re_add_state(pNext, x+1);
207243
break;
208244
}
209245
case RE_OP_NOTWORD: {
210
- if( !re_word_char(c) ) re_add_state(pNext, x+1);
246
+ if( !re_word_char(c) && c!=0 ) re_add_state(pNext, x+1);
211247
break;
212248
}
213249
case RE_OP_DIGIT: {
214250
if( re_digit_char(c) ) re_add_state(pNext, x+1);
215251
break;
216252
}
217253
case RE_OP_NOTDIGIT: {
218
- if( !re_digit_char(c) ) re_add_state(pNext, x+1);
254
+ if( !re_digit_char(c) && c!=0 ) re_add_state(pNext, x+1);
219255
break;
220256
}
221257
case RE_OP_SPACE: {
222258
if( re_space_char(c) ) re_add_state(pNext, x+1);
223259
break;
224260
}
225261
case RE_OP_NOTSPACE: {
226
- if( !re_space_char(c) ) re_add_state(pNext, x+1);
262
+ if( !re_space_char(c) && c!=0 ) re_add_state(pNext, x+1);
227263
break;
228264
}
229265
case RE_OP_BOUNDARY: {
230266
if( re_word_char(c)!=re_word_char(cPrev) ) re_add_state(pThis, x+1);
231267
break;
@@ -246,12 +282,15 @@
246282
}
247283
case RE_OP_ACCEPT: {
248284
rc = 1;
249285
goto re_match_end;
250286
}
251
- case RE_OP_CC_INC:
252287
case RE_OP_CC_EXC: {
288
+ if( c==0 ) break;
289
+ /* fall-through */
290
+ }
291
+ case RE_OP_CC_INC: {
253292
int j = 1;
254293
int n = pRe->aArg[x];
255294
int hit = 0;
256295
for(j=1; j>0 && j<n; j++){
257296
if( pRe->aOp[x+j]==RE_OP_CC_VALUE ){
@@ -622,12 +661,12 @@
622661
** zInit[]. The re_match() routine can then search ahead in the input
623662
** string looking for the initial match without having to run the whole
624663
** regex engine over the string. Do not worry able trying to match
625664
** unicode characters beyond plane 0 - those are very rare and this is
626665
** just an optimization. */
627
- if( pRe->aOp[0]==RE_OP_ANYSTAR ){
628
- for(j=0, i=1; j<sizeof(pRe->zInit)-2 && pRe->aOp[i]==RE_OP_MATCH; i++){
666
+ if( pRe->aOp[0]==RE_OP_ANYSTAR && !noCase ){
667
+ for(j=0, i=1; j<(int)sizeof(pRe->zInit)-2 && pRe->aOp[i]==RE_OP_MATCH; i++){
629668
unsigned x = pRe->aArg[i];
630669
if( x<=127 ){
631670
pRe->zInit[j++] = (unsigned char)x;
632671
}else if( x<=0xfff ){
633672
pRe->zInit[j++] = (unsigned char)(0xc0 | (x>>6));
@@ -664,15 +703,16 @@
664703
const char *zPattern; /* The regular expression */
665704
const unsigned char *zStr;/* String being searched */
666705
const char *zErr; /* Compile error message */
667706
int setAux = 0; /* True to invoke sqlite3_set_auxdata() */
668707
708
+ (void)argc; /* Unused */
669709
pRe = sqlite3_get_auxdata(context, 0);
670710
if( pRe==0 ){
671711
zPattern = (const char*)sqlite3_value_text(argv[0]);
672712
if( zPattern==0 ) return;
673
- zErr = re_compile(&pRe, zPattern, 0);
713
+ zErr = re_compile(&pRe, zPattern, sqlite3_user_data(context)!=0);
674714
if( zErr ){
675715
re_free(pRe);
676716
sqlite3_result_error(context, zErr, -1);
677717
return;
678718
}
@@ -694,12 +734,20 @@
694734
/*
695735
** Invoke this routine to register the regexp() function with the
696736
** SQLite database connection.
697737
*/
698738
int re_add_sql_func(sqlite3 *db){
699
- return sqlite3_create_function(db, "regexp", 2, SQLITE_UTF8, 0,
700
- re_sql_func, 0, 0);
739
+ int rc;
740
+ rc = sqlite3_create_function(db, "regexp", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
741
+ 0, re_sql_func, 0, 0);
742
+ if( rc==SQLITE_OK ){
743
+ /* The regexpi(PATTERN,STRING) function is a case-insensitive version
744
+ ** of regexp(PATTERN,STRING). */
745
+ rc = sqlite3_create_function(db, "regexpi", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
746
+ (void*)db, re_sql_func, 0, 0);
747
+ }
748
+ return rc;
701749
}
702750
703751
/*
704752
** Run a "grep" over a single file read from disk.
705753
*/
706754
--- src/regexp.c
+++ src/regexp.c
@@ -11,16 +11,52 @@
11 **
12 ** Author contact information:
13 ** [email protected]
14 ** http://www.hwaci.com/drh/
15 **
16 *******************************************************************************
17 **
18 ** This file was adapted from the ext/misc/regexp.c file in SQLite3. That
19 ** file is in the public domain.
20 **
21 ** See ../www/grep.md for details of the algorithm and RE dialect.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22 */
23 #include "config.h"
24 #include "regexp.h"
25
26 /* The end-of-input character */
@@ -197,35 +233,35 @@
197 case RE_OP_MATCH: {
198 if( pRe->aArg[x]==c ) re_add_state(pNext, x+1);
199 break;
200 }
201 case RE_OP_ANY: {
202 re_add_state(pNext, x+1);
203 break;
204 }
205 case RE_OP_WORD: {
206 if( re_word_char(c) ) re_add_state(pNext, x+1);
207 break;
208 }
209 case RE_OP_NOTWORD: {
210 if( !re_word_char(c) ) re_add_state(pNext, x+1);
211 break;
212 }
213 case RE_OP_DIGIT: {
214 if( re_digit_char(c) ) re_add_state(pNext, x+1);
215 break;
216 }
217 case RE_OP_NOTDIGIT: {
218 if( !re_digit_char(c) ) re_add_state(pNext, x+1);
219 break;
220 }
221 case RE_OP_SPACE: {
222 if( re_space_char(c) ) re_add_state(pNext, x+1);
223 break;
224 }
225 case RE_OP_NOTSPACE: {
226 if( !re_space_char(c) ) re_add_state(pNext, x+1);
227 break;
228 }
229 case RE_OP_BOUNDARY: {
230 if( re_word_char(c)!=re_word_char(cPrev) ) re_add_state(pThis, x+1);
231 break;
@@ -246,12 +282,15 @@
246 }
247 case RE_OP_ACCEPT: {
248 rc = 1;
249 goto re_match_end;
250 }
251 case RE_OP_CC_INC:
252 case RE_OP_CC_EXC: {
 
 
 
 
253 int j = 1;
254 int n = pRe->aArg[x];
255 int hit = 0;
256 for(j=1; j>0 && j<n; j++){
257 if( pRe->aOp[x+j]==RE_OP_CC_VALUE ){
@@ -622,12 +661,12 @@
622 ** zInit[]. The re_match() routine can then search ahead in the input
623 ** string looking for the initial match without having to run the whole
624 ** regex engine over the string. Do not worry able trying to match
625 ** unicode characters beyond plane 0 - those are very rare and this is
626 ** just an optimization. */
627 if( pRe->aOp[0]==RE_OP_ANYSTAR ){
628 for(j=0, i=1; j<sizeof(pRe->zInit)-2 && pRe->aOp[i]==RE_OP_MATCH; i++){
629 unsigned x = pRe->aArg[i];
630 if( x<=127 ){
631 pRe->zInit[j++] = (unsigned char)x;
632 }else if( x<=0xfff ){
633 pRe->zInit[j++] = (unsigned char)(0xc0 | (x>>6));
@@ -664,15 +703,16 @@
664 const char *zPattern; /* The regular expression */
665 const unsigned char *zStr;/* String being searched */
666 const char *zErr; /* Compile error message */
667 int setAux = 0; /* True to invoke sqlite3_set_auxdata() */
668
 
669 pRe = sqlite3_get_auxdata(context, 0);
670 if( pRe==0 ){
671 zPattern = (const char*)sqlite3_value_text(argv[0]);
672 if( zPattern==0 ) return;
673 zErr = re_compile(&pRe, zPattern, 0);
674 if( zErr ){
675 re_free(pRe);
676 sqlite3_result_error(context, zErr, -1);
677 return;
678 }
@@ -694,12 +734,20 @@
694 /*
695 ** Invoke this routine to register the regexp() function with the
696 ** SQLite database connection.
697 */
698 int re_add_sql_func(sqlite3 *db){
699 return sqlite3_create_function(db, "regexp", 2, SQLITE_UTF8, 0,
700 re_sql_func, 0, 0);
 
 
 
 
 
 
 
 
701 }
702
703 /*
704 ** Run a "grep" over a single file read from disk.
705 */
706
--- src/regexp.c
+++ src/regexp.c
@@ -11,16 +11,52 @@
11 **
12 ** Author contact information:
13 ** [email protected]
14 ** http://www.hwaci.com/drh/
15 **
16 ******************************************************************************
17 **
18 ** This file was adapted from the ext/misc/regexp.c file in SQLite3. That
19 ** file is in the public domain.
20 **
21 ** See ../www/grep.md for details of the algorithm and RE dialect.
22 **
23 **
24 ** The following regular expression syntax is supported:
25 **
26 ** X* zero or more occurrences of X
27 ** X+ one or more occurrences of X
28 ** X? zero or one occurrences of X
29 ** X{p,q} between p and q occurrences of X
30 ** (X) match X
31 ** X|Y X or Y
32 ** ^X X occurring at the beginning of the string
33 ** X$ X occurring at the end of the string
34 ** . Match any single character
35 ** \c Character c where c is one of \{}()[]|*+?.
36 ** \c C-language escapes for c in afnrtv. ex: \t or \n
37 ** \uXXXX Where XXXX is exactly 4 hex digits, unicode value XXXX
38 ** \xXX Where XX is exactly 2 hex digits, unicode value XX
39 ** [abc] Any single character from the set abc
40 ** [^abc] Any single character not in the set abc
41 ** [a-z] Any single character in the range a-z
42 ** [^a-z] Any single character not in the range a-z
43 ** \b Word boundary
44 ** \w Word character. [A-Za-z0-9_]
45 ** \W Non-word character
46 ** \d Digit
47 ** \D Non-digit
48 ** \s Whitespace character
49 ** \S Non-whitespace character
50 **
51 ** A nondeterministic finite automaton (NFA) is used for matching, so the
52 ** performance is bounded by O(N*M) where N is the size of the regular
53 ** expression and M is the size of the input string. The matcher never
54 ** exhibits exponential behavior. Note that the X{p,q} operator expands
55 ** to p copies of X following by q-p copies of X? and that the size of the
56 ** regular expression in the O(N*M) performance bound is computed after
57 ** this expansion.
58 */
59 #include "config.h"
60 #include "regexp.h"
61
62 /* The end-of-input character */
@@ -197,35 +233,35 @@
233 case RE_OP_MATCH: {
234 if( pRe->aArg[x]==c ) re_add_state(pNext, x+1);
235 break;
236 }
237 case RE_OP_ANY: {
238 if( c!=0 ) re_add_state(pNext, x+1);
239 break;
240 }
241 case RE_OP_WORD: {
242 if( re_word_char(c) ) re_add_state(pNext, x+1);
243 break;
244 }
245 case RE_OP_NOTWORD: {
246 if( !re_word_char(c) && c!=0 ) re_add_state(pNext, x+1);
247 break;
248 }
249 case RE_OP_DIGIT: {
250 if( re_digit_char(c) ) re_add_state(pNext, x+1);
251 break;
252 }
253 case RE_OP_NOTDIGIT: {
254 if( !re_digit_char(c) && c!=0 ) re_add_state(pNext, x+1);
255 break;
256 }
257 case RE_OP_SPACE: {
258 if( re_space_char(c) ) re_add_state(pNext, x+1);
259 break;
260 }
261 case RE_OP_NOTSPACE: {
262 if( !re_space_char(c) && c!=0 ) re_add_state(pNext, x+1);
263 break;
264 }
265 case RE_OP_BOUNDARY: {
266 if( re_word_char(c)!=re_word_char(cPrev) ) re_add_state(pThis, x+1);
267 break;
@@ -246,12 +282,15 @@
282 }
283 case RE_OP_ACCEPT: {
284 rc = 1;
285 goto re_match_end;
286 }
 
287 case RE_OP_CC_EXC: {
288 if( c==0 ) break;
289 /* fall-through */
290 }
291 case RE_OP_CC_INC: {
292 int j = 1;
293 int n = pRe->aArg[x];
294 int hit = 0;
295 for(j=1; j>0 && j<n; j++){
296 if( pRe->aOp[x+j]==RE_OP_CC_VALUE ){
@@ -622,12 +661,12 @@
661 ** zInit[]. The re_match() routine can then search ahead in the input
662 ** string looking for the initial match without having to run the whole
663 ** regex engine over the string. Do not worry able trying to match
664 ** unicode characters beyond plane 0 - those are very rare and this is
665 ** just an optimization. */
666 if( pRe->aOp[0]==RE_OP_ANYSTAR && !noCase ){
667 for(j=0, i=1; j<(int)sizeof(pRe->zInit)-2 && pRe->aOp[i]==RE_OP_MATCH; i++){
668 unsigned x = pRe->aArg[i];
669 if( x<=127 ){
670 pRe->zInit[j++] = (unsigned char)x;
671 }else if( x<=0xfff ){
672 pRe->zInit[j++] = (unsigned char)(0xc0 | (x>>6));
@@ -664,15 +703,16 @@
703 const char *zPattern; /* The regular expression */
704 const unsigned char *zStr;/* String being searched */
705 const char *zErr; /* Compile error message */
706 int setAux = 0; /* True to invoke sqlite3_set_auxdata() */
707
708 (void)argc; /* Unused */
709 pRe = sqlite3_get_auxdata(context, 0);
710 if( pRe==0 ){
711 zPattern = (const char*)sqlite3_value_text(argv[0]);
712 if( zPattern==0 ) return;
713 zErr = re_compile(&pRe, zPattern, sqlite3_user_data(context)!=0);
714 if( zErr ){
715 re_free(pRe);
716 sqlite3_result_error(context, zErr, -1);
717 return;
718 }
@@ -694,12 +734,20 @@
734 /*
735 ** Invoke this routine to register the regexp() function with the
736 ** SQLite database connection.
737 */
738 int re_add_sql_func(sqlite3 *db){
739 int rc;
740 rc = sqlite3_create_function(db, "regexp", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
741 0, re_sql_func, 0, 0);
742 if( rc==SQLITE_OK ){
743 /* The regexpi(PATTERN,STRING) function is a case-insensitive version
744 ** of regexp(PATTERN,STRING). */
745 rc = sqlite3_create_function(db, "regexpi", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
746 (void*)db, re_sql_func, 0, 0);
747 }
748 return rc;
749 }
750
751 /*
752 ** Run a "grep" over a single file read from disk.
753 */
754
+19 -3
--- src/repolist.c
+++ src/repolist.c
@@ -31,10 +31,11 @@
3131
int isValid; /* True if zRepoName is a valid Fossil repository */
3232
int isRepolistSkin; /* 1 or 2 if this repository wants to be the skin
3333
** for the repository list. 2 means do use this
3434
** repository but do not display it in the list. */
3535
char *zProjName; /* Project Name. Memory from fossil_malloc() */
36
+ char *zLoginGroup; /* Name of login group, or NULL. Malloced() */
3637
double rMTime; /* Last update. Julian day number */
3738
};
3839
#endif
3940
4041
/*
@@ -48,10 +49,11 @@
4849
int rc;
4950
5051
pRepo->isRepolistSkin = 0;
5152
pRepo->isValid = 0;
5253
pRepo->zProjName = 0;
54
+ pRepo->zLoginGroup = 0;
5355
pRepo->rMTime = 0.0;
5456
5557
g.dbIgnoreErrors++;
5658
rc = sqlite3_open_v2(pRepo->zRepoName, &db, SQLITE_OPEN_READWRITE, 0);
5759
if( rc ) goto finish_repo_list;
@@ -69,10 +71,17 @@
6971
-1, &pStmt, 0);
7072
if( rc ) goto finish_repo_list;
7173
if( sqlite3_step(pStmt)==SQLITE_ROW ){
7274
pRepo->zProjName = fossil_strdup((char*)sqlite3_column_text(pStmt,0));
7375
}
76
+ sqlite3_finalize(pStmt);
77
+ rc = sqlite3_prepare_v2(db, "SELECT value FROM config"
78
+ " WHERE name='login-group-name'",
79
+ -1, &pStmt, 0);
80
+ if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
81
+ pRepo->zLoginGroup = fossil_strdup((char*)sqlite3_column_text(pStmt,0));
82
+ }
7483
sqlite3_finalize(pStmt);
7584
rc = sqlite3_prepare_v2(db, "SELECT max(mtime) FROM event", -1, &pStmt, 0);
7685
if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
7786
pRepo->rMTime = sqlite3_column_double(pStmt,0);
7887
}
@@ -149,14 +158,15 @@
149158
}else{
150159
Stmt q;
151160
double rNow;
152161
blob_append_sql(&html,
153162
"<table border='0' class='sortable' data-init-sort='1'"
154
- " data-column-types='txtxk'><thead>\n"
163
+ " data-column-types='txtxkxt'><thead>\n"
155164
"<tr><th>Filename<th width='20'>"
156165
"<th>Project Name<th width='20'>"
157
- "<th>Last Modified</tr>\n"
166
+ "<th>Last Modified<th width='20'>"
167
+ "<th>Login Group</tr>\n"
158168
"</thead><tbody>\n");
159169
db_prepare(&q, "SELECT pathname"
160170
" FROM sfile ORDER BY pathname COLLATE nocase;");
161171
rNow = db_double(0, "SELECT julianday('now')");
162172
while( db_step(&q)==SQLITE_ROW ){
@@ -223,13 +233,19 @@
223233
fossil_free(x.zProjName);
224234
}else{
225235
blob_append_sql(&html, "<td></td><td></td>\n");
226236
}
227237
blob_append_sql(&html,
228
- "<td></td><td data-sortkey='%08x'>%h</tr>\n",
238
+ "<td></td><td data-sortkey='%08x'>%h</td>\n",
229239
iAge, zAge);
230240
fossil_free(zAge);
241
+ if( x.zLoginGroup ){
242
+ blob_append_sql(&html, "<td></td><td>%h</td></tr>\n", x.zLoginGroup);
243
+ fossil_free(x.zLoginGroup);
244
+ }else{
245
+ blob_append_sql(&html, "<td></td><td></td></tr>\n");
246
+ }
231247
sqlite3_free(zUrl);
232248
}
233249
db_finalize(&q);
234250
blob_append_sql(&html,"</tbody></table>\n");
235251
}
236252
--- src/repolist.c
+++ src/repolist.c
@@ -31,10 +31,11 @@
31 int isValid; /* True if zRepoName is a valid Fossil repository */
32 int isRepolistSkin; /* 1 or 2 if this repository wants to be the skin
33 ** for the repository list. 2 means do use this
34 ** repository but do not display it in the list. */
35 char *zProjName; /* Project Name. Memory from fossil_malloc() */
 
36 double rMTime; /* Last update. Julian day number */
37 };
38 #endif
39
40 /*
@@ -48,10 +49,11 @@
48 int rc;
49
50 pRepo->isRepolistSkin = 0;
51 pRepo->isValid = 0;
52 pRepo->zProjName = 0;
 
53 pRepo->rMTime = 0.0;
54
55 g.dbIgnoreErrors++;
56 rc = sqlite3_open_v2(pRepo->zRepoName, &db, SQLITE_OPEN_READWRITE, 0);
57 if( rc ) goto finish_repo_list;
@@ -69,10 +71,17 @@
69 -1, &pStmt, 0);
70 if( rc ) goto finish_repo_list;
71 if( sqlite3_step(pStmt)==SQLITE_ROW ){
72 pRepo->zProjName = fossil_strdup((char*)sqlite3_column_text(pStmt,0));
73 }
 
 
 
 
 
 
 
74 sqlite3_finalize(pStmt);
75 rc = sqlite3_prepare_v2(db, "SELECT max(mtime) FROM event", -1, &pStmt, 0);
76 if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
77 pRepo->rMTime = sqlite3_column_double(pStmt,0);
78 }
@@ -149,14 +158,15 @@
149 }else{
150 Stmt q;
151 double rNow;
152 blob_append_sql(&html,
153 "<table border='0' class='sortable' data-init-sort='1'"
154 " data-column-types='txtxk'><thead>\n"
155 "<tr><th>Filename<th width='20'>"
156 "<th>Project Name<th width='20'>"
157 "<th>Last Modified</tr>\n"
 
158 "</thead><tbody>\n");
159 db_prepare(&q, "SELECT pathname"
160 " FROM sfile ORDER BY pathname COLLATE nocase;");
161 rNow = db_double(0, "SELECT julianday('now')");
162 while( db_step(&q)==SQLITE_ROW ){
@@ -223,13 +233,19 @@
223 fossil_free(x.zProjName);
224 }else{
225 blob_append_sql(&html, "<td></td><td></td>\n");
226 }
227 blob_append_sql(&html,
228 "<td></td><td data-sortkey='%08x'>%h</tr>\n",
229 iAge, zAge);
230 fossil_free(zAge);
 
 
 
 
 
 
231 sqlite3_free(zUrl);
232 }
233 db_finalize(&q);
234 blob_append_sql(&html,"</tbody></table>\n");
235 }
236
--- src/repolist.c
+++ src/repolist.c
@@ -31,10 +31,11 @@
31 int isValid; /* True if zRepoName is a valid Fossil repository */
32 int isRepolistSkin; /* 1 or 2 if this repository wants to be the skin
33 ** for the repository list. 2 means do use this
34 ** repository but do not display it in the list. */
35 char *zProjName; /* Project Name. Memory from fossil_malloc() */
36 char *zLoginGroup; /* Name of login group, or NULL. Malloced() */
37 double rMTime; /* Last update. Julian day number */
38 };
39 #endif
40
41 /*
@@ -48,10 +49,11 @@
49 int rc;
50
51 pRepo->isRepolistSkin = 0;
52 pRepo->isValid = 0;
53 pRepo->zProjName = 0;
54 pRepo->zLoginGroup = 0;
55 pRepo->rMTime = 0.0;
56
57 g.dbIgnoreErrors++;
58 rc = sqlite3_open_v2(pRepo->zRepoName, &db, SQLITE_OPEN_READWRITE, 0);
59 if( rc ) goto finish_repo_list;
@@ -69,10 +71,17 @@
71 -1, &pStmt, 0);
72 if( rc ) goto finish_repo_list;
73 if( sqlite3_step(pStmt)==SQLITE_ROW ){
74 pRepo->zProjName = fossil_strdup((char*)sqlite3_column_text(pStmt,0));
75 }
76 sqlite3_finalize(pStmt);
77 rc = sqlite3_prepare_v2(db, "SELECT value FROM config"
78 " WHERE name='login-group-name'",
79 -1, &pStmt, 0);
80 if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
81 pRepo->zLoginGroup = fossil_strdup((char*)sqlite3_column_text(pStmt,0));
82 }
83 sqlite3_finalize(pStmt);
84 rc = sqlite3_prepare_v2(db, "SELECT max(mtime) FROM event", -1, &pStmt, 0);
85 if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
86 pRepo->rMTime = sqlite3_column_double(pStmt,0);
87 }
@@ -149,14 +158,15 @@
158 }else{
159 Stmt q;
160 double rNow;
161 blob_append_sql(&html,
162 "<table border='0' class='sortable' data-init-sort='1'"
163 " data-column-types='txtxkxt'><thead>\n"
164 "<tr><th>Filename<th width='20'>"
165 "<th>Project Name<th width='20'>"
166 "<th>Last Modified<th width='20'>"
167 "<th>Login Group</tr>\n"
168 "</thead><tbody>\n");
169 db_prepare(&q, "SELECT pathname"
170 " FROM sfile ORDER BY pathname COLLATE nocase;");
171 rNow = db_double(0, "SELECT julianday('now')");
172 while( db_step(&q)==SQLITE_ROW ){
@@ -223,13 +233,19 @@
233 fossil_free(x.zProjName);
234 }else{
235 blob_append_sql(&html, "<td></td><td></td>\n");
236 }
237 blob_append_sql(&html,
238 "<td></td><td data-sortkey='%08x'>%h</td>\n",
239 iAge, zAge);
240 fossil_free(zAge);
241 if( x.zLoginGroup ){
242 blob_append_sql(&html, "<td></td><td>%h</td></tr>\n", x.zLoginGroup);
243 fossil_free(x.zLoginGroup);
244 }else{
245 blob_append_sql(&html, "<td></td><td></td></tr>\n");
246 }
247 sqlite3_free(zUrl);
248 }
249 db_finalize(&q);
250 blob_append_sql(&html,"</tbody></table>\n");
251 }
252
+14 -2
--- src/report.c
+++ src/report.c
@@ -161,10 +161,13 @@
161161
/*
162162
** This is the SQLite authorizer callback used to make sure that the
163163
** SQL statements entered by users do not try to do anything untoward.
164164
** If anything suspicious is tried, set *(char**)pError to an error
165165
** message obtained from malloc.
166
+**
167
+** Use the "fossil test-db-prepare --auth-report SQL" command to perform
168
+** manual testing of this authorizer.
166169
*/
167170
static int report_query_authorizer(
168171
void *pError,
169172
int code,
170173
const char *zArg1,
@@ -240,11 +243,12 @@
240243
}
241244
return rc;
242245
}
243246
244247
/*
245
-** Activate the query authorizer
248
+** Activate the ticket report query authorizer. Must be followed by an
249
+** eventual call to report_unrestrict_sql().
246250
*/
247251
void report_restrict_sql(char **pzErr){
248252
db_set_authorizer(report_query_authorizer,(void*)pzErr,"Ticket-Report");
249253
sqlite3_limit(g.db, SQLITE_LIMIT_VDBE_OP, 10000);
250254
}
@@ -1033,14 +1037,22 @@
10331037
}
10341038
10351039
count = 0;
10361040
if( !tabs ){
10371041
struct GenerateHTML sState = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
1042
+ const char *zQS = PD("QUERY_STRING","");
10381043
10391044
db_multi_exec("PRAGMA empty_result_callbacks=ON");
10401045
style_set_current_feature("report");
1041
- style_submenu_element("Raw", "rptview?tablist=1&rn=%d&%h", rn, PD("QUERY_STRING","") );
1046
+ /* style_finish_page() should provide escaping via %h formatting */
1047
+ if( zQS[0] ){
1048
+ style_submenu_element("Raw","%R/%s?tablist=1&%s",g.zPath,zQS);
1049
+ style_submenu_element("Reports","%R/reportlist?%s",zQS);
1050
+ } else {
1051
+ style_submenu_element("Raw","%R/%s?tablist=1",g.zPath);
1052
+ style_submenu_element("Reports","%R/reportlist");
1053
+ }
10421054
if( g.perm.Admin
10431055
|| (g.perm.TktFmt && g.zLogin && fossil_strcmp(g.zLogin,zOwner)==0) ){
10441056
style_submenu_element("Edit", "rptedit?rn=%d", rn);
10451057
}
10461058
if( g.perm.TktFmt ){
10471059
--- src/report.c
+++ src/report.c
@@ -161,10 +161,13 @@
161 /*
162 ** This is the SQLite authorizer callback used to make sure that the
163 ** SQL statements entered by users do not try to do anything untoward.
164 ** If anything suspicious is tried, set *(char**)pError to an error
165 ** message obtained from malloc.
 
 
 
166 */
167 static int report_query_authorizer(
168 void *pError,
169 int code,
170 const char *zArg1,
@@ -240,11 +243,12 @@
240 }
241 return rc;
242 }
243
244 /*
245 ** Activate the query authorizer
 
246 */
247 void report_restrict_sql(char **pzErr){
248 db_set_authorizer(report_query_authorizer,(void*)pzErr,"Ticket-Report");
249 sqlite3_limit(g.db, SQLITE_LIMIT_VDBE_OP, 10000);
250 }
@@ -1033,14 +1037,22 @@
1033 }
1034
1035 count = 0;
1036 if( !tabs ){
1037 struct GenerateHTML sState = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 
1038
1039 db_multi_exec("PRAGMA empty_result_callbacks=ON");
1040 style_set_current_feature("report");
1041 style_submenu_element("Raw", "rptview?tablist=1&rn=%d&%h", rn, PD("QUERY_STRING","") );
 
 
 
 
 
 
 
1042 if( g.perm.Admin
1043 || (g.perm.TktFmt && g.zLogin && fossil_strcmp(g.zLogin,zOwner)==0) ){
1044 style_submenu_element("Edit", "rptedit?rn=%d", rn);
1045 }
1046 if( g.perm.TktFmt ){
1047
--- src/report.c
+++ src/report.c
@@ -161,10 +161,13 @@
161 /*
162 ** This is the SQLite authorizer callback used to make sure that the
163 ** SQL statements entered by users do not try to do anything untoward.
164 ** If anything suspicious is tried, set *(char**)pError to an error
165 ** message obtained from malloc.
166 **
167 ** Use the "fossil test-db-prepare --auth-report SQL" command to perform
168 ** manual testing of this authorizer.
169 */
170 static int report_query_authorizer(
171 void *pError,
172 int code,
173 const char *zArg1,
@@ -240,11 +243,12 @@
243 }
244 return rc;
245 }
246
247 /*
248 ** Activate the ticket report query authorizer. Must be followed by an
249 ** eventual call to report_unrestrict_sql().
250 */
251 void report_restrict_sql(char **pzErr){
252 db_set_authorizer(report_query_authorizer,(void*)pzErr,"Ticket-Report");
253 sqlite3_limit(g.db, SQLITE_LIMIT_VDBE_OP, 10000);
254 }
@@ -1033,14 +1037,22 @@
1037 }
1038
1039 count = 0;
1040 if( !tabs ){
1041 struct GenerateHTML sState = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
1042 const char *zQS = PD("QUERY_STRING","");
1043
1044 db_multi_exec("PRAGMA empty_result_callbacks=ON");
1045 style_set_current_feature("report");
1046 /* style_finish_page() should provide escaping via %h formatting */
1047 if( zQS[0] ){
1048 style_submenu_element("Raw","%R/%s?tablist=1&%s",g.zPath,zQS);
1049 style_submenu_element("Reports","%R/reportlist?%s",zQS);
1050 } else {
1051 style_submenu_element("Raw","%R/%s?tablist=1",g.zPath);
1052 style_submenu_element("Reports","%R/reportlist");
1053 }
1054 if( g.perm.Admin
1055 || (g.perm.TktFmt && g.zLogin && fossil_strcmp(g.zLogin,zOwner)==0) ){
1056 style_submenu_element("Edit", "rptedit?rn=%d", rn);
1057 }
1058 if( g.perm.TktFmt ){
1059
+1 -1
--- src/schema.c
+++ src/schema.c
@@ -329,11 +329,11 @@
329329
@ rid INTEGER PRIMARY KEY -- Record ID of the phantom
330330
@ );
331331
@
332332
@ -- A record of orphaned delta-manifests. An orphan is a delta-manifest
333333
@ -- for which we have content, but its baseline-manifest is a phantom.
334
-@ -- We have to track all orphan maniftests so that when the baseline arrives,
334
+@ -- We have to track all orphan manifests so that when the baseline arrives,
335335
@ -- we know to process the orphaned deltas.
336336
@ CREATE TABLE orphan(
337337
@ rid INTEGER PRIMARY KEY, -- Delta manifest with a phantom baseline
338338
@ baseline INTEGER -- Phantom baseline of this orphan
339339
@ );
340340
--- src/schema.c
+++ src/schema.c
@@ -329,11 +329,11 @@
329 @ rid INTEGER PRIMARY KEY -- Record ID of the phantom
330 @ );
331 @
332 @ -- A record of orphaned delta-manifests. An orphan is a delta-manifest
333 @ -- for which we have content, but its baseline-manifest is a phantom.
334 @ -- We have to track all orphan maniftests so that when the baseline arrives,
335 @ -- we know to process the orphaned deltas.
336 @ CREATE TABLE orphan(
337 @ rid INTEGER PRIMARY KEY, -- Delta manifest with a phantom baseline
338 @ baseline INTEGER -- Phantom baseline of this orphan
339 @ );
340
--- src/schema.c
+++ src/schema.c
@@ -329,11 +329,11 @@
329 @ rid INTEGER PRIMARY KEY -- Record ID of the phantom
330 @ );
331 @
332 @ -- A record of orphaned delta-manifests. An orphan is a delta-manifest
333 @ -- for which we have content, but its baseline-manifest is a phantom.
334 @ -- We have to track all orphan manifests so that when the baseline arrives,
335 @ -- we know to process the orphaned deltas.
336 @ CREATE TABLE orphan(
337 @ rid INTEGER PRIMARY KEY, -- Delta manifest with a phantom baseline
338 @ baseline INTEGER -- Phantom baseline of this orphan
339 @ );
340
+5 -5
--- src/setup.c
+++ src/setup.c
@@ -970,14 +970,14 @@
970970
**
971971
** * The third term is an argument to the TH1 "capexpr" command.
972972
** If capexpr evalutes to true, then the entry is shown. If not,
973973
** the entry is omitted. "*" is always true. "{}" is never true.
974974
**
975
-** * The fourth term is a list of extra class names to apply to the new
976
-** menu entry. Some skins will classes "desktoponly" and "wideonly"
977
-** to only show the entries when the web browser screen is wide or
978
-** very wide, respectively.
975
+** * The fourth term is a list of extra class names to apply to the
976
+** new menu entry. Some skins use classes "desktoponly" and
977
+** "wideonly" to only show the entries when the web browser
978
+** screen is wide or very wide, respectively.
979979
**
980980
** Some custom skins might not use this property. Whether the property
981981
** is used or not a choice made by the skin designer. Some skins may add
982982
** extra choices (such as the hamburger button) to the menu.
983983
*/
@@ -1090,11 +1090,11 @@
10901090
@ repository root.
10911091
@ <li> The third term is an argument to the TH1 "capexpr" command.
10921092
@ If capexpr evalutes to true, then the entry is shown. If not,
10931093
@ the entry is omitted. "*" is always true. "{}" is never true.
10941094
@ <li> The fourth term is a list of extra class names to apply to the new
1095
- @ menu entry. Some skins will classes "desktoponly" and "wideonly"
1095
+ @ menu entry. Some skins use classes "desktoponly" and "wideonly"
10961096
@ to only show the entries when the web browser screen is wide or
10971097
@ very wide, respectively.
10981098
@ </ol>
10991099
@
11001100
@ <p>Some custom skins might not use this property. Whether the property
11011101
--- src/setup.c
+++ src/setup.c
@@ -970,14 +970,14 @@
970 **
971 ** * The third term is an argument to the TH1 "capexpr" command.
972 ** If capexpr evalutes to true, then the entry is shown. If not,
973 ** the entry is omitted. "*" is always true. "{}" is never true.
974 **
975 ** * The fourth term is a list of extra class names to apply to the new
976 ** menu entry. Some skins will classes "desktoponly" and "wideonly"
977 ** to only show the entries when the web browser screen is wide or
978 ** very wide, respectively.
979 **
980 ** Some custom skins might not use this property. Whether the property
981 ** is used or not a choice made by the skin designer. Some skins may add
982 ** extra choices (such as the hamburger button) to the menu.
983 */
@@ -1090,11 +1090,11 @@
1090 @ repository root.
1091 @ <li> The third term is an argument to the TH1 "capexpr" command.
1092 @ If capexpr evalutes to true, then the entry is shown. If not,
1093 @ the entry is omitted. "*" is always true. "{}" is never true.
1094 @ <li> The fourth term is a list of extra class names to apply to the new
1095 @ menu entry. Some skins will classes "desktoponly" and "wideonly"
1096 @ to only show the entries when the web browser screen is wide or
1097 @ very wide, respectively.
1098 @ </ol>
1099 @
1100 @ <p>Some custom skins might not use this property. Whether the property
1101
--- src/setup.c
+++ src/setup.c
@@ -970,14 +970,14 @@
970 **
971 ** * The third term is an argument to the TH1 "capexpr" command.
972 ** If capexpr evalutes to true, then the entry is shown. If not,
973 ** the entry is omitted. "*" is always true. "{}" is never true.
974 **
975 ** * The fourth term is a list of extra class names to apply to the
976 ** new menu entry. Some skins use classes "desktoponly" and
977 ** "wideonly" to only show the entries when the web browser
978 ** screen is wide or very wide, respectively.
979 **
980 ** Some custom skins might not use this property. Whether the property
981 ** is used or not a choice made by the skin designer. Some skins may add
982 ** extra choices (such as the hamburger button) to the menu.
983 */
@@ -1090,11 +1090,11 @@
1090 @ repository root.
1091 @ <li> The third term is an argument to the TH1 "capexpr" command.
1092 @ If capexpr evalutes to true, then the entry is shown. If not,
1093 @ the entry is omitted. "*" is always true. "{}" is never true.
1094 @ <li> The fourth term is a list of extra class names to apply to the new
1095 @ menu entry. Some skins use classes "desktoponly" and "wideonly"
1096 @ to only show the entries when the web browser screen is wide or
1097 @ very wide, respectively.
1098 @ </ol>
1099 @
1100 @ <p>Some custom skins might not use this property. Whether the property
1101
+887 -58
--- src/shell.c
+++ src/shell.c
@@ -4963,14 +4963,15 @@
49634963
sqlite3_value **argv
49644964
){
49654965
Decimal *pA = decimal_new(context, argv[0], 0, 0);
49664966
Decimal *pB = decimal_new(context, argv[1], 0, 0);
49674967
UNUSED_PARAMETER(argc);
4968
- if( pB==0 ) return;
4969
- pB->sign = !pB->sign;
4970
- decimal_add(pA, pB);
4971
- decimal_result(context, pA);
4968
+ if( pB ){
4969
+ pB->sign = !pB->sign;
4970
+ decimal_add(pA, pB);
4971
+ decimal_result(context, pA);
4972
+ }
49724973
decimal_free(pA);
49734974
decimal_free(pB);
49744975
}
49754976
49764977
/* Aggregate funcion: decimal_sum(X)
@@ -5878,10 +5879,784 @@
58785879
#endif
58795880
return rc;
58805881
}
58815882
58825883
/************************* End ../ext/misc/series.c ********************/
5884
+/************************* Begin ../ext/misc/regexp.c ******************/
5885
+/*
5886
+** 2012-11-13
5887
+**
5888
+** The author disclaims copyright to this source code. In place of
5889
+** a legal notice, here is a blessing:
5890
+**
5891
+** May you do good and not evil.
5892
+** May you find forgiveness for yourself and forgive others.
5893
+** May you share freely, never taking more than you give.
5894
+**
5895
+******************************************************************************
5896
+**
5897
+** The code in this file implements a compact but reasonably
5898
+** efficient regular-expression matcher for posix extended regular
5899
+** expressions against UTF8 text.
5900
+**
5901
+** This file is an SQLite extension. It registers a single function
5902
+** named "regexp(A,B)" where A is the regular expression and B is the
5903
+** string to be matched. By registering this function, SQLite will also
5904
+** then implement the "B regexp A" operator. Note that with the function
5905
+** the regular expression comes first, but with the operator it comes
5906
+** second.
5907
+**
5908
+** The following regular expression syntax is supported:
5909
+**
5910
+** X* zero or more occurrences of X
5911
+** X+ one or more occurrences of X
5912
+** X? zero or one occurrences of X
5913
+** X{p,q} between p and q occurrences of X
5914
+** (X) match X
5915
+** X|Y X or Y
5916
+** ^X X occurring at the beginning of the string
5917
+** X$ X occurring at the end of the string
5918
+** . Match any single character
5919
+** \c Character c where c is one of \{}()[]|*+?.
5920
+** \c C-language escapes for c in afnrtv. ex: \t or \n
5921
+** \uXXXX Where XXXX is exactly 4 hex digits, unicode value XXXX
5922
+** \xXX Where XX is exactly 2 hex digits, unicode value XX
5923
+** [abc] Any single character from the set abc
5924
+** [^abc] Any single character not in the set abc
5925
+** [a-z] Any single character in the range a-z
5926
+** [^a-z] Any single character not in the range a-z
5927
+** \b Word boundary
5928
+** \w Word character. [A-Za-z0-9_]
5929
+** \W Non-word character
5930
+** \d Digit
5931
+** \D Non-digit
5932
+** \s Whitespace character
5933
+** \S Non-whitespace character
5934
+**
5935
+** A nondeterministic finite automaton (NFA) is used for matching, so the
5936
+** performance is bounded by O(N*M) where N is the size of the regular
5937
+** expression and M is the size of the input string. The matcher never
5938
+** exhibits exponential behavior. Note that the X{p,q} operator expands
5939
+** to p copies of X following by q-p copies of X? and that the size of the
5940
+** regular expression in the O(N*M) performance bound is computed after
5941
+** this expansion.
5942
+*/
5943
+#include <string.h>
5944
+#include <stdlib.h>
5945
+/* #include "sqlite3ext.h" */
5946
+SQLITE_EXTENSION_INIT1
5947
+
5948
+/*
5949
+** The following #defines change the names of some functions implemented in
5950
+** this file to prevent name collisions with C-library functions of the
5951
+** same name.
5952
+*/
5953
+#define re_match sqlite3re_match
5954
+#define re_compile sqlite3re_compile
5955
+#define re_free sqlite3re_free
5956
+
5957
+/* The end-of-input character */
5958
+#define RE_EOF 0 /* End of input */
5959
+
5960
+/* The NFA is implemented as sequence of opcodes taken from the following
5961
+** set. Each opcode has a single integer argument.
5962
+*/
5963
+#define RE_OP_MATCH 1 /* Match the one character in the argument */
5964
+#define RE_OP_ANY 2 /* Match any one character. (Implements ".") */
5965
+#define RE_OP_ANYSTAR 3 /* Special optimized version of .* */
5966
+#define RE_OP_FORK 4 /* Continue to both next and opcode at iArg */
5967
+#define RE_OP_GOTO 5 /* Jump to opcode at iArg */
5968
+#define RE_OP_ACCEPT 6 /* Halt and indicate a successful match */
5969
+#define RE_OP_CC_INC 7 /* Beginning of a [...] character class */
5970
+#define RE_OP_CC_EXC 8 /* Beginning of a [^...] character class */
5971
+#define RE_OP_CC_VALUE 9 /* Single value in a character class */
5972
+#define RE_OP_CC_RANGE 10 /* Range of values in a character class */
5973
+#define RE_OP_WORD 11 /* Perl word character [A-Za-z0-9_] */
5974
+#define RE_OP_NOTWORD 12 /* Not a perl word character */
5975
+#define RE_OP_DIGIT 13 /* digit: [0-9] */
5976
+#define RE_OP_NOTDIGIT 14 /* Not a digit */
5977
+#define RE_OP_SPACE 15 /* space: [ \t\n\r\v\f] */
5978
+#define RE_OP_NOTSPACE 16 /* Not a digit */
5979
+#define RE_OP_BOUNDARY 17 /* Boundary between word and non-word */
5980
+
5981
+/* Each opcode is a "state" in the NFA */
5982
+typedef unsigned short ReStateNumber;
5983
+
5984
+/* Because this is an NFA and not a DFA, multiple states can be active at
5985
+** once. An instance of the following object records all active states in
5986
+** the NFA. The implementation is optimized for the common case where the
5987
+** number of actives states is small.
5988
+*/
5989
+typedef struct ReStateSet {
5990
+ unsigned nState; /* Number of current states */
5991
+ ReStateNumber *aState; /* Current states */
5992
+} ReStateSet;
5993
+
5994
+/* An input string read one character at a time.
5995
+*/
5996
+typedef struct ReInput ReInput;
5997
+struct ReInput {
5998
+ const unsigned char *z; /* All text */
5999
+ int i; /* Next byte to read */
6000
+ int mx; /* EOF when i>=mx */
6001
+};
6002
+
6003
+/* A compiled NFA (or an NFA that is in the process of being compiled) is
6004
+** an instance of the following object.
6005
+*/
6006
+typedef struct ReCompiled ReCompiled;
6007
+struct ReCompiled {
6008
+ ReInput sIn; /* Regular expression text */
6009
+ const char *zErr; /* Error message to return */
6010
+ char *aOp; /* Operators for the virtual machine */
6011
+ int *aArg; /* Arguments to each operator */
6012
+ unsigned (*xNextChar)(ReInput*); /* Next character function */
6013
+ unsigned char zInit[12]; /* Initial text to match */
6014
+ int nInit; /* Number of characters in zInit */
6015
+ unsigned nState; /* Number of entries in aOp[] and aArg[] */
6016
+ unsigned nAlloc; /* Slots allocated for aOp[] and aArg[] */
6017
+};
6018
+
6019
+/* Add a state to the given state set if it is not already there */
6020
+static void re_add_state(ReStateSet *pSet, int newState){
6021
+ unsigned i;
6022
+ for(i=0; i<pSet->nState; i++) if( pSet->aState[i]==newState ) return;
6023
+ pSet->aState[pSet->nState++] = (ReStateNumber)newState;
6024
+}
6025
+
6026
+/* Extract the next unicode character from *pzIn and return it. Advance
6027
+** *pzIn to the first byte past the end of the character returned. To
6028
+** be clear: this routine converts utf8 to unicode. This routine is
6029
+** optimized for the common case where the next character is a single byte.
6030
+*/
6031
+static unsigned re_next_char(ReInput *p){
6032
+ unsigned c;
6033
+ if( p->i>=p->mx ) return 0;
6034
+ c = p->z[p->i++];
6035
+ if( c>=0x80 ){
6036
+ if( (c&0xe0)==0xc0 && p->i<p->mx && (p->z[p->i]&0xc0)==0x80 ){
6037
+ c = (c&0x1f)<<6 | (p->z[p->i++]&0x3f);
6038
+ if( c<0x80 ) c = 0xfffd;
6039
+ }else if( (c&0xf0)==0xe0 && p->i+1<p->mx && (p->z[p->i]&0xc0)==0x80
6040
+ && (p->z[p->i+1]&0xc0)==0x80 ){
6041
+ c = (c&0x0f)<<12 | ((p->z[p->i]&0x3f)<<6) | (p->z[p->i+1]&0x3f);
6042
+ p->i += 2;
6043
+ if( c<=0x7ff || (c>=0xd800 && c<=0xdfff) ) c = 0xfffd;
6044
+ }else if( (c&0xf8)==0xf0 && p->i+3<p->mx && (p->z[p->i]&0xc0)==0x80
6045
+ && (p->z[p->i+1]&0xc0)==0x80 && (p->z[p->i+2]&0xc0)==0x80 ){
6046
+ c = (c&0x07)<<18 | ((p->z[p->i]&0x3f)<<12) | ((p->z[p->i+1]&0x3f)<<6)
6047
+ | (p->z[p->i+2]&0x3f);
6048
+ p->i += 3;
6049
+ if( c<=0xffff || c>0x10ffff ) c = 0xfffd;
6050
+ }else{
6051
+ c = 0xfffd;
6052
+ }
6053
+ }
6054
+ return c;
6055
+}
6056
+static unsigned re_next_char_nocase(ReInput *p){
6057
+ unsigned c = re_next_char(p);
6058
+ if( c>='A' && c<='Z' ) c += 'a' - 'A';
6059
+ return c;
6060
+}
6061
+
6062
+/* Return true if c is a perl "word" character: [A-Za-z0-9_] */
6063
+static int re_word_char(int c){
6064
+ return (c>='0' && c<='9') || (c>='a' && c<='z')
6065
+ || (c>='A' && c<='Z') || c=='_';
6066
+}
6067
+
6068
+/* Return true if c is a "digit" character: [0-9] */
6069
+static int re_digit_char(int c){
6070
+ return (c>='0' && c<='9');
6071
+}
6072
+
6073
+/* Return true if c is a perl "space" character: [ \t\r\n\v\f] */
6074
+static int re_space_char(int c){
6075
+ return c==' ' || c=='\t' || c=='\n' || c=='\r' || c=='\v' || c=='\f';
6076
+}
6077
+
6078
+/* Run a compiled regular expression on the zero-terminated input
6079
+** string zIn[]. Return true on a match and false if there is no match.
6080
+*/
6081
+static int re_match(ReCompiled *pRe, const unsigned char *zIn, int nIn){
6082
+ ReStateSet aStateSet[2], *pThis, *pNext;
6083
+ ReStateNumber aSpace[100];
6084
+ ReStateNumber *pToFree;
6085
+ unsigned int i = 0;
6086
+ unsigned int iSwap = 0;
6087
+ int c = RE_EOF+1;
6088
+ int cPrev = 0;
6089
+ int rc = 0;
6090
+ ReInput in;
6091
+
6092
+ in.z = zIn;
6093
+ in.i = 0;
6094
+ in.mx = nIn>=0 ? nIn : (int)strlen((char const*)zIn);
6095
+
6096
+ /* Look for the initial prefix match, if there is one. */
6097
+ if( pRe->nInit ){
6098
+ unsigned char x = pRe->zInit[0];
6099
+ while( in.i+pRe->nInit<=in.mx
6100
+ && (zIn[in.i]!=x ||
6101
+ strncmp((const char*)zIn+in.i, (const char*)pRe->zInit, pRe->nInit)!=0)
6102
+ ){
6103
+ in.i++;
6104
+ }
6105
+ if( in.i+pRe->nInit>in.mx ) return 0;
6106
+ }
6107
+
6108
+ if( pRe->nState<=(sizeof(aSpace)/(sizeof(aSpace[0])*2)) ){
6109
+ pToFree = 0;
6110
+ aStateSet[0].aState = aSpace;
6111
+ }else{
6112
+ pToFree = sqlite3_malloc64( sizeof(ReStateNumber)*2*pRe->nState );
6113
+ if( pToFree==0 ) return -1;
6114
+ aStateSet[0].aState = pToFree;
6115
+ }
6116
+ aStateSet[1].aState = &aStateSet[0].aState[pRe->nState];
6117
+ pNext = &aStateSet[1];
6118
+ pNext->nState = 0;
6119
+ re_add_state(pNext, 0);
6120
+ while( c!=RE_EOF && pNext->nState>0 ){
6121
+ cPrev = c;
6122
+ c = pRe->xNextChar(&in);
6123
+ pThis = pNext;
6124
+ pNext = &aStateSet[iSwap];
6125
+ iSwap = 1 - iSwap;
6126
+ pNext->nState = 0;
6127
+ for(i=0; i<pThis->nState; i++){
6128
+ int x = pThis->aState[i];
6129
+ switch( pRe->aOp[x] ){
6130
+ case RE_OP_MATCH: {
6131
+ if( pRe->aArg[x]==c ) re_add_state(pNext, x+1);
6132
+ break;
6133
+ }
6134
+ case RE_OP_ANY: {
6135
+ if( c!=0 ) re_add_state(pNext, x+1);
6136
+ break;
6137
+ }
6138
+ case RE_OP_WORD: {
6139
+ if( re_word_char(c) ) re_add_state(pNext, x+1);
6140
+ break;
6141
+ }
6142
+ case RE_OP_NOTWORD: {
6143
+ if( !re_word_char(c) && c!=0 ) re_add_state(pNext, x+1);
6144
+ break;
6145
+ }
6146
+ case RE_OP_DIGIT: {
6147
+ if( re_digit_char(c) ) re_add_state(pNext, x+1);
6148
+ break;
6149
+ }
6150
+ case RE_OP_NOTDIGIT: {
6151
+ if( !re_digit_char(c) && c!=0 ) re_add_state(pNext, x+1);
6152
+ break;
6153
+ }
6154
+ case RE_OP_SPACE: {
6155
+ if( re_space_char(c) ) re_add_state(pNext, x+1);
6156
+ break;
6157
+ }
6158
+ case RE_OP_NOTSPACE: {
6159
+ if( !re_space_char(c) && c!=0 ) re_add_state(pNext, x+1);
6160
+ break;
6161
+ }
6162
+ case RE_OP_BOUNDARY: {
6163
+ if( re_word_char(c)!=re_word_char(cPrev) ) re_add_state(pThis, x+1);
6164
+ break;
6165
+ }
6166
+ case RE_OP_ANYSTAR: {
6167
+ re_add_state(pNext, x);
6168
+ re_add_state(pThis, x+1);
6169
+ break;
6170
+ }
6171
+ case RE_OP_FORK: {
6172
+ re_add_state(pThis, x+pRe->aArg[x]);
6173
+ re_add_state(pThis, x+1);
6174
+ break;
6175
+ }
6176
+ case RE_OP_GOTO: {
6177
+ re_add_state(pThis, x+pRe->aArg[x]);
6178
+ break;
6179
+ }
6180
+ case RE_OP_ACCEPT: {
6181
+ rc = 1;
6182
+ goto re_match_end;
6183
+ }
6184
+ case RE_OP_CC_EXC: {
6185
+ if( c==0 ) break;
6186
+ /* fall-through */
6187
+ }
6188
+ case RE_OP_CC_INC: {
6189
+ int j = 1;
6190
+ int n = pRe->aArg[x];
6191
+ int hit = 0;
6192
+ for(j=1; j>0 && j<n; j++){
6193
+ if( pRe->aOp[x+j]==RE_OP_CC_VALUE ){
6194
+ if( pRe->aArg[x+j]==c ){
6195
+ hit = 1;
6196
+ j = -1;
6197
+ }
6198
+ }else{
6199
+ if( pRe->aArg[x+j]<=c && pRe->aArg[x+j+1]>=c ){
6200
+ hit = 1;
6201
+ j = -1;
6202
+ }else{
6203
+ j++;
6204
+ }
6205
+ }
6206
+ }
6207
+ if( pRe->aOp[x]==RE_OP_CC_EXC ) hit = !hit;
6208
+ if( hit ) re_add_state(pNext, x+n);
6209
+ break;
6210
+ }
6211
+ }
6212
+ }
6213
+ }
6214
+ for(i=0; i<pNext->nState; i++){
6215
+ if( pRe->aOp[pNext->aState[i]]==RE_OP_ACCEPT ){ rc = 1; break; }
6216
+ }
6217
+re_match_end:
6218
+ sqlite3_free(pToFree);
6219
+ return rc;
6220
+}
6221
+
6222
+/* Resize the opcode and argument arrays for an RE under construction.
6223
+*/
6224
+static int re_resize(ReCompiled *p, int N){
6225
+ char *aOp;
6226
+ int *aArg;
6227
+ aOp = sqlite3_realloc64(p->aOp, N*sizeof(p->aOp[0]));
6228
+ if( aOp==0 ) return 1;
6229
+ p->aOp = aOp;
6230
+ aArg = sqlite3_realloc64(p->aArg, N*sizeof(p->aArg[0]));
6231
+ if( aArg==0 ) return 1;
6232
+ p->aArg = aArg;
6233
+ p->nAlloc = N;
6234
+ return 0;
6235
+}
6236
+
6237
+/* Insert a new opcode and argument into an RE under construction. The
6238
+** insertion point is just prior to existing opcode iBefore.
6239
+*/
6240
+static int re_insert(ReCompiled *p, int iBefore, int op, int arg){
6241
+ int i;
6242
+ if( p->nAlloc<=p->nState && re_resize(p, p->nAlloc*2) ) return 0;
6243
+ for(i=p->nState; i>iBefore; i--){
6244
+ p->aOp[i] = p->aOp[i-1];
6245
+ p->aArg[i] = p->aArg[i-1];
6246
+ }
6247
+ p->nState++;
6248
+ p->aOp[iBefore] = (char)op;
6249
+ p->aArg[iBefore] = arg;
6250
+ return iBefore;
6251
+}
6252
+
6253
+/* Append a new opcode and argument to the end of the RE under construction.
6254
+*/
6255
+static int re_append(ReCompiled *p, int op, int arg){
6256
+ return re_insert(p, p->nState, op, arg);
6257
+}
6258
+
6259
+/* Make a copy of N opcodes starting at iStart onto the end of the RE
6260
+** under construction.
6261
+*/
6262
+static void re_copy(ReCompiled *p, int iStart, int N){
6263
+ if( p->nState+N>=p->nAlloc && re_resize(p, p->nAlloc*2+N) ) return;
6264
+ memcpy(&p->aOp[p->nState], &p->aOp[iStart], N*sizeof(p->aOp[0]));
6265
+ memcpy(&p->aArg[p->nState], &p->aArg[iStart], N*sizeof(p->aArg[0]));
6266
+ p->nState += N;
6267
+}
6268
+
6269
+/* Return true if c is a hexadecimal digit character: [0-9a-fA-F]
6270
+** If c is a hex digit, also set *pV = (*pV)*16 + valueof(c). If
6271
+** c is not a hex digit *pV is unchanged.
6272
+*/
6273
+static int re_hex(int c, int *pV){
6274
+ if( c>='0' && c<='9' ){
6275
+ c -= '0';
6276
+ }else if( c>='a' && c<='f' ){
6277
+ c -= 'a' - 10;
6278
+ }else if( c>='A' && c<='F' ){
6279
+ c -= 'A' - 10;
6280
+ }else{
6281
+ return 0;
6282
+ }
6283
+ *pV = (*pV)*16 + (c & 0xff);
6284
+ return 1;
6285
+}
6286
+
6287
+/* A backslash character has been seen, read the next character and
6288
+** return its interpretation.
6289
+*/
6290
+static unsigned re_esc_char(ReCompiled *p){
6291
+ static const char zEsc[] = "afnrtv\\()*.+?[$^{|}]";
6292
+ static const char zTrans[] = "\a\f\n\r\t\v";
6293
+ int i, v = 0;
6294
+ char c;
6295
+ if( p->sIn.i>=p->sIn.mx ) return 0;
6296
+ c = p->sIn.z[p->sIn.i];
6297
+ if( c=='u' && p->sIn.i+4<p->sIn.mx ){
6298
+ const unsigned char *zIn = p->sIn.z + p->sIn.i;
6299
+ if( re_hex(zIn[1],&v)
6300
+ && re_hex(zIn[2],&v)
6301
+ && re_hex(zIn[3],&v)
6302
+ && re_hex(zIn[4],&v)
6303
+ ){
6304
+ p->sIn.i += 5;
6305
+ return v;
6306
+ }
6307
+ }
6308
+ if( c=='x' && p->sIn.i+2<p->sIn.mx ){
6309
+ const unsigned char *zIn = p->sIn.z + p->sIn.i;
6310
+ if( re_hex(zIn[1],&v)
6311
+ && re_hex(zIn[2],&v)
6312
+ ){
6313
+ p->sIn.i += 3;
6314
+ return v;
6315
+ }
6316
+ }
6317
+ for(i=0; zEsc[i] && zEsc[i]!=c; i++){}
6318
+ if( zEsc[i] ){
6319
+ if( i<6 ) c = zTrans[i];
6320
+ p->sIn.i++;
6321
+ }else{
6322
+ p->zErr = "unknown \\ escape";
6323
+ }
6324
+ return c;
6325
+}
6326
+
6327
+/* Forward declaration */
6328
+static const char *re_subcompile_string(ReCompiled*);
6329
+
6330
+/* Peek at the next byte of input */
6331
+static unsigned char rePeek(ReCompiled *p){
6332
+ return p->sIn.i<p->sIn.mx ? p->sIn.z[p->sIn.i] : 0;
6333
+}
6334
+
6335
+/* Compile RE text into a sequence of opcodes. Continue up to the
6336
+** first unmatched ")" character, then return. If an error is found,
6337
+** return a pointer to the error message string.
6338
+*/
6339
+static const char *re_subcompile_re(ReCompiled *p){
6340
+ const char *zErr;
6341
+ int iStart, iEnd, iGoto;
6342
+ iStart = p->nState;
6343
+ zErr = re_subcompile_string(p);
6344
+ if( zErr ) return zErr;
6345
+ while( rePeek(p)=='|' ){
6346
+ iEnd = p->nState;
6347
+ re_insert(p, iStart, RE_OP_FORK, iEnd + 2 - iStart);
6348
+ iGoto = re_append(p, RE_OP_GOTO, 0);
6349
+ p->sIn.i++;
6350
+ zErr = re_subcompile_string(p);
6351
+ if( zErr ) return zErr;
6352
+ p->aArg[iGoto] = p->nState - iGoto;
6353
+ }
6354
+ return 0;
6355
+}
6356
+
6357
+/* Compile an element of regular expression text (anything that can be
6358
+** an operand to the "|" operator). Return NULL on success or a pointer
6359
+** to the error message if there is a problem.
6360
+*/
6361
+static const char *re_subcompile_string(ReCompiled *p){
6362
+ int iPrev = -1;
6363
+ int iStart;
6364
+ unsigned c;
6365
+ const char *zErr;
6366
+ while( (c = p->xNextChar(&p->sIn))!=0 ){
6367
+ iStart = p->nState;
6368
+ switch( c ){
6369
+ case '|':
6370
+ case '$':
6371
+ case ')': {
6372
+ p->sIn.i--;
6373
+ return 0;
6374
+ }
6375
+ case '(': {
6376
+ zErr = re_subcompile_re(p);
6377
+ if( zErr ) return zErr;
6378
+ if( rePeek(p)!=')' ) return "unmatched '('";
6379
+ p->sIn.i++;
6380
+ break;
6381
+ }
6382
+ case '.': {
6383
+ if( rePeek(p)=='*' ){
6384
+ re_append(p, RE_OP_ANYSTAR, 0);
6385
+ p->sIn.i++;
6386
+ }else{
6387
+ re_append(p, RE_OP_ANY, 0);
6388
+ }
6389
+ break;
6390
+ }
6391
+ case '*': {
6392
+ if( iPrev<0 ) return "'*' without operand";
6393
+ re_insert(p, iPrev, RE_OP_GOTO, p->nState - iPrev + 1);
6394
+ re_append(p, RE_OP_FORK, iPrev - p->nState + 1);
6395
+ break;
6396
+ }
6397
+ case '+': {
6398
+ if( iPrev<0 ) return "'+' without operand";
6399
+ re_append(p, RE_OP_FORK, iPrev - p->nState);
6400
+ break;
6401
+ }
6402
+ case '?': {
6403
+ if( iPrev<0 ) return "'?' without operand";
6404
+ re_insert(p, iPrev, RE_OP_FORK, p->nState - iPrev+1);
6405
+ break;
6406
+ }
6407
+ case '{': {
6408
+ int m = 0, n = 0;
6409
+ int sz, j;
6410
+ if( iPrev<0 ) return "'{m,n}' without operand";
6411
+ while( (c=rePeek(p))>='0' && c<='9' ){ m = m*10 + c - '0'; p->sIn.i++; }
6412
+ n = m;
6413
+ if( c==',' ){
6414
+ p->sIn.i++;
6415
+ n = 0;
6416
+ while( (c=rePeek(p))>='0' && c<='9' ){ n = n*10 + c-'0'; p->sIn.i++; }
6417
+ }
6418
+ if( c!='}' ) return "unmatched '{'";
6419
+ if( n>0 && n<m ) return "n less than m in '{m,n}'";
6420
+ p->sIn.i++;
6421
+ sz = p->nState - iPrev;
6422
+ if( m==0 ){
6423
+ if( n==0 ) return "both m and n are zero in '{m,n}'";
6424
+ re_insert(p, iPrev, RE_OP_FORK, sz+1);
6425
+ n--;
6426
+ }else{
6427
+ for(j=1; j<m; j++) re_copy(p, iPrev, sz);
6428
+ }
6429
+ for(j=m; j<n; j++){
6430
+ re_append(p, RE_OP_FORK, sz+1);
6431
+ re_copy(p, iPrev, sz);
6432
+ }
6433
+ if( n==0 && m>0 ){
6434
+ re_append(p, RE_OP_FORK, -sz);
6435
+ }
6436
+ break;
6437
+ }
6438
+ case '[': {
6439
+ int iFirst = p->nState;
6440
+ if( rePeek(p)=='^' ){
6441
+ re_append(p, RE_OP_CC_EXC, 0);
6442
+ p->sIn.i++;
6443
+ }else{
6444
+ re_append(p, RE_OP_CC_INC, 0);
6445
+ }
6446
+ while( (c = p->xNextChar(&p->sIn))!=0 ){
6447
+ if( c=='[' && rePeek(p)==':' ){
6448
+ return "POSIX character classes not supported";
6449
+ }
6450
+ if( c=='\\' ) c = re_esc_char(p);
6451
+ if( rePeek(p)=='-' ){
6452
+ re_append(p, RE_OP_CC_RANGE, c);
6453
+ p->sIn.i++;
6454
+ c = p->xNextChar(&p->sIn);
6455
+ if( c=='\\' ) c = re_esc_char(p);
6456
+ re_append(p, RE_OP_CC_RANGE, c);
6457
+ }else{
6458
+ re_append(p, RE_OP_CC_VALUE, c);
6459
+ }
6460
+ if( rePeek(p)==']' ){ p->sIn.i++; break; }
6461
+ }
6462
+ if( c==0 ) return "unclosed '['";
6463
+ p->aArg[iFirst] = p->nState - iFirst;
6464
+ break;
6465
+ }
6466
+ case '\\': {
6467
+ int specialOp = 0;
6468
+ switch( rePeek(p) ){
6469
+ case 'b': specialOp = RE_OP_BOUNDARY; break;
6470
+ case 'd': specialOp = RE_OP_DIGIT; break;
6471
+ case 'D': specialOp = RE_OP_NOTDIGIT; break;
6472
+ case 's': specialOp = RE_OP_SPACE; break;
6473
+ case 'S': specialOp = RE_OP_NOTSPACE; break;
6474
+ case 'w': specialOp = RE_OP_WORD; break;
6475
+ case 'W': specialOp = RE_OP_NOTWORD; break;
6476
+ }
6477
+ if( specialOp ){
6478
+ p->sIn.i++;
6479
+ re_append(p, specialOp, 0);
6480
+ }else{
6481
+ c = re_esc_char(p);
6482
+ re_append(p, RE_OP_MATCH, c);
6483
+ }
6484
+ break;
6485
+ }
6486
+ default: {
6487
+ re_append(p, RE_OP_MATCH, c);
6488
+ break;
6489
+ }
6490
+ }
6491
+ iPrev = iStart;
6492
+ }
6493
+ return 0;
6494
+}
6495
+
6496
+/* Free and reclaim all the memory used by a previously compiled
6497
+** regular expression. Applications should invoke this routine once
6498
+** for every call to re_compile() to avoid memory leaks.
6499
+*/
6500
+static void re_free(ReCompiled *pRe){
6501
+ if( pRe ){
6502
+ sqlite3_free(pRe->aOp);
6503
+ sqlite3_free(pRe->aArg);
6504
+ sqlite3_free(pRe);
6505
+ }
6506
+}
6507
+
6508
+/*
6509
+** Compile a textual regular expression in zIn[] into a compiled regular
6510
+** expression suitable for us by re_match() and return a pointer to the
6511
+** compiled regular expression in *ppRe. Return NULL on success or an
6512
+** error message if something goes wrong.
6513
+*/
6514
+static const char *re_compile(ReCompiled **ppRe, const char *zIn, int noCase){
6515
+ ReCompiled *pRe;
6516
+ const char *zErr;
6517
+ int i, j;
6518
+
6519
+ *ppRe = 0;
6520
+ pRe = sqlite3_malloc( sizeof(*pRe) );
6521
+ if( pRe==0 ){
6522
+ return "out of memory";
6523
+ }
6524
+ memset(pRe, 0, sizeof(*pRe));
6525
+ pRe->xNextChar = noCase ? re_next_char_nocase : re_next_char;
6526
+ if( re_resize(pRe, 30) ){
6527
+ re_free(pRe);
6528
+ return "out of memory";
6529
+ }
6530
+ if( zIn[0]=='^' ){
6531
+ zIn++;
6532
+ }else{
6533
+ re_append(pRe, RE_OP_ANYSTAR, 0);
6534
+ }
6535
+ pRe->sIn.z = (unsigned char*)zIn;
6536
+ pRe->sIn.i = 0;
6537
+ pRe->sIn.mx = (int)strlen(zIn);
6538
+ zErr = re_subcompile_re(pRe);
6539
+ if( zErr ){
6540
+ re_free(pRe);
6541
+ return zErr;
6542
+ }
6543
+ if( rePeek(pRe)=='$' && pRe->sIn.i+1>=pRe->sIn.mx ){
6544
+ re_append(pRe, RE_OP_MATCH, RE_EOF);
6545
+ re_append(pRe, RE_OP_ACCEPT, 0);
6546
+ *ppRe = pRe;
6547
+ }else if( pRe->sIn.i>=pRe->sIn.mx ){
6548
+ re_append(pRe, RE_OP_ACCEPT, 0);
6549
+ *ppRe = pRe;
6550
+ }else{
6551
+ re_free(pRe);
6552
+ return "unrecognized character";
6553
+ }
6554
+
6555
+ /* The following is a performance optimization. If the regex begins with
6556
+ ** ".*" (if the input regex lacks an initial "^") and afterwards there are
6557
+ ** one or more matching characters, enter those matching characters into
6558
+ ** zInit[]. The re_match() routine can then search ahead in the input
6559
+ ** string looking for the initial match without having to run the whole
6560
+ ** regex engine over the string. Do not worry able trying to match
6561
+ ** unicode characters beyond plane 0 - those are very rare and this is
6562
+ ** just an optimization. */
6563
+ if( pRe->aOp[0]==RE_OP_ANYSTAR && !noCase ){
6564
+ for(j=0, i=1; j<(int)sizeof(pRe->zInit)-2 && pRe->aOp[i]==RE_OP_MATCH; i++){
6565
+ unsigned x = pRe->aArg[i];
6566
+ if( x<=127 ){
6567
+ pRe->zInit[j++] = (unsigned char)x;
6568
+ }else if( x<=0xfff ){
6569
+ pRe->zInit[j++] = (unsigned char)(0xc0 | (x>>6));
6570
+ pRe->zInit[j++] = 0x80 | (x&0x3f);
6571
+ }else if( x<=0xffff ){
6572
+ pRe->zInit[j++] = (unsigned char)(0xd0 | (x>>12));
6573
+ pRe->zInit[j++] = 0x80 | ((x>>6)&0x3f);
6574
+ pRe->zInit[j++] = 0x80 | (x&0x3f);
6575
+ }else{
6576
+ break;
6577
+ }
6578
+ }
6579
+ if( j>0 && pRe->zInit[j-1]==0 ) j--;
6580
+ pRe->nInit = j;
6581
+ }
6582
+ return pRe->zErr;
6583
+}
6584
+
6585
+/*
6586
+** Implementation of the regexp() SQL function. This function implements
6587
+** the build-in REGEXP operator. The first argument to the function is the
6588
+** pattern and the second argument is the string. So, the SQL statements:
6589
+**
6590
+** A REGEXP B
6591
+**
6592
+** is implemented as regexp(B,A).
6593
+*/
6594
+static void re_sql_func(
6595
+ sqlite3_context *context,
6596
+ int argc,
6597
+ sqlite3_value **argv
6598
+){
6599
+ ReCompiled *pRe; /* Compiled regular expression */
6600
+ const char *zPattern; /* The regular expression */
6601
+ const unsigned char *zStr;/* String being searched */
6602
+ const char *zErr; /* Compile error message */
6603
+ int setAux = 0; /* True to invoke sqlite3_set_auxdata() */
6604
+
6605
+ (void)argc; /* Unused */
6606
+ pRe = sqlite3_get_auxdata(context, 0);
6607
+ if( pRe==0 ){
6608
+ zPattern = (const char*)sqlite3_value_text(argv[0]);
6609
+ if( zPattern==0 ) return;
6610
+ zErr = re_compile(&pRe, zPattern, sqlite3_user_data(context)!=0);
6611
+ if( zErr ){
6612
+ re_free(pRe);
6613
+ sqlite3_result_error(context, zErr, -1);
6614
+ return;
6615
+ }
6616
+ if( pRe==0 ){
6617
+ sqlite3_result_error_nomem(context);
6618
+ return;
6619
+ }
6620
+ setAux = 1;
6621
+ }
6622
+ zStr = (const unsigned char*)sqlite3_value_text(argv[1]);
6623
+ if( zStr!=0 ){
6624
+ sqlite3_result_int(context, re_match(pRe, zStr, -1));
6625
+ }
6626
+ if( setAux ){
6627
+ sqlite3_set_auxdata(context, 0, pRe, (void(*)(void*))re_free);
6628
+ }
6629
+}
6630
+
6631
+/*
6632
+** Invoke this routine to register the regexp() function with the
6633
+** SQLite database connection.
6634
+*/
6635
+#ifdef _WIN32
6636
+
6637
+#endif
6638
+int sqlite3_regexp_init(
6639
+ sqlite3 *db,
6640
+ char **pzErrMsg,
6641
+ const sqlite3_api_routines *pApi
6642
+){
6643
+ int rc = SQLITE_OK;
6644
+ SQLITE_EXTENSION_INIT2(pApi);
6645
+ (void)pzErrMsg; /* Unused */
6646
+ rc = sqlite3_create_function(db, "regexp", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
6647
+ 0, re_sql_func, 0, 0);
6648
+ if( rc==SQLITE_OK ){
6649
+ /* The regexpi(PATTERN,STRING) function is a case-insensitive version
6650
+ ** of regexp(PATTERN,STRING). */
6651
+ rc = sqlite3_create_function(db, "regexpi", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
6652
+ (void*)db, re_sql_func, 0, 0);
6653
+ }
6654
+ return rc;
6655
+}
6656
+
6657
+/************************* End ../ext/misc/regexp.c ********************/
58836658
#ifdef SQLITE_HAVE_ZLIB
58846659
/************************* Begin ../ext/misc/zipfile.c ******************/
58856660
/*
58866661
** 2017-12-26
58876662
**
@@ -5918,14 +6693,28 @@
59186693
59196694
#ifndef SQLITE_OMIT_VIRTUALTABLE
59206695
59216696
#ifndef SQLITE_AMALGAMATION
59226697
6698
+#ifndef UINT32_TYPE
6699
+# ifdef HAVE_UINT32_T
6700
+# define UINT32_TYPE uint32_t
6701
+# else
6702
+# define UINT32_TYPE unsigned int
6703
+# endif
6704
+#endif
6705
+#ifndef UINT16_TYPE
6706
+# ifdef HAVE_UINT16_T
6707
+# define UINT16_TYPE uint16_t
6708
+# else
6709
+# define UINT16_TYPE unsigned short int
6710
+# endif
6711
+#endif
59236712
/* typedef sqlite3_int64 i64; */
59246713
/* typedef unsigned char u8; */
5925
-typedef unsigned short u16;
5926
-typedef unsigned long u32;
6714
+typedef UINT32_TYPE u32; /* 4-byte unsigned integer */
6715
+typedef UINT16_TYPE u16; /* 2-byte unsigned integer */
59276716
#define MIN(a,b) ((a)<(b) ? (a) : (b))
59286717
59296718
#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
59306719
# define ALWAYS(X) (1)
59316720
# define NEVER(X) (0)
@@ -6588,38 +7377,28 @@
65887377
** Bits 09-15: years from 1980
65897378
**
65907379
** https://msdn.microsoft.com/en-us/library/9kkf9tah.aspx
65917380
*/
65927381
static u32 zipfileMtime(ZipfileCDS *pCDS){
6593
- int Y = (1980 + ((pCDS->mDate >> 9) & 0x7F));
6594
- int M = ((pCDS->mDate >> 5) & 0x0F);
6595
- int D = (pCDS->mDate & 0x1F);
6596
- int B = -13;
6597
-
6598
- int sec = (pCDS->mTime & 0x1F)*2;
6599
- int min = (pCDS->mTime >> 5) & 0x3F;
6600
- int hr = (pCDS->mTime >> 11) & 0x1F;
6601
- i64 JD;
6602
-
6603
- /* JD = INT(365.25 * (Y+4716)) + INT(30.6001 * (M+1)) + D + B - 1524.5 */
6604
-
6605
- /* Calculate the JD in seconds for noon on the day in question */
6606
- if( M<3 ){
6607
- Y = Y-1;
6608
- M = M+12;
6609
- }
6610
- JD = (i64)(24*60*60) * (
6611
- (int)(365.25 * (Y + 4716))
6612
- + (int)(30.6001 * (M + 1))
6613
- + D + B - 1524
6614
- );
6615
-
6616
- /* Correct the JD for the time within the day */
6617
- JD += (hr-12) * 3600 + min * 60 + sec;
6618
-
6619
- /* Convert JD to unix timestamp (the JD epoch is 2440587.5) */
6620
- return (u32)(JD - (i64)(24405875) * 24*60*6);
7382
+ int Y,M,D,X1,X2,A,B,sec,min,hr;
7383
+ i64 JDsec;
7384
+ Y = (1980 + ((pCDS->mDate >> 9) & 0x7F));
7385
+ M = ((pCDS->mDate >> 5) & 0x0F);
7386
+ D = (pCDS->mDate & 0x1F);
7387
+ sec = (pCDS->mTime & 0x1F)*2;
7388
+ min = (pCDS->mTime >> 5) & 0x3F;
7389
+ hr = (pCDS->mTime >> 11) & 0x1F;
7390
+ if( M<=2 ){
7391
+ Y--;
7392
+ M += 12;
7393
+ }
7394
+ X1 = 36525*(Y+4716)/100;
7395
+ X2 = 306001*(M+1)/10000;
7396
+ A = Y/100;
7397
+ B = 2 - A + (A/4);
7398
+ JDsec = (i64)((X1 + X2 + D + B - 1524.5)*86400) + hr*3600 + min*60 + sec;
7399
+ return (u32)(JDsec - (i64)24405875*(i64)8640);
66217400
}
66227401
66237402
/*
66247403
** The opposite of zipfileMtime(). This function populates the mTime and
66257404
** mDate fields of the CDS structure passed as the first argument according
@@ -8052,10 +8831,14 @@
80528831
if( rc==SQLITE_OK ){
80538832
rc = sqlite3_create_function(db, "zipfile", -1, SQLITE_UTF8, 0, 0,
80548833
zipfileStep, zipfileFinal
80558834
);
80568835
}
8836
+ assert( sizeof(i64)==8 );
8837
+ assert( sizeof(u32)==4 );
8838
+ assert( sizeof(u16)==2 );
8839
+ assert( sizeof(u8)==1 );
80578840
return rc;
80588841
}
80598842
#else /* SQLITE_OMIT_VIRTUALTABLE */
80608843
# define zipfileRegister(x) SQLITE_OK
80618844
#endif
@@ -14032,11 +14815,11 @@
1403214815
" Examples:",
1403314816
" .ar -cf ARCHIVE foo bar # Create ARCHIVE from files foo and bar",
1403414817
" .ar -tf ARCHIVE # List members of ARCHIVE",
1403514818
" .ar -xvf ARCHIVE # Verbosely extract files from ARCHIVE",
1403614819
" See also:",
14037
- " http://sqlite.org/cli.html#sqlar_archive_support",
14820
+ " http://sqlite.org/cli.html#sqlite_archive_support",
1403814821
#endif
1403914822
#ifndef SQLITE_OMIT_AUTHORIZATION
1404014823
".auth ON|OFF Show authorizer callbacks",
1404114824
#endif
1404214825
".backup ?DB? FILE Backup DB (default \"main\") to FILE",
@@ -14134,12 +14917,12 @@
1413414917
".oom ?--repeat M? ?N? Simulate an OOM error on the N-th allocation",
1413514918
#endif
1413614919
".open ?OPTIONS? ?FILE? Close existing database and reopen FILE",
1413714920
" Options:",
1413814921
" --append Use appendvfs to append database to the end of FILE",
14139
-#ifdef SQLITE_ENABLE_DESERIALIZE
14140
- " --deserialize Load into memory useing sqlite3_deserialize()",
14922
+#ifndef SQLITE_OMIT_DESERIALIZE
14923
+ " --deserialize Load into memory using sqlite3_deserialize()",
1414114924
" --hexdb Load the output of \"dbtotxt\" as an in-memory db",
1414214925
" --maxsize N Maximum size for --hexdb or --deserialized database",
1414314926
#endif
1414414927
" --new Initialize FILE to an empty database",
1414514928
" --nofollow Do not follow symbolic links",
@@ -14456,11 +15239,11 @@
1445615239
}
1445715240
fclose(f);
1445815241
return rc;
1445915242
}
1446015243
14461
-#ifdef SQLITE_ENABLE_DESERIALIZE
15244
+#ifndef SQLITE_OMIT_DESERIALIZE
1446215245
/*
1446315246
** Reconstruct an in-memory database using the output from the "dbtotxt"
1446415247
** program. Read content from the file in p->zDbFilename. If p->zDbFilename
1446515248
** is 0, then read from standard input.
1446615249
*/
@@ -14545,11 +15328,11 @@
1454515328
}
1454615329
sqlite3_free(a);
1454715330
utf8_printf(stderr,"Error on line %d of --hexdb input\n", nLine);
1454815331
return 0;
1454915332
}
14550
-#endif /* SQLITE_ENABLE_DESERIALIZE */
15333
+#endif /* SQLITE_OMIT_DESERIALIZE */
1455115334
1455215335
/*
1455315336
** Scalar function "shell_int32". The first argument to this function
1455415337
** must be a blob. The second a non-negative integer. This function
1455515338
** reads and returns a 32-bit big-endian integer from byte
@@ -14771,10 +15554,11 @@
1477115554
sqlite3_fileio_init(p->db, 0, 0);
1477215555
sqlite3_shathree_init(p->db, 0, 0);
1477315556
sqlite3_completion_init(p->db, 0, 0);
1477415557
sqlite3_uint_init(p->db, 0, 0);
1477515558
sqlite3_decimal_init(p->db, 0, 0);
15559
+ sqlite3_regexp_init(p->db, 0, 0);
1477615560
sqlite3_ieee_init(p->db, 0, 0);
1477715561
sqlite3_series_init(p->db, 0, 0);
1477815562
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
1477915563
sqlite3_dbdata_init(p->db, 0, 0);
1478015564
#endif
@@ -14806,11 +15590,11 @@
1480615590
char *zSql = sqlite3_mprintf(
1480715591
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);
1480815592
sqlite3_exec(p->db, zSql, 0, 0, 0);
1480915593
sqlite3_free(zSql);
1481015594
}
14811
-#ifdef SQLITE_ENABLE_DESERIALIZE
15595
+#ifndef SQLITE_OMIT_DESERIALIZE
1481215596
else
1481315597
if( p->openMode==SHELL_OPEN_DESERIALIZE || p->openMode==SHELL_OPEN_HEXDB ){
1481415598
int rc;
1481515599
int nData = 0;
1481615600
unsigned char *aData;
@@ -16873,10 +17657,11 @@
1687317657
char *zErr = 0;
1687417658
rc = sqlite3_exec(db, zSql, 0, 0, &zErr);
1687517659
if( rc!=SQLITE_OK ){
1687617660
raw_printf(stderr, "SQL error: %s\n", zErr);
1687717661
}
17662
+ sqlite3_free(zErr);
1687817663
*pRc = rc;
1687917664
}
1688017665
}
1688117666
1688217667
/*
@@ -17894,15 +18679,30 @@
1789418679
raw_printf(stderr, "Unknown option \"%s\" on \".dump\"\n", azArg[i]);
1789518680
rc = 1;
1789618681
sqlite3_free(zLike);
1789718682
goto meta_command_exit;
1789818683
}
17899
- }else if( zLike ){
17900
- zLike = sqlite3_mprintf("%z OR name LIKE %Q ESCAPE '\\'",
17901
- zLike, azArg[i]);
1790218684
}else{
17903
- zLike = sqlite3_mprintf("name LIKE %Q ESCAPE '\\'", azArg[i]);
18685
+ /* azArg[i] contains a LIKE pattern. This ".dump" request should
18686
+ ** only dump data for tables for which either the table name matches
18687
+ ** the LIKE pattern, or the table appears to be a shadow table of
18688
+ ** a virtual table for which the name matches the LIKE pattern.
18689
+ */
18690
+ char *zExpr = sqlite3_mprintf(
18691
+ "name LIKE %Q ESCAPE '\\' OR EXISTS ("
18692
+ " SELECT 1 FROM sqlite_schema WHERE "
18693
+ " name LIKE %Q ESCAPE '\\' AND"
18694
+ " sql LIKE 'CREATE VIRTUAL TABLE%%' AND"
18695
+ " substr(o.name, 1, length(name)+1) == (name||'_')"
18696
+ ")", azArg[i], azArg[i]
18697
+ );
18698
+
18699
+ if( zLike ){
18700
+ zLike = sqlite3_mprintf("%z OR %z", zLike, zExpr);
18701
+ }else{
18702
+ zLike = zExpr;
18703
+ }
1790418704
}
1790518705
}
1790618706
1790718707
open_db(p, 0);
1790818708
@@ -17920,21 +18720,21 @@
1792018720
** corrupt. */
1792118721
sqlite3_exec(p->db, "SAVEPOINT dump; PRAGMA writable_schema=ON", 0, 0, 0);
1792218722
p->nErr = 0;
1792318723
if( zLike==0 ) zLike = sqlite3_mprintf("true");
1792418724
zSql = sqlite3_mprintf(
17925
- "SELECT name, type, sql FROM sqlite_schema "
18725
+ "SELECT name, type, sql FROM sqlite_schema AS o "
1792618726
"WHERE (%s) AND type=='table'"
1792718727
" AND sql NOT NULL"
1792818728
" ORDER BY tbl_name='sqlite_sequence', rowid",
1792918729
zLike
1793018730
);
1793118731
run_schema_dump_query(p,zSql);
1793218732
sqlite3_free(zSql);
1793318733
if( (p->shellFlgs & SHFLG_DumpDataOnly)==0 ){
1793418734
zSql = sqlite3_mprintf(
17935
- "SELECT sql FROM sqlite_schema "
18735
+ "SELECT sql FROM sqlite_schema AS o "
1793618736
"WHERE (%s) AND sql NOT NULL"
1793718737
" AND type IN ('index','trigger','view')",
1793818738
zLike
1793918739
);
1794018740
run_table_dump_query(p, zSql);
@@ -18177,11 +18977,10 @@
1817718977
}
1817818978
}else
1817918979
1818018980
if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){
1818118981
ShellState data;
18182
- char *zErrMsg = 0;
1818318982
int doStats = 0;
1818418983
memcpy(&data, p, sizeof(data));
1818518984
data.showHeader = 0;
1818618985
data.cMode = data.mode = MODE_Semi;
1818718986
if( nArg==2 && optionMatch(azArg[1], "indent") ){
@@ -18199,11 +18998,11 @@
1819918998
" (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
1820018999
" FROM sqlite_schema UNION ALL"
1820119000
" SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_schema) "
1820219001
"WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' "
1820319002
"ORDER BY rowid",
18204
- callback, &data, &zErrMsg
19003
+ callback, &data, 0
1820519004
);
1820619005
if( rc==SQLITE_OK ){
1820719006
sqlite3_stmt *pStmt;
1820819007
rc = sqlite3_prepare_v2(p->db,
1820919008
"SELECT rowid FROM sqlite_schema"
@@ -18215,16 +19014,16 @@
1821519014
if( doStats==0 ){
1821619015
raw_printf(p->out, "/* No STAT tables available */\n");
1821719016
}else{
1821819017
raw_printf(p->out, "ANALYZE sqlite_schema;\n");
1821919018
sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_schema'",
18220
- callback, &data, &zErrMsg);
19019
+ callback, &data, 0);
1822119020
data.cMode = data.mode = MODE_Insert;
1822219021
data.zDestTable = "sqlite_stat1";
18223
- shell_exec(&data, "SELECT * FROM sqlite_stat1", &zErrMsg);
19022
+ shell_exec(&data, "SELECT * FROM sqlite_stat1", 0);
1822419023
data.zDestTable = "sqlite_stat4";
18225
- shell_exec(&data, "SELECT * FROM sqlite_stat4", &zErrMsg);
19024
+ shell_exec(&data, "SELECT * FROM sqlite_stat4", 0);
1822619025
raw_printf(p->out, "ANALYZE sqlite_schema;\n");
1822719026
}
1822819027
}else
1822919028
1823019029
if( c=='h' && strncmp(azArg[0], "headers", n)==0 ){
@@ -18868,18 +19667,18 @@
1886819667
p->openMode = SHELL_OPEN_APPENDVFS;
1886919668
}else if( optionMatch(z, "readonly") ){
1887019669
p->openMode = SHELL_OPEN_READONLY;
1887119670
}else if( optionMatch(z, "nofollow") ){
1887219671
p->openFlags |= SQLITE_OPEN_NOFOLLOW;
18873
-#ifdef SQLITE_ENABLE_DESERIALIZE
19672
+#ifndef SQLITE_OMIT_DESERIALIZE
1887419673
}else if( optionMatch(z, "deserialize") ){
1887519674
p->openMode = SHELL_OPEN_DESERIALIZE;
1887619675
}else if( optionMatch(z, "hexdb") ){
1887719676
p->openMode = SHELL_OPEN_HEXDB;
1887819677
}else if( optionMatch(z, "maxsize") && iName+1<nArg ){
1887919678
p->szMax = integerValue(azArg[++iName]);
18880
-#endif /* SQLITE_ENABLE_DESERIALIZE */
19679
+#endif /* SQLITE_OMIT_DESERIALIZE */
1888119680
}else if( z[0]=='-' ){
1888219681
utf8_printf(stderr, "unknown option: %s\n", z);
1888319682
rc = 1;
1888419683
goto meta_command_exit;
1888519684
}else if( zNewFilename ){
@@ -20113,10 +20912,11 @@
2011320912
{ "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE, "OFFSET " },
2011420913
{ "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE, "" },
2011520914
{ "prng_save", SQLITE_TESTCTRL_PRNG_SAVE, "" },
2011620915
{ "prng_seed", SQLITE_TESTCTRL_PRNG_SEED, "SEED ?db?" },
2011720916
{ "seek_count", SQLITE_TESTCTRL_SEEK_COUNT, "" },
20917
+ { "tune", SQLITE_TESTCTRL_TUNE, "ID VALUE" },
2011820918
};
2011920919
int testctrl = -1;
2012020920
int iCtrl = -1;
2012120921
int rc2 = 0; /* 0: usage. 1: %d 2: %x 3: no-output */
2012220922
int isOk = 0;
@@ -20257,15 +21057,44 @@
2025721057
isOk = 3;
2025821058
break;
2025921059
}
2026021060
2026121061
#ifdef YYCOVERAGE
20262
- case SQLITE_TESTCTRL_PARSER_COVERAGE:
21062
+ case SQLITE_TESTCTRL_PARSER_COVERAGE: {
2026321063
if( nArg==2 ){
2026421064
sqlite3_test_control(testctrl, p->out);
2026521065
isOk = 3;
2026621066
}
21067
+ break;
21068
+ }
21069
+#endif
21070
+#ifdef SQLITE_DEBUG
21071
+ case SQLITE_TESTCTRL_TUNE: {
21072
+ if( nArg==4 ){
21073
+ int id = (int)integerValue(azArg[2]);
21074
+ int val = (int)integerValue(azArg[3]);
21075
+ sqlite3_test_control(testctrl, id, &val);
21076
+ isOk = 3;
21077
+ }else if( nArg==3 ){
21078
+ int id = (int)integerValue(azArg[2]);
21079
+ sqlite3_test_control(testctrl, -id, &rc2);
21080
+ isOk = 1;
21081
+ }else if( nArg==2 ){
21082
+ int id = 1;
21083
+ while(1){
21084
+ int val = 0;
21085
+ rc2 = sqlite3_test_control(testctrl, -id, &val);
21086
+ if( rc2!=SQLITE_OK ) break;
21087
+ if( id>1 ) utf8_printf(p->out, " ");
21088
+ utf8_printf(p->out, "%d: %d", id, val);
21089
+ id++;
21090
+ }
21091
+ if( id>1 ) utf8_printf(p->out, "\n");
21092
+ isOk = 3;
21093
+ }
21094
+ break;
21095
+ }
2026721096
#endif
2026821097
}
2026921098
}
2027021099
if( isOk==0 && iCtrl>=0 ){
2027121100
utf8_printf(p->out, "Usage: .testctrl %s %s\n", zCmd,aCtrl[iCtrl].zUsage);
@@ -20859,11 +21688,11 @@
2085921688
" -batch force batch I/O\n"
2086021689
" -box set output mode to 'box'\n"
2086121690
" -column set output mode to 'column'\n"
2086221691
" -cmd COMMAND run \"COMMAND\" before reading stdin\n"
2086321692
" -csv set output mode to 'csv'\n"
20864
-#if defined(SQLITE_ENABLE_DESERIALIZE)
21693
+#if !defined(SQLITE_OMIT_DESERIALIZE)
2086521694
" -deserialize open the database using sqlite3_deserialize()\n"
2086621695
#endif
2086721696
" -echo print commands before execution\n"
2086821697
" -init FILENAME read/process named file\n"
2086921698
" -[no]header turn headers on or off\n"
@@ -20876,11 +21705,11 @@
2087621705
" -json set output mode to 'json'\n"
2087721706
" -line set output mode to 'line'\n"
2087821707
" -list set output mode to 'list'\n"
2087921708
" -lookaside SIZE N use N entries of SZ bytes for lookaside memory\n"
2088021709
" -markdown set output mode to 'markdown'\n"
20881
-#if defined(SQLITE_ENABLE_DESERIALIZE)
21710
+#if !defined(SQLITE_OMIT_DESERIALIZE)
2088221711
" -maxsize N maximum size for a --deserialize database\n"
2088321712
#endif
2088421713
" -memtrace trace all memory allocations and deallocations\n"
2088521714
" -mmap N default mmap size set to N\n"
2088621715
#ifdef SQLITE_ENABLE_MULTIPLEX
@@ -21206,11 +22035,11 @@
2120622035
}else if( strcmp(z,"-zip")==0 ){
2120722036
data.openMode = SHELL_OPEN_ZIPFILE;
2120822037
#endif
2120922038
}else if( strcmp(z,"-append")==0 ){
2121022039
data.openMode = SHELL_OPEN_APPENDVFS;
21211
-#ifdef SQLITE_ENABLE_DESERIALIZE
22040
+#ifndef SQLITE_OMIT_DESERIALIZE
2121222041
}else if( strcmp(z,"-deserialize")==0 ){
2121322042
data.openMode = SHELL_OPEN_DESERIALIZE;
2121422043
}else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
2121522044
data.szMax = integerValue(argv[++i]);
2121622045
#endif
@@ -21323,11 +22152,11 @@
2132322152
}else if( strcmp(z,"-zip")==0 ){
2132422153
data.openMode = SHELL_OPEN_ZIPFILE;
2132522154
#endif
2132622155
}else if( strcmp(z,"-append")==0 ){
2132722156
data.openMode = SHELL_OPEN_APPENDVFS;
21328
-#ifdef SQLITE_ENABLE_DESERIALIZE
22157
+#ifndef SQLITE_OMIT_DESERIALIZE
2132922158
}else if( strcmp(z,"-deserialize")==0 ){
2133022159
data.openMode = SHELL_OPEN_DESERIALIZE;
2133122160
}else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
2133222161
data.szMax = integerValue(argv[++i]);
2133322162
#endif
2133422163
--- src/shell.c
+++ src/shell.c
@@ -4963,14 +4963,15 @@
4963 sqlite3_value **argv
4964 ){
4965 Decimal *pA = decimal_new(context, argv[0], 0, 0);
4966 Decimal *pB = decimal_new(context, argv[1], 0, 0);
4967 UNUSED_PARAMETER(argc);
4968 if( pB==0 ) return;
4969 pB->sign = !pB->sign;
4970 decimal_add(pA, pB);
4971 decimal_result(context, pA);
 
4972 decimal_free(pA);
4973 decimal_free(pB);
4974 }
4975
4976 /* Aggregate funcion: decimal_sum(X)
@@ -5878,10 +5879,784 @@
5878 #endif
5879 return rc;
5880 }
5881
5882 /************************* End ../ext/misc/series.c ********************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5883 #ifdef SQLITE_HAVE_ZLIB
5884 /************************* Begin ../ext/misc/zipfile.c ******************/
5885 /*
5886 ** 2017-12-26
5887 **
@@ -5918,14 +6693,28 @@
5918
5919 #ifndef SQLITE_OMIT_VIRTUALTABLE
5920
5921 #ifndef SQLITE_AMALGAMATION
5922
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5923 /* typedef sqlite3_int64 i64; */
5924 /* typedef unsigned char u8; */
5925 typedef unsigned short u16;
5926 typedef unsigned long u32;
5927 #define MIN(a,b) ((a)<(b) ? (a) : (b))
5928
5929 #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
5930 # define ALWAYS(X) (1)
5931 # define NEVER(X) (0)
@@ -6588,38 +7377,28 @@
6588 ** Bits 09-15: years from 1980
6589 **
6590 ** https://msdn.microsoft.com/en-us/library/9kkf9tah.aspx
6591 */
6592 static u32 zipfileMtime(ZipfileCDS *pCDS){
6593 int Y = (1980 + ((pCDS->mDate >> 9) & 0x7F));
6594 int M = ((pCDS->mDate >> 5) & 0x0F);
6595 int D = (pCDS->mDate & 0x1F);
6596 int B = -13;
6597
6598 int sec = (pCDS->mTime & 0x1F)*2;
6599 int min = (pCDS->mTime >> 5) & 0x3F;
6600 int hr = (pCDS->mTime >> 11) & 0x1F;
6601 i64 JD;
6602
6603 /* JD = INT(365.25 * (Y+4716)) + INT(30.6001 * (M+1)) + D + B - 1524.5 */
6604
6605 /* Calculate the JD in seconds for noon on the day in question */
6606 if( M<3 ){
6607 Y = Y-1;
6608 M = M+12;
6609 }
6610 JD = (i64)(24*60*60) * (
6611 (int)(365.25 * (Y + 4716))
6612 + (int)(30.6001 * (M + 1))
6613 + D + B - 1524
6614 );
6615
6616 /* Correct the JD for the time within the day */
6617 JD += (hr-12) * 3600 + min * 60 + sec;
6618
6619 /* Convert JD to unix timestamp (the JD epoch is 2440587.5) */
6620 return (u32)(JD - (i64)(24405875) * 24*60*6);
6621 }
6622
6623 /*
6624 ** The opposite of zipfileMtime(). This function populates the mTime and
6625 ** mDate fields of the CDS structure passed as the first argument according
@@ -8052,10 +8831,14 @@
8052 if( rc==SQLITE_OK ){
8053 rc = sqlite3_create_function(db, "zipfile", -1, SQLITE_UTF8, 0, 0,
8054 zipfileStep, zipfileFinal
8055 );
8056 }
 
 
 
 
8057 return rc;
8058 }
8059 #else /* SQLITE_OMIT_VIRTUALTABLE */
8060 # define zipfileRegister(x) SQLITE_OK
8061 #endif
@@ -14032,11 +14815,11 @@
14032 " Examples:",
14033 " .ar -cf ARCHIVE foo bar # Create ARCHIVE from files foo and bar",
14034 " .ar -tf ARCHIVE # List members of ARCHIVE",
14035 " .ar -xvf ARCHIVE # Verbosely extract files from ARCHIVE",
14036 " See also:",
14037 " http://sqlite.org/cli.html#sqlar_archive_support",
14038 #endif
14039 #ifndef SQLITE_OMIT_AUTHORIZATION
14040 ".auth ON|OFF Show authorizer callbacks",
14041 #endif
14042 ".backup ?DB? FILE Backup DB (default \"main\") to FILE",
@@ -14134,12 +14917,12 @@
14134 ".oom ?--repeat M? ?N? Simulate an OOM error on the N-th allocation",
14135 #endif
14136 ".open ?OPTIONS? ?FILE? Close existing database and reopen FILE",
14137 " Options:",
14138 " --append Use appendvfs to append database to the end of FILE",
14139 #ifdef SQLITE_ENABLE_DESERIALIZE
14140 " --deserialize Load into memory useing sqlite3_deserialize()",
14141 " --hexdb Load the output of \"dbtotxt\" as an in-memory db",
14142 " --maxsize N Maximum size for --hexdb or --deserialized database",
14143 #endif
14144 " --new Initialize FILE to an empty database",
14145 " --nofollow Do not follow symbolic links",
@@ -14456,11 +15239,11 @@
14456 }
14457 fclose(f);
14458 return rc;
14459 }
14460
14461 #ifdef SQLITE_ENABLE_DESERIALIZE
14462 /*
14463 ** Reconstruct an in-memory database using the output from the "dbtotxt"
14464 ** program. Read content from the file in p->zDbFilename. If p->zDbFilename
14465 ** is 0, then read from standard input.
14466 */
@@ -14545,11 +15328,11 @@
14545 }
14546 sqlite3_free(a);
14547 utf8_printf(stderr,"Error on line %d of --hexdb input\n", nLine);
14548 return 0;
14549 }
14550 #endif /* SQLITE_ENABLE_DESERIALIZE */
14551
14552 /*
14553 ** Scalar function "shell_int32". The first argument to this function
14554 ** must be a blob. The second a non-negative integer. This function
14555 ** reads and returns a 32-bit big-endian integer from byte
@@ -14771,10 +15554,11 @@
14771 sqlite3_fileio_init(p->db, 0, 0);
14772 sqlite3_shathree_init(p->db, 0, 0);
14773 sqlite3_completion_init(p->db, 0, 0);
14774 sqlite3_uint_init(p->db, 0, 0);
14775 sqlite3_decimal_init(p->db, 0, 0);
 
14776 sqlite3_ieee_init(p->db, 0, 0);
14777 sqlite3_series_init(p->db, 0, 0);
14778 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
14779 sqlite3_dbdata_init(p->db, 0, 0);
14780 #endif
@@ -14806,11 +15590,11 @@
14806 char *zSql = sqlite3_mprintf(
14807 "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);
14808 sqlite3_exec(p->db, zSql, 0, 0, 0);
14809 sqlite3_free(zSql);
14810 }
14811 #ifdef SQLITE_ENABLE_DESERIALIZE
14812 else
14813 if( p->openMode==SHELL_OPEN_DESERIALIZE || p->openMode==SHELL_OPEN_HEXDB ){
14814 int rc;
14815 int nData = 0;
14816 unsigned char *aData;
@@ -16873,10 +17657,11 @@
16873 char *zErr = 0;
16874 rc = sqlite3_exec(db, zSql, 0, 0, &zErr);
16875 if( rc!=SQLITE_OK ){
16876 raw_printf(stderr, "SQL error: %s\n", zErr);
16877 }
 
16878 *pRc = rc;
16879 }
16880 }
16881
16882 /*
@@ -17894,15 +18679,30 @@
17894 raw_printf(stderr, "Unknown option \"%s\" on \".dump\"\n", azArg[i]);
17895 rc = 1;
17896 sqlite3_free(zLike);
17897 goto meta_command_exit;
17898 }
17899 }else if( zLike ){
17900 zLike = sqlite3_mprintf("%z OR name LIKE %Q ESCAPE '\\'",
17901 zLike, azArg[i]);
17902 }else{
17903 zLike = sqlite3_mprintf("name LIKE %Q ESCAPE '\\'", azArg[i]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17904 }
17905 }
17906
17907 open_db(p, 0);
17908
@@ -17920,21 +18720,21 @@
17920 ** corrupt. */
17921 sqlite3_exec(p->db, "SAVEPOINT dump; PRAGMA writable_schema=ON", 0, 0, 0);
17922 p->nErr = 0;
17923 if( zLike==0 ) zLike = sqlite3_mprintf("true");
17924 zSql = sqlite3_mprintf(
17925 "SELECT name, type, sql FROM sqlite_schema "
17926 "WHERE (%s) AND type=='table'"
17927 " AND sql NOT NULL"
17928 " ORDER BY tbl_name='sqlite_sequence', rowid",
17929 zLike
17930 );
17931 run_schema_dump_query(p,zSql);
17932 sqlite3_free(zSql);
17933 if( (p->shellFlgs & SHFLG_DumpDataOnly)==0 ){
17934 zSql = sqlite3_mprintf(
17935 "SELECT sql FROM sqlite_schema "
17936 "WHERE (%s) AND sql NOT NULL"
17937 " AND type IN ('index','trigger','view')",
17938 zLike
17939 );
17940 run_table_dump_query(p, zSql);
@@ -18177,11 +18977,10 @@
18177 }
18178 }else
18179
18180 if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){
18181 ShellState data;
18182 char *zErrMsg = 0;
18183 int doStats = 0;
18184 memcpy(&data, p, sizeof(data));
18185 data.showHeader = 0;
18186 data.cMode = data.mode = MODE_Semi;
18187 if( nArg==2 && optionMatch(azArg[1], "indent") ){
@@ -18199,11 +18998,11 @@
18199 " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
18200 " FROM sqlite_schema UNION ALL"
18201 " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_schema) "
18202 "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' "
18203 "ORDER BY rowid",
18204 callback, &data, &zErrMsg
18205 );
18206 if( rc==SQLITE_OK ){
18207 sqlite3_stmt *pStmt;
18208 rc = sqlite3_prepare_v2(p->db,
18209 "SELECT rowid FROM sqlite_schema"
@@ -18215,16 +19014,16 @@
18215 if( doStats==0 ){
18216 raw_printf(p->out, "/* No STAT tables available */\n");
18217 }else{
18218 raw_printf(p->out, "ANALYZE sqlite_schema;\n");
18219 sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_schema'",
18220 callback, &data, &zErrMsg);
18221 data.cMode = data.mode = MODE_Insert;
18222 data.zDestTable = "sqlite_stat1";
18223 shell_exec(&data, "SELECT * FROM sqlite_stat1", &zErrMsg);
18224 data.zDestTable = "sqlite_stat4";
18225 shell_exec(&data, "SELECT * FROM sqlite_stat4", &zErrMsg);
18226 raw_printf(p->out, "ANALYZE sqlite_schema;\n");
18227 }
18228 }else
18229
18230 if( c=='h' && strncmp(azArg[0], "headers", n)==0 ){
@@ -18868,18 +19667,18 @@
18868 p->openMode = SHELL_OPEN_APPENDVFS;
18869 }else if( optionMatch(z, "readonly") ){
18870 p->openMode = SHELL_OPEN_READONLY;
18871 }else if( optionMatch(z, "nofollow") ){
18872 p->openFlags |= SQLITE_OPEN_NOFOLLOW;
18873 #ifdef SQLITE_ENABLE_DESERIALIZE
18874 }else if( optionMatch(z, "deserialize") ){
18875 p->openMode = SHELL_OPEN_DESERIALIZE;
18876 }else if( optionMatch(z, "hexdb") ){
18877 p->openMode = SHELL_OPEN_HEXDB;
18878 }else if( optionMatch(z, "maxsize") && iName+1<nArg ){
18879 p->szMax = integerValue(azArg[++iName]);
18880 #endif /* SQLITE_ENABLE_DESERIALIZE */
18881 }else if( z[0]=='-' ){
18882 utf8_printf(stderr, "unknown option: %s\n", z);
18883 rc = 1;
18884 goto meta_command_exit;
18885 }else if( zNewFilename ){
@@ -20113,10 +20912,11 @@
20113 { "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE, "OFFSET " },
20114 { "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE, "" },
20115 { "prng_save", SQLITE_TESTCTRL_PRNG_SAVE, "" },
20116 { "prng_seed", SQLITE_TESTCTRL_PRNG_SEED, "SEED ?db?" },
20117 { "seek_count", SQLITE_TESTCTRL_SEEK_COUNT, "" },
 
20118 };
20119 int testctrl = -1;
20120 int iCtrl = -1;
20121 int rc2 = 0; /* 0: usage. 1: %d 2: %x 3: no-output */
20122 int isOk = 0;
@@ -20257,15 +21057,44 @@
20257 isOk = 3;
20258 break;
20259 }
20260
20261 #ifdef YYCOVERAGE
20262 case SQLITE_TESTCTRL_PARSER_COVERAGE:
20263 if( nArg==2 ){
20264 sqlite3_test_control(testctrl, p->out);
20265 isOk = 3;
20266 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20267 #endif
20268 }
20269 }
20270 if( isOk==0 && iCtrl>=0 ){
20271 utf8_printf(p->out, "Usage: .testctrl %s %s\n", zCmd,aCtrl[iCtrl].zUsage);
@@ -20859,11 +21688,11 @@
20859 " -batch force batch I/O\n"
20860 " -box set output mode to 'box'\n"
20861 " -column set output mode to 'column'\n"
20862 " -cmd COMMAND run \"COMMAND\" before reading stdin\n"
20863 " -csv set output mode to 'csv'\n"
20864 #if defined(SQLITE_ENABLE_DESERIALIZE)
20865 " -deserialize open the database using sqlite3_deserialize()\n"
20866 #endif
20867 " -echo print commands before execution\n"
20868 " -init FILENAME read/process named file\n"
20869 " -[no]header turn headers on or off\n"
@@ -20876,11 +21705,11 @@
20876 " -json set output mode to 'json'\n"
20877 " -line set output mode to 'line'\n"
20878 " -list set output mode to 'list'\n"
20879 " -lookaside SIZE N use N entries of SZ bytes for lookaside memory\n"
20880 " -markdown set output mode to 'markdown'\n"
20881 #if defined(SQLITE_ENABLE_DESERIALIZE)
20882 " -maxsize N maximum size for a --deserialize database\n"
20883 #endif
20884 " -memtrace trace all memory allocations and deallocations\n"
20885 " -mmap N default mmap size set to N\n"
20886 #ifdef SQLITE_ENABLE_MULTIPLEX
@@ -21206,11 +22035,11 @@
21206 }else if( strcmp(z,"-zip")==0 ){
21207 data.openMode = SHELL_OPEN_ZIPFILE;
21208 #endif
21209 }else if( strcmp(z,"-append")==0 ){
21210 data.openMode = SHELL_OPEN_APPENDVFS;
21211 #ifdef SQLITE_ENABLE_DESERIALIZE
21212 }else if( strcmp(z,"-deserialize")==0 ){
21213 data.openMode = SHELL_OPEN_DESERIALIZE;
21214 }else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
21215 data.szMax = integerValue(argv[++i]);
21216 #endif
@@ -21323,11 +22152,11 @@
21323 }else if( strcmp(z,"-zip")==0 ){
21324 data.openMode = SHELL_OPEN_ZIPFILE;
21325 #endif
21326 }else if( strcmp(z,"-append")==0 ){
21327 data.openMode = SHELL_OPEN_APPENDVFS;
21328 #ifdef SQLITE_ENABLE_DESERIALIZE
21329 }else if( strcmp(z,"-deserialize")==0 ){
21330 data.openMode = SHELL_OPEN_DESERIALIZE;
21331 }else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
21332 data.szMax = integerValue(argv[++i]);
21333 #endif
21334
--- src/shell.c
+++ src/shell.c
@@ -4963,14 +4963,15 @@
4963 sqlite3_value **argv
4964 ){
4965 Decimal *pA = decimal_new(context, argv[0], 0, 0);
4966 Decimal *pB = decimal_new(context, argv[1], 0, 0);
4967 UNUSED_PARAMETER(argc);
4968 if( pB ){
4969 pB->sign = !pB->sign;
4970 decimal_add(pA, pB);
4971 decimal_result(context, pA);
4972 }
4973 decimal_free(pA);
4974 decimal_free(pB);
4975 }
4976
4977 /* Aggregate funcion: decimal_sum(X)
@@ -5878,10 +5879,784 @@
5879 #endif
5880 return rc;
5881 }
5882
5883 /************************* End ../ext/misc/series.c ********************/
5884 /************************* Begin ../ext/misc/regexp.c ******************/
5885 /*
5886 ** 2012-11-13
5887 **
5888 ** The author disclaims copyright to this source code. In place of
5889 ** a legal notice, here is a blessing:
5890 **
5891 ** May you do good and not evil.
5892 ** May you find forgiveness for yourself and forgive others.
5893 ** May you share freely, never taking more than you give.
5894 **
5895 ******************************************************************************
5896 **
5897 ** The code in this file implements a compact but reasonably
5898 ** efficient regular-expression matcher for posix extended regular
5899 ** expressions against UTF8 text.
5900 **
5901 ** This file is an SQLite extension. It registers a single function
5902 ** named "regexp(A,B)" where A is the regular expression and B is the
5903 ** string to be matched. By registering this function, SQLite will also
5904 ** then implement the "B regexp A" operator. Note that with the function
5905 ** the regular expression comes first, but with the operator it comes
5906 ** second.
5907 **
5908 ** The following regular expression syntax is supported:
5909 **
5910 ** X* zero or more occurrences of X
5911 ** X+ one or more occurrences of X
5912 ** X? zero or one occurrences of X
5913 ** X{p,q} between p and q occurrences of X
5914 ** (X) match X
5915 ** X|Y X or Y
5916 ** ^X X occurring at the beginning of the string
5917 ** X$ X occurring at the end of the string
5918 ** . Match any single character
5919 ** \c Character c where c is one of \{}()[]|*+?.
5920 ** \c C-language escapes for c in afnrtv. ex: \t or \n
5921 ** \uXXXX Where XXXX is exactly 4 hex digits, unicode value XXXX
5922 ** \xXX Where XX is exactly 2 hex digits, unicode value XX
5923 ** [abc] Any single character from the set abc
5924 ** [^abc] Any single character not in the set abc
5925 ** [a-z] Any single character in the range a-z
5926 ** [^a-z] Any single character not in the range a-z
5927 ** \b Word boundary
5928 ** \w Word character. [A-Za-z0-9_]
5929 ** \W Non-word character
5930 ** \d Digit
5931 ** \D Non-digit
5932 ** \s Whitespace character
5933 ** \S Non-whitespace character
5934 **
5935 ** A nondeterministic finite automaton (NFA) is used for matching, so the
5936 ** performance is bounded by O(N*M) where N is the size of the regular
5937 ** expression and M is the size of the input string. The matcher never
5938 ** exhibits exponential behavior. Note that the X{p,q} operator expands
5939 ** to p copies of X following by q-p copies of X? and that the size of the
5940 ** regular expression in the O(N*M) performance bound is computed after
5941 ** this expansion.
5942 */
5943 #include <string.h>
5944 #include <stdlib.h>
5945 /* #include "sqlite3ext.h" */
5946 SQLITE_EXTENSION_INIT1
5947
5948 /*
5949 ** The following #defines change the names of some functions implemented in
5950 ** this file to prevent name collisions with C-library functions of the
5951 ** same name.
5952 */
5953 #define re_match sqlite3re_match
5954 #define re_compile sqlite3re_compile
5955 #define re_free sqlite3re_free
5956
5957 /* The end-of-input character */
5958 #define RE_EOF 0 /* End of input */
5959
5960 /* The NFA is implemented as sequence of opcodes taken from the following
5961 ** set. Each opcode has a single integer argument.
5962 */
5963 #define RE_OP_MATCH 1 /* Match the one character in the argument */
5964 #define RE_OP_ANY 2 /* Match any one character. (Implements ".") */
5965 #define RE_OP_ANYSTAR 3 /* Special optimized version of .* */
5966 #define RE_OP_FORK 4 /* Continue to both next and opcode at iArg */
5967 #define RE_OP_GOTO 5 /* Jump to opcode at iArg */
5968 #define RE_OP_ACCEPT 6 /* Halt and indicate a successful match */
5969 #define RE_OP_CC_INC 7 /* Beginning of a [...] character class */
5970 #define RE_OP_CC_EXC 8 /* Beginning of a [^...] character class */
5971 #define RE_OP_CC_VALUE 9 /* Single value in a character class */
5972 #define RE_OP_CC_RANGE 10 /* Range of values in a character class */
5973 #define RE_OP_WORD 11 /* Perl word character [A-Za-z0-9_] */
5974 #define RE_OP_NOTWORD 12 /* Not a perl word character */
5975 #define RE_OP_DIGIT 13 /* digit: [0-9] */
5976 #define RE_OP_NOTDIGIT 14 /* Not a digit */
5977 #define RE_OP_SPACE 15 /* space: [ \t\n\r\v\f] */
5978 #define RE_OP_NOTSPACE 16 /* Not a digit */
5979 #define RE_OP_BOUNDARY 17 /* Boundary between word and non-word */
5980
5981 /* Each opcode is a "state" in the NFA */
5982 typedef unsigned short ReStateNumber;
5983
5984 /* Because this is an NFA and not a DFA, multiple states can be active at
5985 ** once. An instance of the following object records all active states in
5986 ** the NFA. The implementation is optimized for the common case where the
5987 ** number of actives states is small.
5988 */
5989 typedef struct ReStateSet {
5990 unsigned nState; /* Number of current states */
5991 ReStateNumber *aState; /* Current states */
5992 } ReStateSet;
5993
5994 /* An input string read one character at a time.
5995 */
5996 typedef struct ReInput ReInput;
5997 struct ReInput {
5998 const unsigned char *z; /* All text */
5999 int i; /* Next byte to read */
6000 int mx; /* EOF when i>=mx */
6001 };
6002
6003 /* A compiled NFA (or an NFA that is in the process of being compiled) is
6004 ** an instance of the following object.
6005 */
6006 typedef struct ReCompiled ReCompiled;
6007 struct ReCompiled {
6008 ReInput sIn; /* Regular expression text */
6009 const char *zErr; /* Error message to return */
6010 char *aOp; /* Operators for the virtual machine */
6011 int *aArg; /* Arguments to each operator */
6012 unsigned (*xNextChar)(ReInput*); /* Next character function */
6013 unsigned char zInit[12]; /* Initial text to match */
6014 int nInit; /* Number of characters in zInit */
6015 unsigned nState; /* Number of entries in aOp[] and aArg[] */
6016 unsigned nAlloc; /* Slots allocated for aOp[] and aArg[] */
6017 };
6018
6019 /* Add a state to the given state set if it is not already there */
6020 static void re_add_state(ReStateSet *pSet, int newState){
6021 unsigned i;
6022 for(i=0; i<pSet->nState; i++) if( pSet->aState[i]==newState ) return;
6023 pSet->aState[pSet->nState++] = (ReStateNumber)newState;
6024 }
6025
6026 /* Extract the next unicode character from *pzIn and return it. Advance
6027 ** *pzIn to the first byte past the end of the character returned. To
6028 ** be clear: this routine converts utf8 to unicode. This routine is
6029 ** optimized for the common case where the next character is a single byte.
6030 */
6031 static unsigned re_next_char(ReInput *p){
6032 unsigned c;
6033 if( p->i>=p->mx ) return 0;
6034 c = p->z[p->i++];
6035 if( c>=0x80 ){
6036 if( (c&0xe0)==0xc0 && p->i<p->mx && (p->z[p->i]&0xc0)==0x80 ){
6037 c = (c&0x1f)<<6 | (p->z[p->i++]&0x3f);
6038 if( c<0x80 ) c = 0xfffd;
6039 }else if( (c&0xf0)==0xe0 && p->i+1<p->mx && (p->z[p->i]&0xc0)==0x80
6040 && (p->z[p->i+1]&0xc0)==0x80 ){
6041 c = (c&0x0f)<<12 | ((p->z[p->i]&0x3f)<<6) | (p->z[p->i+1]&0x3f);
6042 p->i += 2;
6043 if( c<=0x7ff || (c>=0xd800 && c<=0xdfff) ) c = 0xfffd;
6044 }else if( (c&0xf8)==0xf0 && p->i+3<p->mx && (p->z[p->i]&0xc0)==0x80
6045 && (p->z[p->i+1]&0xc0)==0x80 && (p->z[p->i+2]&0xc0)==0x80 ){
6046 c = (c&0x07)<<18 | ((p->z[p->i]&0x3f)<<12) | ((p->z[p->i+1]&0x3f)<<6)
6047 | (p->z[p->i+2]&0x3f);
6048 p->i += 3;
6049 if( c<=0xffff || c>0x10ffff ) c = 0xfffd;
6050 }else{
6051 c = 0xfffd;
6052 }
6053 }
6054 return c;
6055 }
6056 static unsigned re_next_char_nocase(ReInput *p){
6057 unsigned c = re_next_char(p);
6058 if( c>='A' && c<='Z' ) c += 'a' - 'A';
6059 return c;
6060 }
6061
6062 /* Return true if c is a perl "word" character: [A-Za-z0-9_] */
6063 static int re_word_char(int c){
6064 return (c>='0' && c<='9') || (c>='a' && c<='z')
6065 || (c>='A' && c<='Z') || c=='_';
6066 }
6067
6068 /* Return true if c is a "digit" character: [0-9] */
6069 static int re_digit_char(int c){
6070 return (c>='0' && c<='9');
6071 }
6072
6073 /* Return true if c is a perl "space" character: [ \t\r\n\v\f] */
6074 static int re_space_char(int c){
6075 return c==' ' || c=='\t' || c=='\n' || c=='\r' || c=='\v' || c=='\f';
6076 }
6077
6078 /* Run a compiled regular expression on the zero-terminated input
6079 ** string zIn[]. Return true on a match and false if there is no match.
6080 */
6081 static int re_match(ReCompiled *pRe, const unsigned char *zIn, int nIn){
6082 ReStateSet aStateSet[2], *pThis, *pNext;
6083 ReStateNumber aSpace[100];
6084 ReStateNumber *pToFree;
6085 unsigned int i = 0;
6086 unsigned int iSwap = 0;
6087 int c = RE_EOF+1;
6088 int cPrev = 0;
6089 int rc = 0;
6090 ReInput in;
6091
6092 in.z = zIn;
6093 in.i = 0;
6094 in.mx = nIn>=0 ? nIn : (int)strlen((char const*)zIn);
6095
6096 /* Look for the initial prefix match, if there is one. */
6097 if( pRe->nInit ){
6098 unsigned char x = pRe->zInit[0];
6099 while( in.i+pRe->nInit<=in.mx
6100 && (zIn[in.i]!=x ||
6101 strncmp((const char*)zIn+in.i, (const char*)pRe->zInit, pRe->nInit)!=0)
6102 ){
6103 in.i++;
6104 }
6105 if( in.i+pRe->nInit>in.mx ) return 0;
6106 }
6107
6108 if( pRe->nState<=(sizeof(aSpace)/(sizeof(aSpace[0])*2)) ){
6109 pToFree = 0;
6110 aStateSet[0].aState = aSpace;
6111 }else{
6112 pToFree = sqlite3_malloc64( sizeof(ReStateNumber)*2*pRe->nState );
6113 if( pToFree==0 ) return -1;
6114 aStateSet[0].aState = pToFree;
6115 }
6116 aStateSet[1].aState = &aStateSet[0].aState[pRe->nState];
6117 pNext = &aStateSet[1];
6118 pNext->nState = 0;
6119 re_add_state(pNext, 0);
6120 while( c!=RE_EOF && pNext->nState>0 ){
6121 cPrev = c;
6122 c = pRe->xNextChar(&in);
6123 pThis = pNext;
6124 pNext = &aStateSet[iSwap];
6125 iSwap = 1 - iSwap;
6126 pNext->nState = 0;
6127 for(i=0; i<pThis->nState; i++){
6128 int x = pThis->aState[i];
6129 switch( pRe->aOp[x] ){
6130 case RE_OP_MATCH: {
6131 if( pRe->aArg[x]==c ) re_add_state(pNext, x+1);
6132 break;
6133 }
6134 case RE_OP_ANY: {
6135 if( c!=0 ) re_add_state(pNext, x+1);
6136 break;
6137 }
6138 case RE_OP_WORD: {
6139 if( re_word_char(c) ) re_add_state(pNext, x+1);
6140 break;
6141 }
6142 case RE_OP_NOTWORD: {
6143 if( !re_word_char(c) && c!=0 ) re_add_state(pNext, x+1);
6144 break;
6145 }
6146 case RE_OP_DIGIT: {
6147 if( re_digit_char(c) ) re_add_state(pNext, x+1);
6148 break;
6149 }
6150 case RE_OP_NOTDIGIT: {
6151 if( !re_digit_char(c) && c!=0 ) re_add_state(pNext, x+1);
6152 break;
6153 }
6154 case RE_OP_SPACE: {
6155 if( re_space_char(c) ) re_add_state(pNext, x+1);
6156 break;
6157 }
6158 case RE_OP_NOTSPACE: {
6159 if( !re_space_char(c) && c!=0 ) re_add_state(pNext, x+1);
6160 break;
6161 }
6162 case RE_OP_BOUNDARY: {
6163 if( re_word_char(c)!=re_word_char(cPrev) ) re_add_state(pThis, x+1);
6164 break;
6165 }
6166 case RE_OP_ANYSTAR: {
6167 re_add_state(pNext, x);
6168 re_add_state(pThis, x+1);
6169 break;
6170 }
6171 case RE_OP_FORK: {
6172 re_add_state(pThis, x+pRe->aArg[x]);
6173 re_add_state(pThis, x+1);
6174 break;
6175 }
6176 case RE_OP_GOTO: {
6177 re_add_state(pThis, x+pRe->aArg[x]);
6178 break;
6179 }
6180 case RE_OP_ACCEPT: {
6181 rc = 1;
6182 goto re_match_end;
6183 }
6184 case RE_OP_CC_EXC: {
6185 if( c==0 ) break;
6186 /* fall-through */
6187 }
6188 case RE_OP_CC_INC: {
6189 int j = 1;
6190 int n = pRe->aArg[x];
6191 int hit = 0;
6192 for(j=1; j>0 && j<n; j++){
6193 if( pRe->aOp[x+j]==RE_OP_CC_VALUE ){
6194 if( pRe->aArg[x+j]==c ){
6195 hit = 1;
6196 j = -1;
6197 }
6198 }else{
6199 if( pRe->aArg[x+j]<=c && pRe->aArg[x+j+1]>=c ){
6200 hit = 1;
6201 j = -1;
6202 }else{
6203 j++;
6204 }
6205 }
6206 }
6207 if( pRe->aOp[x]==RE_OP_CC_EXC ) hit = !hit;
6208 if( hit ) re_add_state(pNext, x+n);
6209 break;
6210 }
6211 }
6212 }
6213 }
6214 for(i=0; i<pNext->nState; i++){
6215 if( pRe->aOp[pNext->aState[i]]==RE_OP_ACCEPT ){ rc = 1; break; }
6216 }
6217 re_match_end:
6218 sqlite3_free(pToFree);
6219 return rc;
6220 }
6221
6222 /* Resize the opcode and argument arrays for an RE under construction.
6223 */
6224 static int re_resize(ReCompiled *p, int N){
6225 char *aOp;
6226 int *aArg;
6227 aOp = sqlite3_realloc64(p->aOp, N*sizeof(p->aOp[0]));
6228 if( aOp==0 ) return 1;
6229 p->aOp = aOp;
6230 aArg = sqlite3_realloc64(p->aArg, N*sizeof(p->aArg[0]));
6231 if( aArg==0 ) return 1;
6232 p->aArg = aArg;
6233 p->nAlloc = N;
6234 return 0;
6235 }
6236
6237 /* Insert a new opcode and argument into an RE under construction. The
6238 ** insertion point is just prior to existing opcode iBefore.
6239 */
6240 static int re_insert(ReCompiled *p, int iBefore, int op, int arg){
6241 int i;
6242 if( p->nAlloc<=p->nState && re_resize(p, p->nAlloc*2) ) return 0;
6243 for(i=p->nState; i>iBefore; i--){
6244 p->aOp[i] = p->aOp[i-1];
6245 p->aArg[i] = p->aArg[i-1];
6246 }
6247 p->nState++;
6248 p->aOp[iBefore] = (char)op;
6249 p->aArg[iBefore] = arg;
6250 return iBefore;
6251 }
6252
6253 /* Append a new opcode and argument to the end of the RE under construction.
6254 */
6255 static int re_append(ReCompiled *p, int op, int arg){
6256 return re_insert(p, p->nState, op, arg);
6257 }
6258
6259 /* Make a copy of N opcodes starting at iStart onto the end of the RE
6260 ** under construction.
6261 */
6262 static void re_copy(ReCompiled *p, int iStart, int N){
6263 if( p->nState+N>=p->nAlloc && re_resize(p, p->nAlloc*2+N) ) return;
6264 memcpy(&p->aOp[p->nState], &p->aOp[iStart], N*sizeof(p->aOp[0]));
6265 memcpy(&p->aArg[p->nState], &p->aArg[iStart], N*sizeof(p->aArg[0]));
6266 p->nState += N;
6267 }
6268
6269 /* Return true if c is a hexadecimal digit character: [0-9a-fA-F]
6270 ** If c is a hex digit, also set *pV = (*pV)*16 + valueof(c). If
6271 ** c is not a hex digit *pV is unchanged.
6272 */
6273 static int re_hex(int c, int *pV){
6274 if( c>='0' && c<='9' ){
6275 c -= '0';
6276 }else if( c>='a' && c<='f' ){
6277 c -= 'a' - 10;
6278 }else if( c>='A' && c<='F' ){
6279 c -= 'A' - 10;
6280 }else{
6281 return 0;
6282 }
6283 *pV = (*pV)*16 + (c & 0xff);
6284 return 1;
6285 }
6286
6287 /* A backslash character has been seen, read the next character and
6288 ** return its interpretation.
6289 */
6290 static unsigned re_esc_char(ReCompiled *p){
6291 static const char zEsc[] = "afnrtv\\()*.+?[$^{|}]";
6292 static const char zTrans[] = "\a\f\n\r\t\v";
6293 int i, v = 0;
6294 char c;
6295 if( p->sIn.i>=p->sIn.mx ) return 0;
6296 c = p->sIn.z[p->sIn.i];
6297 if( c=='u' && p->sIn.i+4<p->sIn.mx ){
6298 const unsigned char *zIn = p->sIn.z + p->sIn.i;
6299 if( re_hex(zIn[1],&v)
6300 && re_hex(zIn[2],&v)
6301 && re_hex(zIn[3],&v)
6302 && re_hex(zIn[4],&v)
6303 ){
6304 p->sIn.i += 5;
6305 return v;
6306 }
6307 }
6308 if( c=='x' && p->sIn.i+2<p->sIn.mx ){
6309 const unsigned char *zIn = p->sIn.z + p->sIn.i;
6310 if( re_hex(zIn[1],&v)
6311 && re_hex(zIn[2],&v)
6312 ){
6313 p->sIn.i += 3;
6314 return v;
6315 }
6316 }
6317 for(i=0; zEsc[i] && zEsc[i]!=c; i++){}
6318 if( zEsc[i] ){
6319 if( i<6 ) c = zTrans[i];
6320 p->sIn.i++;
6321 }else{
6322 p->zErr = "unknown \\ escape";
6323 }
6324 return c;
6325 }
6326
6327 /* Forward declaration */
6328 static const char *re_subcompile_string(ReCompiled*);
6329
6330 /* Peek at the next byte of input */
6331 static unsigned char rePeek(ReCompiled *p){
6332 return p->sIn.i<p->sIn.mx ? p->sIn.z[p->sIn.i] : 0;
6333 }
6334
6335 /* Compile RE text into a sequence of opcodes. Continue up to the
6336 ** first unmatched ")" character, then return. If an error is found,
6337 ** return a pointer to the error message string.
6338 */
6339 static const char *re_subcompile_re(ReCompiled *p){
6340 const char *zErr;
6341 int iStart, iEnd, iGoto;
6342 iStart = p->nState;
6343 zErr = re_subcompile_string(p);
6344 if( zErr ) return zErr;
6345 while( rePeek(p)=='|' ){
6346 iEnd = p->nState;
6347 re_insert(p, iStart, RE_OP_FORK, iEnd + 2 - iStart);
6348 iGoto = re_append(p, RE_OP_GOTO, 0);
6349 p->sIn.i++;
6350 zErr = re_subcompile_string(p);
6351 if( zErr ) return zErr;
6352 p->aArg[iGoto] = p->nState - iGoto;
6353 }
6354 return 0;
6355 }
6356
6357 /* Compile an element of regular expression text (anything that can be
6358 ** an operand to the "|" operator). Return NULL on success or a pointer
6359 ** to the error message if there is a problem.
6360 */
6361 static const char *re_subcompile_string(ReCompiled *p){
6362 int iPrev = -1;
6363 int iStart;
6364 unsigned c;
6365 const char *zErr;
6366 while( (c = p->xNextChar(&p->sIn))!=0 ){
6367 iStart = p->nState;
6368 switch( c ){
6369 case '|':
6370 case '$':
6371 case ')': {
6372 p->sIn.i--;
6373 return 0;
6374 }
6375 case '(': {
6376 zErr = re_subcompile_re(p);
6377 if( zErr ) return zErr;
6378 if( rePeek(p)!=')' ) return "unmatched '('";
6379 p->sIn.i++;
6380 break;
6381 }
6382 case '.': {
6383 if( rePeek(p)=='*' ){
6384 re_append(p, RE_OP_ANYSTAR, 0);
6385 p->sIn.i++;
6386 }else{
6387 re_append(p, RE_OP_ANY, 0);
6388 }
6389 break;
6390 }
6391 case '*': {
6392 if( iPrev<0 ) return "'*' without operand";
6393 re_insert(p, iPrev, RE_OP_GOTO, p->nState - iPrev + 1);
6394 re_append(p, RE_OP_FORK, iPrev - p->nState + 1);
6395 break;
6396 }
6397 case '+': {
6398 if( iPrev<0 ) return "'+' without operand";
6399 re_append(p, RE_OP_FORK, iPrev - p->nState);
6400 break;
6401 }
6402 case '?': {
6403 if( iPrev<0 ) return "'?' without operand";
6404 re_insert(p, iPrev, RE_OP_FORK, p->nState - iPrev+1);
6405 break;
6406 }
6407 case '{': {
6408 int m = 0, n = 0;
6409 int sz, j;
6410 if( iPrev<0 ) return "'{m,n}' without operand";
6411 while( (c=rePeek(p))>='0' && c<='9' ){ m = m*10 + c - '0'; p->sIn.i++; }
6412 n = m;
6413 if( c==',' ){
6414 p->sIn.i++;
6415 n = 0;
6416 while( (c=rePeek(p))>='0' && c<='9' ){ n = n*10 + c-'0'; p->sIn.i++; }
6417 }
6418 if( c!='}' ) return "unmatched '{'";
6419 if( n>0 && n<m ) return "n less than m in '{m,n}'";
6420 p->sIn.i++;
6421 sz = p->nState - iPrev;
6422 if( m==0 ){
6423 if( n==0 ) return "both m and n are zero in '{m,n}'";
6424 re_insert(p, iPrev, RE_OP_FORK, sz+1);
6425 n--;
6426 }else{
6427 for(j=1; j<m; j++) re_copy(p, iPrev, sz);
6428 }
6429 for(j=m; j<n; j++){
6430 re_append(p, RE_OP_FORK, sz+1);
6431 re_copy(p, iPrev, sz);
6432 }
6433 if( n==0 && m>0 ){
6434 re_append(p, RE_OP_FORK, -sz);
6435 }
6436 break;
6437 }
6438 case '[': {
6439 int iFirst = p->nState;
6440 if( rePeek(p)=='^' ){
6441 re_append(p, RE_OP_CC_EXC, 0);
6442 p->sIn.i++;
6443 }else{
6444 re_append(p, RE_OP_CC_INC, 0);
6445 }
6446 while( (c = p->xNextChar(&p->sIn))!=0 ){
6447 if( c=='[' && rePeek(p)==':' ){
6448 return "POSIX character classes not supported";
6449 }
6450 if( c=='\\' ) c = re_esc_char(p);
6451 if( rePeek(p)=='-' ){
6452 re_append(p, RE_OP_CC_RANGE, c);
6453 p->sIn.i++;
6454 c = p->xNextChar(&p->sIn);
6455 if( c=='\\' ) c = re_esc_char(p);
6456 re_append(p, RE_OP_CC_RANGE, c);
6457 }else{
6458 re_append(p, RE_OP_CC_VALUE, c);
6459 }
6460 if( rePeek(p)==']' ){ p->sIn.i++; break; }
6461 }
6462 if( c==0 ) return "unclosed '['";
6463 p->aArg[iFirst] = p->nState - iFirst;
6464 break;
6465 }
6466 case '\\': {
6467 int specialOp = 0;
6468 switch( rePeek(p) ){
6469 case 'b': specialOp = RE_OP_BOUNDARY; break;
6470 case 'd': specialOp = RE_OP_DIGIT; break;
6471 case 'D': specialOp = RE_OP_NOTDIGIT; break;
6472 case 's': specialOp = RE_OP_SPACE; break;
6473 case 'S': specialOp = RE_OP_NOTSPACE; break;
6474 case 'w': specialOp = RE_OP_WORD; break;
6475 case 'W': specialOp = RE_OP_NOTWORD; break;
6476 }
6477 if( specialOp ){
6478 p->sIn.i++;
6479 re_append(p, specialOp, 0);
6480 }else{
6481 c = re_esc_char(p);
6482 re_append(p, RE_OP_MATCH, c);
6483 }
6484 break;
6485 }
6486 default: {
6487 re_append(p, RE_OP_MATCH, c);
6488 break;
6489 }
6490 }
6491 iPrev = iStart;
6492 }
6493 return 0;
6494 }
6495
6496 /* Free and reclaim all the memory used by a previously compiled
6497 ** regular expression. Applications should invoke this routine once
6498 ** for every call to re_compile() to avoid memory leaks.
6499 */
6500 static void re_free(ReCompiled *pRe){
6501 if( pRe ){
6502 sqlite3_free(pRe->aOp);
6503 sqlite3_free(pRe->aArg);
6504 sqlite3_free(pRe);
6505 }
6506 }
6507
6508 /*
6509 ** Compile a textual regular expression in zIn[] into a compiled regular
6510 ** expression suitable for us by re_match() and return a pointer to the
6511 ** compiled regular expression in *ppRe. Return NULL on success or an
6512 ** error message if something goes wrong.
6513 */
6514 static const char *re_compile(ReCompiled **ppRe, const char *zIn, int noCase){
6515 ReCompiled *pRe;
6516 const char *zErr;
6517 int i, j;
6518
6519 *ppRe = 0;
6520 pRe = sqlite3_malloc( sizeof(*pRe) );
6521 if( pRe==0 ){
6522 return "out of memory";
6523 }
6524 memset(pRe, 0, sizeof(*pRe));
6525 pRe->xNextChar = noCase ? re_next_char_nocase : re_next_char;
6526 if( re_resize(pRe, 30) ){
6527 re_free(pRe);
6528 return "out of memory";
6529 }
6530 if( zIn[0]=='^' ){
6531 zIn++;
6532 }else{
6533 re_append(pRe, RE_OP_ANYSTAR, 0);
6534 }
6535 pRe->sIn.z = (unsigned char*)zIn;
6536 pRe->sIn.i = 0;
6537 pRe->sIn.mx = (int)strlen(zIn);
6538 zErr = re_subcompile_re(pRe);
6539 if( zErr ){
6540 re_free(pRe);
6541 return zErr;
6542 }
6543 if( rePeek(pRe)=='$' && pRe->sIn.i+1>=pRe->sIn.mx ){
6544 re_append(pRe, RE_OP_MATCH, RE_EOF);
6545 re_append(pRe, RE_OP_ACCEPT, 0);
6546 *ppRe = pRe;
6547 }else if( pRe->sIn.i>=pRe->sIn.mx ){
6548 re_append(pRe, RE_OP_ACCEPT, 0);
6549 *ppRe = pRe;
6550 }else{
6551 re_free(pRe);
6552 return "unrecognized character";
6553 }
6554
6555 /* The following is a performance optimization. If the regex begins with
6556 ** ".*" (if the input regex lacks an initial "^") and afterwards there are
6557 ** one or more matching characters, enter those matching characters into
6558 ** zInit[]. The re_match() routine can then search ahead in the input
6559 ** string looking for the initial match without having to run the whole
6560 ** regex engine over the string. Do not worry able trying to match
6561 ** unicode characters beyond plane 0 - those are very rare and this is
6562 ** just an optimization. */
6563 if( pRe->aOp[0]==RE_OP_ANYSTAR && !noCase ){
6564 for(j=0, i=1; j<(int)sizeof(pRe->zInit)-2 && pRe->aOp[i]==RE_OP_MATCH; i++){
6565 unsigned x = pRe->aArg[i];
6566 if( x<=127 ){
6567 pRe->zInit[j++] = (unsigned char)x;
6568 }else if( x<=0xfff ){
6569 pRe->zInit[j++] = (unsigned char)(0xc0 | (x>>6));
6570 pRe->zInit[j++] = 0x80 | (x&0x3f);
6571 }else if( x<=0xffff ){
6572 pRe->zInit[j++] = (unsigned char)(0xd0 | (x>>12));
6573 pRe->zInit[j++] = 0x80 | ((x>>6)&0x3f);
6574 pRe->zInit[j++] = 0x80 | (x&0x3f);
6575 }else{
6576 break;
6577 }
6578 }
6579 if( j>0 && pRe->zInit[j-1]==0 ) j--;
6580 pRe->nInit = j;
6581 }
6582 return pRe->zErr;
6583 }
6584
6585 /*
6586 ** Implementation of the regexp() SQL function. This function implements
6587 ** the build-in REGEXP operator. The first argument to the function is the
6588 ** pattern and the second argument is the string. So, the SQL statements:
6589 **
6590 ** A REGEXP B
6591 **
6592 ** is implemented as regexp(B,A).
6593 */
6594 static void re_sql_func(
6595 sqlite3_context *context,
6596 int argc,
6597 sqlite3_value **argv
6598 ){
6599 ReCompiled *pRe; /* Compiled regular expression */
6600 const char *zPattern; /* The regular expression */
6601 const unsigned char *zStr;/* String being searched */
6602 const char *zErr; /* Compile error message */
6603 int setAux = 0; /* True to invoke sqlite3_set_auxdata() */
6604
6605 (void)argc; /* Unused */
6606 pRe = sqlite3_get_auxdata(context, 0);
6607 if( pRe==0 ){
6608 zPattern = (const char*)sqlite3_value_text(argv[0]);
6609 if( zPattern==0 ) return;
6610 zErr = re_compile(&pRe, zPattern, sqlite3_user_data(context)!=0);
6611 if( zErr ){
6612 re_free(pRe);
6613 sqlite3_result_error(context, zErr, -1);
6614 return;
6615 }
6616 if( pRe==0 ){
6617 sqlite3_result_error_nomem(context);
6618 return;
6619 }
6620 setAux = 1;
6621 }
6622 zStr = (const unsigned char*)sqlite3_value_text(argv[1]);
6623 if( zStr!=0 ){
6624 sqlite3_result_int(context, re_match(pRe, zStr, -1));
6625 }
6626 if( setAux ){
6627 sqlite3_set_auxdata(context, 0, pRe, (void(*)(void*))re_free);
6628 }
6629 }
6630
6631 /*
6632 ** Invoke this routine to register the regexp() function with the
6633 ** SQLite database connection.
6634 */
6635 #ifdef _WIN32
6636
6637 #endif
6638 int sqlite3_regexp_init(
6639 sqlite3 *db,
6640 char **pzErrMsg,
6641 const sqlite3_api_routines *pApi
6642 ){
6643 int rc = SQLITE_OK;
6644 SQLITE_EXTENSION_INIT2(pApi);
6645 (void)pzErrMsg; /* Unused */
6646 rc = sqlite3_create_function(db, "regexp", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
6647 0, re_sql_func, 0, 0);
6648 if( rc==SQLITE_OK ){
6649 /* The regexpi(PATTERN,STRING) function is a case-insensitive version
6650 ** of regexp(PATTERN,STRING). */
6651 rc = sqlite3_create_function(db, "regexpi", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
6652 (void*)db, re_sql_func, 0, 0);
6653 }
6654 return rc;
6655 }
6656
6657 /************************* End ../ext/misc/regexp.c ********************/
6658 #ifdef SQLITE_HAVE_ZLIB
6659 /************************* Begin ../ext/misc/zipfile.c ******************/
6660 /*
6661 ** 2017-12-26
6662 **
@@ -5918,14 +6693,28 @@
6693
6694 #ifndef SQLITE_OMIT_VIRTUALTABLE
6695
6696 #ifndef SQLITE_AMALGAMATION
6697
6698 #ifndef UINT32_TYPE
6699 # ifdef HAVE_UINT32_T
6700 # define UINT32_TYPE uint32_t
6701 # else
6702 # define UINT32_TYPE unsigned int
6703 # endif
6704 #endif
6705 #ifndef UINT16_TYPE
6706 # ifdef HAVE_UINT16_T
6707 # define UINT16_TYPE uint16_t
6708 # else
6709 # define UINT16_TYPE unsigned short int
6710 # endif
6711 #endif
6712 /* typedef sqlite3_int64 i64; */
6713 /* typedef unsigned char u8; */
6714 typedef UINT32_TYPE u32; /* 4-byte unsigned integer */
6715 typedef UINT16_TYPE u16; /* 2-byte unsigned integer */
6716 #define MIN(a,b) ((a)<(b) ? (a) : (b))
6717
6718 #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
6719 # define ALWAYS(X) (1)
6720 # define NEVER(X) (0)
@@ -6588,38 +7377,28 @@
7377 ** Bits 09-15: years from 1980
7378 **
7379 ** https://msdn.microsoft.com/en-us/library/9kkf9tah.aspx
7380 */
7381 static u32 zipfileMtime(ZipfileCDS *pCDS){
7382 int Y,M,D,X1,X2,A,B,sec,min,hr;
7383 i64 JDsec;
7384 Y = (1980 + ((pCDS->mDate >> 9) & 0x7F));
7385 M = ((pCDS->mDate >> 5) & 0x0F);
7386 D = (pCDS->mDate & 0x1F);
7387 sec = (pCDS->mTime & 0x1F)*2;
7388 min = (pCDS->mTime >> 5) & 0x3F;
7389 hr = (pCDS->mTime >> 11) & 0x1F;
7390 if( M<=2 ){
7391 Y--;
7392 M += 12;
7393 }
7394 X1 = 36525*(Y+4716)/100;
7395 X2 = 306001*(M+1)/10000;
7396 A = Y/100;
7397 B = 2 - A + (A/4);
7398 JDsec = (i64)((X1 + X2 + D + B - 1524.5)*86400) + hr*3600 + min*60 + sec;
7399 return (u32)(JDsec - (i64)24405875*(i64)8640);
 
 
 
 
 
 
 
 
 
 
7400 }
7401
7402 /*
7403 ** The opposite of zipfileMtime(). This function populates the mTime and
7404 ** mDate fields of the CDS structure passed as the first argument according
@@ -8052,10 +8831,14 @@
8831 if( rc==SQLITE_OK ){
8832 rc = sqlite3_create_function(db, "zipfile", -1, SQLITE_UTF8, 0, 0,
8833 zipfileStep, zipfileFinal
8834 );
8835 }
8836 assert( sizeof(i64)==8 );
8837 assert( sizeof(u32)==4 );
8838 assert( sizeof(u16)==2 );
8839 assert( sizeof(u8)==1 );
8840 return rc;
8841 }
8842 #else /* SQLITE_OMIT_VIRTUALTABLE */
8843 # define zipfileRegister(x) SQLITE_OK
8844 #endif
@@ -14032,11 +14815,11 @@
14815 " Examples:",
14816 " .ar -cf ARCHIVE foo bar # Create ARCHIVE from files foo and bar",
14817 " .ar -tf ARCHIVE # List members of ARCHIVE",
14818 " .ar -xvf ARCHIVE # Verbosely extract files from ARCHIVE",
14819 " See also:",
14820 " http://sqlite.org/cli.html#sqlite_archive_support",
14821 #endif
14822 #ifndef SQLITE_OMIT_AUTHORIZATION
14823 ".auth ON|OFF Show authorizer callbacks",
14824 #endif
14825 ".backup ?DB? FILE Backup DB (default \"main\") to FILE",
@@ -14134,12 +14917,12 @@
14917 ".oom ?--repeat M? ?N? Simulate an OOM error on the N-th allocation",
14918 #endif
14919 ".open ?OPTIONS? ?FILE? Close existing database and reopen FILE",
14920 " Options:",
14921 " --append Use appendvfs to append database to the end of FILE",
14922 #ifndef SQLITE_OMIT_DESERIALIZE
14923 " --deserialize Load into memory using sqlite3_deserialize()",
14924 " --hexdb Load the output of \"dbtotxt\" as an in-memory db",
14925 " --maxsize N Maximum size for --hexdb or --deserialized database",
14926 #endif
14927 " --new Initialize FILE to an empty database",
14928 " --nofollow Do not follow symbolic links",
@@ -14456,11 +15239,11 @@
15239 }
15240 fclose(f);
15241 return rc;
15242 }
15243
15244 #ifndef SQLITE_OMIT_DESERIALIZE
15245 /*
15246 ** Reconstruct an in-memory database using the output from the "dbtotxt"
15247 ** program. Read content from the file in p->zDbFilename. If p->zDbFilename
15248 ** is 0, then read from standard input.
15249 */
@@ -14545,11 +15328,11 @@
15328 }
15329 sqlite3_free(a);
15330 utf8_printf(stderr,"Error on line %d of --hexdb input\n", nLine);
15331 return 0;
15332 }
15333 #endif /* SQLITE_OMIT_DESERIALIZE */
15334
15335 /*
15336 ** Scalar function "shell_int32". The first argument to this function
15337 ** must be a blob. The second a non-negative integer. This function
15338 ** reads and returns a 32-bit big-endian integer from byte
@@ -14771,10 +15554,11 @@
15554 sqlite3_fileio_init(p->db, 0, 0);
15555 sqlite3_shathree_init(p->db, 0, 0);
15556 sqlite3_completion_init(p->db, 0, 0);
15557 sqlite3_uint_init(p->db, 0, 0);
15558 sqlite3_decimal_init(p->db, 0, 0);
15559 sqlite3_regexp_init(p->db, 0, 0);
15560 sqlite3_ieee_init(p->db, 0, 0);
15561 sqlite3_series_init(p->db, 0, 0);
15562 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
15563 sqlite3_dbdata_init(p->db, 0, 0);
15564 #endif
@@ -14806,11 +15590,11 @@
15590 char *zSql = sqlite3_mprintf(
15591 "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);
15592 sqlite3_exec(p->db, zSql, 0, 0, 0);
15593 sqlite3_free(zSql);
15594 }
15595 #ifndef SQLITE_OMIT_DESERIALIZE
15596 else
15597 if( p->openMode==SHELL_OPEN_DESERIALIZE || p->openMode==SHELL_OPEN_HEXDB ){
15598 int rc;
15599 int nData = 0;
15600 unsigned char *aData;
@@ -16873,10 +17657,11 @@
17657 char *zErr = 0;
17658 rc = sqlite3_exec(db, zSql, 0, 0, &zErr);
17659 if( rc!=SQLITE_OK ){
17660 raw_printf(stderr, "SQL error: %s\n", zErr);
17661 }
17662 sqlite3_free(zErr);
17663 *pRc = rc;
17664 }
17665 }
17666
17667 /*
@@ -17894,15 +18679,30 @@
18679 raw_printf(stderr, "Unknown option \"%s\" on \".dump\"\n", azArg[i]);
18680 rc = 1;
18681 sqlite3_free(zLike);
18682 goto meta_command_exit;
18683 }
 
 
 
18684 }else{
18685 /* azArg[i] contains a LIKE pattern. This ".dump" request should
18686 ** only dump data for tables for which either the table name matches
18687 ** the LIKE pattern, or the table appears to be a shadow table of
18688 ** a virtual table for which the name matches the LIKE pattern.
18689 */
18690 char *zExpr = sqlite3_mprintf(
18691 "name LIKE %Q ESCAPE '\\' OR EXISTS ("
18692 " SELECT 1 FROM sqlite_schema WHERE "
18693 " name LIKE %Q ESCAPE '\\' AND"
18694 " sql LIKE 'CREATE VIRTUAL TABLE%%' AND"
18695 " substr(o.name, 1, length(name)+1) == (name||'_')"
18696 ")", azArg[i], azArg[i]
18697 );
18698
18699 if( zLike ){
18700 zLike = sqlite3_mprintf("%z OR %z", zLike, zExpr);
18701 }else{
18702 zLike = zExpr;
18703 }
18704 }
18705 }
18706
18707 open_db(p, 0);
18708
@@ -17920,21 +18720,21 @@
18720 ** corrupt. */
18721 sqlite3_exec(p->db, "SAVEPOINT dump; PRAGMA writable_schema=ON", 0, 0, 0);
18722 p->nErr = 0;
18723 if( zLike==0 ) zLike = sqlite3_mprintf("true");
18724 zSql = sqlite3_mprintf(
18725 "SELECT name, type, sql FROM sqlite_schema AS o "
18726 "WHERE (%s) AND type=='table'"
18727 " AND sql NOT NULL"
18728 " ORDER BY tbl_name='sqlite_sequence', rowid",
18729 zLike
18730 );
18731 run_schema_dump_query(p,zSql);
18732 sqlite3_free(zSql);
18733 if( (p->shellFlgs & SHFLG_DumpDataOnly)==0 ){
18734 zSql = sqlite3_mprintf(
18735 "SELECT sql FROM sqlite_schema AS o "
18736 "WHERE (%s) AND sql NOT NULL"
18737 " AND type IN ('index','trigger','view')",
18738 zLike
18739 );
18740 run_table_dump_query(p, zSql);
@@ -18177,11 +18977,10 @@
18977 }
18978 }else
18979
18980 if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){
18981 ShellState data;
 
18982 int doStats = 0;
18983 memcpy(&data, p, sizeof(data));
18984 data.showHeader = 0;
18985 data.cMode = data.mode = MODE_Semi;
18986 if( nArg==2 && optionMatch(azArg[1], "indent") ){
@@ -18199,11 +18998,11 @@
18998 " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
18999 " FROM sqlite_schema UNION ALL"
19000 " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_schema) "
19001 "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' "
19002 "ORDER BY rowid",
19003 callback, &data, 0
19004 );
19005 if( rc==SQLITE_OK ){
19006 sqlite3_stmt *pStmt;
19007 rc = sqlite3_prepare_v2(p->db,
19008 "SELECT rowid FROM sqlite_schema"
@@ -18215,16 +19014,16 @@
19014 if( doStats==0 ){
19015 raw_printf(p->out, "/* No STAT tables available */\n");
19016 }else{
19017 raw_printf(p->out, "ANALYZE sqlite_schema;\n");
19018 sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_schema'",
19019 callback, &data, 0);
19020 data.cMode = data.mode = MODE_Insert;
19021 data.zDestTable = "sqlite_stat1";
19022 shell_exec(&data, "SELECT * FROM sqlite_stat1", 0);
19023 data.zDestTable = "sqlite_stat4";
19024 shell_exec(&data, "SELECT * FROM sqlite_stat4", 0);
19025 raw_printf(p->out, "ANALYZE sqlite_schema;\n");
19026 }
19027 }else
19028
19029 if( c=='h' && strncmp(azArg[0], "headers", n)==0 ){
@@ -18868,18 +19667,18 @@
19667 p->openMode = SHELL_OPEN_APPENDVFS;
19668 }else if( optionMatch(z, "readonly") ){
19669 p->openMode = SHELL_OPEN_READONLY;
19670 }else if( optionMatch(z, "nofollow") ){
19671 p->openFlags |= SQLITE_OPEN_NOFOLLOW;
19672 #ifndef SQLITE_OMIT_DESERIALIZE
19673 }else if( optionMatch(z, "deserialize") ){
19674 p->openMode = SHELL_OPEN_DESERIALIZE;
19675 }else if( optionMatch(z, "hexdb") ){
19676 p->openMode = SHELL_OPEN_HEXDB;
19677 }else if( optionMatch(z, "maxsize") && iName+1<nArg ){
19678 p->szMax = integerValue(azArg[++iName]);
19679 #endif /* SQLITE_OMIT_DESERIALIZE */
19680 }else if( z[0]=='-' ){
19681 utf8_printf(stderr, "unknown option: %s\n", z);
19682 rc = 1;
19683 goto meta_command_exit;
19684 }else if( zNewFilename ){
@@ -20113,10 +20912,11 @@
20912 { "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE, "OFFSET " },
20913 { "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE, "" },
20914 { "prng_save", SQLITE_TESTCTRL_PRNG_SAVE, "" },
20915 { "prng_seed", SQLITE_TESTCTRL_PRNG_SEED, "SEED ?db?" },
20916 { "seek_count", SQLITE_TESTCTRL_SEEK_COUNT, "" },
20917 { "tune", SQLITE_TESTCTRL_TUNE, "ID VALUE" },
20918 };
20919 int testctrl = -1;
20920 int iCtrl = -1;
20921 int rc2 = 0; /* 0: usage. 1: %d 2: %x 3: no-output */
20922 int isOk = 0;
@@ -20257,15 +21057,44 @@
21057 isOk = 3;
21058 break;
21059 }
21060
21061 #ifdef YYCOVERAGE
21062 case SQLITE_TESTCTRL_PARSER_COVERAGE: {
21063 if( nArg==2 ){
21064 sqlite3_test_control(testctrl, p->out);
21065 isOk = 3;
21066 }
21067 break;
21068 }
21069 #endif
21070 #ifdef SQLITE_DEBUG
21071 case SQLITE_TESTCTRL_TUNE: {
21072 if( nArg==4 ){
21073 int id = (int)integerValue(azArg[2]);
21074 int val = (int)integerValue(azArg[3]);
21075 sqlite3_test_control(testctrl, id, &val);
21076 isOk = 3;
21077 }else if( nArg==3 ){
21078 int id = (int)integerValue(azArg[2]);
21079 sqlite3_test_control(testctrl, -id, &rc2);
21080 isOk = 1;
21081 }else if( nArg==2 ){
21082 int id = 1;
21083 while(1){
21084 int val = 0;
21085 rc2 = sqlite3_test_control(testctrl, -id, &val);
21086 if( rc2!=SQLITE_OK ) break;
21087 if( id>1 ) utf8_printf(p->out, " ");
21088 utf8_printf(p->out, "%d: %d", id, val);
21089 id++;
21090 }
21091 if( id>1 ) utf8_printf(p->out, "\n");
21092 isOk = 3;
21093 }
21094 break;
21095 }
21096 #endif
21097 }
21098 }
21099 if( isOk==0 && iCtrl>=0 ){
21100 utf8_printf(p->out, "Usage: .testctrl %s %s\n", zCmd,aCtrl[iCtrl].zUsage);
@@ -20859,11 +21688,11 @@
21688 " -batch force batch I/O\n"
21689 " -box set output mode to 'box'\n"
21690 " -column set output mode to 'column'\n"
21691 " -cmd COMMAND run \"COMMAND\" before reading stdin\n"
21692 " -csv set output mode to 'csv'\n"
21693 #if !defined(SQLITE_OMIT_DESERIALIZE)
21694 " -deserialize open the database using sqlite3_deserialize()\n"
21695 #endif
21696 " -echo print commands before execution\n"
21697 " -init FILENAME read/process named file\n"
21698 " -[no]header turn headers on or off\n"
@@ -20876,11 +21705,11 @@
21705 " -json set output mode to 'json'\n"
21706 " -line set output mode to 'line'\n"
21707 " -list set output mode to 'list'\n"
21708 " -lookaside SIZE N use N entries of SZ bytes for lookaside memory\n"
21709 " -markdown set output mode to 'markdown'\n"
21710 #if !defined(SQLITE_OMIT_DESERIALIZE)
21711 " -maxsize N maximum size for a --deserialize database\n"
21712 #endif
21713 " -memtrace trace all memory allocations and deallocations\n"
21714 " -mmap N default mmap size set to N\n"
21715 #ifdef SQLITE_ENABLE_MULTIPLEX
@@ -21206,11 +22035,11 @@
22035 }else if( strcmp(z,"-zip")==0 ){
22036 data.openMode = SHELL_OPEN_ZIPFILE;
22037 #endif
22038 }else if( strcmp(z,"-append")==0 ){
22039 data.openMode = SHELL_OPEN_APPENDVFS;
22040 #ifndef SQLITE_OMIT_DESERIALIZE
22041 }else if( strcmp(z,"-deserialize")==0 ){
22042 data.openMode = SHELL_OPEN_DESERIALIZE;
22043 }else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
22044 data.szMax = integerValue(argv[++i]);
22045 #endif
@@ -21323,11 +22152,11 @@
22152 }else if( strcmp(z,"-zip")==0 ){
22153 data.openMode = SHELL_OPEN_ZIPFILE;
22154 #endif
22155 }else if( strcmp(z,"-append")==0 ){
22156 data.openMode = SHELL_OPEN_APPENDVFS;
22157 #ifndef SQLITE_OMIT_DESERIALIZE
22158 }else if( strcmp(z,"-deserialize")==0 ){
22159 data.openMode = SHELL_OPEN_DESERIALIZE;
22160 }else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
22161 data.szMax = integerValue(argv[++i]);
22162 #endif
22163
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -226,10 +226,11 @@
226226
deltafunc_init(db);
227227
helptext_vtab_register(db);
228228
builtin_vtab_register(db);
229229
g.repositoryOpen = 1;
230230
g.db = db;
231
+ sqlite3_busy_timeout(db, 10000);
231232
sqlite3_db_config(db, SQLITE_DBCONFIG_MAINDBNAME, "repository");
232233
db_maybe_set_encryption_key(db, g.zRepositoryName);
233234
if( g.zLocalDbName ){
234235
char *zSql = sqlite3_mprintf("ATTACH %Q AS 'localdb' KEY ''",
235236
g.zLocalDbName);
236237
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -226,10 +226,11 @@
226 deltafunc_init(db);
227 helptext_vtab_register(db);
228 builtin_vtab_register(db);
229 g.repositoryOpen = 1;
230 g.db = db;
 
231 sqlite3_db_config(db, SQLITE_DBCONFIG_MAINDBNAME, "repository");
232 db_maybe_set_encryption_key(db, g.zRepositoryName);
233 if( g.zLocalDbName ){
234 char *zSql = sqlite3_mprintf("ATTACH %Q AS 'localdb' KEY ''",
235 g.zLocalDbName);
236
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -226,10 +226,11 @@
226 deltafunc_init(db);
227 helptext_vtab_register(db);
228 builtin_vtab_register(db);
229 g.repositoryOpen = 1;
230 g.db = db;
231 sqlite3_busy_timeout(db, 10000);
232 sqlite3_db_config(db, SQLITE_DBCONFIG_MAINDBNAME, "repository");
233 db_maybe_set_encryption_key(db, g.zRepositoryName);
234 if( g.zLocalDbName ){
235 char *zSql = sqlite3_mprintf("ATTACH %Q AS 'localdb' KEY ''",
236 g.zLocalDbName);
237
+3241 -2435
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -81,12 +81,14 @@
8181
"4_BYTE_ALIGNED_MALLOC",
8282
#endif
8383
#if SQLITE_64BIT_STATS
8484
"64BIT_STATS",
8585
#endif
86
-#if SQLITE_ALLOW_COVERING_INDEX_SCAN
87
- "ALLOW_COVERING_INDEX_SCAN",
86
+#ifdef SQLITE_ALLOW_COVERING_INDEX_SCAN
87
+# if SQLITE_ALLOW_COVERING_INDEX_SCAN != 1
88
+ "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN),
89
+# endif
8890
#endif
8991
#if SQLITE_ALLOW_URI_AUTHORITY
9092
"ALLOW_URI_AUTHORITY",
9193
#endif
9294
#ifdef SQLITE_BITMASK_TYPE
@@ -144,12 +146,14 @@
144146
"DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
145147
#endif
146148
#ifdef SQLITE_DEFAULT_LOOKASIDE
147149
"DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE),
148150
#endif
149
-#if SQLITE_DEFAULT_MEMSTATUS
150
- "DEFAULT_MEMSTATUS",
151
+#ifdef SQLITE_DEFAULT_MEMSTATUS
152
+# if SQLITE_DEFAULT_MEMSTATUS != 1
153
+ "DEFAULT_MEMSTATUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_MEMSTATUS),
154
+# endif
151155
#endif
152156
#ifdef SQLITE_DEFAULT_MMAP_SIZE
153157
"DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
154158
#endif
155159
#ifdef SQLITE_DEFAULT_PAGE_SIZE
@@ -219,11 +223,11 @@
219223
"ENABLE_BATCH_ATOMIC_WRITE",
220224
#endif
221225
#if SQLITE_ENABLE_BYTECODE_VTAB
222226
"ENABLE_BYTECODE_VTAB",
223227
#endif
224
-#if SQLITE_ENABLE_CEROD
228
+#ifdef SQLITE_ENABLE_CEROD
225229
"ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD),
226230
#endif
227231
#if SQLITE_ENABLE_COLUMN_METADATA
228232
"ENABLE_COLUMN_METADATA",
229233
#endif
@@ -233,22 +237,22 @@
233237
#if SQLITE_ENABLE_COSTMULT
234238
"ENABLE_COSTMULT",
235239
#endif
236240
#if SQLITE_ENABLE_CURSOR_HINTS
237241
"ENABLE_CURSOR_HINTS",
242
+#endif
243
+#if SQLITE_ENABLE_DBPAGE_VTAB
244
+ "ENABLE_DBPAGE_VTAB",
238245
#endif
239246
#if SQLITE_ENABLE_DBSTAT_VTAB
240247
"ENABLE_DBSTAT_VTAB",
241248
#endif
242249
#if SQLITE_ENABLE_EXPENSIVE_ASSERT
243250
"ENABLE_EXPENSIVE_ASSERT",
244251
#endif
245
-#if SQLITE_ENABLE_FTS1
246
- "ENABLE_FTS1",
247
-#endif
248
-#if SQLITE_ENABLE_FTS2
249
- "ENABLE_FTS2",
252
+#if SQLITE_ENABLE_EXPLAIN_COMMENTS
253
+ "ENABLE_EXPLAIN_COMMENTS",
250254
#endif
251255
#if SQLITE_ENABLE_FTS3
252256
"ENABLE_FTS3",
253257
#endif
254258
#if SQLITE_ENABLE_FTS3_PARENTHESIS
@@ -302,10 +306,13 @@
302306
#if SQLITE_ENABLE_NORMALIZE
303307
"ENABLE_NORMALIZE",
304308
#endif
305309
#if SQLITE_ENABLE_NULL_TRIM
306310
"ENABLE_NULL_TRIM",
311
+#endif
312
+#if SQLITE_ENABLE_OFFSET_SQL_FUNC
313
+ "ENABLE_OFFSET_SQL_FUNC",
307314
#endif
308315
#if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
309316
"ENABLE_OVERSIZE_CELL_CHECK",
310317
#endif
311318
#if SQLITE_ENABLE_PREUPDATE_HOOK
@@ -333,11 +340,11 @@
333340
"ENABLE_SORTER_REFERENCES",
334341
#endif
335342
#if SQLITE_ENABLE_SQLLOG
336343
"ENABLE_SQLLOG",
337344
#endif
338
-#if defined(SQLITE_ENABLE_STAT4)
345
+#if SQLITE_ENABLE_STAT4
339346
"ENABLE_STAT4",
340347
#endif
341348
#if SQLITE_ENABLE_STMTVTAB
342349
"ENABLE_STMTVTAB",
343350
#endif
@@ -387,12 +394,14 @@
387394
"FTS5_NO_WITHOUT_ROWID",
388395
#endif
389396
#if HAVE_ISNAN || SQLITE_HAVE_ISNAN
390397
"HAVE_ISNAN",
391398
#endif
392
-#if SQLITE_HOMEGROWN_RECURSIVE_MUTEX
393
- "HOMEGROWN_RECURSIVE_MUTEX",
399
+#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
400
+# if SQLITE_HOMEGROWN_RECURSIVE_MUTEX != 1
401
+ "HOMEGROWN_RECURSIVE_MUTEX=" CTIMEOPT_VAL(SQLITE_HOMEGROWN_RECURSIVE_MUTEX),
402
+# endif
394403
#endif
395404
#if SQLITE_IGNORE_AFP_LOCK_ERRORS
396405
"IGNORE_AFP_LOCK_ERRORS",
397406
#endif
398407
#if SQLITE_IGNORE_FLOCK_LOCK_ERRORS
@@ -486,13 +495,10 @@
486495
"MMAP_READWRITE",
487496
#endif
488497
#if SQLITE_MUTEX_NOOP
489498
"MUTEX_NOOP",
490499
#endif
491
-#if SQLITE_MUTEX_NREF
492
- "MUTEX_NREF",
493
-#endif
494500
#if SQLITE_MUTEX_OMIT
495501
"MUTEX_OMIT",
496502
#endif
497503
#if SQLITE_MUTEX_PTHREADS
498504
"MUTEX_PTHREADS",
@@ -558,18 +564,21 @@
558564
"OMIT_CONFLICT_CLAUSE",
559565
#endif
560566
#if SQLITE_OMIT_CTE
561567
"OMIT_CTE",
562568
#endif
563
-#if SQLITE_OMIT_DATETIME_FUNCS
569
+#if defined(SQLITE_OMIT_DATETIME_FUNCS) || defined(SQLITE_OMIT_FLOATING_POINT)
564570
"OMIT_DATETIME_FUNCS",
565571
#endif
566572
#if SQLITE_OMIT_DECLTYPE
567573
"OMIT_DECLTYPE",
568574
#endif
569575
#if SQLITE_OMIT_DEPRECATED
570576
"OMIT_DEPRECATED",
577
+#endif
578
+#if SQLITE_OMIT_DESERIALIZE
579
+ "OMIT_DESERIALIZE",
571580
#endif
572581
#if SQLITE_OMIT_DISKIO
573582
"OMIT_DISKIO",
574583
#endif
575584
#if SQLITE_OMIT_EXPLAIN
@@ -593,10 +602,13 @@
593602
#if SQLITE_OMIT_INCRBLOB
594603
"OMIT_INCRBLOB",
595604
#endif
596605
#if SQLITE_OMIT_INTEGRITY_CHECK
597606
"OMIT_INTEGRITY_CHECK",
607
+#endif
608
+#if SQLITE_OMIT_INTROSPECTION_PRAGMAS
609
+ "OMIT_INTROSPECTION_PRAGMAS",
598610
#endif
599611
#if SQLITE_OMIT_LIKE_OPTIMIZATION
600612
"OMIT_LIKE_OPTIMIZATION",
601613
#endif
602614
#if SQLITE_OMIT_LOAD_EXTENSION
@@ -657,12 +669,14 @@
657669
"OMIT_TEMPDB",
658670
#endif
659671
#if SQLITE_OMIT_TEST_CONTROL
660672
"OMIT_TEST_CONTROL",
661673
#endif
662
-#if SQLITE_OMIT_TRACE
663
- "OMIT_TRACE",
674
+#ifdef SQLITE_OMIT_TRACE
675
+# if SQLITE_OMIT_TRACE != 1
676
+ "OMIT_TRACE=" CTIMEOPT_VAL(SQLITE_OMIT_TRACE),
677
+# endif
664678
#endif
665679
#if SQLITE_OMIT_TRIGGER
666680
"OMIT_TRIGGER",
667681
#endif
668682
#if SQLITE_OMIT_TRUNCATE_OPTIMIZATION
@@ -693,12 +707,14 @@
693707
"PCACHE_SEPARATE_HEADER",
694708
#endif
695709
#if SQLITE_PERFORMANCE_TRACE
696710
"PERFORMANCE_TRACE",
697711
#endif
698
-#if SQLITE_POWERSAFE_OVERWRITE
699
- "POWERSAFE_OVERWRITE",
712
+#ifdef SQLITE_POWERSAFE_OVERWRITE
713
+# if SQLITE_POWERSAFE_OVERWRITE != 1
714
+ "POWERSAFE_OVERWRITE=" CTIMEOPT_VAL(SQLITE_POWERSAFE_OVERWRITE),
715
+# endif
700716
#endif
701717
#if SQLITE_PREFER_PROXY_LOCKING
702718
"PREFER_PROXY_LOCKING",
703719
#endif
704720
#if SQLITE_PROXY_DEBUG
@@ -729,11 +745,14 @@
729745
"STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),
730746
#endif
731747
#if SQLITE_SUBSTR_COMPATIBILITY
732748
"SUBSTR_COMPATIBILITY",
733749
#endif
734
-#if SQLITE_SYSTEM_MALLOC
750
+#if (!defined(SQLITE_WIN32_MALLOC) \
751
+ && !defined(SQLITE_ZERO_MALLOC) \
752
+ && !defined(SQLITE_MEMDEBUG) \
753
+ ) || defined(SQLITE_SYSTEM_MALLOC)
735754
"SYSTEM_MALLOC",
736755
#endif
737756
#if SQLITE_TCL
738757
"TCL",
739758
#endif
@@ -1186,11 +1205,11 @@
11861205
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11871206
** [sqlite_version()] and [sqlite_source_id()].
11881207
*/
11891208
#define SQLITE_VERSION "3.36.0"
11901209
#define SQLITE_VERSION_NUMBER 3036000
1191
-#define SQLITE_SOURCE_ID "2021-04-07 18:17:53 a2ddb89b206c13876d34c5f9e3db41cda72d6eb3fea31ffa8cc6daa1e1580e16"
1210
+#define SQLITE_SOURCE_ID "2021-06-14 20:41:20 e5a5acd6006133c5da4a7dd79726dbaa41c0d60ebeda890f848a6aafe5f9ef70"
11921211
11931212
/*
11941213
** CAPI3REF: Run-Time Library Version Numbers
11951214
** KEYWORDS: sqlite3_version sqlite3_sourceid
11961215
**
@@ -2202,10 +2221,14 @@
22022221
** currently has an SQL transaction open on the database. It is set to 0 if
22032222
** the database is not a wal-mode db, or if there is no such connection in any
22042223
** other process. This opcode cannot be used to detect transactions opened
22052224
** by clients within the current process, only within other processes.
22062225
** </ul>
2226
+**
2227
+** <li>[[SQLITE_FCNTL_CKSM_FILE]]
2228
+** Used by the cksmvfs VFS module only.
2229
+** </ul>
22072230
*/
22082231
#define SQLITE_FCNTL_LOCKSTATE 1
22092232
#define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
22102233
#define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
22112234
#define SQLITE_FCNTL_LAST_ERRNO 4
@@ -2241,12 +2264,12 @@
22412264
#define SQLITE_FCNTL_DATA_VERSION 35
22422265
#define SQLITE_FCNTL_SIZE_LIMIT 36
22432266
#define SQLITE_FCNTL_CKPT_DONE 37
22442267
#define SQLITE_FCNTL_RESERVE_BYTES 38
22452268
#define SQLITE_FCNTL_CKPT_START 39
2246
-
22472269
#define SQLITE_FCNTL_EXTERNAL_READER 40
2270
+#define SQLITE_FCNTL_CKSM_FILE 41
22482271
22492272
/* deprecated names */
22502273
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
22512274
#define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
22522275
#define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -5255,10 +5278,19 @@
52555278
** changes to the content of the database files on disk.
52565279
** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since
52575280
** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and
52585281
** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so
52595282
** sqlite3_stmt_readonly() returns false for those commands.
5283
+**
5284
+** ^This routine returns false if there is any possibility that the
5285
+** statement might change the database file. ^A false return does
5286
+** not guarantee that the statement will change the database file.
5287
+** ^For example, an UPDATE statement might have a WHERE clause that
5288
+** makes it a no-op, but the sqlite3_stmt_readonly() result would still
5289
+** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a
5290
+** read-only no-op if the table already exists, but
5291
+** sqlite3_stmt_readonly() still returns false for such a statement.
52605292
*/
52615293
SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
52625294
52635295
/*
52645296
** CAPI3REF: Query The EXPLAIN Setting For A Prepared Statement
@@ -5424,22 +5456,26 @@
54245456
** terminated. If any NUL characters occurs at byte offsets less than
54255457
** the value of the fourth parameter then the resulting string value will
54265458
** contain embedded NULs. The result of expressions involving strings
54275459
** with embedded NULs is undefined.
54285460
**
5429
-** ^The fifth argument to the BLOB and string binding interfaces
5430
-** is a destructor used to dispose of the BLOB or
5431
-** string after SQLite has finished with it. ^The destructor is called
5432
-** to dispose of the BLOB or string even if the call to the bind API fails,
5433
-** except the destructor is not called if the third parameter is a NULL
5434
-** pointer or the fourth parameter is negative.
5435
-** ^If the fifth argument is
5436
-** the special value [SQLITE_STATIC], then SQLite assumes that the
5437
-** information is in static, unmanaged space and does not need to be freed.
5438
-** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
5439
-** SQLite makes its own private copy of the data immediately, before
5440
-** the sqlite3_bind_*() routine returns.
5461
+** ^The fifth argument to the BLOB and string binding interfaces controls
5462
+** or indicates the lifetime of the object referenced by the third parameter.
5463
+** ^These three options exist:
5464
+** ^(1) A destructor to dispose of the BLOB or string after SQLite has finished
5465
+** with it may be passed. ^It is called to dispose of the BLOB or string even
5466
+** if the call to the bind API fails, except the destructor is not called if
5467
+** the third parameter is a NULL pointer or the fourth parameter is negative.
5468
+** ^(2) The special constant, [SQLITE_STATIC], may be passsed to indicate that
5469
+** the application remains responsible for disposing of the object. ^In this
5470
+** case, the object and the provided pointer to it must remain valid until
5471
+** either the prepared statement is finalized or the same SQL parameter is
5472
+** bound to something else, whichever occurs sooner.
5473
+** ^(3) The constant, [SQLITE_TRANSIENT], may be passed to indicate that the
5474
+** object is to be copied prior to the return from sqlite3_bind_*(). ^The
5475
+** object and pointer to it must remain valid until then. ^SQLite will then
5476
+** manage the lifetime of its private copy.
54415477
**
54425478
** ^The sixth argument to sqlite3_bind_text64() must be one of
54435479
** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]
54445480
** to specify the encoding of the text in the third parameter. If
54455481
** the sixth argument to sqlite3_bind_text64() is not one of the
@@ -6177,21 +6213,19 @@
61776213
** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY]
61786214
** flag, which if present prevents the function from being invoked from
61796215
** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions,
61806216
** index expressions, or the WHERE clause of partial indexes.
61816217
**
6182
-** <span style="background-color:#ffff90;">
61836218
** For best security, the [SQLITE_DIRECTONLY] flag is recommended for
61846219
** all application-defined SQL functions that do not need to be
61856220
** used inside of triggers, view, CHECK constraints, or other elements of
61866221
** the database schema. This flags is especially recommended for SQL
61876222
** functions that have side effects or reveal internal application state.
61886223
** Without this flag, an attacker might be able to modify the schema of
61896224
** a database file to include invocations of the function with parameters
61906225
** chosen by the attacker, which the application will then execute when
61916226
** the database file is opened and read.
6192
-** </span>
61936227
**
61946228
** ^(The fifth parameter is an arbitrary pointer. The implementation of the
61956229
** function can gain access to this pointer using [sqlite3_user_data()].)^
61966230
**
61976231
** ^The sixth, seventh and eighth parameters passed to the three
@@ -8855,11 +8889,12 @@
88558889
#define SQLITE_TESTCTRL_RESULT_INTREAL 27
88568890
#define SQLITE_TESTCTRL_PRNG_SEED 28
88578891
#define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
88588892
#define SQLITE_TESTCTRL_SEEK_COUNT 30
88598893
#define SQLITE_TESTCTRL_TRACEFLAGS 31
8860
-#define SQLITE_TESTCTRL_LAST 31 /* Largest TESTCTRL */
8894
+#define SQLITE_TESTCTRL_TUNE 32
8895
+#define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */
88618896
88628897
/*
88638898
** CAPI3REF: SQL Keyword Checking
88648899
**
88658900
** These routines provide access to the set of SQL language keywords
@@ -10607,10 +10642,19 @@
1060710642
** callback was invoked as a result of a direct insert, update, or delete
1060810643
** operation; or 1 for inserts, updates, or deletes invoked by top-level
1060910644
** triggers; or 2 for changes resulting from triggers called by top-level
1061010645
** triggers; and so forth.
1061110646
**
10647
+** When the [sqlite3_blob_write()] API is used to update a blob column,
10648
+** the pre-update hook is invoked with SQLITE_DELETE. This is because the
10649
+** in this case the new values are not available. In this case, when a
10650
+** callback made with op==SQLITE_DELETE is actuall a write using the
10651
+** sqlite3_blob_write() API, the [sqlite3_preupdate_blobwrite()] returns
10652
+** the index of the column being written. In other cases, where the
10653
+** pre-update hook is being invoked for some other reason, including a
10654
+** regular DELETE, sqlite3_preupdate_blobwrite() returns -1.
10655
+**
1061210656
** See also: [sqlite3_update_hook()]
1061310657
*/
1061410658
#if defined(SQLITE_ENABLE_PREUPDATE_HOOK)
1061510659
SQLITE_API void *sqlite3_preupdate_hook(
1061610660
sqlite3 *db,
@@ -10627,10 +10671,11 @@
1062710671
);
1062810672
SQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);
1062910673
SQLITE_API int sqlite3_preupdate_count(sqlite3 *);
1063010674
SQLITE_API int sqlite3_preupdate_depth(sqlite3 *);
1063110675
SQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);
10676
+SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *);
1063210677
#endif
1063310678
1063410679
/*
1063510680
** CAPI3REF: Low-level system error code
1063610681
** METHOD: sqlite3
@@ -10865,12 +10910,12 @@
1086510910
**
1086610911
** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
1086710912
** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory
1086810913
** allocation error occurs.
1086910914
**
10870
-** This interface is only available if SQLite is compiled with the
10871
-** [SQLITE_ENABLE_DESERIALIZE] option.
10915
+** This interface is omitted if SQLite is compiled with the
10916
+** [SQLITE_OMIT_DESERIALIZE] option.
1087210917
*/
1087310918
SQLITE_API unsigned char *sqlite3_serialize(
1087410919
sqlite3 *db, /* The database connection */
1087510920
const char *zSchema, /* Which DB to serialize. ex: "main", "temp", ... */
1087610921
sqlite3_int64 *piSize, /* Write size of the DB here, if not NULL */
@@ -10917,12 +10962,12 @@
1091710962
**
1091810963
** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
1091910964
** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
1092010965
** [sqlite3_free()] is invoked on argument P prior to returning.
1092110966
**
10922
-** This interface is only available if SQLite is compiled with the
10923
-** [SQLITE_ENABLE_DESERIALIZE] option.
10967
+** This interface is omitted if SQLite is compiled with the
10968
+** [SQLITE_OMIT_DESERIALIZE] option.
1092410969
*/
1092510970
SQLITE_API int sqlite3_deserialize(
1092610971
sqlite3 *db, /* The database connection */
1092710972
const char *zSchema, /* Which DB to reopen with the deserialization */
1092810973
unsigned char *pData, /* The serialized database content */
@@ -11167,10 +11212,42 @@
1116711212
** are attached is closed. Refer to the documentation for
1116811213
** [sqlite3session_create()] for details.
1116911214
*/
1117011215
SQLITE_API void sqlite3session_delete(sqlite3_session *pSession);
1117111216
11217
+/*
11218
+** CAPIREF: Conigure a Session Object
11219
+** METHOD: sqlite3_session
11220
+**
11221
+** This method is used to configure a session object after it has been
11222
+** created. At present the only valid value for the second parameter is
11223
+** [SQLITE_SESSION_OBJCONFIG_SIZE].
11224
+**
11225
+** Arguments for sqlite3session_object_config()
11226
+**
11227
+** The following values may passed as the the 4th parameter to
11228
+** sqlite3session_object_config().
11229
+**
11230
+** <dt>SQLITE_SESSION_OBJCONFIG_SIZE <dd>
11231
+** This option is used to set, clear or query the flag that enables
11232
+** the [sqlite3session_changeset_size()] API. Because it imposes some
11233
+** computational overhead, this API is disabled by default. Argument
11234
+** pArg must point to a value of type (int). If the value is initially
11235
+** 0, then the sqlite3session_changeset_size() API is disabled. If it
11236
+** is greater than 0, then the same API is enabled. Or, if the initial
11237
+** value is less than zero, no change is made. In all cases the (int)
11238
+** variable is set to 1 if the sqlite3session_changeset_size() API is
11239
+** enabled following the current call, or 0 otherwise.
11240
+**
11241
+** It is an error (SQLITE_MISUSE) to attempt to modify this setting after
11242
+** the first table has been attached to the session object.
11243
+*/
11244
+SQLITE_API int sqlite3session_object_config(sqlite3_session*, int op, void *pArg);
11245
+
11246
+/*
11247
+*/
11248
+#define SQLITE_SESSION_OBJCONFIG_SIZE 1
1117211249
1117311250
/*
1117411251
** CAPI3REF: Enable Or Disable A Session Object
1117511252
** METHOD: sqlite3_session
1117611253
**
@@ -11411,10 +11488,26 @@
1141111488
sqlite3_session *pSession, /* Session object */
1141211489
int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
1141311490
void **ppChangeset /* OUT: Buffer containing changeset */
1141411491
);
1141511492
11493
+/*
11494
+** CAPI3REF: Return An Upper-limit For The Size Of The Changeset
11495
+** METHOD: sqlite3_session
11496
+**
11497
+** By default, this function always returns 0. For it to return
11498
+** a useful result, the sqlite3_session object must have been configured
11499
+** to enable this API using sqlite3session_object_config() with the
11500
+** SQLITE_SESSION_OBJCONFIG_SIZE verb.
11501
+**
11502
+** When enabled, this function returns an upper limit, in bytes, for the size
11503
+** of the changeset that might be produced if sqlite3session_changeset() were
11504
+** called. The final changeset size might be equal to or smaller than the
11505
+** size in bytes returned by this function.
11506
+*/
11507
+SQLITE_API sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession);
11508
+
1141611509
/*
1141711510
** CAPI3REF: Load The Difference Between Tables Into A Session
1141811511
** METHOD: sqlite3_session
1141911512
**
1142011513
** If it is not already attached to the session object passed as the first
@@ -14235,12 +14328,13 @@
1423514328
#define TK_VECTOR 176
1423614329
#define TK_SELECT_COLUMN 177
1423714330
#define TK_IF_NULL_ROW 178
1423814331
#define TK_ASTERISK 179
1423914332
#define TK_SPAN 180
14240
-#define TK_SPACE 181
14241
-#define TK_ILLEGAL 182
14333
+#define TK_ERROR 181
14334
+#define TK_SPACE 182
14335
+#define TK_ILLEGAL 183
1424214336
1424314337
/************** End of parse.h ***********************************************/
1424414338
/************** Continuing where we left off in sqliteInt.h ******************/
1424514339
#include <stdio.h>
1424614340
#include <stdlib.h>
@@ -15931,11 +16025,11 @@
1593116025
/* 152 */ 0x10, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00,\
1593216026
/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
1593316027
/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
1593416028
/* 176 */ 0x00, 0x00, 0x00, 0x00,}
1593516029
15936
-/* The sqlite3P2Values() routine is able to run faster if it knows
16030
+/* The resolve3P2Values() routine is able to run faster if it knows
1593716031
** the value of the largest JUMP opcode. The smaller the maximum
1593816032
** JUMP opcode the better, so the mkopcodeh.tcl script that
1593916033
** generated this include file strives to group all JUMP opcodes
1594016034
** together near the beginning of the list.
1594116035
*/
@@ -16463,10 +16557,16 @@
1646316557
** a no-op
1646416558
*/
1646516559
#ifndef SET_FULLSYNC
1646616560
# define SET_FULLSYNC(x,y)
1646716561
#endif
16562
+
16563
+/* Maximum pathname length. Note: FILENAME_MAX defined by stdio.h
16564
+*/
16565
+#ifndef SQLITE_MAX_PATHLEN
16566
+# define SQLITE_MAX_PATHLEN FILENAME_MAX
16567
+#endif
1646816568
1646916569
/*
1647016570
** The default size of a disk sector
1647116571
*/
1647216572
#ifndef SQLITE_DEFAULT_SECTOR_SIZE
@@ -17219,11 +17319,11 @@
1721917319
#define SQLITE_PushDown 0x00001000 /* The push-down optimization */
1722017320
#define SQLITE_SimplifyJoin 0x00002000 /* Convert LEFT JOIN to JOIN */
1722117321
#define SQLITE_SkipScan 0x00004000 /* Skip-scans */
1722217322
#define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */
1722317323
#define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */
17224
-#define SQLITE_ExistsToIN 0x00020000 /* The EXISTS-to-IN optimization */
17324
+#define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */
1722517325
#define SQLITE_AllOpts 0xffffffff /* All optimizations */
1722617326
1722717327
/*
1722817328
** Macros for testing whether or not optimizations are enabled or disabled.
1722917329
*/
@@ -17724,10 +17824,11 @@
1772417824
#define TF_OOOHidden 0x0400 /* Out-of-Order hidden columns */
1772517825
#define TF_HasNotNull 0x0800 /* Contains NOT NULL constraints */
1772617826
#define TF_Shadow 0x1000 /* True for a shadow table */
1772717827
#define TF_HasStat4 0x2000 /* STAT4 info available for this table */
1772817828
#define TF_Ephemeral 0x4000 /* An ephemeral table */
17829
+#define TF_Eponymous 0x8000 /* An eponymous virtual table */
1772917830
1773017831
/*
1773117832
** Test to see whether or not a table is a virtual table. This is
1773217833
** done as a macro so that it will be optimized out when virtual
1773317834
** table support is omitted from the build.
@@ -18436,10 +18537,11 @@
1843618537
unsigned isCorrelated :1; /* True if sub-query is correlated */
1843718538
unsigned viaCoroutine :1; /* Implemented as a co-routine */
1843818539
unsigned isRecursive :1; /* True for recursive reference in WITH */
1843918540
unsigned fromDDL :1; /* Comes from sqlite_schema */
1844018541
unsigned isCte :1; /* This is a CTE */
18542
+ unsigned notCte :1; /* This item may not match a CTE */
1844118543
} fg;
1844218544
int iCursor; /* The VDBE cursor number used to access this table */
1844318545
Expr *pOn; /* The ON clause of a join */
1844418546
IdList *pUsing; /* The USING clause of a join */
1844518547
Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */
@@ -18553,11 +18655,11 @@
1855318655
Upsert *pUpsert; /* ON CONFLICT clause information from an upsert */
1855418656
int iBaseReg; /* For TK_REGISTER when parsing RETURNING */
1855518657
} uNC;
1855618658
NameContext *pNext; /* Next outer name context. NULL for outermost */
1855718659
int nRef; /* Number of names resolved by this context */
18558
- int nErr; /* Number of errors encountered while resolving names */
18660
+ int nNcErr; /* Number of errors encountered while resolving names */
1855918661
int ncFlags; /* Zero or more NC_* flags defined below */
1856018662
Select *pWinSelect; /* SELECT statement for any window functions */
1856118663
};
1856218664
1856318665
/*
@@ -18586,10 +18688,11 @@
1858618688
#define NC_AllowWin 0x04000 /* Window functions are allowed here */
1858718689
#define NC_HasWin 0x08000 /* One or more window functions seen */
1858818690
#define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */
1858918691
#define NC_InAggFunc 0x20000 /* True if analyzing arguments to an agg func */
1859018692
#define NC_FromDDL 0x40000 /* SQL text comes from sqlite_schema */
18693
+#define NC_NoSelect 0x80000 /* Do not descend into sub-selects */
1859118694
1859218695
/*
1859318696
** An instance of the following object describes a single ON CONFLICT
1859418697
** clause in an upsert.
1859518698
**
@@ -18698,10 +18801,11 @@
1869818801
#define SF_View 0x0200000 /* SELECT statement is a view */
1869918802
#define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */
1870018803
#define SF_UpdateFrom 0x0800000 /* Statement is an UPDATE...FROM */
1870118804
#define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */
1870218805
#define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */
18806
+#define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */
1870318807
1870418808
/*
1870518809
** The results of a SELECT can be distributed in several ways, as defined
1870618810
** by one of the following macros. The "SRT" prefix means "SELECT Result
1870718811
** Type".
@@ -19226,10 +19330,26 @@
1922619330
** Allowed values for mInitFlags
1922719331
*/
1922819332
#define INITFLAG_AlterRename 0x0001 /* Reparse after a RENAME */
1922919333
#define INITFLAG_AlterDrop 0x0002 /* Reparse after a DROP COLUMN */
1923019334
19335
+/* Tuning parameters are set using SQLITE_TESTCTRL_TUNE and are controlled
19336
+** on debug-builds of the CLI using ".testctrl tune ID VALUE". Tuning
19337
+** parameters are for temporary use during development, to help find
19338
+** optimial values for parameters in the query planner. The should not
19339
+** be used on trunk check-ins. They are a temporary mechanism available
19340
+** for transient development builds only.
19341
+**
19342
+** Tuning parameters are numbered starting with 1.
19343
+*/
19344
+#define SQLITE_NTUNE 6 /* Should be zero for all trunk check-ins */
19345
+#ifdef SQLITE_DEBUG
19346
+# define Tuning(X) (sqlite3Config.aTune[(X)-1])
19347
+#else
19348
+# define Tuning(X) 0
19349
+#endif
19350
+
1923119351
/*
1923219352
** Structure containing global configuration data for the SQLite library.
1923319353
**
1923419354
** This structure also contains some state information.
1923519355
*/
@@ -19280,20 +19400,24 @@
1928019400
** operation. Set the callback using SQLITE_TESTCTRL_VDBE_COVERAGE.
1928119401
*/
1928219402
void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx); /* Callback */
1928319403
void *pVdbeBranchArg; /* 1st argument */
1928419404
#endif
19285
-#ifdef SQLITE_ENABLE_DESERIALIZE
19405
+#ifndef SQLITE_OMIT_DESERIALIZE
1928619406
sqlite3_int64 mxMemdbSize; /* Default max memdb size */
1928719407
#endif
1928819408
#ifndef SQLITE_UNTESTABLE
1928919409
int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
1929019410
#endif
1929119411
int bLocaltimeFault; /* True to fail localtime() calls */
1929219412
int iOnceResetThreshold; /* When to reset OP_Once counters */
1929319413
u32 szSorterRef; /* Min size in bytes to use sorter-refs */
1929419414
unsigned int iPrngSeed; /* Alternative fixed seed for the PRNG */
19415
+ /* vvvv--- must be last ---vvv */
19416
+#ifdef SQLITE_DEBUG
19417
+ sqlite3_int64 aTune[SQLITE_NTUNE]; /* Tuning parameters */
19418
+#endif
1929519419
};
1929619420
1929719421
/*
1929819422
** This macro is used inside of assert() statements to indicate that
1929919423
** the assert is only valid on a well-formed database. Instead of:
@@ -19367,14 +19491,21 @@
1936719491
SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker*, Expr*);
1936819492
SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker*, Select*);
1936919493
SQLITE_PRIVATE int sqlite3SelectWalkFail(Walker*, Select*);
1937019494
SQLITE_PRIVATE int sqlite3WalkerDepthIncrease(Walker*,Select*);
1937119495
SQLITE_PRIVATE void sqlite3WalkerDepthDecrease(Walker*,Select*);
19496
+SQLITE_PRIVATE void sqlite3WalkWinDefnDummyCallback(Walker*,Select*);
1937219497
1937319498
#ifdef SQLITE_DEBUG
1937419499
SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*);
1937519500
#endif
19501
+
19502
+#ifndef SQLITE_OMIT_CTE
19503
+SQLITE_PRIVATE void sqlite3SelectPopWith(Walker*, Select*);
19504
+#else
19505
+# define sqlite3SelectPopWith 0
19506
+#endif
1937619507
1937719508
/*
1937819509
** Return code from the parse-tree walking primitives and their
1937919510
** callbacks.
1938019511
*/
@@ -19405,10 +19536,11 @@
1940519536
** An instance of the With object represents a WITH clause containing
1940619537
** one or more CTEs (common table expressions).
1940719538
*/
1940819539
struct With {
1940919540
int nCte; /* Number of CTEs in the WITH clause */
19541
+ int bView; /* Belongs to the outermost Select of a view */
1941019542
With *pOuter; /* Containing WITH clause, or NULL */
1941119543
Cte a[1]; /* For each CTE in the WITH clause.... */
1941219544
};
1941319545
1941419546
/*
@@ -19797,10 +19929,11 @@
1979719929
SQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*);
1979819930
SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int);
1979919931
SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*);
1980019932
SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*);
1980119933
SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*);
19934
+SQLITE_PRIVATE void sqlite3GenerateColumnNames(Parse *pParse, Select *pSelect);
1980219935
SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
1980319936
SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*,char);
1980419937
SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*,char);
1980519938
SQLITE_PRIVATE void sqlite3OpenSchemaTable(Parse *, int);
1980619939
SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
@@ -20032,10 +20165,11 @@
2003220165
SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
2003320166
SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
2003420167
SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*);
2003520168
SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*);
2003620169
SQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int);
20170
+SQLITE_PRIVATE With *sqlite3WithDup(sqlite3 *db, With *p);
2003720171
2003820172
#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
2003920173
SQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int);
2004020174
#endif
2004120175
@@ -20175,11 +20309,11 @@
2017520309
2017620310
#if defined(SQLITE_NEED_ERR_NAME)
2017720311
SQLITE_PRIVATE const char *sqlite3ErrName(int);
2017820312
#endif
2017920313
20180
-#ifdef SQLITE_ENABLE_DESERIALIZE
20314
+#ifndef SQLITE_OMIT_DESERIALIZE
2018120315
SQLITE_PRIVATE int sqlite3MemdbInit(void);
2018220316
#endif
2018320317
2018420318
SQLITE_PRIVATE const char *sqlite3ErrStr(int);
2018520319
SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);
@@ -20442,11 +20576,11 @@
2044220576
#ifndef SQLITE_OMIT_CTE
2044320577
SQLITE_PRIVATE Cte *sqlite3CteNew(Parse*,Token*,ExprList*,Select*,u8);
2044420578
SQLITE_PRIVATE void sqlite3CteDelete(sqlite3*,Cte*);
2044520579
SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Cte*);
2044620580
SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*);
20447
-SQLITE_PRIVATE void sqlite3WithPush(Parse*, With*, u8);
20581
+SQLITE_PRIVATE With *sqlite3WithPush(Parse*, With*, u8);
2044820582
#else
2044920583
# define sqlite3CteNew(P,T,E,S) ((void*)0)
2045020584
# define sqlite3CteDelete(D,C)
2045120585
# define sqlite3CteWithAdd(P,W,C) ((void*)0)
2045220586
# define sqlite3WithDelete(x,y)
@@ -20937,11 +21071,11 @@
2093721071
#endif
2093821072
#ifdef SQLITE_VDBE_COVERAGE
2093921073
0, /* xVdbeBranch */
2094021074
0, /* pVbeBranchArg */
2094121075
#endif
20942
-#ifdef SQLITE_ENABLE_DESERIALIZE
21076
+#ifndef SQLITE_OMIT_DESERIALIZE
2094321077
SQLITE_MEMDB_DEFAULT_MAXSIZE, /* mxMemdbSize */
2094421078
#endif
2094521079
#ifndef SQLITE_UNTESTABLE
2094621080
0, /* xTestCallback */
2094721081
#endif
@@ -21500,10 +21634,11 @@
2150021634
u8 *aRecord; /* old.* database record */
2150121635
KeyInfo keyinfo;
2150221636
UnpackedRecord *pUnpacked; /* Unpacked version of aRecord[] */
2150321637
UnpackedRecord *pNewUnpacked; /* Unpacked version of new.* record */
2150421638
int iNewReg; /* Register for new.* values */
21639
+ int iBlobWrite; /* Value returned by preupdate_blobwrite() */
2150521640
i64 iKey1; /* First key value passed to hook */
2150621641
i64 iKey2; /* Second key value passed to hook */
2150721642
Mem *aNew; /* Array of new.* values */
2150821643
Table *pTab; /* Schema object being upated */
2150921644
Index *pPk; /* PK index if pTab is WITHOUT ROWID */
@@ -21543,11 +21678,11 @@
2154321678
SQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem*);
2154421679
SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem*, const Mem*);
2154521680
SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);
2154621681
SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*);
2154721682
SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*);
21548
-SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*));
21683
+SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, i64, u8, void(*)(void*));
2154921684
SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64);
2155021685
#ifdef SQLITE_OMIT_FLOATING_POINT
2155121686
# define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
2155221687
#else
2155321688
SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double);
@@ -21588,11 +21723,12 @@
2158821723
#endif
2158921724
SQLITE_PRIVATE void sqlite3VdbeFrameMemDel(void*); /* Destructor on Mem */
2159021725
SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*); /* Actually deletes the Frame */
2159121726
SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
2159221727
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
21593
-SQLITE_PRIVATE void sqlite3VdbePreUpdateHook(Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int);
21728
+SQLITE_PRIVATE void sqlite3VdbePreUpdateHook(
21729
+ Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int,int);
2159421730
#endif
2159521731
SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p);
2159621732
2159721733
SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *);
2159821734
SQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *);
@@ -23539,10 +23675,12 @@
2353923675
zPathOut[0] = 0;
2354023676
return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);
2354123677
}
2354223678
#ifndef SQLITE_OMIT_LOAD_EXTENSION
2354323679
SQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){
23680
+ assert( zPath!=0 );
23681
+ assert( strlen(zPath)<=SQLITE_MAX_PATHLEN ); /* tag-20210611-1 */
2354423682
return pVfs->xDlOpen(pVfs, zPath);
2354523683
}
2354623684
SQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
2354723685
pVfs->xDlError(pVfs, nByte, zBufOut);
2354823686
}
@@ -27806,11 +27944,10 @@
2780627944
SQLITE_PRIVATE int sqlite3MallocInit(void){
2780727945
int rc;
2780827946
if( sqlite3GlobalConfig.m.xMalloc==0 ){
2780927947
sqlite3MemSetDefault();
2781027948
}
27811
- memset(&mem0, 0, sizeof(mem0));
2781227949
mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
2781327950
if( sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.szPage<512
2781427951
|| sqlite3GlobalConfig.nPage<=0 ){
2781527952
sqlite3GlobalConfig.pPage = 0;
2781627953
sqlite3GlobalConfig.szPage = 0;
@@ -29932,10 +30069,11 @@
2993230069
for(i=0; i<pSrc->nSrc; i++){
2993330070
const SrcItem *pItem = &pSrc->a[i];
2993430071
StrAccum x;
2993530072
char zLine[100];
2993630073
sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
30074
+ x.printfFlags |= SQLITE_PRINTF_INTERNAL;
2993730075
sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem);
2993830076
if( pItem->pTab ){
2993930077
sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx",
2994030078
pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed);
2994130079
}
@@ -30502,10 +30640,18 @@
3050230640
}
3050330641
case TK_IF_NULL_ROW: {
3050430642
sqlite3TreeViewLine(pView, "IF-NULL-ROW %d", pExpr->iTable);
3050530643
sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
3050630644
break;
30645
+ }
30646
+ case TK_ERROR: {
30647
+ Expr tmp;
30648
+ sqlite3TreeViewLine(pView, "ERROR");
30649
+ tmp = *pExpr;
30650
+ tmp.op = pExpr->op2;
30651
+ sqlite3TreeViewExpr(pView, &tmp, 0);
30652
+ break;
3050730653
}
3050830654
default: {
3050930655
sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
3051030656
break;
3051130657
}
@@ -41972,10 +42118,26 @@
4197242118
/* Register all VFSes defined in the aVfs[] array */
4197342119
for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){
4197442120
sqlite3_vfs_register(&aVfs[i], i==0);
4197542121
}
4197642122
unixBigLock = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1);
42123
+
42124
+ /* Validate lock assumptions */
42125
+ assert( SQLITE_SHM_NLOCK==8 ); /* Number of available locks */
42126
+ assert( UNIX_SHM_BASE==120 ); /* Start of locking area */
42127
+ /* Locks:
42128
+ ** WRITE UNIX_SHM_BASE 120
42129
+ ** CKPT UNIX_SHM_BASE+1 121
42130
+ ** RECOVER UNIX_SHM_BASE+2 122
42131
+ ** READ-0 UNIX_SHM_BASE+3 123
42132
+ ** READ-1 UNIX_SHM_BASE+4 124
42133
+ ** READ-2 UNIX_SHM_BASE+5 125
42134
+ ** READ-3 UNIX_SHM_BASE+6 126
42135
+ ** READ-4 UNIX_SHM_BASE+7 127
42136
+ ** DMS UNIX_SHM_BASE+8 128
42137
+ */
42138
+ assert( UNIX_SHM_DMS==128 ); /* Byte offset of the deadman-switch */
4197742139
return SQLITE_OK;
4197842140
}
4197942141
4198042142
/*
4198142143
** Shutdown the operating system interface.
@@ -48365,35 +48527,92 @@
4836548527
**
4836648528
** This file also implements interface sqlite3_serialize() and
4836748529
** sqlite3_deserialize().
4836848530
*/
4836948531
/* #include "sqliteInt.h" */
48370
-#ifdef SQLITE_ENABLE_DESERIALIZE
48532
+#ifndef SQLITE_OMIT_DESERIALIZE
4837148533
4837248534
/*
4837348535
** Forward declaration of objects used by this utility
4837448536
*/
4837548537
typedef struct sqlite3_vfs MemVfs;
4837648538
typedef struct MemFile MemFile;
48539
+typedef struct MemStore MemStore;
4837748540
4837848541
/* Access to a lower-level VFS that (might) implement dynamic loading,
4837948542
** access to randomness, etc.
4838048543
*/
4838148544
#define ORIGVFS(p) ((sqlite3_vfs*)((p)->pAppData))
4838248545
48383
-/* An open file */
48384
-struct MemFile {
48385
- sqlite3_file base; /* IO methods */
48546
+/* Storage for a memdb file.
48547
+**
48548
+** An memdb object can be shared or separate. Shared memdb objects can be
48549
+** used by more than one database connection. Mutexes are used by shared
48550
+** memdb objects to coordinate access. Separate memdb objects are only
48551
+** connected to a single database connection and do not require additional
48552
+** mutexes.
48553
+**
48554
+** Shared memdb objects have .zFName!=0 and .pMutex!=0. They are created
48555
+** using "file:/name?vfs=memdb". The first character of the name must be
48556
+** "/" or else the object will be a separate memdb object. All shared
48557
+** memdb objects are stored in memdb_g.apMemStore[] in an arbitrary order.
48558
+**
48559
+** Separate memdb objects are created using a name that does not begin
48560
+** with "/" or using sqlite3_deserialize().
48561
+**
48562
+** Access rules for shared MemStore objects:
48563
+**
48564
+** * .zFName is initialized when the object is created and afterwards
48565
+** is unchanged until the object is destroyed. So it can be accessed
48566
+** at any time as long as we know the object is not being destroyed,
48567
+** which means while either the SQLITE_MUTEX_STATIC_VFS1 or
48568
+** .pMutex is held or the object is not part of memdb_g.apMemStore[].
48569
+**
48570
+** * Can .pMutex can only be changed while holding the
48571
+** SQLITE_MUTEX_STATIC_VFS1 mutex or while the object is not part
48572
+** of memdb_g.apMemStore[].
48573
+**
48574
+** * Other fields can only be changed while holding the .pMutex mutex
48575
+** or when the .nRef is less than zero and the object is not part of
48576
+** memdb_g.apMemStore[].
48577
+**
48578
+** * The .aData pointer has the added requirement that it can can only
48579
+** be changed (for resizing) when nMmap is zero.
48580
+**
48581
+*/
48582
+struct MemStore {
4838648583
sqlite3_int64 sz; /* Size of the file */
4838748584
sqlite3_int64 szAlloc; /* Space allocated to aData */
4838848585
sqlite3_int64 szMax; /* Maximum allowed size of the file */
4838948586
unsigned char *aData; /* content of the file */
48587
+ sqlite3_mutex *pMutex; /* Used by shared stores only */
4839048588
int nMmap; /* Number of memory mapped pages */
4839148589
unsigned mFlags; /* Flags */
48590
+ int nRdLock; /* Number of readers */
48591
+ int nWrLock; /* Number of writers. (Always 0 or 1) */
48592
+ int nRef; /* Number of users of this MemStore */
48593
+ char *zFName; /* The filename for shared stores */
48594
+};
48595
+
48596
+/* An open file */
48597
+struct MemFile {
48598
+ sqlite3_file base; /* IO methods */
48599
+ MemStore *pStore; /* The storage */
4839248600
int eLock; /* Most recent lock against this file */
4839348601
};
4839448602
48603
+/*
48604
+** File-scope variables for holding the memdb files that are accessible
48605
+** to multiple database connections in separate threads.
48606
+**
48607
+** Must hold SQLITE_MUTEX_STATIC_VFS1 to access any part of this object.
48608
+*/
48609
+static struct MemFS {
48610
+ int nMemStore; /* Number of shared MemStore objects */
48611
+ MemStore **apMemStore; /* Array of all shared MemStore objects */
48612
+} memdb_g;
48613
+
4839548614
/*
4839648615
** Methods for MemFile
4839748616
*/
4839848617
static int memdbClose(sqlite3_file*);
4839948618
static int memdbRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
@@ -48443,11 +48662,14 @@
4844348662
memdbDlClose, /* xDlClose */
4844448663
memdbRandomness, /* xRandomness */
4844548664
memdbSleep, /* xSleep */
4844648665
0, /* memdbCurrentTime, */ /* xCurrentTime */
4844748666
memdbGetLastError, /* xGetLastError */
48448
- memdbCurrentTimeInt64 /* xCurrentTimeInt64 */
48667
+ memdbCurrentTimeInt64, /* xCurrentTimeInt64 */
48668
+ 0, /* xSetSystemCall */
48669
+ 0, /* xGetSystemCall */
48670
+ 0, /* xNextSystemCall */
4844948671
};
4845048672
4845148673
static const sqlite3_io_methods memdb_io_methods = {
4845248674
3, /* iVersion */
4845348675
memdbClose, /* xClose */
@@ -48468,23 +48690,71 @@
4846848690
0, /* xShmUnmap */
4846948691
memdbFetch, /* xFetch */
4847048692
memdbUnfetch /* xUnfetch */
4847148693
};
4847248694
48695
+/*
48696
+** Enter/leave the mutex on a MemStore
48697
+*/
48698
+#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0
48699
+static void memdbEnter(MemStore *p){
48700
+ UNUSED_PARAMETER(p);
48701
+}
48702
+static void memdbLeave(MemStore *p){
48703
+ UNUSED_PARAMETER(p);
48704
+}
48705
+#else
48706
+static void memdbEnter(MemStore *p){
48707
+ sqlite3_mutex_enter(p->pMutex);
48708
+}
48709
+static void memdbLeave(MemStore *p){
48710
+ sqlite3_mutex_leave(p->pMutex);
48711
+}
48712
+#endif
48713
+
4847348714
4847448715
4847548716
/*
4847648717
** Close an memdb-file.
48477
-**
48478
-** The pData pointer is owned by the application, so there is nothing
48479
-** to free. Unless the SQLITE_DESERIALIZE_FREEONCLOSE flag is set,
48480
-** in which case we own the pData pointer and need to free it.
48718
+** Free the underlying MemStore object when its refcount drops to zero
48719
+** or less.
4848148720
*/
4848248721
static int memdbClose(sqlite3_file *pFile){
48483
- MemFile *p = (MemFile *)pFile;
48484
- if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ){
48485
- sqlite3_free(p->aData);
48722
+ MemStore *p = ((MemFile*)pFile)->pStore;
48723
+ if( p->zFName ){
48724
+ int i;
48725
+#ifndef SQLITE_MUTEX_OMIT
48726
+ sqlite3_mutex *pVfsMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1);
48727
+#endif
48728
+ sqlite3_mutex_enter(pVfsMutex);
48729
+ for(i=0; ALWAYS(i<memdb_g.nMemStore); i++){
48730
+ if( memdb_g.apMemStore[i]==p ){
48731
+ memdbEnter(p);
48732
+ if( p->nRef==1 ){
48733
+ memdb_g.apMemStore[i] = memdb_g.apMemStore[--memdb_g.nMemStore];
48734
+ if( memdb_g.nMemStore==0 ){
48735
+ sqlite3_free(memdb_g.apMemStore);
48736
+ memdb_g.apMemStore = 0;
48737
+ }
48738
+ }
48739
+ break;
48740
+ }
48741
+ }
48742
+ sqlite3_mutex_leave(pVfsMutex);
48743
+ }else{
48744
+ memdbEnter(p);
48745
+ }
48746
+ p->nRef--;
48747
+ if( p->nRef<=0 ){
48748
+ if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ){
48749
+ sqlite3_free(p->aData);
48750
+ }
48751
+ memdbLeave(p);
48752
+ sqlite3_mutex_free(p->pMutex);
48753
+ sqlite3_free(p);
48754
+ }else{
48755
+ memdbLeave(p);
4848648756
}
4848748757
return SQLITE_OK;
4848848758
}
4848948759
4849048760
/*
@@ -48494,24 +48764,27 @@
4849448764
sqlite3_file *pFile,
4849548765
void *zBuf,
4849648766
int iAmt,
4849748767
sqlite_int64 iOfst
4849848768
){
48499
- MemFile *p = (MemFile *)pFile;
48769
+ MemStore *p = ((MemFile*)pFile)->pStore;
48770
+ memdbEnter(p);
4850048771
if( iOfst+iAmt>p->sz ){
4850148772
memset(zBuf, 0, iAmt);
4850248773
if( iOfst<p->sz ) memcpy(zBuf, p->aData+iOfst, p->sz - iOfst);
48774
+ memdbLeave(p);
4850348775
return SQLITE_IOERR_SHORT_READ;
4850448776
}
4850548777
memcpy(zBuf, p->aData+iOfst, iAmt);
48778
+ memdbLeave(p);
4850648779
return SQLITE_OK;
4850748780
}
4850848781
4850948782
/*
4851048783
** Try to enlarge the memory allocation to hold at least sz bytes
4851148784
*/
48512
-static int memdbEnlarge(MemFile *p, sqlite3_int64 newSz){
48785
+static int memdbEnlarge(MemStore *p, sqlite3_int64 newSz){
4851348786
unsigned char *pNew;
4851448787
if( (p->mFlags & SQLITE_DESERIALIZE_RESIZEABLE)==0 || p->nMmap>0 ){
4851548788
return SQLITE_FULL;
4851648789
}
4851748790
if( newSz>p->szMax ){
@@ -48518,11 +48791,11 @@
4851848791
return SQLITE_FULL;
4851948792
}
4852048793
newSz *= 2;
4852148794
if( newSz>p->szMax ) newSz = p->szMax;
4852248795
pNew = sqlite3Realloc(p->aData, newSz);
48523
- if( pNew==0 ) return SQLITE_NOMEM;
48796
+ if( pNew==0 ) return SQLITE_IOERR_NOMEM;
4852448797
p->aData = pNew;
4852548798
p->szAlloc = newSz;
4852648799
return SQLITE_OK;
4852748800
}
4852848801
@@ -48533,23 +48806,31 @@
4853348806
sqlite3_file *pFile,
4853448807
const void *z,
4853548808
int iAmt,
4853648809
sqlite_int64 iOfst
4853748810
){
48538
- MemFile *p = (MemFile *)pFile;
48539
- if( NEVER(p->mFlags & SQLITE_DESERIALIZE_READONLY) ) return SQLITE_READONLY;
48811
+ MemStore *p = ((MemFile*)pFile)->pStore;
48812
+ memdbEnter(p);
48813
+ if( NEVER(p->mFlags & SQLITE_DESERIALIZE_READONLY) ){
48814
+ /* Can't happen: memdbLock() will return SQLITE_READONLY before
48815
+ ** reaching this point */
48816
+ memdbLeave(p);
48817
+ return SQLITE_IOERR_WRITE;
48818
+ }
4854048819
if( iOfst+iAmt>p->sz ){
4854148820
int rc;
4854248821
if( iOfst+iAmt>p->szAlloc
4854348822
&& (rc = memdbEnlarge(p, iOfst+iAmt))!=SQLITE_OK
4854448823
){
48824
+ memdbLeave(p);
4854548825
return rc;
4854648826
}
4854748827
if( iOfst>p->sz ) memset(p->aData+p->sz, 0, iOfst-p->sz);
4854848828
p->sz = iOfst+iAmt;
4854948829
}
4855048830
memcpy(p->aData+iOfst, z, iAmt);
48831
+ memdbLeave(p);
4855148832
return SQLITE_OK;
4855248833
}
4855348834
4855448835
/*
4855548836
** Truncate an memdb-file.
@@ -48557,62 +48838,103 @@
4855748838
** In rollback mode (which is always the case for memdb, as it does not
4855848839
** support WAL mode) the truncate() method is only used to reduce
4855948840
** the size of a file, never to increase the size.
4856048841
*/
4856148842
static int memdbTruncate(sqlite3_file *pFile, sqlite_int64 size){
48562
- MemFile *p = (MemFile *)pFile;
48563
- if( NEVER(size>p->sz) ) return SQLITE_FULL;
48564
- p->sz = size;
48565
- return SQLITE_OK;
48843
+ MemStore *p = ((MemFile*)pFile)->pStore;
48844
+ int rc = SQLITE_OK;
48845
+ memdbEnter(p);
48846
+ if( NEVER(size>p->sz) ){
48847
+ rc = SQLITE_FULL;
48848
+ }else{
48849
+ p->sz = size;
48850
+ }
48851
+ memdbLeave(p);
48852
+ return rc;
4856648853
}
4856748854
4856848855
/*
4856948856
** Sync an memdb-file.
4857048857
*/
4857148858
static int memdbSync(sqlite3_file *pFile, int flags){
48859
+ UNUSED_PARAMETER(pFile);
48860
+ UNUSED_PARAMETER(flags);
4857248861
return SQLITE_OK;
4857348862
}
4857448863
4857548864
/*
4857648865
** Return the current file-size of an memdb-file.
4857748866
*/
4857848867
static int memdbFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){
48579
- MemFile *p = (MemFile *)pFile;
48868
+ MemStore *p = ((MemFile*)pFile)->pStore;
48869
+ memdbEnter(p);
4858048870
*pSize = p->sz;
48871
+ memdbLeave(p);
4858148872
return SQLITE_OK;
4858248873
}
4858348874
4858448875
/*
4858548876
** Lock an memdb-file.
4858648877
*/
4858748878
static int memdbLock(sqlite3_file *pFile, int eLock){
48588
- MemFile *p = (MemFile *)pFile;
48589
- if( eLock>SQLITE_LOCK_SHARED
48590
- && (p->mFlags & SQLITE_DESERIALIZE_READONLY)!=0
48591
- ){
48592
- return SQLITE_READONLY;
48593
- }
48594
- p->eLock = eLock;
48595
- return SQLITE_OK;
48879
+ MemFile *pThis = (MemFile*)pFile;
48880
+ MemStore *p = pThis->pStore;
48881
+ int rc = SQLITE_OK;
48882
+ if( eLock==pThis->eLock ) return SQLITE_OK;
48883
+ memdbEnter(p);
48884
+ if( eLock>SQLITE_LOCK_SHARED ){
48885
+ if( p->mFlags & SQLITE_DESERIALIZE_READONLY ){
48886
+ rc = SQLITE_READONLY;
48887
+ }else if( pThis->eLock<=SQLITE_LOCK_SHARED ){
48888
+ if( p->nWrLock ){
48889
+ rc = SQLITE_BUSY;
48890
+ }else{
48891
+ p->nWrLock = 1;
48892
+ }
48893
+ }
48894
+ }else if( eLock==SQLITE_LOCK_SHARED ){
48895
+ if( pThis->eLock > SQLITE_LOCK_SHARED ){
48896
+ assert( p->nWrLock==1 );
48897
+ p->nWrLock = 0;
48898
+ }else if( p->nWrLock ){
48899
+ rc = SQLITE_BUSY;
48900
+ }else{
48901
+ p->nRdLock++;
48902
+ }
48903
+ }else{
48904
+ assert( eLock==SQLITE_LOCK_NONE );
48905
+ if( pThis->eLock>SQLITE_LOCK_SHARED ){
48906
+ assert( p->nWrLock==1 );
48907
+ p->nWrLock = 0;
48908
+ }
48909
+ assert( p->nRdLock>0 );
48910
+ p->nRdLock--;
48911
+ }
48912
+ if( rc==SQLITE_OK ) pThis->eLock = eLock;
48913
+ memdbLeave(p);
48914
+ return rc;
4859648915
}
4859748916
48598
-#if 0 /* Never used because memdbAccess() always returns false */
48917
+#if 0
4859948918
/*
48600
-** Check if another file-handle holds a RESERVED lock on an memdb-file.
48919
+** This interface is only used for crash recovery, which does not
48920
+** occur on an in-memory database.
4860148921
*/
4860248922
static int memdbCheckReservedLock(sqlite3_file *pFile, int *pResOut){
4860348923
*pResOut = 0;
4860448924
return SQLITE_OK;
4860548925
}
4860648926
#endif
48927
+
4860748928
4860848929
/*
4860948930
** File control method. For custom operations on an memdb-file.
4861048931
*/
4861148932
static int memdbFileControl(sqlite3_file *pFile, int op, void *pArg){
48612
- MemFile *p = (MemFile *)pFile;
48933
+ MemStore *p = ((MemFile*)pFile)->pStore;
4861348934
int rc = SQLITE_NOTFOUND;
48935
+ memdbEnter(p);
4861448936
if( op==SQLITE_FCNTL_VFSNAME ){
4861548937
*(char**)pArg = sqlite3_mprintf("memdb(%p,%lld)", p->aData, p->sz);
4861648938
rc = SQLITE_OK;
4861748939
}
4861848940
if( op==SQLITE_FCNTL_SIZE_LIMIT ){
@@ -48626,10 +48948,11 @@
4862648948
}
4862748949
p->szMax = iLimit;
4862848950
*(sqlite3_int64*)pArg = iLimit;
4862948951
rc = SQLITE_OK;
4863048952
}
48953
+ memdbLeave(p);
4863148954
return rc;
4863248955
}
4863348956
4863448957
#if 0 /* Not used because of SQLITE_IOCAP_POWERSAFE_OVERWRITE */
4863548958
/*
@@ -48642,10 +48965,11 @@
4864248965
4864348966
/*
4864448967
** Return the device characteristic flags supported by an memdb-file.
4864548968
*/
4864648969
static int memdbDeviceCharacteristics(sqlite3_file *pFile){
48970
+ UNUSED_PARAMETER(pFile);
4864748971
return SQLITE_IOCAP_ATOMIC |
4864848972
SQLITE_IOCAP_POWERSAFE_OVERWRITE |
4864948973
SQLITE_IOCAP_SAFE_APPEND |
4865048974
SQLITE_IOCAP_SEQUENTIAL;
4865148975
}
@@ -48655,47 +48979,112 @@
4865548979
sqlite3_file *pFile,
4865648980
sqlite3_int64 iOfst,
4865748981
int iAmt,
4865848982
void **pp
4865948983
){
48660
- MemFile *p = (MemFile *)pFile;
48984
+ MemStore *p = ((MemFile*)pFile)->pStore;
48985
+ memdbEnter(p);
4866148986
if( iOfst+iAmt>p->sz ){
4866248987
*pp = 0;
4866348988
}else{
4866448989
p->nMmap++;
4866548990
*pp = (void*)(p->aData + iOfst);
4866648991
}
48992
+ memdbLeave(p);
4866748993
return SQLITE_OK;
4866848994
}
4866948995
4867048996
/* Release a memory-mapped page */
4867148997
static int memdbUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){
48672
- MemFile *p = (MemFile *)pFile;
48998
+ MemStore *p = ((MemFile*)pFile)->pStore;
48999
+ UNUSED_PARAMETER(iOfst);
49000
+ UNUSED_PARAMETER(pPage);
49001
+ memdbEnter(p);
4867349002
p->nMmap--;
49003
+ memdbLeave(p);
4867449004
return SQLITE_OK;
4867549005
}
4867649006
4867749007
/*
4867849008
** Open an mem file handle.
4867949009
*/
4868049010
static int memdbOpen(
4868149011
sqlite3_vfs *pVfs,
4868249012
const char *zName,
48683
- sqlite3_file *pFile,
49013
+ sqlite3_file *pFd,
4868449014
int flags,
4868549015
int *pOutFlags
4868649016
){
48687
- MemFile *p = (MemFile*)pFile;
49017
+ MemFile *pFile = (MemFile*)pFd;
49018
+ MemStore *p = 0;
49019
+ int szName;
4868849020
if( (flags & SQLITE_OPEN_MAIN_DB)==0 ){
48689
- return ORIGVFS(pVfs)->xOpen(ORIGVFS(pVfs), zName, pFile, flags, pOutFlags);
49021
+ return ORIGVFS(pVfs)->xOpen(ORIGVFS(pVfs), zName, pFd, flags, pOutFlags);
4869049022
}
48691
- memset(p, 0, sizeof(*p));
48692
- p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE;
49023
+ memset(pFile, 0, sizeof(*p));
49024
+ szName = sqlite3Strlen30(zName);
49025
+ if( szName>1 && zName[0]=='/' ){
49026
+ int i;
49027
+#ifndef SQLITE_MUTEX_OMIT
49028
+ sqlite3_mutex *pVfsMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1);
49029
+#endif
49030
+ sqlite3_mutex_enter(pVfsMutex);
49031
+ for(i=0; i<memdb_g.nMemStore; i++){
49032
+ if( strcmp(memdb_g.apMemStore[i]->zFName,zName)==0 ){
49033
+ p = memdb_g.apMemStore[i];
49034
+ break;
49035
+ }
49036
+ }
49037
+ if( p==0 ){
49038
+ MemStore **apNew;
49039
+ p = sqlite3Malloc( sizeof(*p) + szName + 3 );
49040
+ if( p==0 ){
49041
+ sqlite3_mutex_leave(pVfsMutex);
49042
+ return SQLITE_NOMEM;
49043
+ }
49044
+ apNew = sqlite3Realloc(memdb_g.apMemStore,
49045
+ sizeof(apNew[0])*(memdb_g.nMemStore+1) );
49046
+ if( apNew==0 ){
49047
+ sqlite3_free(p);
49048
+ sqlite3_mutex_leave(pVfsMutex);
49049
+ return SQLITE_NOMEM;
49050
+ }
49051
+ apNew[memdb_g.nMemStore++] = p;
49052
+ memdb_g.apMemStore = apNew;
49053
+ memset(p, 0, sizeof(*p));
49054
+ p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE|SQLITE_DESERIALIZE_FREEONCLOSE;
49055
+ p->szMax = sqlite3GlobalConfig.mxMemdbSize;
49056
+ p->zFName = (char*)&p[1];
49057
+ memcpy(p->zFName, zName, szName+1);
49058
+ p->pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
49059
+ if( p->pMutex==0 ){
49060
+ memdb_g.nMemStore--;
49061
+ sqlite3_free(p);
49062
+ sqlite3_mutex_leave(pVfsMutex);
49063
+ return SQLITE_NOMEM;
49064
+ }
49065
+ p->nRef = 1;
49066
+ memdbEnter(p);
49067
+ }else{
49068
+ memdbEnter(p);
49069
+ p->nRef++;
49070
+ }
49071
+ sqlite3_mutex_leave(pVfsMutex);
49072
+ }else{
49073
+ p = sqlite3Malloc( sizeof(*p) );
49074
+ if( p==0 ){
49075
+ return SQLITE_NOMEM;
49076
+ }
49077
+ memset(p, 0, sizeof(*p));
49078
+ p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE;
49079
+ p->szMax = sqlite3GlobalConfig.mxMemdbSize;
49080
+ }
49081
+ pFile->pStore = p;
4869349082
assert( pOutFlags!=0 ); /* True because flags==SQLITE_OPEN_MAIN_DB */
4869449083
*pOutFlags = flags | SQLITE_OPEN_MEMORY;
48695
- pFile->pMethods = &memdb_io_methods;
48696
- p->szMax = sqlite3GlobalConfig.mxMemdbSize;
49084
+ pFd->pMethods = &memdb_io_methods;
49085
+ memdbLeave(p);
4869749086
return SQLITE_OK;
4869849087
}
4869949088
4870049089
#if 0 /* Only used to delete rollback journals, super-journals, and WAL
4870149090
** files, none of which exist in memdb. So this routine is never used */
@@ -48719,10 +49108,13 @@
4871949108
sqlite3_vfs *pVfs,
4872049109
const char *zPath,
4872149110
int flags,
4872249111
int *pResOut
4872349112
){
49113
+ UNUSED_PARAMETER(pVfs);
49114
+ UNUSED_PARAMETER(zPath);
49115
+ UNUSED_PARAMETER(flags);
4872449116
*pResOut = 0;
4872549117
return SQLITE_OK;
4872649118
}
4872749119
4872849120
/*
@@ -48734,10 +49126,11 @@
4873449126
sqlite3_vfs *pVfs,
4873549127
const char *zPath,
4873649128
int nOut,
4873749129
char *zOut
4873849130
){
49131
+ UNUSED_PARAMETER(pVfs);
4873949132
sqlite3_snprintf(nOut, zOut, "%s", zPath);
4874049133
return SQLITE_OK;
4874149134
}
4874249135
4874349136
/*
@@ -48806,13 +49199,18 @@
4880649199
** Translate a database connection pointer and schema name into a
4880749200
** MemFile pointer.
4880849201
*/
4880949202
static MemFile *memdbFromDbSchema(sqlite3 *db, const char *zSchema){
4881049203
MemFile *p = 0;
49204
+ MemStore *pStore;
4881149205
int rc = sqlite3_file_control(db, zSchema, SQLITE_FCNTL_FILE_POINTER, &p);
4881249206
if( rc ) return 0;
4881349207
if( p->base.pMethods!=&memdb_io_methods ) return 0;
49208
+ pStore = p->pStore;
49209
+ memdbEnter(pStore);
49210
+ if( pStore->zFName!=0 ) p = 0;
49211
+ memdbLeave(pStore);
4881449212
return p;
4881549213
}
4881649214
4881749215
/*
4881849216
** Return the serialization of a database
@@ -48844,16 +49242,18 @@
4884449242
p = memdbFromDbSchema(db, zSchema);
4884549243
iDb = sqlite3FindDbName(db, zSchema);
4884649244
if( piSize ) *piSize = -1;
4884749245
if( iDb<0 ) return 0;
4884849246
if( p ){
48849
- if( piSize ) *piSize = p->sz;
49247
+ MemStore *pStore = p->pStore;
49248
+ assert( pStore->pMutex==0 );
49249
+ if( piSize ) *piSize = pStore->sz;
4885049250
if( mFlags & SQLITE_SERIALIZE_NOCOPY ){
48851
- pOut = p->aData;
49251
+ pOut = pStore->aData;
4885249252
}else{
48853
- pOut = sqlite3_malloc64( p->sz );
48854
- if( pOut ) memcpy(pOut, p->aData, p->sz);
49253
+ pOut = sqlite3_malloc64( pStore->sz );
49254
+ if( pOut ) memcpy(pOut, pStore->aData, pStore->sz);
4885549255
}
4885649256
return pOut;
4885749257
}
4885849258
pBt = db->aDb[iDb].pBt;
4885949259
if( pBt==0 ) return 0;
@@ -48943,19 +49343,20 @@
4894349343
}
4894449344
p = memdbFromDbSchema(db, zSchema);
4894549345
if( p==0 ){
4894649346
rc = SQLITE_ERROR;
4894749347
}else{
48948
- p->aData = pData;
49348
+ MemStore *pStore = p->pStore;
49349
+ pStore->aData = pData;
4894949350
pData = 0;
48950
- p->sz = szDb;
48951
- p->szAlloc = szBuf;
48952
- p->szMax = szBuf;
48953
- if( p->szMax<sqlite3GlobalConfig.mxMemdbSize ){
48954
- p->szMax = sqlite3GlobalConfig.mxMemdbSize;
49351
+ pStore->sz = szDb;
49352
+ pStore->szAlloc = szBuf;
49353
+ pStore->szMax = szBuf;
49354
+ if( pStore->szMax<sqlite3GlobalConfig.mxMemdbSize ){
49355
+ pStore->szMax = sqlite3GlobalConfig.mxMemdbSize;
4895549356
}
48956
- p->mFlags = mFlags;
49357
+ pStore->mFlags = mFlags;
4895749358
rc = SQLITE_OK;
4895849359
}
4895949360
4896049361
end_deserialize:
4896149362
sqlite3_finalize(pStmt);
@@ -48970,21 +49371,21 @@
4897049371
** This routine is called when the extension is loaded.
4897149372
** Register the new VFS.
4897249373
*/
4897349374
SQLITE_PRIVATE int sqlite3MemdbInit(void){
4897449375
sqlite3_vfs *pLower = sqlite3_vfs_find(0);
48975
- int sz = pLower->szOsFile;
49376
+ unsigned int sz = pLower->szOsFile;
4897649377
memdb_vfs.pAppData = pLower;
4897749378
/* The following conditional can only be true when compiled for
4897849379
** Windows x86 and SQLITE_MAX_MMAP_SIZE=0. We always leave
4897949380
** it in, to be safe, but it is marked as NO_TEST since there
4898049381
** is no way to reach it under most builds. */
4898149382
if( sz<sizeof(MemFile) ) sz = sizeof(MemFile); /*NO_TEST*/
4898249383
memdb_vfs.szOsFile = sz;
4898349384
return sqlite3_vfs_register(&memdb_vfs, 0);
4898449385
}
48985
-#endif /* SQLITE_ENABLE_DESERIALIZE */
49386
+#endif /* SQLITE_OMIT_DESERIALIZE */
4898649387
4898749388
/************** End of memdb.c ***********************************************/
4898849389
/************** Begin file bitvec.c ******************************************/
4898949390
/*
4899049391
** 2008 February 16
@@ -56895,11 +57296,11 @@
5689557296
u8 *pPtr;
5689657297
Pager *pPager = 0; /* Pager object to allocate and return */
5689757298
int rc = SQLITE_OK; /* Return code */
5689857299
int tempFile = 0; /* True for temp files (incl. in-memory files) */
5689957300
int memDb = 0; /* True if this is an in-memory file */
56900
-#ifdef SQLITE_ENABLE_DESERIALIZE
57301
+#ifndef SQLITE_OMIT_DESERIALIZE
5690157302
int memJM = 0; /* Memory journal mode */
5690257303
#else
5690357304
# define memJM 0
5690457305
#endif
5690557306
int readOnly = 0; /* True if this is a read-only file */
@@ -57099,11 +57500,11 @@
5709957500
*/
5710057501
if( zFilename && zFilename[0] ){
5710157502
int fout = 0; /* VFS flags returned by xOpen() */
5710257503
rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout);
5710357504
assert( !memDb );
57104
-#ifdef SQLITE_ENABLE_DESERIALIZE
57505
+#ifndef SQLITE_OMIT_DESERIALIZE
5710557506
memJM = (fout&SQLITE_OPEN_MEMORY)!=0;
5710657507
#endif
5710757508
readOnly = (fout&SQLITE_OPEN_READONLY)!=0;
5710857509
5710957510
/* If the file was successfully opened for read/write access,
@@ -58067,11 +58468,11 @@
5806758468
5806858469
if( pPager->errCode ) return pPager->errCode;
5806958470
assert( pPager->eState>=PAGER_READER && pPager->eState<PAGER_ERROR );
5807058471
pPager->subjInMemory = (u8)subjInMemory;
5807158472
58072
- if( ALWAYS(pPager->eState==PAGER_READER) ){
58473
+ if( pPager->eState==PAGER_READER ){
5807358474
assert( pPager->pInJournal==0 );
5807458475
5807558476
if( pagerUseWal(pPager) ){
5807658477
/* If the pager is configured to use locking_mode=exclusive, and an
5807758478
** exclusive lock on the database is not already held, obtain it now.
@@ -60941,11 +61342,10 @@
6094161342
static void walCleanupHash(Wal *pWal){
6094261343
WalHashLoc sLoc; /* Hash table location */
6094361344
int iLimit = 0; /* Zero values greater than this */
6094461345
int nByte; /* Number of bytes to zero in aPgno[] */
6094561346
int i; /* Used to iterate through aHash[] */
60946
- int rc; /* Return code form walHashGet() */
6094761347
6094861348
assert( pWal->writeLock );
6094961349
testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 );
6095061350
testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE );
6095161351
testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 );
@@ -60956,12 +61356,12 @@
6095661356
** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed
6095761357
** that the page said hash-table and array reside on is already mapped.(1)
6095861358
*/
6095961359
assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );
6096061360
assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );
60961
- rc = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
60962
- if( NEVER(rc) ) return; /* Defense-in-depth, in case (1) above is wrong */
61361
+ i = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
61362
+ if( NEVER(i) ) return; /* Defense-in-depth, in case (1) above is wrong */
6096361363
6096461364
/* Zero all hash-table entries that correspond to frame numbers greater
6096561365
** than pWal->hdr.mxFrame.
6096661366
*/
6096761367
iLimit = pWal->hdr.mxFrame - sLoc.iZero;
@@ -65587,11 +65987,11 @@
6558765987
Pgno pgnoRoot, /* The table that might be changing */
6558865988
i64 iRow, /* The rowid that might be changing */
6558965989
int isClearTable /* True if all rows are being deleted */
6559065990
){
6559165991
BtCursor *p;
65592
- if( pBtree->hasIncrblobCur==0 ) return;
65992
+ assert( pBtree->hasIncrblobCur );
6559365993
assert( sqlite3BtreeHoldsMutex(pBtree) );
6559465994
pBtree->hasIncrblobCur = 0;
6559565995
for(p=pBtree->pBt->pCursor; p; p=p->pNext){
6559665996
if( (p->curFlags & BTCF_Incrblob)!=0 ){
6559765997
pBtree->hasIncrblobCur = 1;
@@ -66488,10 +66888,11 @@
6648866888
unsigned char *data; /* The page data */
6648966889
unsigned char *temp; /* Temp area for cell content */
6649066890
unsigned char *src; /* Source of content */
6649166891
int iCellFirst; /* First allowable cell index */
6649266892
int iCellLast; /* Last possible cell index */
66893
+ int iCellStart; /* First cell offset in input */
6649366894
6649466895
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
6649566896
assert( pPage->pBt!=0 );
6649666897
assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE );
6649766898
assert( pPage->nOverflow==0 );
@@ -66529,11 +66930,11 @@
6652966930
if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage);
6653066931
sz2 = get2byte(&data[iFree2+2]);
6653166932
if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage);
6653266933
memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));
6653366934
sz += sz2;
66534
- }else if( NEVER(iFree+sz>usableSize) ){
66935
+ }else if( iFree+sz>usableSize ){
6653566936
return SQLITE_CORRUPT_PAGE(pPage);
6653666937
}
6653766938
6653866939
cbrk = top+sz;
6653966940
assert( cbrk+(iFree-top) <= usableSize );
@@ -66548,38 +66949,37 @@
6654866949
}
6654966950
}
6655066951
6655166952
cbrk = usableSize;
6655266953
iCellLast = usableSize - 4;
66954
+ iCellStart = get2byte(&data[hdr+5]);
6655366955
for(i=0; i<nCell; i++){
6655466956
u8 *pAddr; /* The i-th cell pointer */
6655566957
pAddr = &data[cellOffset + i*2];
6655666958
pc = get2byte(pAddr);
6655766959
testcase( pc==iCellFirst );
6655866960
testcase( pc==iCellLast );
6655966961
/* These conditions have already been verified in btreeInitPage()
6656066962
** if PRAGMA cell_size_check=ON.
6656166963
*/
66562
- if( pc<iCellFirst || pc>iCellLast ){
66964
+ if( pc<iCellStart || pc>iCellLast ){
6656366965
return SQLITE_CORRUPT_PAGE(pPage);
6656466966
}
66565
- assert( pc>=iCellFirst && pc<=iCellLast );
66967
+ assert( pc>=iCellStart && pc<=iCellLast );
6656666968
size = pPage->xCellSize(pPage, &src[pc]);
6656766969
cbrk -= size;
66568
- if( cbrk<iCellFirst || pc+size>usableSize ){
66970
+ if( cbrk<iCellStart || pc+size>usableSize ){
6656966971
return SQLITE_CORRUPT_PAGE(pPage);
6657066972
}
66571
- assert( cbrk+size<=usableSize && cbrk>=iCellFirst );
66973
+ assert( cbrk+size<=usableSize && cbrk>=iCellStart );
6657266974
testcase( cbrk+size==usableSize );
6657366975
testcase( pc+size==usableSize );
6657466976
put2byte(pAddr, cbrk);
6657566977
if( temp==0 ){
66576
- int x;
6657766978
if( cbrk==pc ) continue;
6657866979
temp = sqlite3PagerTempSpace(pPage->pBt->pPager);
66579
- x = get2byte(&data[hdr+5]);
66580
- memcpy(&temp[x], &data[x], (cbrk+size) - x);
66980
+ memcpy(&temp[iCellStart], &data[iCellStart], usableSize - iCellStart);
6658166981
src = temp;
6658266982
}
6658366983
memcpy(&data[cbrk], &src[pc], size);
6658466984
}
6658566985
data[hdr+7] = 0;
@@ -71459,14 +71859,13 @@
7145971859
*pRC = freePage2(pPage->pBt, pPage, pPage->pgno);
7146071860
}
7146171861
}
7146271862
7146371863
/*
71464
-** Free any overflow pages associated with the given Cell. Store
71465
-** size information about the cell in pInfo.
71864
+** Free the overflow pages associated with the given Cell.
7146671865
*/
71467
-static int clearCell(
71866
+static SQLITE_NOINLINE int clearCellOverflow(
7146871867
MemPage *pPage, /* The page that contains the Cell */
7146971868
unsigned char *pCell, /* First byte of the Cell */
7147071869
CellInfo *pInfo /* Size information about the cell */
7147171870
){
7147271871
BtShared *pBt;
@@ -71474,14 +71873,11 @@
7147471873
int rc;
7147571874
int nOvfl;
7147671875
u32 ovflPageSize;
7147771876
7147871877
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
71479
- pPage->xParseCell(pPage, pCell, pInfo);
71480
- if( pInfo->nLocal==pInfo->nPayload ){
71481
- return SQLITE_OK; /* No overflow pages. Return without doing anything */
71482
- }
71878
+ assert( pInfo->nLocal!=pInfo->nPayload );
7148371879
testcase( pCell + pInfo->nSize == pPage->aDataEnd );
7148471880
testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd );
7148571881
if( pCell + pInfo->nSize > pPage->aDataEnd ){
7148671882
/* Cell extends past end of page */
7148771883
return SQLITE_CORRUPT_PAGE(pPage);
@@ -71532,10 +71928,25 @@
7153271928
if( rc ) return rc;
7153371929
ovflPgno = iNext;
7153471930
}
7153571931
return SQLITE_OK;
7153671932
}
71933
+
71934
+/* Call xParseCell to compute the size of a cell. If the cell contains
71935
+** overflow, then invoke cellClearOverflow to clear out that overflow.
71936
+** STore the result code (SQLITE_OK or some error code) in rc.
71937
+**
71938
+** Implemented as macro to force inlining for performance.
71939
+*/
71940
+#define BTREE_CLEAR_CELL(rc, pPage, pCell, sInfo) \
71941
+ pPage->xParseCell(pPage, pCell, &sInfo); \
71942
+ if( sInfo.nLocal!=sInfo.nPayload ){ \
71943
+ rc = clearCellOverflow(pPage, pCell, &sInfo); \
71944
+ }else{ \
71945
+ rc = SQLITE_OK; \
71946
+ }
71947
+
7153771948
7153871949
/*
7153971950
** Create the byte sequence used to represent a cell on page pPage
7154071951
** and write that byte sequence into pCell[]. Overflow pages are
7154171952
** allocated and filled in as necessary. The calling procedure
@@ -72055,11 +72466,11 @@
7205572466
pData = pEnd;
7205672467
while( 1/*exit by break*/ ){
7205772468
u8 *pCell = pCArray->apCell[i];
7205872469
u16 sz = pCArray->szCell[i];
7205972470
assert( sz>0 );
72060
- if( SQLITE_WITHIN(pCell,aData,pEnd) ){
72471
+ if( SQLITE_WITHIN(pCell,aData+j,pEnd) ){
7206172472
if( ((uptr)(pCell+sz))>(uptr)pEnd ) return SQLITE_CORRUPT_BKPT;
7206272473
pCell = &pTmp[pCell - aData];
7206372474
}else if( (uptr)(pCell+sz)>(uptr)pSrcEnd
7206472475
&& (uptr)(pCell)<(uptr)pSrcEnd
7206572476
){
@@ -72068,13 +72479,12 @@
7206872479
7206972480
pData -= sz;
7207072481
put2byte(pCellptr, (pData - aData));
7207172482
pCellptr += 2;
7207272483
if( pData < pCellptr ) return SQLITE_CORRUPT_BKPT;
72073
- memcpy(pData, pCell, sz);
72484
+ memmove(pData, pCell, sz);
7207472485
assert( sz==pPg->xCellSize(pPg, pCell) || CORRUPT_DB );
72075
- testcase( sz!=pPg->xCellSize(pPg,pCell) )
7207672486
i++;
7207772487
if( i>=iEnd ) break;
7207872488
if( pCArray->ixNx[k]<=i ){
7207972489
k++;
7208072490
pSrcEnd = pCArray->apEnd[k];
@@ -72209,11 +72619,13 @@
7220972619
assert( pFree>aData && (pFree - aData)<65536 );
7221072620
freeSpace(pPg, (u16)(pFree - aData), szFree);
7221172621
}
7221272622
pFree = pCell;
7221372623
szFree = sz;
72214
- if( pFree+sz>pEnd ) return 0;
72624
+ if( pFree+sz>pEnd ){
72625
+ return 0;
72626
+ }
7221572627
}else{
7221672628
pFree = pCell;
7221772629
szFree += sz;
7221872630
}
7221972631
nRet++;
@@ -72862,11 +73274,11 @@
7286273274
b.apCell[b.nCell] = pTemp+leafCorrection;
7286373275
assert( leafCorrection==0 || leafCorrection==4 );
7286473276
b.szCell[b.nCell] = b.szCell[b.nCell] - leafCorrection;
7286573277
if( !pOld->leaf ){
7286673278
assert( leafCorrection==0 );
72867
- assert( pOld->hdrOffset==0 );
73279
+ assert( pOld->hdrOffset==0 || CORRUPT_DB );
7286873280
/* The right pointer of the child page pOld becomes the left
7286973281
** pointer of the divider cell */
7287073282
memcpy(b.apCell[b.nCell], &pOld->aData[8], 4);
7287173283
}else{
7287273284
assert( leafCorrection==4 );
@@ -73185,10 +73597,11 @@
7318573597
/* Insert new divider cells into pParent. */
7318673598
for(i=0; i<nNew-1; i++){
7318773599
u8 *pCell;
7318873600
u8 *pTemp;
7318973601
int sz;
73602
+ u8 *pSrcEnd;
7319073603
MemPage *pNew = apNew[i];
7319173604
j = cntNew[i];
7319273605
7319373606
assert( j<nMaxCells );
7319473607
assert( b.apCell[j]!=0 );
@@ -73228,10 +73641,16 @@
7322873641
}
7322973642
}
7323073643
iOvflSpace += sz;
7323173644
assert( sz<=pBt->maxLocal+23 );
7323273645
assert( iOvflSpace <= (int)pBt->pageSize );
73646
+ for(k=0; b.ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
73647
+ pSrcEnd = b.apEnd[k];
73648
+ if( SQLITE_WITHIN(pSrcEnd, pCell, pCell+sz) ){
73649
+ rc = SQLITE_CORRUPT_BKPT;
73650
+ goto balance_cleanup;
73651
+ }
7323373652
insertCell(pParent, nxDiv+i, pCell, sz, pTemp, pNew->pgno, &rc);
7323473653
if( rc!=SQLITE_OK ) goto balance_cleanup;
7323573654
assert( sqlite3PagerIswriteable(pParent->pDbPage) );
7323673655
}
7323773656
@@ -73770,17 +74189,27 @@
7377074189
** not to clear the cursor here.
7377174190
*/
7377274191
if( pCur->curFlags & BTCF_Multiple ){
7377374192
rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
7377474193
if( rc ) return rc;
74194
+ if( loc && pCur->iPage<0 ){
74195
+ /* This can only happen if the schema is corrupt such that there is more
74196
+ ** than one table or index with the same root page as used by the cursor.
74197
+ ** Which can only happen if the SQLITE_NoSchemaError flag was set when
74198
+ ** the schema was loaded. This cannot be asserted though, as a user might
74199
+ ** set the flag, load the schema, and then unset the flag. */
74200
+ return SQLITE_CORRUPT_BKPT;
74201
+ }
7377574202
}
7377674203
7377774204
if( pCur->pKeyInfo==0 ){
7377874205
assert( pX->pKey==0 );
7377974206
/* If this is an insert into a table b-tree, invalidate any incrblob
7378074207
** cursors open on the row being replaced */
73781
- invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0);
74208
+ if( p->hasIncrblobCur ){
74209
+ invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0);
74210
+ }
7378274211
7378374212
/* If BTREE_SAVEPOSITION is set, the cursor must already be pointing
7378474213
** to a row with the same key as the new entry being inserted.
7378574214
*/
7378674215
#ifdef SQLITE_DEBUG
@@ -73857,21 +74286,20 @@
7385774286
x2.nData = pX->nKey;
7385874287
x2.nZero = 0;
7385974288
return btreeOverwriteCell(pCur, &x2);
7386074289
}
7386174290
}
73862
-
7386374291
}
7386474292
assert( pCur->eState==CURSOR_VALID
7386574293
|| (pCur->eState==CURSOR_INVALID && loc)
7386674294
|| CORRUPT_DB );
7386774295
7386874296
pPage = pCur->pPage;
7386974297
assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) );
7387074298
assert( pPage->leaf || !pPage->intKey );
7387174299
if( pPage->nFree<0 ){
73872
- if( pCur->eState>CURSOR_INVALID ){
74300
+ if( NEVER(pCur->eState>CURSOR_INVALID) ){
7387374301
rc = SQLITE_CORRUPT_BKPT;
7387474302
}else{
7387574303
rc = btreeComputeFreeSpace(pPage);
7387674304
}
7387774305
if( rc ) return rc;
@@ -73911,11 +74339,11 @@
7391174339
}
7391274340
oldCell = findCell(pPage, idx);
7391374341
if( !pPage->leaf ){
7391474342
memcpy(newCell, oldCell, 4);
7391574343
}
73916
- rc = clearCell(pPage, oldCell, &info);
74344
+ BTREE_CLEAR_CELL(rc, pPage, oldCell, info);
7391774345
testcase( pCur->curFlags & BTCF_ValidOvfl );
7391874346
invalidateOverflowCache(pCur);
7391974347
if( info.nSize==szNew && info.nLocal==info.nPayload
7392074348
&& (!ISAUTOVACUUM || szNew<pPage->minLocal)
7392174349
){
@@ -74148,11 +74576,12 @@
7414874576
assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );
7414974577
assert( !hasReadConflicts(p, pCur->pgnoRoot) );
7415074578
assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 );
7415174579
if( pCur->eState==CURSOR_REQUIRESEEK ){
7415274580
rc = btreeRestoreCursorPosition(pCur);
74153
- if( rc ) return rc;
74581
+ assert( rc!=SQLITE_OK || CORRUPT_DB || pCur->eState==CURSOR_VALID );
74582
+ if( rc || pCur->eState!=CURSOR_VALID ) return rc;
7415474583
}
7415574584
assert( CORRUPT_DB || pCur->eState==CURSOR_VALID );
7415674585
7415774586
iCellDepth = pCur->iPage;
7415874587
iCellIdx = pCur->ix;
@@ -74203,20 +74632,20 @@
7420374632
if( rc ) return rc;
7420474633
}
7420574634
7420674635
/* If this is a delete operation to remove a row from a table b-tree,
7420774636
** invalidate any incrblob cursors open on the row being deleted. */
74208
- if( pCur->pKeyInfo==0 ){
74637
+ if( pCur->pKeyInfo==0 && p->hasIncrblobCur ){
7420974638
invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0);
7421074639
}
7421174640
7421274641
/* Make the page containing the entry to be deleted writable. Then free any
7421374642
** overflow pages associated with the entry and finally remove the cell
7421474643
** itself from within the page. */
7421574644
rc = sqlite3PagerWrite(pPage->pDbPage);
7421674645
if( rc ) return rc;
74217
- rc = clearCell(pPage, pCell, &info);
74646
+ BTREE_CLEAR_CELL(rc, pPage, pCell, info);
7421874647
dropCell(pPage, iCellIdx, info.nSize, &rc);
7421974648
if( rc ) return rc;
7422074649
7422174650
/* If the cell deleted was not located on a leaf page, then the cursor
7422274651
** is currently pointing to the largest entry in the sub-tree headed
@@ -74499,18 +74928,18 @@
7449974928
pCell = findCell(pPage, i);
7450074929
if( !pPage->leaf ){
7450174930
rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
7450274931
if( rc ) goto cleardatabasepage_out;
7450374932
}
74504
- rc = clearCell(pPage, pCell, &info);
74933
+ BTREE_CLEAR_CELL(rc, pPage, pCell, info);
7450574934
if( rc ) goto cleardatabasepage_out;
7450674935
}
7450774936
if( !pPage->leaf ){
7450874937
rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
7450974938
if( rc ) goto cleardatabasepage_out;
74510
- }else if( pnChange ){
74511
- assert( pPage->intKey || CORRUPT_DB );
74939
+ }
74940
+ if( pnChange ){
7451274941
testcase( !pPage->intKey );
7451374942
*pnChange += pPage->nCell;
7451474943
}
7451574944
if( freePageFlag ){
7451674945
freePage(pPage, &rc);
@@ -74531,13 +74960,12 @@
7453174960
**
7453274961
** This routine will fail with SQLITE_LOCKED if there are any open
7453374962
** read cursors on the table. Open write cursors are moved to the
7453474963
** root of the table.
7453574964
**
74536
-** If pnChange is not NULL, then table iTable must be an intkey table. The
74537
-** integer value pointed to by pnChange is incremented by the number of
74538
-** entries in the table.
74965
+** If pnChange is not NULL, then the integer value pointed to by pnChange
74966
+** is incremented by the number of entries in the table.
7453974967
*/
7454074968
SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){
7454174969
int rc;
7454274970
BtShared *pBt = p->pBt;
7454374971
sqlite3BtreeEnter(p);
@@ -74547,11 +74975,13 @@
7454774975
7454874976
if( SQLITE_OK==rc ){
7454974977
/* Invalidate all incrblob cursors open on table iTable (assuming iTable
7455074978
** is the root of a table b-tree - if it is not, the following call is
7455174979
** a no-op). */
74552
- invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1);
74980
+ if( p->hasIncrblobCur ){
74981
+ invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1);
74982
+ }
7455374983
rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
7455474984
}
7455574985
sqlite3BtreeLeave(p);
7455674986
return rc;
7455774987
}
@@ -76630,11 +77060,13 @@
7663077060
assert( (p->flags & MEM_Cleared)==0 );
7663177061
}
7663277062
7663377063
/* The szMalloc field holds the correct memory allocation size */
7663477064
assert( p->szMalloc==0
76635
- || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) );
77065
+ || (p->flags==MEM_Undefined
77066
+ && p->szMalloc<=sqlite3DbMallocSize(p->db,p->zMalloc))
77067
+ || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc));
7663677068
7663777069
/* If p holds a string or blob, the Mem.z must point to exactly
7663877070
** one of the following:
7663977071
**
7664077072
** (1) Memory in Mem.zMalloc and managed by the Mem object
@@ -76794,11 +77226,13 @@
7679477226
** contain a valid string or blob value. */
7679577227
assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
7679677228
testcase( bPreserve && pMem->z==0 );
7679777229
7679877230
assert( pMem->szMalloc==0
76799
- || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );
77231
+ || (pMem->flags==MEM_Undefined
77232
+ && pMem->szMalloc<=sqlite3DbMallocSize(pMem->db,pMem->zMalloc))
77233
+ || pMem->szMalloc==sqlite3DbMallocSize(pMem->db,pMem->zMalloc));
7680077234
if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){
7680177235
if( pMem->db ){
7680277236
pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
7680377237
}else{
7680477238
pMem->zMalloc = sqlite3Realloc(pMem->z, n);
@@ -77623,15 +78057,15 @@
7762378057
** either case, SQLITE_TOOBIG is returned.
7762478058
*/
7762578059
SQLITE_PRIVATE int sqlite3VdbeMemSetStr(
7762678060
Mem *pMem, /* Memory cell to set to string value */
7762778061
const char *z, /* String pointer */
77628
- int n, /* Bytes in string, or negative */
78062
+ i64 n, /* Bytes in string, or negative */
7762978063
u8 enc, /* Encoding of z. 0 for BLOBs */
7763078064
void (*xDel)(void*) /* Destructor function */
7763178065
){
77632
- int nByte = n; /* New value for pMem->n */
78066
+ i64 nByte = n; /* New value for pMem->n */
7763378067
int iLimit; /* Maximum allowed string or blob size */
7763478068
u16 flags = 0; /* New value for pMem->flags */
7763578069
7763678070
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
7763778071
assert( !sqlite3VdbeMemIsRowSet(pMem) );
@@ -77649,11 +78083,11 @@
7764978083
}
7765078084
flags = (enc==0?MEM_Blob:MEM_Str);
7765178085
if( nByte<0 ){
7765278086
assert( enc!=0 );
7765378087
if( enc==SQLITE_UTF8 ){
77654
- nByte = 0x7fffffff & (int)strlen(z);
78088
+ nByte = strlen(z);
7765578089
}else{
7765678090
for(nByte=0; nByte<=iLimit && (z[nByte] | z[nByte+1]); nByte+=2){}
7765778091
}
7765878092
flags |= MEM_Term;
7765978093
}
@@ -77661,11 +78095,11 @@
7766178095
/* The following block sets the new values of Mem.z and Mem.xDel. It
7766278096
** also sets a flag in local variable "flags" to indicate the memory
7766378097
** management (one of MEM_Dyn or MEM_Static).
7766478098
*/
7766578099
if( xDel==SQLITE_TRANSIENT ){
77666
- u32 nAlloc = nByte;
78100
+ i64 nAlloc = nByte;
7766778101
if( flags&MEM_Term ){
7766878102
nAlloc += (enc==SQLITE_UTF8?1:2);
7766978103
}
7767078104
if( nByte>iLimit ){
7767178105
return sqlite3ErrorToParser(pMem->db, SQLITE_TOOBIG);
@@ -77687,11 +78121,11 @@
7768778121
pMem->xDel = xDel;
7768878122
flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn);
7768978123
}
7769078124
}
7769178125
77692
- pMem->n = nByte;
78126
+ pMem->n = (int)(nByte & 0x7fffffff);
7769378127
pMem->flags = flags;
7769478128
if( enc ){
7769578129
pMem->enc = enc;
7769678130
#ifdef SQLITE_ENABLE_SESSION
7769778131
}else if( pMem->db==0 ){
@@ -77707,11 +78141,11 @@
7770778141
return SQLITE_NOMEM_BKPT;
7770878142
}
7770978143
#endif
7771078144
7771178145
if( nByte>iLimit ){
77712
- return SQLITE_TOOBIG;
78146
+ return sqlite3ErrorToParser(pMem->db, SQLITE_TOOBIG);
7771378147
}
7771478148
7771578149
return SQLITE_OK;
7771678150
}
7771778151
@@ -83652,11 +84086,12 @@
8365284086
VdbeCursor *pCsr, /* Cursor to grab old.* values from */
8365384087
int op, /* SQLITE_INSERT, UPDATE or DELETE */
8365484088
const char *zDb, /* Database name */
8365584089
Table *pTab, /* Modified table */
8365684090
i64 iKey1, /* Initial key value */
83657
- int iReg /* Register for new.* record */
84091
+ int iReg, /* Register for new.* record */
84092
+ int iBlobWrite
8365884093
){
8365984094
sqlite3 *db = v->db;
8366084095
i64 iKey2;
8366184096
PreUpdate preupdate;
8366284097
const char *zTbl = pTab->zName;
@@ -83688,10 +84123,11 @@
8368884123
preupdate.keyinfo.nKeyField = pTab->nCol;
8368984124
preupdate.keyinfo.aSortFlags = (u8*)&fakeSortOrder;
8369084125
preupdate.iKey1 = iKey1;
8369184126
preupdate.iKey2 = iKey2;
8369284127
preupdate.pTab = pTab;
84128
+ preupdate.iBlobWrite = iBlobWrite;
8369384129
8369484130
db->pPreUpdate = &preupdate;
8369584131
db->xPreUpdateCallback(db->pPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2);
8369684132
db->pPreUpdate = 0;
8369784133
sqlite3DbFree(db, preupdate.aRecord);
@@ -84101,11 +84537,11 @@
8410184537
}else if( xDel==SQLITE_TRANSIENT ){
8410284538
/* noop */
8410384539
}else{
8410484540
xDel((void*)p);
8410584541
}
84106
- if( pCtx ) sqlite3_result_error_toobig(pCtx);
84542
+ sqlite3_result_error_toobig(pCtx);
8410784543
return SQLITE_TOOBIG;
8410884544
}
8410984545
SQLITE_API void sqlite3_result_blob(
8411084546
sqlite3_context *pCtx,
8411184547
const void *z,
@@ -85083,11 +85519,11 @@
8508385519
*/
8508485520
static int bindText(
8508585521
sqlite3_stmt *pStmt, /* The statement to bind against */
8508685522
int i, /* Index of the parameter to bind */
8508785523
const void *zData, /* Pointer to the data to be bound */
85088
- int nData, /* Number of bytes of data to be bound */
85524
+ i64 nData, /* Number of bytes of data to be bound */
8508985525
void (*xDel)(void*), /* Destructor for the data */
8509085526
u8 encoding /* Encoding for the data */
8509185527
){
8509285528
Vdbe *p = (Vdbe *)pStmt;
8509385529
Mem *pVar;
@@ -85135,15 +85571,11 @@
8513585571
const void *zData,
8513685572
sqlite3_uint64 nData,
8513785573
void (*xDel)(void*)
8513885574
){
8513985575
assert( xDel!=SQLITE_DYNAMIC );
85140
- if( nData>0x7fffffff ){
85141
- return invokeValueDestructor(zData, xDel, 0);
85142
- }else{
85143
- return bindText(pStmt, i, zData, (int)nData, xDel, 0);
85144
- }
85576
+ return bindText(pStmt, i, zData, nData, xDel, 0);
8514585577
}
8514685578
SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
8514785579
int rc;
8514885580
Vdbe *p = (Vdbe *)pStmt;
8514985581
rc = vdbeUnbind(p, i);
@@ -85209,16 +85641,12 @@
8520985641
sqlite3_uint64 nData,
8521085642
void (*xDel)(void*),
8521185643
unsigned char enc
8521285644
){
8521385645
assert( xDel!=SQLITE_DYNAMIC );
85214
- if( nData>0x7fffffff ){
85215
- return invokeValueDestructor(zData, xDel, 0);
85216
- }else{
85217
- if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
85218
- return bindText(pStmt, i, zData, (int)nData, xDel, enc);
85219
- }
85646
+ if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
85647
+ return bindText(pStmt, i, zData, nData, xDel, enc);
8522085648
}
8522185649
#ifndef SQLITE_OMIT_UTF16
8522285650
SQLITE_API int sqlite3_bind_text16(
8522385651
sqlite3_stmt *pStmt,
8522485652
int i,
@@ -85613,10 +86041,21 @@
8561386041
SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){
8561486042
PreUpdate *p = db->pPreUpdate;
8561586043
return (p ? p->v->nFrame : 0);
8561686044
}
8561786045
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
86046
+
86047
+#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
86048
+/*
86049
+** This function is designed to be called from within a pre-update callback
86050
+** only.
86051
+*/
86052
+SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){
86053
+ PreUpdate *p = db->pPreUpdate;
86054
+ return (p ? p->iBlobWrite : -1);
86055
+}
86056
+#endif
8561886057
8561986058
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
8562086059
/*
8562186060
** This function is called from within a pre-update callback to retrieve
8562286061
** a field of the row currently being updated or inserted.
@@ -86235,22 +86674,40 @@
8623586674
assert( iCur>=0 && iCur<p->nCursor );
8623686675
if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/
8623786676
sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);
8623886677
p->apCsr[iCur] = 0;
8623986678
}
86240
- if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){
86241
- p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;
86242
- memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));
86243
- pCx->eCurType = eCurType;
86244
- pCx->iDb = iDb;
86245
- pCx->nField = nField;
86246
- pCx->aOffset = &pCx->aType[nField];
86247
- if( eCurType==CURTYPE_BTREE ){
86248
- pCx->uc.pCursor = (BtCursor*)
86249
- &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];
86250
- sqlite3BtreeCursorZero(pCx->uc.pCursor);
86251
- }
86679
+
86680
+ /* There used to be a call to sqlite3VdbeMemClearAndResize() to make sure
86681
+ ** the pMem used to hold space for the cursor has enough storage available
86682
+ ** in pMem->zMalloc. But for the special case of the aMem[] entries used
86683
+ ** to hold cursors, it is faster to in-line the logic. */
86684
+ assert( pMem->flags==MEM_Undefined );
86685
+ assert( (pMem->flags & MEM_Dyn)==0 );
86686
+ assert( pMem->szMalloc==0 || pMem->z==pMem->zMalloc );
86687
+ if( pMem->szMalloc<nByte ){
86688
+ if( pMem->szMalloc>0 ){
86689
+ sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
86690
+ }
86691
+ pMem->z = pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, nByte);
86692
+ if( pMem->zMalloc==0 ){
86693
+ pMem->szMalloc = 0;
86694
+ return 0;
86695
+ }
86696
+ pMem->szMalloc = nByte;
86697
+ }
86698
+
86699
+ p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->zMalloc;
86700
+ memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));
86701
+ pCx->eCurType = eCurType;
86702
+ pCx->iDb = iDb;
86703
+ pCx->nField = nField;
86704
+ pCx->aOffset = &pCx->aType[nField];
86705
+ if( eCurType==CURTYPE_BTREE ){
86706
+ pCx->uc.pCursor = (BtCursor*)
86707
+ &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];
86708
+ sqlite3BtreeCursorZero(pCx->uc.pCursor);
8625286709
}
8625386710
return pCx;
8625486711
}
8625586712
8625686713
/*
@@ -86393,11 +86850,14 @@
8639386850
static u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){
8639486851
int rc;
8639586852
sqlite3_int64 ix;
8639686853
assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal))==0 );
8639786854
assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 );
86398
- ExpandBlob(pMem);
86855
+ if( ExpandBlob(pMem) ){
86856
+ pMem->u.i = 0;
86857
+ return MEM_Int;
86858
+ }
8639986859
rc = sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc);
8640086860
if( rc<=0 ){
8640186861
if( rc==0 && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1 ){
8640286862
pMem->u.i = ix;
8640386863
return MEM_Int;
@@ -86530,10 +86990,15 @@
8653086990
if( p->pScopyFrom ){
8653186991
printf(" <== R[%d]", (int)(p->pScopyFrom - &p[-iReg]));
8653286992
}
8653386993
printf("\n");
8653486994
sqlite3VdbeCheckMemInvariants(p);
86995
+}
86996
+/**/ void sqlite3PrintMem(Mem *pMem){
86997
+ memTracePrint(pMem);
86998
+ printf("\n");
86999
+ fflush(stdout);
8653587000
}
8653687001
#endif
8653787002
8653887003
#ifdef SQLITE_DEBUG
8653987004
/*
@@ -88067,10 +88532,35 @@
8806788532
8806888533
pIn1 = &aMem[pOp->p1];
8806988534
pIn3 = &aMem[pOp->p3];
8807088535
flags1 = pIn1->flags;
8807188536
flags3 = pIn3->flags;
88537
+ if( (flags1 & flags3 & MEM_Int)!=0 ){
88538
+ assert( (pOp->p5 & SQLITE_AFF_MASK)!=SQLITE_AFF_TEXT || CORRUPT_DB );
88539
+ /* Common case of comparison of two integers */
88540
+ if( pIn3->u.i > pIn1->u.i ){
88541
+ iCompare = +1;
88542
+ if( sqlite3aGTb[pOp->opcode] ){
88543
+ VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88544
+ goto jump_to_p2;
88545
+ }
88546
+ }else if( pIn3->u.i < pIn1->u.i ){
88547
+ iCompare = -1;
88548
+ if( sqlite3aLTb[pOp->opcode] ){
88549
+ VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88550
+ goto jump_to_p2;
88551
+ }
88552
+ }else{
88553
+ iCompare = 0;
88554
+ if( sqlite3aEQb[pOp->opcode] ){
88555
+ VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88556
+ goto jump_to_p2;
88557
+ }
88558
+ }
88559
+ VdbeBranchTaken(0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88560
+ break;
88561
+ }
8807288562
if( (flags1 | flags3)&MEM_Null ){
8807388563
/* One or both operands are NULL */
8807488564
if( pOp->p5 & SQLITE_NULLEQ ){
8807588565
/* If SQLITE_NULLEQ is set (which will only happen if the operator is
8807688566
** OP_Eq or OP_Ne) then take the jump or not depending on whether
@@ -88097,11 +88587,12 @@
8809788587
goto jump_to_p2;
8809888588
}
8809988589
break;
8810088590
}
8810188591
}else{
88102
- /* Neither operand is NULL. Do a comparison. */
88592
+ /* Neither operand is NULL and we couldn't do the special high-speed
88593
+ ** integer comparison case. So do a general-case comparison. */
8810388594
affinity = pOp->p5 & SQLITE_AFF_MASK;
8810488595
if( affinity>=SQLITE_AFF_NUMERIC ){
8810588596
if( (flags1 | flags3)&MEM_Str ){
8810688597
if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
8810788598
applyNumericAffinity(pIn1,0);
@@ -88110,18 +88601,10 @@
8811088601
}
8811188602
if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
8811288603
applyNumericAffinity(pIn3,0);
8811388604
}
8811488605
}
88115
- /* Handle the common case of integer comparison here, as an
88116
- ** optimization, to avoid a call to sqlite3MemCompare() */
88117
- if( (pIn1->flags & pIn3->flags & MEM_Int)!=0 ){
88118
- if( pIn3->u.i > pIn1->u.i ){ res = +1; goto compare_op; }
88119
- if( pIn3->u.i < pIn1->u.i ){ res = -1; goto compare_op; }
88120
- res = 0;
88121
- goto compare_op;
88122
- }
8812388606
}else if( affinity==SQLITE_AFF_TEXT ){
8812488607
if( (flags1 & MEM_Str)==0 && (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
8812588608
testcase( pIn1->flags & MEM_Int );
8812688609
testcase( pIn1->flags & MEM_Real );
8812788610
testcase( pIn1->flags & MEM_IntReal );
@@ -88140,11 +88623,11 @@
8814088623
}
8814188624
}
8814288625
assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
8814388626
res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
8814488627
}
88145
-compare_op:
88628
+
8814688629
/* At this point, res is negative, zero, or positive if reg[P1] is
8814788630
** less than, equal to, or greater than reg[P3], respectively. Compute
8814888631
** the answer to this operator in res2, depending on what the comparison
8814988632
** operator actually is. The next block of code depends on the fact
8815088633
** that the 6 comparison operators are consecutive integers in this
@@ -90581,12 +91064,22 @@
9058191064
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
9058291065
pC = p->apCsr[pOp->p1];
9058391066
assert( pC!=0 );
9058491067
assert( pOp->p3>=pOp->p2 );
9058591068
if( pC->seekHit<pOp->p2 ){
91069
+#ifdef SQLITE_DEBUG
91070
+ if( db->flags&SQLITE_VdbeTrace ){
91071
+ printf("seekHit changes from %d to %d\n", pC->seekHit, pOp->p2);
91072
+ }
91073
+#endif
9058691074
pC->seekHit = pOp->p2;
9058791075
}else if( pC->seekHit>pOp->p3 ){
91076
+#ifdef SQLITE_DEBUG
91077
+ if( db->flags&SQLITE_VdbeTrace ){
91078
+ printf("seekHit changes from %d to %d\n", pC->seekHit, pOp->p3);
91079
+ }
91080
+#endif
9058891081
pC->seekHit = pOp->p3;
9058991082
}
9059091083
break;
9059191084
}
9059291085
@@ -90697,10 +91190,15 @@
9069791190
case OP_IfNoHope: { /* jump, in3 */
9069891191
VdbeCursor *pC;
9069991192
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
9070091193
pC = p->apCsr[pOp->p1];
9070191194
assert( pC!=0 );
91195
+#ifdef SQLITE_DEBUG
91196
+ if( db->flags&SQLITE_VdbeTrace ){
91197
+ printf("seekHit is %d\n", pC->seekHit);
91198
+ }
91199
+#endif
9070291200
if( pC->seekHit>=pOp->p4.i ) break;
9070391201
/* Fall through into OP_NotFound */
9070491202
/* no break */ deliberate_fall_through
9070591203
}
9070691204
case OP_NoConflict: /* jump, in3 */
@@ -91126,11 +91624,11 @@
9112691624
9112791625
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
9112891626
/* Invoke the pre-update hook, if any */
9112991627
if( pTab ){
9113091628
if( db->xPreUpdateCallback && !(pOp->p5 & OPFLAG_ISUPDATE) ){
91131
- sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey,pOp->p2);
91629
+ sqlite3VdbePreUpdateHook(p,pC,SQLITE_INSERT,zDb,pTab,x.nKey,pOp->p2,-1);
9113291630
}
9113391631
if( db->xUpdateCallback==0 || pTab->aCol==0 ){
9113491632
/* Prevent post-update hook from running in cases when it should not */
9113591633
pTab = 0;
9113691634
}
@@ -91286,11 +91784,11 @@
9128691784
|| (aMem[pOp->p3].flags & MEM_Int)
9128791785
);
9128891786
sqlite3VdbePreUpdateHook(p, pC,
9128991787
(opflags & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_DELETE,
9129091788
zDb, pTab, pC->movetoTarget,
91291
- pOp->p3
91789
+ pOp->p3, -1
9129291790
);
9129391791
}
9129491792
if( opflags & OPFLAG_ISNOOP ) break;
9129591793
#endif
9129691794
@@ -92232,15 +92730,14 @@
9223292730
**
9223392731
** The table being clear is in the main database file if P2==0. If
9223492732
** P2==1 then the table to be clear is in the auxiliary database file
9223592733
** that is used to store tables create using CREATE TEMPORARY TABLE.
9223692734
**
92237
-** If the P3 value is non-zero, then the table referred to must be an
92238
-** intkey table (an SQL table, not an index). In this case the row change
92239
-** count is incremented by the number of rows in the table being cleared.
92240
-** If P3 is greater than zero, then the value stored in register P3 is
92241
-** also incremented by the number of rows in the table being cleared.
92735
+** If the P3 value is non-zero, then the row change count is incremented
92736
+** by the number of rows in the table being cleared. If P3 is greater
92737
+** than zero, then the value stored in register P3 is also incremented
92738
+** by the number of rows in the table being cleared.
9224292739
**
9224392740
** See also: Destroy
9224492741
*/
9224592742
case OP_Clear: {
9224692743
int nChange;
@@ -92247,13 +92744,11 @@
9224792744
9224892745
sqlite3VdbeIncrWriteCounter(p, 0);
9224992746
nChange = 0;
9225092747
assert( p->readOnly==0 );
9225192748
assert( DbMaskTest(p->btreeMask, pOp->p2) );
92252
- rc = sqlite3BtreeClearTable(
92253
- db->aDb[pOp->p2].pBt, (u32)pOp->p1, (pOp->p3 ? &nChange : 0)
92254
- );
92749
+ rc = sqlite3BtreeClearTable(db->aDb[pOp->p2].pBt, (u32)pOp->p1, &nChange);
9225592750
if( pOp->p3 ){
9225692751
p->nChange += nChange;
9225792752
if( pOp->p3>0 ){
9225892753
assert( memIsValid(&aMem[pOp->p3]) );
9225992754
memAboutToChange(p, &aMem[pOp->p3]);
@@ -92355,11 +92850,13 @@
9235592850
}
9235692851
#endif
9235792852
9235892853
iDb = pOp->p1;
9235992854
assert( iDb>=0 && iDb<db->nDb );
92360
- assert( DbHasProperty(db, iDb, DB_SchemaLoaded) );
92855
+ assert( DbHasProperty(db, iDb, DB_SchemaLoaded)
92856
+ || db->mallocFailed
92857
+ || (CORRUPT_DB && (db->flags & SQLITE_NoSchemaError)!=0) );
9236192858
9236292859
#ifndef SQLITE_OMIT_ALTERTABLE
9236392860
if( pOp->p4.z==0 ){
9236492861
sqlite3SchemaClear(db->aDb[iDb].pSchema);
9236592862
db->mDbFlags &= ~DBFLAG_SchemaKnownOk;
@@ -93237,10 +93734,11 @@
9323793734
9323893735
pBt = db->aDb[pOp->p1].pBt;
9323993736
pPager = sqlite3BtreePager(pBt);
9324093737
eOld = sqlite3PagerGetJournalMode(pPager);
9324193738
if( eNew==PAGER_JOURNALMODE_QUERY ) eNew = eOld;
93739
+ assert( sqlite3BtreeHoldsMutex(pBt) );
9324293740
if( !sqlite3PagerOkToChangeJournalMode(pPager) ) eNew = eOld;
9324393741
9324493742
#ifndef SQLITE_OMIT_WAL
9324593743
zFilename = sqlite3PagerFilename(pPager, 1);
9324693744
@@ -94715,11 +95213,11 @@
9471595213
** anyhow.
9471695214
*/
9471795215
sqlite3_int64 iKey;
9471895216
iKey = sqlite3BtreeIntegerKey(p->pCsr);
9471995217
sqlite3VdbePreUpdateHook(
94720
- v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1
95218
+ v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1, p->iCol
9472195219
);
9472295220
}
9472395221
#endif
9472495222
9472595223
rc = xCall(p->pCsr, iOffset+p->iOffset, n, z);
@@ -94786,10 +95284,11 @@
9478695284
** already been invalidated. Return SQLITE_ABORT in this case.
9478795285
*/
9478895286
rc = SQLITE_ABORT;
9478995287
}else{
9479095288
char *zErr;
95289
+ ((Vdbe*)p->pStmt)->rc = SQLITE_OK;
9479195290
rc = blobSeekToRow(p, iRow, &zErr);
9479295291
if( rc!=SQLITE_OK ){
9479395292
sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr);
9479495293
sqlite3DbFree(db, zErr);
9479595294
}
@@ -98256,30 +98755,32 @@
9825698755
/*
9825798756
** Truncate the in-memory file.
9825898757
*/
9825998758
static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){
9826098759
MemJournal *p = (MemJournal *)pJfd;
98261
- FileChunk *pIter = 0;
98262
-
98263
- if( size==0 ){
98264
- memjrnlFreeChunks(p->pFirst);
98265
- p->pFirst = 0;
98266
- }else{
98267
- i64 iOff = p->nChunkSize;
98268
- for(pIter=p->pFirst; ALWAYS(pIter) && iOff<=size; pIter=pIter->pNext){
98269
- iOff += p->nChunkSize;
98270
- }
98271
- if( ALWAYS(pIter) ){
98272
- memjrnlFreeChunks(pIter->pNext);
98273
- pIter->pNext = 0;
98274
- }
98275
- }
98276
-
98277
- p->endpoint.pChunk = pIter;
98278
- p->endpoint.iOffset = size;
98279
- p->readpoint.pChunk = 0;
98280
- p->readpoint.iOffset = 0;
98760
+ assert( p->endpoint.pChunk==0 || p->endpoint.pChunk->pNext==0 );
98761
+ if( size<p->endpoint.iOffset ){
98762
+ FileChunk *pIter = 0;
98763
+ if( size==0 ){
98764
+ memjrnlFreeChunks(p->pFirst);
98765
+ p->pFirst = 0;
98766
+ }else{
98767
+ i64 iOff = p->nChunkSize;
98768
+ for(pIter=p->pFirst; ALWAYS(pIter) && iOff<=size; pIter=pIter->pNext){
98769
+ iOff += p->nChunkSize;
98770
+ }
98771
+ if( ALWAYS(pIter) ){
98772
+ memjrnlFreeChunks(pIter->pNext);
98773
+ pIter->pNext = 0;
98774
+ }
98775
+ }
98776
+
98777
+ p->endpoint.pChunk = pIter;
98778
+ p->endpoint.iOffset = size;
98779
+ p->readpoint.pChunk = 0;
98780
+ p->readpoint.iOffset = 0;
98781
+ }
9828198782
return SQLITE_OK;
9828298783
}
9828398784
9828498785
/*
9828598786
** Close the file.
@@ -98468,19 +98969,14 @@
9846898969
if( rc ) return WRC_Abort;
9846998970
rc = sqlite3WalkExprList(pWalker, pWin->pPartition);
9847098971
if( rc ) return WRC_Abort;
9847198972
rc = sqlite3WalkExpr(pWalker, pWin->pFilter);
9847298973
if( rc ) return WRC_Abort;
98473
-
98474
- /* The next two are purely for calls to sqlite3RenameExprUnmap()
98475
- ** within sqlite3WindowOffsetExpr(). Because of constraints imposed
98476
- ** by sqlite3WindowOffsetExpr(), they can never fail. The results do
98477
- ** not matter anyhow. */
9847898974
rc = sqlite3WalkExpr(pWalker, pWin->pStart);
98479
- if( NEVER(rc) ) return WRC_Abort;
98975
+ if( rc ) return WRC_Abort;
9848098976
rc = sqlite3WalkExpr(pWalker, pWin->pEnd);
98481
- if( NEVER(rc) ) return WRC_Abort;
98977
+ if( rc ) return WRC_Abort;
9848298978
if( bOneOnly ) break;
9848398979
}
9848498980
return WRC_Continue;
9848598981
}
9848698982
#endif
@@ -98552,10 +99048,20 @@
9855299048
if( sqlite3WalkExpr(pWalker, pItem->pExpr) ) return WRC_Abort;
9855399049
}
9855499050
}
9855599051
return WRC_Continue;
9855699052
}
99053
+
99054
+/*
99055
+** This is a no-op callback for Walker->xSelectCallback2. If this
99056
+** callback is set, then the Select->pWinDefn list is traversed.
99057
+*/
99058
+SQLITE_PRIVATE void sqlite3WalkWinDefnDummyCallback(Walker *pWalker, Select *p){
99059
+ UNUSED_PARAMETER(pWalker);
99060
+ UNUSED_PARAMETER(p);
99061
+ /* No-op */
99062
+}
9855799063
9855899064
/*
9855999065
** Walk all expressions associated with SELECT statement p. Do
9856099066
** not invoke the SELECT callback on p, but do (of course) invoke
9856199067
** any expr callbacks and SELECT callbacks that come from subqueries.
@@ -98566,14 +99072,19 @@
9856699072
if( sqlite3WalkExpr(pWalker, p->pWhere) ) return WRC_Abort;
9856799073
if( sqlite3WalkExprList(pWalker, p->pGroupBy) ) return WRC_Abort;
9856899074
if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort;
9856999075
if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort;
9857099076
if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort;
98571
-#if !defined(SQLITE_OMIT_WINDOWFUNC) && !defined(SQLITE_OMIT_ALTERTABLE)
98572
- {
98573
- Parse *pParse = pWalker->pParse;
98574
- if( pParse && IN_RENAME_OBJECT ){
99077
+#if !defined(SQLITE_OMIT_WINDOWFUNC)
99078
+ if( p->pWinDefn ){
99079
+ Parse *pParse;
99080
+ if( pWalker->xSelectCallback2==sqlite3WalkWinDefnDummyCallback
99081
+ || ((pParse = pWalker->pParse)!=0 && IN_RENAME_OBJECT)
99082
+#ifndef SQLITE_OMIT_CTE
99083
+ || pWalker->xSelectCallback2==sqlite3SelectPopWith
99084
+#endif
99085
+ ){
9857599086
/* The following may return WRC_Abort if there are unresolvable
9857699087
** symbols (e.g. a table that does not exist) in a window definition. */
9857799088
int rc = walkWindowList(pWalker, p->pWinDefn, 0);
9857899089
return rc;
9857999090
}
@@ -98593,11 +99104,11 @@
9859399104
SrcList *pSrc;
9859499105
int i;
9859599106
SrcItem *pItem;
9859699107
9859799108
pSrc = p->pSrc;
98598
- if( pSrc ){
99109
+ if( ALWAYS(pSrc) ){
9859999110
for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){
9860099111
if( pItem->pSelect && sqlite3WalkSelect(pWalker, pItem->pSelect) ){
9860199112
return WRC_Abort;
9860299113
}
9860399114
if( pItem->fg.isTabFunc
@@ -98767,11 +99278,14 @@
9876799278
assert( iCol>=0 && iCol<pEList->nExpr );
9876899279
pOrig = pEList->a[iCol].pExpr;
9876999280
assert( pOrig!=0 );
9877099281
db = pParse->db;
9877199282
pDup = sqlite3ExprDup(db, pOrig, 0);
98772
- if( pDup!=0 ){
99283
+ if( db->mallocFailed ){
99284
+ sqlite3ExprDelete(db, pDup);
99285
+ pDup = 0;
99286
+ }else{
9877399287
incrAggFunctionDepth(pDup, nSubquery);
9877499288
if( pExpr->op==TK_COLLATE ){
9877599289
pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken);
9877699290
}
9877799291
@@ -98789,14 +99303,12 @@
9878999303
assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );
9879099304
pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);
9879199305
pExpr->flags |= EP_MemToken;
9879299306
}
9879399307
if( ExprHasProperty(pExpr, EP_WinFunc) ){
98794
- if( pExpr->y.pWin!=0 ){
99308
+ if( ALWAYS(pExpr->y.pWin!=0) ){
9879599309
pExpr->y.pWin->pOwner = pExpr;
98796
- }else{
98797
- assert( db->mallocFailed );
9879899310
}
9879999311
}
9880099312
sqlite3DbFree(db, pDup);
9880199313
}
9880299314
}
@@ -99184,12 +99696,12 @@
9918499696
** or HAVING clauses, or as part of a larger expression in the ORDER BY
9918599697
** clause is not standard SQL. This is a (goofy) SQLite extension, that
9918699698
** is supported for backwards compatibility only. Hence, we issue a warning
9918799699
** on sqlite3_log() whenever the capability is used.
9918899700
*/
99189
- if( (pNC->ncFlags & NC_UEList)!=0
99190
- && cnt==0
99701
+ if( cnt==0
99702
+ && (pNC->ncFlags & NC_UEList)!=0
9919199703
&& zTab==0
9919299704
){
9919399705
pEList = pNC->uNC.pEList;
9919499706
assert( pEList!=0 );
9919599707
for(j=0; j<pEList->nExpr; j++){
@@ -99293,11 +99805,11 @@
9929399805
sqlite3ErrorMsg(pParse, "%s: %s.%s", zErr, zTab, zCol);
9929499806
}else{
9929599807
sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol);
9929699808
}
9929799809
pParse->checkSchema = 1;
99298
- pTopNC->nErr++;
99810
+ pTopNC->nNcErr++;
9929999811
}
9930099812
9930199813
/* If a column from a table in pSrcList is referenced, then record
9930299814
** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes
9930399815
** bit 0 to be set. Column 1 sets bit 1. And so forth. Bit 63 is
@@ -99600,11 +100112,11 @@
99600100112
pExpr->iTable = exprProbability(pList->a[1].pExpr);
99601100113
if( pExpr->iTable<0 ){
99602100114
sqlite3ErrorMsg(pParse,
99603100115
"second argument to likelihood() must be a "
99604100116
"constant between 0.0 and 1.0");
99605
- pNC->nErr++;
100117
+ pNC->nNcErr++;
99606100118
}
99607100119
}else{
99608100120
/* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is
99609100121
** equivalent to likelihood(X, 0.0625).
99610100122
** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is
@@ -99622,11 +100134,11 @@
99622100134
int auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0,pDef->zName,0);
99623100135
if( auth!=SQLITE_OK ){
99624100136
if( auth==SQLITE_DENY ){
99625100137
sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
99626100138
pDef->zName);
99627
- pNC->nErr++;
100139
+ pNC->nNcErr++;
99628100140
}
99629100141
pExpr->op = TK_NULL;
99630100142
return WRC_Prune;
99631100143
}
99632100144
}
@@ -99678,11 +100190,11 @@
99678100190
);
99679100191
if( pDef && pDef->xValue==0 && pWin ){
99680100192
sqlite3ErrorMsg(pParse,
99681100193
"%.*s() may not be used as a window function", nId, zId
99682100194
);
99683
- pNC->nErr++;
100195
+ pNC->nNcErr++;
99684100196
}else if(
99685100197
(is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
99686100198
|| (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !pWin)
99687100199
|| (is_agg && pWin && (pNC->ncFlags & NC_AllowWin)==0)
99688100200
){
@@ -99691,39 +100203,39 @@
99691100203
zType = "window";
99692100204
}else{
99693100205
zType = "aggregate";
99694100206
}
99695100207
sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
99696
- pNC->nErr++;
100208
+ pNC->nNcErr++;
99697100209
is_agg = 0;
99698100210
}
99699100211
#else
99700100212
if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){
99701100213
sqlite3ErrorMsg(pParse,"misuse of aggregate function %.*s()",nId,zId);
99702
- pNC->nErr++;
100214
+ pNC->nNcErr++;
99703100215
is_agg = 0;
99704100216
}
99705100217
#endif
99706100218
else if( no_such_func && pParse->db->init.busy==0
99707100219
#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
99708100220
&& pParse->explain==0
99709100221
#endif
99710100222
){
99711100223
sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
99712
- pNC->nErr++;
100224
+ pNC->nNcErr++;
99713100225
}else if( wrong_num_args ){
99714100226
sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
99715100227
nId, zId);
99716
- pNC->nErr++;
100228
+ pNC->nNcErr++;
99717100229
}
99718100230
#ifndef SQLITE_OMIT_WINDOWFUNC
99719100231
else if( is_agg==0 && ExprHasProperty(pExpr, EP_WinFunc) ){
99720100232
sqlite3ErrorMsg(pParse,
99721100233
"FILTER may not be used with non-aggregate %.*s()",
99722100234
nId, zId
99723100235
);
99724
- pNC->nErr++;
100236
+ pNC->nNcErr++;
99725100237
}
99726100238
#endif
99727100239
if( is_agg ){
99728100240
/* Window functions may not be arguments of aggregate functions.
99729100241
** Or arguments of other window functions. But aggregate functions
@@ -99943,15 +100455,15 @@
99943100455
*/
99944100456
memset(&nc, 0, sizeof(nc));
99945100457
nc.pParse = pParse;
99946100458
nc.pSrcList = pSelect->pSrc;
99947100459
nc.uNC.pEList = pEList;
99948
- nc.ncFlags = NC_AllowAgg|NC_UEList;
99949
- nc.nErr = 0;
100460
+ nc.ncFlags = NC_AllowAgg|NC_UEList|NC_NoSelect;
100461
+ nc.nNcErr = 0;
99950100462
db = pParse->db;
99951100463
savedSuppErr = db->suppressErr;
99952
- if( IN_RENAME_OBJECT==0 ) db->suppressErr = 1;
100464
+ db->suppressErr = 1;
99953100465
rc = sqlite3ResolveExprNames(&nc, pE);
99954100466
db->suppressErr = savedSuppErr;
99955100467
if( rc ) return 0;
99956100468
99957100469
/* Try to match the ORDER BY expression against an expression
@@ -100046,33 +100558,28 @@
100046100558
** expression, resolving any symbols in it, and then comparing
100047100559
** it against each expression returned by the SELECT statement.
100048100560
** Once the comparisons are finished, the duplicate expression
100049100561
** is deleted.
100050100562
**
100051
- ** Or, if this is running as part of an ALTER TABLE operation,
100052
- ** resolve the symbols in the actual expression, not a duplicate.
100053
- ** And, if one of the comparisons is successful, leave the expression
100054
- ** as is instead of transforming it to an integer as in the usual
100055
- ** case. This allows the code in alter.c to modify column
100056
- ** refererences within the ORDER BY expression as required. */
100057
- if( IN_RENAME_OBJECT ){
100058
- pDup = pE;
100059
- }else{
100060
- pDup = sqlite3ExprDup(db, pE, 0);
100061
- }
100563
+ ** If this is running as part of an ALTER TABLE operation and
100564
+ ** the symbols resolve successfully, also resolve the symbols in the
100565
+ ** actual expression. This allows the code in alter.c to modify
100566
+ ** column references within the ORDER BY expression as required. */
100567
+ pDup = sqlite3ExprDup(db, pE, 0);
100062100568
if( !db->mallocFailed ){
100063100569
assert(pDup);
100064100570
iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup);
100571
+ if( IN_RENAME_OBJECT && iCol>0 ){
100572
+ resolveOrderByTermToExprList(pParse, pSelect, pE);
100573
+ }
100065100574
}
100066
- if( !IN_RENAME_OBJECT ){
100067
- sqlite3ExprDelete(db, pDup);
100068
- }
100575
+ sqlite3ExprDelete(db, pDup);
100069100576
}
100070100577
}
100071100578
if( iCol>0 ){
100072100579
/* Convert the ORDER BY term into an integer column number iCol,
100073
- ** taking care to preserve the COLLATE clause if it exists */
100580
+ ** taking care to preserve the COLLATE clause if it exists. */
100074100581
if( !IN_RENAME_OBJECT ){
100075100582
Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);
100076100583
if( pNew==0 ) return 1;
100077100584
pNew->flags |= EP_IntValue;
100078100585
pNew->u.iValue = iCol;
@@ -100203,11 +100710,11 @@
100203100710
int iCol; /* Column number */
100204100711
struct ExprList_item *pItem; /* A term of the ORDER BY clause */
100205100712
Parse *pParse; /* Parsing context */
100206100713
int nResult; /* Number of terms in the result set */
100207100714
100208
- if( pOrderBy==0 ) return 0;
100715
+ assert( pOrderBy!=0 );
100209100716
nResult = pSelect->pEList->nExpr;
100210100717
pParse = pNC->pParse;
100211100718
for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){
100212100719
Expr *pE = pItem->pExpr;
100213100720
Expr *pE2 = sqlite3ExprSkipCollateAndLikely(pE);
@@ -100293,11 +100800,13 @@
100293100800
nCompound = 0;
100294100801
pLeftmost = p;
100295100802
while( p ){
100296100803
assert( (p->selFlags & SF_Expanded)!=0 );
100297100804
assert( (p->selFlags & SF_Resolved)==0 );
100805
+ assert( db->suppressErr==0 ); /* SF_Resolved not set if errors suppressed */
100298100806
p->selFlags |= SF_Resolved;
100807
+
100299100808
100300100809
/* Resolve the expressions in the LIMIT and OFFSET clauses. These
100301100810
** are not allowed to refer to any names, so pass an empty NameContext.
100302100811
*/
100303100812
memset(&sNC, 0, sizeof(sNC));
@@ -100368,17 +100877,10 @@
100368100877
p->selFlags |= SF_Aggregate | (sNC.ncFlags&NC_MinMaxAgg);
100369100878
}else{
100370100879
sNC.ncFlags &= ~NC_AllowAgg;
100371100880
}
100372100881
100373
- /* If a HAVING clause is present, then there must be a GROUP BY clause.
100374
- */
100375
- if( p->pHaving && !pGroupBy ){
100376
- sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING");
100377
- return WRC_Abort;
100378
- }
100379
-
100380100882
/* Add the output column list to the name-context before parsing the
100381100883
** other expressions in the SELECT statement. This is so that
100382100884
** expressions in the WHERE clause (etc.) can refer to expressions by
100383100885
** aliases in the result set.
100384100886
**
@@ -100386,11 +100888,17 @@
100386100888
** re-evaluated for each reference to it.
100387100889
*/
100388100890
assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert|NC_UBaseReg))==0 );
100389100891
sNC.uNC.pEList = p->pEList;
100390100892
sNC.ncFlags |= NC_UEList;
100391
- if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
100893
+ if( p->pHaving ){
100894
+ if( !pGroupBy ){
100895
+ sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING");
100896
+ return WRC_Abort;
100897
+ }
100898
+ if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
100899
+ }
100392100900
if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;
100393100901
100394100902
/* Resolve names in table-valued-function arguments */
100395100903
for(i=0; i<p->pSrc->nSrc; i++){
100396100904
SrcItem *pItem = &p->pSrc->a[i];
@@ -100398,10 +100906,23 @@
100398100906
&& sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg)
100399100907
){
100400100908
return WRC_Abort;
100401100909
}
100402100910
}
100911
+
100912
+#ifndef SQLITE_OMIT_WINDOWFUNC
100913
+ if( IN_RENAME_OBJECT ){
100914
+ Window *pWin;
100915
+ for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){
100916
+ if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy)
100917
+ || sqlite3ResolveExprListNames(&sNC, pWin->pPartition)
100918
+ ){
100919
+ return WRC_Abort;
100920
+ }
100921
+ }
100922
+ }
100923
+#endif
100403100924
100404100925
/* The ORDER BY and GROUP BY clauses may not refer to terms in
100405100926
** outer queries
100406100927
*/
100407100928
sNC.pNext = 0;
@@ -100426,11 +100947,12 @@
100426100947
** If there is an ORDER BY clause on a term of a compound-select other
100427100948
** than the right-most term, then that is a syntax error. But the error
100428100949
** is not detected until much later, and so we need to go ahead and
100429100950
** resolve those symbols on the incorrect ORDER BY for consistency.
100430100951
*/
100431
- if( isCompound<=nCompound /* Defer right-most ORDER BY of a compound */
100952
+ if( p->pOrderBy!=0
100953
+ && isCompound<=nCompound /* Defer right-most ORDER BY of a compound */
100432100954
&& resolveOrderGroupBy(&sNC, p, p->pOrderBy, "ORDER")
100433100955
){
100434100956
return WRC_Abort;
100435100957
}
100436100958
if( db->mallocFailed ){
@@ -100454,23 +100976,10 @@
100454100976
return WRC_Abort;
100455100977
}
100456100978
}
100457100979
}
100458100980
100459
-#ifndef SQLITE_OMIT_WINDOWFUNC
100460
- if( IN_RENAME_OBJECT ){
100461
- Window *pWin;
100462
- for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){
100463
- if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy)
100464
- || sqlite3ResolveExprListNames(&sNC, pWin->pPartition)
100465
- ){
100466
- return WRC_Abort;
100467
- }
100468
- }
100469
- }
100470
-#endif
100471
-
100472100981
/* If this is part of a compound SELECT, check that it has the right
100473100982
** number of expressions in the select list. */
100474100983
if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){
100475100984
sqlite3SelectWrongNumTermsError(pParse, p->pNext);
100476100985
return WRC_Abort;
@@ -100550,11 +101059,11 @@
100550101059
if( pExpr==0 ) return SQLITE_OK;
100551101060
savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
100552101061
pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
100553101062
w.pParse = pNC->pParse;
100554101063
w.xExprCallback = resolveExprStep;
100555
- w.xSelectCallback = resolveSelectStep;
101064
+ w.xSelectCallback = (pNC->ncFlags & NC_NoSelect) ? 0 : resolveSelectStep;
100556101065
w.xSelectCallback2 = 0;
100557101066
w.u.pNC = pNC;
100558101067
#if SQLITE_MAX_EXPR_DEPTH>0
100559101068
w.pParse->nHeight += pExpr->nHeight;
100560101069
if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){
@@ -100569,11 +101078,11 @@
100569101078
assert( EP_Win==NC_HasWin );
100570101079
testcase( pNC->ncFlags & NC_HasAgg );
100571101080
testcase( pNC->ncFlags & NC_HasWin );
100572101081
ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) );
100573101082
pNC->ncFlags |= savedHasAgg;
100574
- return pNC->nErr>0 || w.pParse->nErr>0;
101083
+ return pNC->nNcErr>0 || w.pParse->nErr>0;
100575101084
}
100576101085
100577101086
/*
100578101087
** Resolve all names for all expression in an expression list. This is
100579101088
** just like sqlite3ResolveExprNames() except that it works for an expression
@@ -100614,11 +101123,11 @@
100614101123
if( pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin) ){
100615101124
ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) );
100616101125
savedHasAgg |= pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
100617101126
pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
100618101127
}
100619
- if( pNC->nErr>0 || w.pParse->nErr>0 ) return WRC_Abort;
101128
+ if( w.pParse->nErr>0 ) return WRC_Abort;
100620101129
}
100621101130
pNC->ncFlags |= savedHasAgg;
100622101131
return WRC_Continue;
100623101132
}
100624101133
@@ -100757,27 +101266,27 @@
100757101266
|| (pExpr->op==TK_REGISTER && pExpr->op2==TK_IF_NULL_ROW) );
100758101267
pExpr = pExpr->pLeft;
100759101268
assert( pExpr!=0 );
100760101269
}
100761101270
op = pExpr->op;
101271
+ if( op==TK_REGISTER ) op = pExpr->op2;
101272
+ if( (op==TK_COLUMN || op==TK_AGG_COLUMN) && pExpr->y.pTab ){
101273
+ return sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
101274
+ }
100762101275
if( op==TK_SELECT ){
100763101276
assert( pExpr->flags&EP_xIsSelect );
100764101277
assert( pExpr->x.pSelect!=0 );
100765101278
assert( pExpr->x.pSelect->pEList!=0 );
100766101279
assert( pExpr->x.pSelect->pEList->a[0].pExpr!=0 );
100767101280
return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);
100768101281
}
100769
- if( op==TK_REGISTER ) op = pExpr->op2;
100770101282
#ifndef SQLITE_OMIT_CAST
100771101283
if( op==TK_CAST ){
100772101284
assert( !ExprHasProperty(pExpr, EP_IntValue) );
100773101285
return sqlite3AffinityType(pExpr->u.zToken, 0);
100774101286
}
100775101287
#endif
100776
- if( (op==TK_AGG_COLUMN || op==TK_COLUMN) && pExpr->y.pTab ){
100777
- return sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
100778
- }
100779101288
if( op==TK_SELECT_COLUMN ){
100780101289
assert( pExpr->pLeft->flags&EP_xIsSelect );
100781101290
return sqlite3ExprAffinity(
100782101291
pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
100783101292
);
@@ -100800,22 +101309,11 @@
100800101309
Parse *pParse, /* Parsing context */
100801101310
Expr *pExpr, /* Add the "COLLATE" clause to this expression */
100802101311
const Token *pCollName, /* Name of collating sequence */
100803101312
int dequote /* True to dequote pCollName */
100804101313
){
100805
- assert( pExpr!=0 || pParse->db->mallocFailed );
100806
- if( pExpr==0 ) return 0;
100807
- if( pExpr->op==TK_VECTOR ){
100808
- ExprList *pList = pExpr->x.pList;
100809
- if( ALWAYS(pList!=0) ){
100810
- int i;
100811
- for(i=0; i<pList->nExpr; i++){
100812
- pList->a[i].pExpr = sqlite3ExprAddCollateToken(pParse,pList->a[i].pExpr,
100813
- pCollName, dequote);
100814
- }
100815
- }
100816
- }else if( pCollName->n>0 ){
101314
+ if( pCollName->n>0 ){
100817101315
Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote);
100818101316
if( pNew ){
100819101317
pNew->pLeft = pExpr;
100820101318
pNew->flags |= EP_Collate|EP_Skip;
100821101319
pExpr = pNew;
@@ -101161,11 +101659,11 @@
101161101659
** just the expression for the i-th term of the result set, and may
101162101660
** not be ready for evaluation because the table cursor has not yet
101163101661
** been positioned.
101164101662
*/
101165101663
SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr *pVector, int i){
101166
- assert( i<sqlite3ExprVectorSize(pVector) );
101664
+ assert( i<sqlite3ExprVectorSize(pVector) || pVector->op==TK_ERROR );
101167101665
if( sqlite3ExprIsVector(pVector) ){
101168101666
assert( pVector->op2==0 || pVector->op==TK_REGISTER );
101169101667
if( pVector->op==TK_SELECT || pVector->op2==TK_SELECT ){
101170101668
return pVector->x.pSelect->pEList->a[i].pExpr;
101171101669
}else{
@@ -101277,21 +101775,24 @@
101277101775
int regSelect, /* First in array of registers */
101278101776
Expr **ppExpr, /* OUT: Expression element */
101279101777
int *pRegFree /* OUT: Temp register to free */
101280101778
){
101281101779
u8 op = pVector->op;
101282
- assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT );
101780
+ assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT || op==TK_ERROR );
101283101781
if( op==TK_REGISTER ){
101284101782
*ppExpr = sqlite3VectorFieldSubexpr(pVector, iField);
101285101783
return pVector->iTable+iField;
101286101784
}
101287101785
if( op==TK_SELECT ){
101288101786
*ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr;
101289101787
return regSelect+iField;
101290101788
}
101291
- *ppExpr = pVector->x.pList->a[iField].pExpr;
101292
- return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree);
101789
+ if( op==TK_VECTOR ){
101790
+ *ppExpr = pVector->x.pList->a[iField].pExpr;
101791
+ return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree);
101792
+ }
101793
+ return 0;
101293101794
}
101294101795
101295101796
/*
101296101797
** Expression pExpr is a comparison between two vector values. Compute
101297101798
** the result of the comparison (1, 0, or NULL) and write that
@@ -101346,11 +101847,11 @@
101346101847
regRight = exprCodeSubselect(pParse, pRight);
101347101848
101348101849
sqlite3VdbeAddOp2(v, OP_Integer, 1, dest);
101349101850
for(i=0; 1 /*Loop exits by "break"*/; i++){
101350101851
int regFree1 = 0, regFree2 = 0;
101351
- Expr *pL, *pR;
101852
+ Expr *pL = 0, *pR = 0;
101352101853
int r1, r2;
101353101854
assert( i>=0 && i<nLeft );
101354101855
if( addrCmp ) sqlite3VdbeJumpHere(v, addrCmp);
101355101856
r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, &regFree1);
101356101857
r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, &regFree2);
@@ -102029,10 +102530,11 @@
102029102530
102030102531
/* Figure out where to write the new Expr structure. */
102031102532
if( pzBuffer ){
102032102533
zAlloc = *pzBuffer;
102033102534
staticFlag = EP_Static;
102535
+ assert( zAlloc!=0 );
102034102536
}else{
102035102537
zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags));
102036102538
staticFlag = 0;
102037102539
}
102038102540
pNew = (Expr *)zAlloc;
@@ -102107,11 +102609,12 @@
102107102609
}else{
102108102610
if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
102109102611
if( pNew->op==TK_SELECT_COLUMN ){
102110102612
pNew->pLeft = p->pLeft;
102111102613
assert( p->iColumn==0 || p->pRight==0 );
102112
- assert( p->pRight==0 || p->pRight==p->pLeft );
102614
+ assert( p->pRight==0 || p->pRight==p->pLeft
102615
+ || ExprHasProperty(p->pLeft, EP_Subquery) );
102113102616
}else{
102114102617
pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
102115102618
}
102116102619
pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
102117102620
}
@@ -102124,11 +102627,11 @@
102124102627
** Create and return a deep copy of the object passed as the second
102125102628
** argument. If an OOM condition is encountered, NULL is returned
102126102629
** and the db->mallocFailed flag set.
102127102630
*/
102128102631
#ifndef SQLITE_OMIT_CTE
102129
-static With *withDup(sqlite3 *db, With *p){
102632
+SQLITE_PRIVATE With *sqlite3WithDup(sqlite3 *db, With *p){
102130102633
With *pRet = 0;
102131102634
if( p ){
102132102635
sqlite3_int64 nByte = sizeof(*p) + sizeof(p->a[0]) * (p->nCte-1);
102133102636
pRet = sqlite3DbMallocZero(db, nByte);
102134102637
if( pRet ){
@@ -102142,11 +102645,11 @@
102142102645
}
102143102646
}
102144102647
return pRet;
102145102648
}
102146102649
#else
102147
-# define withDup(x,y) 0
102650
+# define sqlite3WithDup(x,y) 0
102148102651
#endif
102149102652
102150102653
#ifndef SQLITE_OMIT_WINDOWFUNC
102151102654
/*
102152102655
** The gatherSelectWindows() procedure and its helper routine
@@ -102222,11 +102725,12 @@
102222102725
&& pOldExpr->op==TK_SELECT_COLUMN
102223102726
&& (pNewExpr = pItem->pExpr)!=0
102224102727
){
102225102728
assert( pNewExpr->iColumn==0 || i>0 );
102226102729
if( pNewExpr->iColumn==0 ){
102227
- assert( pOldExpr->pLeft==pOldExpr->pRight );
102730
+ assert( pOldExpr->pLeft==pOldExpr->pRight
102731
+ || ExprHasProperty(pOldExpr->pLeft, EP_Subquery) );
102228102732
pPriorSelectCol = pNewExpr->pLeft = pNewExpr->pRight;
102229102733
}else{
102230102734
assert( i>0 );
102231102735
assert( pItem[-1].pExpr!=0 );
102232102736
assert( pNewExpr->iColumn==pItem[-1].pExpr->iColumn+1 );
@@ -102345,17 +102849,25 @@
102345102849
pNew->iOffset = 0;
102346102850
pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;
102347102851
pNew->addrOpenEphm[0] = -1;
102348102852
pNew->addrOpenEphm[1] = -1;
102349102853
pNew->nSelectRow = p->nSelectRow;
102350
- pNew->pWith = withDup(db, p->pWith);
102854
+ pNew->pWith = sqlite3WithDup(db, p->pWith);
102351102855
#ifndef SQLITE_OMIT_WINDOWFUNC
102352102856
pNew->pWin = 0;
102353102857
pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
102354102858
if( p->pWin && db->mallocFailed==0 ) gatherSelectWindows(pNew);
102355102859
#endif
102356102860
pNew->selId = p->selId;
102861
+ if( db->mallocFailed ){
102862
+ /* Any prior OOM might have left the Select object incomplete.
102863
+ ** Delete the whole thing rather than allow an incomplete Select
102864
+ ** to be used by the code generator. */
102865
+ pNew->pNext = 0;
102866
+ sqlite3SelectDelete(db, pNew);
102867
+ break;
102868
+ }
102357102869
*pp = pNew;
102358102870
pp = &pNew->pPrior;
102359102871
pNext = pNew;
102360102872
}
102361102873
@@ -103052,12 +103564,14 @@
103052103564
** will likely result in an incorrect answer. So when in doubt, return
103053103565
** TRUE.
103054103566
*/
103055103567
SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){
103056103568
u8 op;
103569
+ assert( p!=0 );
103057103570
while( p->op==TK_UPLUS || p->op==TK_UMINUS ){
103058103571
p = p->pLeft;
103572
+ assert( p!=0 );
103059103573
}
103060103574
op = p->op;
103061103575
if( op==TK_REGISTER ) op = p->op2;
103062103576
switch( op ){
103063103577
case TK_INTEGER:
@@ -103685,23 +104199,27 @@
103685104199
addrOnce?"":"CORRELATED ", pSelect->selId
103686104200
));
103687104201
/* If the LHS and RHS of the IN operator do not match, that
103688104202
** error will have been caught long before we reach this point. */
103689104203
if( ALWAYS(pEList->nExpr==nVal) ){
104204
+ Select *pCopy;
103690104205
SelectDest dest;
103691104206
int i;
104207
+ int rc;
103692104208
sqlite3SelectDestInit(&dest, SRT_Set, iTab);
103693104209
dest.zAffSdst = exprINAffinity(pParse, pExpr);
103694104210
pSelect->iLimit = 0;
103695104211
testcase( pSelect->selFlags & SF_Distinct );
103696104212
testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
103697
- if( sqlite3Select(pParse, pSelect, &dest) ){
103698
- sqlite3DbFree(pParse->db, dest.zAffSdst);
104213
+ pCopy = sqlite3SelectDup(pParse->db, pSelect, 0);
104214
+ rc = pParse->db->mallocFailed ? 1 :sqlite3Select(pParse, pCopy, &dest);
104215
+ sqlite3SelectDelete(pParse->db, pCopy);
104216
+ sqlite3DbFree(pParse->db, dest.zAffSdst);
104217
+ if( rc ){
103699104218
sqlite3KeyInfoUnref(pKeyInfo);
103700104219
return;
103701104220
}
103702
- sqlite3DbFree(pParse->db, dest.zAffSdst);
103703104221
assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */
103704104222
assert( pEList!=0 );
103705104223
assert( pEList->nExpr>0 );
103706104224
assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
103707104225
for(i=0; i<nVal; i++){
@@ -103796,15 +104314,33 @@
103796104314
int nReg; /* Registers to allocate */
103797104315
Expr *pLimit; /* New limit expression */
103798104316
103799104317
Vdbe *v = pParse->pVdbe;
103800104318
assert( v!=0 );
104319
+ if( pParse->nErr ) return 0;
103801104320
testcase( pExpr->op==TK_EXISTS );
103802104321
testcase( pExpr->op==TK_SELECT );
103803104322
assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
103804104323
assert( ExprHasProperty(pExpr, EP_xIsSelect) );
103805104324
pSel = pExpr->x.pSelect;
104325
+
104326
+ /* If this routine has already been coded, then invoke it as a
104327
+ ** subroutine. */
104328
+ if( ExprHasProperty(pExpr, EP_Subrtn) ){
104329
+ ExplainQueryPlan((pParse, 0, "REUSE SUBQUERY %d", pSel->selId));
104330
+ sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn,
104331
+ pExpr->y.sub.iAddr);
104332
+ return pExpr->iTable;
104333
+ }
104334
+
104335
+ /* Begin coding the subroutine */
104336
+ ExprSetProperty(pExpr, EP_Subrtn);
104337
+ pExpr->y.sub.regReturn = ++pParse->nMem;
104338
+ pExpr->y.sub.iAddr =
104339
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
104340
+ VdbeComment((v, "return address"));
104341
+
103806104342
103807104343
/* The evaluation of the EXISTS/SELECT must be repeated every time it
103808104344
** is encountered if any of the following is true:
103809104345
**
103810104346
** * The right-hand side is a correlated subquery
@@ -103813,26 +104349,10 @@
103813104349
**
103814104350
** If all of the above are false, then we can run this code just once
103815104351
** save the results, and reuse the same result on subsequent invocations.
103816104352
*/
103817104353
if( !ExprHasProperty(pExpr, EP_VarSelect) ){
103818
- /* If this routine has already been coded, then invoke it as a
103819
- ** subroutine. */
103820
- if( ExprHasProperty(pExpr, EP_Subrtn) ){
103821
- ExplainQueryPlan((pParse, 0, "REUSE SUBQUERY %d", pSel->selId));
103822
- sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn,
103823
- pExpr->y.sub.iAddr);
103824
- return pExpr->iTable;
103825
- }
103826
-
103827
- /* Begin coding the subroutine */
103828
- ExprSetProperty(pExpr, EP_Subrtn);
103829
- pExpr->y.sub.regReturn = ++pParse->nMem;
103830
- pExpr->y.sub.iAddr =
103831
- sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
103832
- VdbeComment((v, "return address"));
103833
-
103834104354
addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
103835104355
}
103836104356
103837104357
/* For a SELECT, generate code to put the values for all columns of
103838104358
** the first row into an array of registers and return the index of
@@ -103877,23 +104397,26 @@
103877104397
pLimit = sqlite3Expr(pParse->db, TK_INTEGER, "1");
103878104398
pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0);
103879104399
}
103880104400
pSel->iLimit = 0;
103881104401
if( sqlite3Select(pParse, pSel, &dest) ){
104402
+ if( pParse->nErr ){
104403
+ pExpr->op2 = pExpr->op;
104404
+ pExpr->op = TK_ERROR;
104405
+ }
103882104406
return 0;
103883104407
}
103884104408
pExpr->iTable = rReg = dest.iSDParm;
103885104409
ExprSetVVAProperty(pExpr, EP_NoReduce);
103886104410
if( addrOnce ){
103887104411
sqlite3VdbeJumpHere(v, addrOnce);
103888
-
103889
- /* Subroutine return */
103890
- sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
103891
- sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
103892
- sqlite3ClearTempRegCache(pParse);
103893104412
}
103894104413
104414
+ /* Subroutine return */
104415
+ sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
104416
+ sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
104417
+ sqlite3ClearTempRegCache(pParse);
103895104418
return rReg;
103896104419
}
103897104420
#endif /* SQLITE_OMIT_SUBQUERY */
103898104421
103899104422
#ifndef SQLITE_OMIT_SUBQUERY
@@ -103903,11 +104426,11 @@
103903104426
** columns as the vector on the LHS. Or, if the RHS of the IN() is not
103904104427
** a sub-query, that the LHS is a vector of size 1.
103905104428
*/
103906104429
SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse *pParse, Expr *pIn){
103907104430
int nVector = sqlite3ExprVectorSize(pIn->pLeft);
103908
- if( (pIn->flags & EP_xIsSelect) ){
104431
+ if( (pIn->flags & EP_xIsSelect)!=0 && !pParse->db->mallocFailed ){
103909104432
if( nVector!=pIn->x.pSelect->pEList->nExpr ){
103910104433
sqlite3SubselectError(pParse, pIn->x.pSelect->pEList->nExpr, nVector);
103911104434
return 1;
103912104435
}
103913104436
}else if( nVector!=1 ){
@@ -104720,11 +105243,11 @@
104720105243
default: {
104721105244
/* Make NULL the default case so that if a bug causes an illegal
104722105245
** Expr node to be passed into this function, it will be handled
104723105246
** sanely and not crash. But keep the assert() to bring the problem
104724105247
** to the attention of the developers. */
104725
- assert( op==TK_NULL );
105248
+ assert( op==TK_NULL || op==TK_ERROR || pParse->db->mallocFailed );
104726105249
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
104727105250
return target;
104728105251
}
104729105252
#ifndef SQLITE_OMIT_BLOB_LITERAL
104730105253
case TK_BLOB: {
@@ -105063,11 +105586,12 @@
105063105586
case TK_SELECT_COLUMN: {
105064105587
int n;
105065105588
if( pExpr->pLeft->iTable==0 ){
105066105589
pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft);
105067105590
}
105068
- assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT );
105591
+ assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT
105592
+ || pExpr->pLeft->op==TK_ERROR );
105069105593
if( pExpr->iTable!=0
105070105594
&& pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft))
105071105595
){
105072105596
sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
105073105597
pExpr->iTable, n);
@@ -106695,10 +107219,11 @@
106695107219
/* Check to see if pExpr is a duplicate of another aggregate
106696107220
** function that is already in the pAggInfo structure
106697107221
*/
106698107222
struct AggInfo_func *pItem = pAggInfo->aFunc;
106699107223
for(i=0; i<pAggInfo->nFunc; i++, pItem++){
107224
+ if( pItem->pFExpr==pExpr ) break;
106700107225
if( sqlite3ExprCompare(0, pItem->pFExpr, pExpr, -1)==0 ){
106701107226
break;
106702107227
}
106703107228
}
106704107229
if( i>=pAggInfo->nFunc ){
@@ -106895,10 +107420,11 @@
106895107420
** Or, if zName is not a system table, zero is returned.
106896107421
*/
106897107422
static int isAlterableTable(Parse *pParse, Table *pTab){
106898107423
if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7)
106899107424
#ifndef SQLITE_OMIT_VIRTUALTABLE
107425
+ || (pTab->tabFlags & TF_Eponymous)!=0
106900107426
|| ( (pTab->tabFlags & TF_Shadow)!=0
106901107427
&& sqlite3ReadOnlyShadowTables(pParse->db)
106902107428
)
106903107429
#endif
106904107430
){
@@ -107663,19 +108189,34 @@
107663108189
** to select statement pSelect.
107664108190
*/
107665108191
static void renameWalkWith(Walker *pWalker, Select *pSelect){
107666108192
With *pWith = pSelect->pWith;
107667108193
if( pWith ){
108194
+ Parse *pParse = pWalker->pParse;
107668108195
int i;
108196
+ With *pCopy = 0;
108197
+ assert( pWith->nCte>0 );
108198
+ if( (pWith->a[0].pSelect->selFlags & SF_Expanded)==0 ){
108199
+ /* Push a copy of the With object onto the with-stack. We use a copy
108200
+ ** here as the original will be expanded and resolved (flags SF_Expanded
108201
+ ** and SF_Resolved) below. And the parser code that uses the with-stack
108202
+ ** fails if the Select objects on it have already been expanded and
108203
+ ** resolved. */
108204
+ pCopy = sqlite3WithDup(pParse->db, pWith);
108205
+ pCopy = sqlite3WithPush(pParse, pCopy, 1);
108206
+ }
107669108207
for(i=0; i<pWith->nCte; i++){
107670108208
Select *p = pWith->a[i].pSelect;
107671108209
NameContext sNC;
107672108210
memset(&sNC, 0, sizeof(sNC));
107673
- sNC.pParse = pWalker->pParse;
107674
- sqlite3SelectPrep(sNC.pParse, p, &sNC);
108211
+ sNC.pParse = pParse;
108212
+ if( pCopy ) sqlite3SelectPrep(sNC.pParse, p, &sNC);
107675108213
sqlite3WalkSelect(pWalker, p);
107676
- sqlite3RenameExprlistUnmap(pWalker->pParse, pWith->a[i].pCols);
108214
+ sqlite3RenameExprlistUnmap(pParse, pWith->a[i].pCols);
108215
+ }
108216
+ if( pCopy && pParse->pWith==pCopy ){
108217
+ pParse->pWith = pCopy->pOuter;
107677108218
}
107678108219
}
107679108220
}
107680108221
107681108222
/*
@@ -107698,11 +108239,15 @@
107698108239
*/
107699108240
static int renameUnmapSelectCb(Walker *pWalker, Select *p){
107700108241
Parse *pParse = pWalker->pParse;
107701108242
int i;
107702108243
if( pParse->nErr ) return WRC_Abort;
107703
- if( NEVER(p->selFlags & SF_View) ) return WRC_Prune;
108244
+ if( p->selFlags & (SF_View|SF_CopyCte) ){
108245
+ testcase( pSelect->selFlags & SF_View );
108246
+ testcase( pSelect->selFlags & SF_CopyCte );
108247
+ return WRC_Prune;
108248
+ }
107704108249
if( ALWAYS(p->pEList) ){
107705108250
ExprList *pList = p->pEList;
107706108251
for(i=0; i<pList->nExpr; i++){
107707108252
if( pList->a[i].zEName && pList->a[i].eEName==ENAME_NAME ){
107708108253
sqlite3RenameTokenRemap(pParse, 0, (void*)pList->a[i].zEName);
@@ -107782,11 +108327,13 @@
107782108327
Parse *pParse,
107783108328
struct RenameCtx *pCtx,
107784108329
void *pPtr
107785108330
){
107786108331
RenameToken **pp;
107787
- assert( pPtr!=0 );
108332
+ if( NEVER(pPtr==0) ){
108333
+ return 0;
108334
+ }
107788108335
for(pp=&pParse->pRename; (*pp); pp=&(*pp)->pNext){
107789108336
if( (*pp)->p==pPtr ){
107790108337
RenameToken *pToken = *pp;
107791108338
if( pCtx ){
107792108339
*pp = pToken->pNext;
@@ -107804,11 +108351,15 @@
107804108351
** This is a Walker select callback. It does nothing. It is only required
107805108352
** because without a dummy callback, sqlite3WalkExpr() and similar do not
107806108353
** descend into sub-select statements.
107807108354
*/
107808108355
static int renameColumnSelectCb(Walker *pWalker, Select *p){
107809
- if( p->selFlags & SF_View ) return WRC_Prune;
108356
+ if( p->selFlags & (SF_View|SF_CopyCte) ){
108357
+ testcase( pSelect->selFlags & SF_View );
108358
+ testcase( pSelect->selFlags & SF_CopyCte );
108359
+ return WRC_Prune;
108360
+ }
107810108361
renameWalkWith(pWalker, p);
107811108362
return WRC_Continue;
107812108363
}
107813108364
107814108365
/*
@@ -108334,13 +108885,15 @@
108334108885
int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName);
108335108886
FKey *pFKey;
108336108887
assert( sParse.pNewTable->pSelect==0 );
108337108888
sCtx.pTab = sParse.pNewTable;
108338108889
if( bFKOnly==0 ){
108339
- renameTokenFind(
108340
- &sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zName
108341
- );
108890
+ if( iCol<sParse.pNewTable->nCol ){
108891
+ renameTokenFind(
108892
+ &sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zName
108893
+ );
108894
+ }
108342108895
if( sCtx.iCol<0 ){
108343108896
renameTokenFind(&sParse, &sCtx, (void*)&sParse.pNewTable->iPKey);
108344108897
}
108345108898
sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck);
108346108899
for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){
@@ -108438,12 +108991,16 @@
108438108991
*/
108439108992
static int renameTableSelectCb(Walker *pWalker, Select *pSelect){
108440108993
int i;
108441108994
RenameCtx *p = pWalker->u.pRename;
108442108995
SrcList *pSrc = pSelect->pSrc;
108443
- if( pSelect->selFlags & SF_View ) return WRC_Prune;
108444
- if( pSrc==0 ){
108996
+ if( pSelect->selFlags & (SF_View|SF_CopyCte) ){
108997
+ testcase( pSelect->selFlags & SF_View );
108998
+ testcase( pSelect->selFlags & SF_CopyCte );
108999
+ return WRC_Prune;
109000
+ }
109001
+ if( NEVER(pSrc==0) ){
108445109002
assert( pWalker->pParse->db->mallocFailed );
108446109003
return WRC_Abort;
108447109004
}
108448109005
for(i=0; i<pSrc->nSrc; i++){
108449109006
SrcItem *pItem = &pSrc->a[i];
@@ -108983,20 +109540,25 @@
108983109540
if( iPos<pPk->nKeyCol ) continue;
108984109541
regOut = reg+1+iPos-(iPos>iColPos);
108985109542
}else{
108986109543
regOut = reg+1+nField;
108987109544
}
108988
- sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOut);
109545
+ if( i==pTab->iPKey ){
109546
+ sqlite3VdbeAddOp2(v, OP_Null, 0, regOut);
109547
+ }else{
109548
+ sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOut);
109549
+ }
108989109550
nField++;
108990109551
}
108991109552
}
108992109553
sqlite3VdbeAddOp3(v, OP_MakeRecord, reg+1, nField, regRec);
108993109554
if( pPk ){
108994109555
sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iCur, regRec, reg+1, pPk->nKeyCol);
108995109556
}else{
108996109557
sqlite3VdbeAddOp3(v, OP_Insert, iCur, regRec, reg);
108997109558
}
109559
+ sqlite3VdbeChangeP5(v, OPFLAG_SAVEPOSITION);
108998109560
108999109561
sqlite3VdbeAddOp2(v, OP_Next, iCur, addr+1); VdbeCoverage(v);
109000109562
sqlite3VdbeJumpHere(v, addr);
109001109563
}
109002109564
@@ -111063,11 +111625,11 @@
111063111625
zFile = (const char *)sqlite3_value_text(argv[0]);
111064111626
zName = (const char *)sqlite3_value_text(argv[1]);
111065111627
if( zFile==0 ) zFile = "";
111066111628
if( zName==0 ) zName = "";
111067111629
111068
-#ifdef SQLITE_ENABLE_DESERIALIZE
111630
+#ifndef SQLITE_OMIT_DESERIALIZE
111069111631
# define REOPEN_AS_MEMDB(db) (db->init.reopenMemdb)
111070111632
#else
111071111633
# define REOPEN_AS_MEMDB(db) (0)
111072111634
#endif
111073111635
@@ -111432,18 +111994,21 @@
111432111994
SrcList *pList = pSelect->pSrc;
111433111995
111434111996
if( NEVER(pList==0) ) return WRC_Continue;
111435111997
for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
111436111998
if( pFix->bTemp==0 ){
111437
- if( pItem->zDatabase && iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){
111438
- sqlite3ErrorMsg(pFix->pParse,
111439
- "%s %T cannot reference objects in database %s",
111440
- pFix->zType, pFix->pName, pItem->zDatabase);
111441
- return WRC_Abort;
111442
- }
111443
- sqlite3DbFree(db, pItem->zDatabase);
111444
- pItem->zDatabase = 0;
111999
+ if( pItem->zDatabase ){
112000
+ if( iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){
112001
+ sqlite3ErrorMsg(pFix->pParse,
112002
+ "%s %T cannot reference objects in database %s",
112003
+ pFix->zType, pFix->pName, pItem->zDatabase);
112004
+ return WRC_Abort;
112005
+ }
112006
+ sqlite3DbFree(db, pItem->zDatabase);
112007
+ pItem->zDatabase = 0;
112008
+ pItem->fg.notCte = 1;
112009
+ }
111445112010
pItem->pSchema = pFix->pSchema;
111446112011
pItem->fg.fromDDL = 1;
111447112012
}
111448112013
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
111449112014
if( sqlite3WalkExpr(&pFix->w, pList->a[i].pOn) ) return WRC_Abort;
@@ -111479,11 +112044,11 @@
111479112044
pFix->pName = pName;
111480112045
pFix->bTemp = (iDb==1);
111481112046
pFix->w.pParse = pParse;
111482112047
pFix->w.xExprCallback = fixExprCb;
111483112048
pFix->w.xSelectCallback = fixSelectCb;
111484
- pFix->w.xSelectCallback2 = 0;
112049
+ pFix->w.xSelectCallback2 = sqlite3WalkWinDefnDummyCallback;
111485112050
pFix->w.walkerDepth = 0;
111486112051
pFix->w.eCode = 0;
111487112052
pFix->w.u.pFix = pFix;
111488112053
}
111489112054
@@ -111541,18 +112106,20 @@
111541112106
|| sqlite3FixSrcList(pFix, pStep->pFrom)
111542112107
){
111543112108
return 1;
111544112109
}
111545112110
#ifndef SQLITE_OMIT_UPSERT
111546
- if( pStep->pUpsert ){
111547
- Upsert *pUp = pStep->pUpsert;
111548
- if( sqlite3WalkExprList(&pFix->w, pUp->pUpsertTarget)
111549
- || sqlite3WalkExpr(&pFix->w, pUp->pUpsertTargetWhere)
111550
- || sqlite3WalkExprList(&pFix->w, pUp->pUpsertSet)
111551
- || sqlite3WalkExpr(&pFix->w, pUp->pUpsertWhere)
111552
- ){
111553
- return 1;
112111
+ {
112112
+ Upsert *pUp;
112113
+ for(pUp=pStep->pUpsert; pUp; pUp=pUp->pNextUpsert){
112114
+ if( sqlite3WalkExprList(&pFix->w, pUp->pUpsertTarget)
112115
+ || sqlite3WalkExpr(&pFix->w, pUp->pUpsertTargetWhere)
112116
+ || sqlite3WalkExprList(&pFix->w, pUp->pUpsertSet)
112117
+ || sqlite3WalkExpr(&pFix->w, pUp->pUpsertWhere)
112118
+ ){
112119
+ return 1;
112120
+ }
111554112121
}
111555112122
}
111556112123
#endif
111557112124
pStep = pStep->pNext;
111558112125
}
@@ -111880,11 +112447,11 @@
111880112447
**
111881112448
** This routine just records the fact that the lock is desired. The
111882112449
** code to make the lock occur is generated by a later call to
111883112450
** codeTableLocks() which occurs during sqlite3FinishCoding().
111884112451
*/
111885
-SQLITE_PRIVATE void sqlite3TableLock(
112452
+static SQLITE_NOINLINE void lockTable(
111886112453
Parse *pParse, /* Parsing context */
111887112454
int iDb, /* Index of the database containing the table to lock */
111888112455
Pgno iTab, /* Root page number of the table to be locked */
111889112456
u8 isWriteLock, /* True for a write lock */
111890112457
const char *zName /* Name of the table to be locked */
@@ -111893,12 +112460,10 @@
111893112460
int i;
111894112461
int nBytes;
111895112462
TableLock *p;
111896112463
assert( iDb>=0 );
111897112464
111898
- if( iDb==1 ) return;
111899
- if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return;
111900112465
pToplevel = sqlite3ParseToplevel(pParse);
111901112466
for(i=0; i<pToplevel->nTableLock; i++){
111902112467
p = &pToplevel->aTableLock[i];
111903112468
if( p->iDb==iDb && p->iTab==iTab ){
111904112469
p->isWriteLock = (p->isWriteLock || isWriteLock);
@@ -111918,10 +112483,21 @@
111918112483
}else{
111919112484
pToplevel->nTableLock = 0;
111920112485
sqlite3OomFault(pToplevel->db);
111921112486
}
111922112487
}
112488
+SQLITE_PRIVATE void sqlite3TableLock(
112489
+ Parse *pParse, /* Parsing context */
112490
+ int iDb, /* Index of the database containing the table to lock */
112491
+ Pgno iTab, /* Root page number of the table to be locked */
112492
+ u8 isWriteLock, /* True for a write lock */
112493
+ const char *zName /* Name of the table to be locked */
112494
+){
112495
+ if( iDb==1 ) return;
112496
+ if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return;
112497
+ lockTable(pParse, iDb, iTab, isWriteLock, zName);
112498
+}
111923112499
111924112500
/*
111925112501
** Code an OP_TableLock instruction for each table locked by the
111926112502
** statement (configured by calls to sqlite3TableLock()).
111927112503
*/
@@ -112272,11 +112848,11 @@
112272112848
if( p==0 ){
112273112849
#ifndef SQLITE_OMIT_VIRTUALTABLE
112274112850
/* If zName is the not the name of a table in the schema created using
112275112851
** CREATE, then check to see if it is the name of an virtual table that
112276112852
** can be an eponymous virtual table. */
112277
- if( pParse->disableVtab==0 ){
112853
+ if( pParse->disableVtab==0 && db->init.busy==0 ){
112278112854
Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
112279112855
if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
112280112856
pMod = sqlite3PragmaVtabRegister(db, zName);
112281112857
}
112282112858
if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
@@ -112295,10 +112871,12 @@
112295112871
if( zDbase ){
112296112872
sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
112297112873
}else{
112298112874
sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
112299112875
}
112876
+ }else{
112877
+ assert( HasRowid(p) || p->iPKey<0 );
112300112878
}
112301112879
112302112880
return p;
112303112881
}
112304112882
@@ -112711,11 +113289,11 @@
112711113289
if( iDb<0 ){
112712113290
sqlite3ErrorMsg(pParse, "unknown database %T", pName1);
112713113291
return -1;
112714113292
}
112715113293
}else{
112716
- assert( db->init.iDb==0 || db->init.busy || IN_RENAME_OBJECT
113294
+ assert( db->init.iDb==0 || db->init.busy || IN_SPECIAL_PARSE
112717113295
|| (db->mDbFlags & DBFLAG_Vacuum)!=0);
112718113296
iDb = db->init.iDb;
112719113297
*pUnqual = pName1;
112720113298
}
112721113299
return iDb;
@@ -112879,10 +113457,27 @@
112879113457
/* iCol is a normal or stored column */
112880113458
return n;
112881113459
}
112882113460
}
112883113461
#endif
113462
+
113463
+/*
113464
+** Insert a single OP_JournalMode query opcode in order to force the
113465
+** prepared statement to return false for sqlite3_stmt_readonly(). This
113466
+** is used by CREATE TABLE IF NOT EXISTS and similar if the table already
113467
+** exists, so that the prepared statement for CREATE TABLE IF NOT EXISTS
113468
+** will return false for sqlite3_stmt_readonly() even if that statement
113469
+** is a read-only no-op.
113470
+*/
113471
+static void sqlite3ForceNotReadOnly(Parse *pParse){
113472
+ int iReg = ++pParse->nMem;
113473
+ Vdbe *v = sqlite3GetVdbe(pParse);
113474
+ if( v ){
113475
+ sqlite3VdbeAddOp3(v, OP_JournalMode, 0, iReg, PAGER_JOURNALMODE_QUERY);
113476
+ sqlite3VdbeUsesBtree(v, 0);
113477
+ }
113478
+}
112884113479
112885113480
/*
112886113481
** Begin constructing a new table representation in memory. This is
112887113482
** the first of several action routines that get called in response
112888113483
** to a CREATE TABLE statement. In particular, this routine is called
@@ -112979,10 +113574,11 @@
112979113574
if( !noErr ){
112980113575
sqlite3ErrorMsg(pParse, "table %T already exists", pName);
112981113576
}else{
112982113577
assert( !db->init.busy || CORRUPT_DB );
112983113578
sqlite3CodeVerifySchema(pParse, iDb);
113579
+ sqlite3ForceNotReadOnly(pParse);
112984113580
}
112985113581
goto begin_table_error;
112986113582
}
112987113583
if( sqlite3FindIndex(db, zName, zDb)!=0 ){
112988113584
sqlite3ErrorMsg(pParse, "there is already an index named %s", zName);
@@ -113155,10 +113751,11 @@
113155113751
pRet->retTrig.zName = RETURNING_TRIGGER_NAME;
113156113752
pRet->retTrig.op = TK_RETURNING;
113157113753
pRet->retTrig.tr_tm = TRIGGER_AFTER;
113158113754
pRet->retTrig.bReturning = 1;
113159113755
pRet->retTrig.pSchema = db->aDb[1].pSchema;
113756
+ pRet->retTrig.pTabSchema = db->aDb[1].pSchema;
113160113757
pRet->retTrig.step_list = &pRet->retTStep;
113161113758
pRet->retTStep.op = TK_RETURNING;
113162113759
pRet->retTStep.pTrig = &pRet->retTrig;
113163113760
pRet->retTStep.pExprList = pList;
113164113761
pHash = &(db->aDb[1].pSchema->trigHash);
@@ -114013,20 +114610,26 @@
114013114610
ExprList *pList;
114014114611
Token ipkToken;
114015114612
sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName);
114016114613
pList = sqlite3ExprListAppend(pParse, 0,
114017114614
sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
114018
- if( pList==0 ) return;
114615
+ if( pList==0 ){
114616
+ pTab->tabFlags &= ~TF_WithoutRowid;
114617
+ return;
114618
+ }
114019114619
if( IN_RENAME_OBJECT ){
114020114620
sqlite3RenameTokenRemap(pParse, pList->a[0].pExpr, &pTab->iPKey);
114021114621
}
114022114622
pList->a[0].sortFlags = pParse->iPkSortOrder;
114023114623
assert( pParse->pNewTable==pTab );
114024114624
pTab->iPKey = -1;
114025114625
sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
114026114626
SQLITE_IDXTYPE_PRIMARYKEY);
114027
- if( db->mallocFailed || pParse->nErr ) return;
114627
+ if( db->mallocFailed || pParse->nErr ){
114628
+ pTab->tabFlags &= ~TF_WithoutRowid;
114629
+ return;
114630
+ }
114028114631
pPk = sqlite3PrimaryKeyIndex(pTab);
114029114632
assert( pPk->nKeyCol==1 );
114030114633
}else{
114031114634
pPk = sqlite3PrimaryKeyIndex(pTab);
114032114635
assert( pPk!=0 );
@@ -114226,11 +114829,10 @@
114226114829
Index *pIdx; /* An implied index of the table */
114227114830
114228114831
if( pEnd==0 && pSelect==0 ){
114229114832
return;
114230114833
}
114231
- assert( !db->mallocFailed );
114232114834
p = pParse->pNewTable;
114233114835
if( p==0 ) return;
114234114836
114235114837
if( pSelect==0 && sqlite3ShadowTableName(db, p->zName) ){
114236114838
p->tabFlags |= TF_Shadow;
@@ -114474,10 +115076,11 @@
114474115076
*/
114475115077
if( db->init.busy ){
114476115078
Table *pOld;
114477115079
Schema *pSchema = p->pSchema;
114478115080
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
115081
+ assert( HasRowid(p) || p->iPKey<0 );
114479115082
pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName, p);
114480115083
if( pOld ){
114481115084
assert( p==pOld ); /* Malloc must have failed inside HashInsert() */
114482115085
sqlite3OomFault(db);
114483115086
return;
@@ -115022,11 +115625,14 @@
115022115625
assert( isView==0 || isView==LOCATE_VIEW );
115023115626
pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);
115024115627
if( noErr ) db->suppressErr--;
115025115628
115026115629
if( pTab==0 ){
115027
- if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
115630
+ if( noErr ){
115631
+ sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
115632
+ sqlite3ForceNotReadOnly(pParse);
115633
+ }
115028115634
goto exit_drop_table;
115029115635
}
115030115636
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
115031115637
assert( iDb>=0 && iDb<db->nDb );
115032115638
@@ -115592,10 +116198,11 @@
115592116198
if( !ifNotExist ){
115593116199
sqlite3ErrorMsg(pParse, "index %s already exists", zName);
115594116200
}else{
115595116201
assert( !db->init.busy );
115596116202
sqlite3CodeVerifySchema(pParse, iDb);
116203
+ sqlite3ForceNotReadOnly(pParse);
115597116204
}
115598116205
goto exit_create_index;
115599116206
}
115600116207
}
115601116208
}else{
@@ -116072,11 +116679,11 @@
116072116679
x = pIdx->pTable->nRowLogEst;
116073116680
assert( 99==sqlite3LogEst(1000) );
116074116681
if( x<99 ){
116075116682
pIdx->pTable->nRowLogEst = x = 99;
116076116683
}
116077
- if( pIdx->pPartIdxWhere!=0 ) x -= 10; assert( 10==sqlite3LogEst(2) );
116684
+ if( pIdx->pPartIdxWhere!=0 ){ x -= 10; assert( 10==sqlite3LogEst(2) ); }
116078116685
a[0] = x;
116079116686
116080116687
/* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is
116081116688
** 6 and each subsequent value (if any) is 5. */
116082116689
memcpy(&a[1], aVal, nCopy*sizeof(LogEst));
@@ -116110,10 +116717,11 @@
116110116717
if( pIndex==0 ){
116111116718
if( !ifExists ){
116112116719
sqlite3ErrorMsg(pParse, "no such index: %S", pName->a);
116113116720
}else{
116114116721
sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
116722
+ sqlite3ForceNotReadOnly(pParse);
116115116723
}
116116116724
pParse->checkSchema = 1;
116117116725
goto exit_drop_index;
116118116726
}
116119116727
if( pIndex->idxType!=SQLITE_IDXTYPE_APPDEF ){
@@ -116129,11 +116737,11 @@
116129116737
const char *zDb = db->aDb[iDb].zDbSName;
116130116738
const char *zTab = SCHEMA_TABLE(iDb);
116131116739
if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){
116132116740
goto exit_drop_index;
116133116741
}
116134
- if( !OMIT_TEMPDB && iDb ) code = SQLITE_DROP_TEMP_INDEX;
116742
+ if( !OMIT_TEMPDB && iDb==1 ) code = SQLITE_DROP_TEMP_INDEX;
116135116743
if( sqlite3AuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){
116136116744
goto exit_drop_index;
116137116745
}
116138116746
}
116139116747
#endif
@@ -116421,12 +117029,12 @@
116421117029
** Assign VdbeCursor index numbers to all tables in a SrcList
116422117030
*/
116423117031
SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){
116424117032
int i;
116425117033
SrcItem *pItem;
116426
- assert(pList || pParse->db->mallocFailed );
116427
- if( pList ){
117034
+ assert( pList || pParse->db->mallocFailed );
117035
+ if( ALWAYS(pList) ){
116428117036
for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
116429117037
if( pItem->iCursor>=0 ) continue;
116430117038
pItem->iCursor = pParse->nTab++;
116431117039
if( pItem->pSelect ){
116432117040
sqlite3SrcListAssignCursors(pParse, pItem->pSelect->pSrc);
@@ -118147,10 +118755,13 @@
118147118755
pTab->zName, P4_STATIC);
118148118756
}
118149118757
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
118150118758
assert( pIdx->pSchema==pTab->pSchema );
118151118759
sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);
118760
+ if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
118761
+ sqlite3VdbeChangeP3(v, -1, memCnt ? memCnt : -1);
118762
+ }
118152118763
}
118153118764
}else
118154118765
#endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */
118155118766
{
118156118767
u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK;
@@ -118658,17 +119269,19 @@
118658119269
){
118659119270
/* This column was already computed by the previous index */
118660119271
continue;
118661119272
}
118662119273
sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j);
118663
- /* If the column affinity is REAL but the number is an integer, then it
118664
- ** might be stored in the table as an integer (using a compact
118665
- ** representation) then converted to REAL by an OP_RealAffinity opcode.
118666
- ** But we are getting ready to store this value back into an index, where
118667
- ** it should be converted by to INTEGER again. So omit the OP_RealAffinity
118668
- ** opcode if it is present */
118669
- sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);
119274
+ if( pIdx->aiColumn[j]>=0 ){
119275
+ /* If the column affinity is REAL but the number is an integer, then it
119276
+ ** might be stored in the table as an integer (using a compact
119277
+ ** representation) then converted to REAL by an OP_RealAffinity opcode.
119278
+ ** But we are getting ready to store this value back into an index, where
119279
+ ** it should be converted by to INTEGER again. So omit the
119280
+ ** OP_RealAffinity opcode if it is present */
119281
+ sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);
119282
+ }
118670119283
}
118671119284
if( regOut ){
118672119285
sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut);
118673119286
}
118674119287
sqlite3ReleaseTempRange(pParse, regBase, nCol);
@@ -120759,13 +121372,11 @@
120759121372
ans = x(v0, v1);
120760121373
sqlite3_result_double(context, ans);
120761121374
}
120762121375
120763121376
/*
120764
-** Implementation of 2-argument SQL math functions:
120765
-**
120766
-** power(X,Y) - Compute X to the Y-th power
121377
+** Implementation of 0-argument pi() function.
120767121378
*/
120768121379
static void piFunc(
120769121380
sqlite3_context *context,
120770121381
int argc,
120771121382
sqlite3_value **argv
@@ -122791,11 +123402,11 @@
122791123402
/* Verify that the sqlite_sequence table exists and is an ordinary
122792123403
** rowid table with exactly two columns.
122793123404
** Ticket d8dc2b3a58cd5dc2918a1d4acb 2018-05-23 */
122794123405
if( pSeqTab==0
122795123406
|| !HasRowid(pSeqTab)
122796
- || IsVirtual(pSeqTab)
123407
+ || NEVER(IsVirtual(pSeqTab))
122797123408
|| pSeqTab->nCol!=2
122798123409
){
122799123410
pParse->nErr++;
122800123411
pParse->rc = SQLITE_CORRUPT_SEQUENCE;
122801123412
return 0;
@@ -126824,11 +127435,11 @@
126824127435
sqlite3_loadext_entry xInit;
126825127436
char *zErrmsg = 0;
126826127437
const char *zEntry;
126827127438
char *zAltEntry = 0;
126828127439
void **aHandle;
126829
- u64 nMsg = 300 + sqlite3Strlen30(zFile);
127440
+ u64 nMsg = strlen(zFile);
126830127441
int ii;
126831127442
int rc;
126832127443
126833127444
/* Shared library endings to try if zFile cannot be loaded as written */
126834127445
static const char *azEndings[] = {
@@ -126858,30 +127469,26 @@
126858127469
return SQLITE_ERROR;
126859127470
}
126860127471
126861127472
zEntry = zProc ? zProc : "sqlite3_extension_init";
126862127473
127474
+ /* tag-20210611-1. Some dlopen() implementations will segfault if given
127475
+ ** an oversize filename. Most filesystems have a pathname limit of 4K,
127476
+ ** so limit the extension filename length to about twice that.
127477
+ ** https://sqlite.org/forum/forumpost/08a0d6d9bf */
127478
+ if( nMsg>SQLITE_MAX_PATHLEN ) goto extension_not_found;
127479
+
126863127480
handle = sqlite3OsDlOpen(pVfs, zFile);
126864127481
#if SQLITE_OS_UNIX || SQLITE_OS_WIN
126865127482
for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){
126866127483
char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEndings[ii]);
126867127484
if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;
126868127485
handle = sqlite3OsDlOpen(pVfs, zAltFile);
126869127486
sqlite3_free(zAltFile);
126870127487
}
126871127488
#endif
126872
- if( handle==0 ){
126873
- if( pzErrMsg ){
126874
- *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
126875
- if( zErrmsg ){
126876
- sqlite3_snprintf(nMsg, zErrmsg,
126877
- "unable to open shared library [%s]", zFile);
126878
- sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
126879
- }
126880
- }
126881
- return SQLITE_ERROR;
126882
- }
127489
+ if( handle==0 ) goto extension_not_found;
126883127490
xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
126884127491
126885127492
/* If no entry point was specified and the default legacy
126886127493
** entry point name "sqlite3_extension_init" was not found, then
126887127494
** construct an entry point name "sqlite3_X_init" where the X is
@@ -126914,14 +127521,15 @@
126914127521
zEntry = zAltEntry;
126915127522
xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
126916127523
}
126917127524
if( xInit==0 ){
126918127525
if( pzErrMsg ){
126919
- nMsg += sqlite3Strlen30(zEntry);
127526
+ nMsg += strlen(zEntry) + 300;
126920127527
*pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
126921127528
if( zErrmsg ){
126922
- sqlite3_snprintf(nMsg, zErrmsg,
127529
+ assert( nMsg<0x7fffffff ); /* zErrmsg would be NULL if not so */
127530
+ sqlite3_snprintf((int)nMsg, zErrmsg,
126923127531
"no entry point [%s] in shared library [%s]", zEntry, zFile);
126924127532
sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
126925127533
}
126926127534
}
126927127535
sqlite3OsDlClose(pVfs, handle);
@@ -126951,10 +127559,23 @@
126951127559
sqlite3DbFree(db, db->aExtension);
126952127560
db->aExtension = aHandle;
126953127561
126954127562
db->aExtension[db->nExtension++] = handle;
126955127563
return SQLITE_OK;
127564
+
127565
+extension_not_found:
127566
+ if( pzErrMsg ){
127567
+ nMsg += 300;
127568
+ *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
127569
+ if( zErrmsg ){
127570
+ assert( nMsg<0x7fffffff ); /* zErrmsg would be NULL if not so */
127571
+ sqlite3_snprintf((int)nMsg, zErrmsg,
127572
+ "unable to open shared library [%.*s]", SQLITE_MAX_PATHLEN, zFile);
127573
+ sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
127574
+ }
127575
+ }
127576
+ return SQLITE_ERROR;
126956127577
}
126957127578
SQLITE_API int sqlite3_load_extension(
126958127579
sqlite3 *db, /* Load the extension into this database connection */
126959127580
const char *zFile, /* Name of the shared library containing extension */
126960127581
const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
@@ -130510,18 +131131,18 @@
130510131131
130511131132
assert( argc==5 );
130512131133
UNUSED_PARAMETER2(NotUsed, argc);
130513131134
assert( sqlite3_mutex_held(db->mutex) );
130514131135
db->mDbFlags |= DBFLAG_EncodingFixed;
131136
+ if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */
130515131137
pData->nInitRow++;
130516131138
if( db->mallocFailed ){
130517131139
corruptSchema(pData, argv, 0);
130518131140
return 1;
130519131141
}
130520131142
130521131143
assert( iDb>=0 && iDb<db->nDb );
130522
- if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */
130523131144
if( argv[3]==0 ){
130524131145
corruptSchema(pData, argv, 0);
130525131146
}else if( argv[4]
130526131147
&& 'c'==sqlite3UpperToLower[(unsigned char)argv[4][0]]
130527131148
&& 'r'==sqlite3UpperToLower[(unsigned char)argv[4][1]] ){
@@ -130791,22 +131412,26 @@
130791131412
if( rc==SQLITE_OK ){
130792131413
sqlite3AnalysisLoad(db, iDb);
130793131414
}
130794131415
#endif
130795131416
}
131417
+ assert( pDb == &(db->aDb[iDb]) );
130796131418
if( db->mallocFailed ){
130797131419
rc = SQLITE_NOMEM_BKPT;
130798131420
sqlite3ResetAllSchemasOfConnection(db);
130799
- }
131421
+ pDb = &db->aDb[iDb];
131422
+ }else
130800131423
if( rc==SQLITE_OK || (db->flags&SQLITE_NoSchemaError)){
130801
- /* Black magic: If the SQLITE_NoSchemaError flag is set, then consider
130802
- ** the schema loaded, even if errors occurred. In this situation the
130803
- ** current sqlite3_prepare() operation will fail, but the following one
130804
- ** will attempt to compile the supplied statement against whatever subset
130805
- ** of the schema was loaded before the error occurred. The primary
130806
- ** purpose of this is to allow access to the sqlite_schema table
130807
- ** even when its contents have been corrupted.
131424
+ /* Hack: If the SQLITE_NoSchemaError flag is set, then consider
131425
+ ** the schema loaded, even if errors (other than OOM) occurred. In
131426
+ ** this situation the current sqlite3_prepare() operation will fail,
131427
+ ** but the following one will attempt to compile the supplied statement
131428
+ ** against whatever subset of the schema was loaded before the error
131429
+ ** occurred.
131430
+ **
131431
+ ** The primary purpose of this is to allow access to the sqlite_schema
131432
+ ** table even when its contents have been corrupted.
130808131433
*/
130809131434
DbSetProperty(db, iDb, DB_SchemaLoaded);
130810131435
rc = SQLITE_OK;
130811131436
}
130812131437
@@ -133387,11 +134012,11 @@
133387134012
**
133388134013
** full=ON, short=ANY: If the result refers directly to a table column,
133389134014
** then the result column name with the table name
133390134015
** prefix, ex: TABLE.COLUMN. Otherwise use zSpan.
133391134016
*/
133392
-static void generateColumnNames(
134017
+SQLITE_PRIVATE void sqlite3GenerateColumnNames(
133393134018
Parse *pParse, /* Parser context */
133394134019
Select *pSelect /* Generate column names for this SELECT statement */
133395134020
){
133396134021
Vdbe *v = pParse->pVdbe;
133397134022
int i;
@@ -133477,11 +134102,11 @@
133477134102
** That is the only documented guarantee. However, countless applications
133478134103
** developed over the years have made baseless assumptions about column names
133479134104
** and will break if those assumptions changes. Hence, use extreme caution
133480134105
** when modifying this routine to avoid breaking legacy.
133481134106
**
133482
-** See Also: generateColumnNames()
134107
+** See Also: sqlite3GenerateColumnNames()
133483134108
*/
133484134109
SQLITE_PRIVATE int sqlite3ColumnsFromExprList(
133485134110
Parse *pParse, /* Parsing context */
133486134111
ExprList *pEList, /* Expr list from which to derive column names */
133487134112
i16 *pnCol, /* Write the number of columns here */
@@ -134180,10 +134805,11 @@
134180134805
int nLimit = 0; /* Initialize to suppress harmless compiler warning */
134181134806
assert( !pPrior->pLimit );
134182134807
pPrior->iLimit = p->iLimit;
134183134808
pPrior->iOffset = p->iOffset;
134184134809
pPrior->pLimit = p->pLimit;
134810
+ SELECTTRACE(1, pParse, p, ("multiSelect UNION ALL left...\n"));
134185134811
rc = sqlite3Select(pParse, pPrior, &dest);
134186134812
pPrior->pLimit = 0;
134187134813
if( rc ){
134188134814
goto multi_select_end;
134189134815
}
@@ -134197,10 +134823,11 @@
134197134823
sqlite3VdbeAddOp3(v, OP_OffsetLimit,
134198134824
p->iLimit, p->iOffset+1, p->iOffset);
134199134825
}
134200134826
}
134201134827
ExplainQueryPlan((pParse, 1, "UNION ALL"));
134828
+ SELECTTRACE(1, pParse, p, ("multiSelect UNION ALL right...\n"));
134202134829
rc = sqlite3Select(pParse, p, &dest);
134203134830
testcase( rc!=SQLITE_OK );
134204134831
pDelete = p->pPrior;
134205134832
p->pPrior = pPrior;
134206134833
p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
@@ -134249,10 +134876,11 @@
134249134876
134250134877
/* Code the SELECT statements to our left
134251134878
*/
134252134879
assert( !pPrior->pOrderBy );
134253134880
sqlite3SelectDestInit(&uniondest, priorOp, unionTab);
134881
+ SELECTTRACE(1, pParse, p, ("multiSelect EXCEPT/UNION left...\n"));
134254134882
rc = sqlite3Select(pParse, pPrior, &uniondest);
134255134883
if( rc ){
134256134884
goto multi_select_end;
134257134885
}
134258134886
@@ -134268,10 +134896,11 @@
134268134896
pLimit = p->pLimit;
134269134897
p->pLimit = 0;
134270134898
uniondest.eDest = op;
134271134899
ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
134272134900
sqlite3SelectOpName(p->op)));
134901
+ SELECTTRACE(1, pParse, p, ("multiSelect EXCEPT/UNION right...\n"));
134273134902
rc = sqlite3Select(pParse, p, &uniondest);
134274134903
testcase( rc!=SQLITE_OK );
134275134904
assert( p->pOrderBy==0 );
134276134905
pDelete = p->pPrior;
134277134906
p->pPrior = pPrior;
@@ -134328,10 +134957,11 @@
134328134957
assert( p->pEList );
134329134958
134330134959
/* Code the SELECTs to our left into temporary table "tab1".
134331134960
*/
134332134961
sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1);
134962
+ SELECTTRACE(1, pParse, p, ("multiSelect INTERSECT left...\n"));
134333134963
rc = sqlite3Select(pParse, pPrior, &intersectdest);
134334134964
if( rc ){
134335134965
goto multi_select_end;
134336134966
}
134337134967
@@ -134344,10 +134974,11 @@
134344134974
pLimit = p->pLimit;
134345134975
p->pLimit = 0;
134346134976
intersectdest.iSDParm = tab2;
134347134977
ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
134348134978
sqlite3SelectOpName(p->op)));
134979
+ SELECTTRACE(1, pParse, p, ("multiSelect INTERSECT right...\n"));
134349134980
rc = sqlite3Select(pParse, p, &intersectdest);
134350134981
testcase( rc!=SQLITE_OK );
134351134982
pDelete = p->pPrior;
134352134983
p->pPrior = pPrior;
134353134984
if( p->nSelectRow>pPrior->nSelectRow ){
@@ -134976,10 +135607,13 @@
134976135607
if( p->pPrior ){
134977135608
sqlite3SelectDelete(db, p->pPrior);
134978135609
}
134979135610
p->pPrior = pPrior;
134980135611
pPrior->pNext = p;
135612
+
135613
+ sqlite3ExprListDelete(db, pPrior->pOrderBy);
135614
+ pPrior->pOrderBy = 0;
134981135615
134982135616
/*** TBD: Insert subroutine calls to close cursors on incomplete
134983135617
**** subqueries ****/
134984135618
ExplainQueryPlanPop(pParse);
134985135619
return pParse->nErr!=0;
@@ -135056,30 +135690,32 @@
135056135690
ifNullRow.flags = EP_IfNullRow;
135057135691
pCopy = &ifNullRow;
135058135692
}
135059135693
testcase( ExprHasProperty(pCopy, EP_Subquery) );
135060135694
pNew = sqlite3ExprDup(db, pCopy, 0);
135061
- if( pNew && pSubst->isLeftJoin ){
135695
+ if( db->mallocFailed ){
135696
+ sqlite3ExprDelete(db, pNew);
135697
+ return pExpr;
135698
+ }
135699
+ if( pSubst->isLeftJoin ){
135062135700
ExprSetProperty(pNew, EP_CanBeNull);
135063135701
}
135064
- if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){
135702
+ if( ExprHasProperty(pExpr,EP_FromJoin) ){
135065135703
sqlite3SetJoinExpr(pNew, pExpr->iRightJoinTable);
135066135704
}
135067135705
sqlite3ExprDelete(db, pExpr);
135068135706
pExpr = pNew;
135069135707
135070135708
/* Ensure that the expression now has an implicit collation sequence,
135071135709
** just as it did when it was a column of a view or sub-query. */
135072
- if( pExpr ){
135073
- if( pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE ){
135074
- CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, pExpr);
135075
- pExpr = sqlite3ExprAddCollateString(pSubst->pParse, pExpr,
135076
- (pColl ? pColl->zName : "BINARY")
135077
- );
135078
- }
135079
- ExprClearProperty(pExpr, EP_Collate);
135080
- }
135710
+ if( pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE ){
135711
+ CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, pExpr);
135712
+ pExpr = sqlite3ExprAddCollateString(pSubst->pParse, pExpr,
135713
+ (pColl ? pColl->zName : "BINARY")
135714
+ );
135715
+ }
135716
+ ExprClearProperty(pExpr, EP_Collate);
135081135717
}
135082135718
}
135083135719
}else{
135084135720
if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){
135085135721
pExpr->iTable = pSubst->iNewTable;
@@ -135194,11 +135830,14 @@
135194135830
int i;
135195135831
SrcItem *pItem;
135196135832
for(i=0, pItem=pSrc->a; i<pSrc->nSrc; i++, pItem++){
135197135833
if( i!=iExcept ){
135198135834
Select *p;
135199
- pItem->iCursor = aCsrMap[pItem->iCursor] = pParse->nTab++;
135835
+ if( !pItem->fg.isRecursive || aCsrMap[pItem->iCursor]==0 ){
135836
+ aCsrMap[pItem->iCursor] = pParse->nTab++;
135837
+ }
135838
+ pItem->iCursor = aCsrMap[pItem->iCursor];
135200135839
for(p=pItem->pSelect; p; p=p->pPrior){
135201135840
srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1);
135202135841
}
135203135842
}
135204135843
}
@@ -135634,11 +136273,11 @@
135634136273
pSubitem->pTab = pItemTab;
135635136274
if( pNew==0 ){
135636136275
p->pPrior = pPrior;
135637136276
}else{
135638136277
pNew->selId = ++pParse->nSelect;
135639
- if( aCsrMap && db->mallocFailed==0 ){
136278
+ if( aCsrMap && ALWAYS(db->mallocFailed==0) ){
135640136279
renumberCursors(pParse, pNew, iFrom, aCsrMap);
135641136280
}
135642136281
pNew->pPrior = pPrior;
135643136282
if( pPrior ) pPrior->pNext = pNew;
135644136283
pNew->pNext = p;
@@ -135833,12 +136472,14 @@
135833136472
** a known value due to WHERE clause constraints of the form COLUMN=VALUE.
135834136473
*/
135835136474
typedef struct WhereConst WhereConst;
135836136475
struct WhereConst {
135837136476
Parse *pParse; /* Parsing context */
136477
+ u8 *pOomFault; /* Pointer to pParse->db->mallocFailed */
135838136478
int nConst; /* Number for COLUMN=CONSTANT terms */
135839136479
int nChng; /* Number of times a constant is propagated */
136480
+ int bHasAffBlob; /* At least one column in apExpr[] as affinity BLOB */
135840136481
Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */
135841136482
};
135842136483
135843136484
/*
135844136485
** Add a new entry to the pConst object. Except, do not add duplicate
@@ -135873,10 +136514,13 @@
135873136514
&& pE2->iColumn==pColumn->iColumn
135874136515
){
135875136516
return; /* Already present. Return without doing anything. */
135876136517
}
135877136518
}
136519
+ if( sqlite3ExprAffinity(pColumn)==SQLITE_AFF_BLOB ){
136520
+ pConst->bHasAffBlob = 1;
136521
+ }
135878136522
135879136523
pConst->nConst++;
135880136524
pConst->apExpr = sqlite3DbReallocOrFree(pConst->pParse->db, pConst->apExpr,
135881136525
pConst->nConst*2*sizeof(Expr*));
135882136526
if( pConst->apExpr==0 ){
@@ -135893,11 +136537,11 @@
135893136537
** is part of the AND-connected terms of the expression. For each term
135894136538
** found, add it to the pConst structure.
135895136539
*/
135896136540
static void findConstInWhere(WhereConst *pConst, Expr *pExpr){
135897136541
Expr *pRight, *pLeft;
135898
- if( pExpr==0 ) return;
136542
+ if( NEVER(pExpr==0) ) return;
135899136543
if( ExprHasProperty(pExpr, EP_FromJoin) ) return;
135900136544
if( pExpr->op==TK_AND ){
135901136545
findConstInWhere(pConst, pExpr->pRight);
135902136546
findConstInWhere(pConst, pExpr->pLeft);
135903136547
return;
@@ -135914,40 +136558,86 @@
135914136558
constInsert(pConst,pLeft,pRight,pExpr);
135915136559
}
135916136560
}
135917136561
135918136562
/*
135919
-** This is a Walker expression callback. pExpr is a candidate expression
135920
-** to be replaced by a value. If pExpr is equivalent to one of the
135921
-** columns named in pWalker->u.pConst, then overwrite it with its
135922
-** corresponding value.
136563
+** This is a helper function for Walker callback propagateConstantExprRewrite().
136564
+**
136565
+** Argument pExpr is a candidate expression to be replaced by a value. If
136566
+** pExpr is equivalent to one of the columns named in pWalker->u.pConst,
136567
+** then overwrite it with the corresponding value. Except, do not do so
136568
+** if argument bIgnoreAffBlob is non-zero and the affinity of pExpr
136569
+** is SQLITE_AFF_BLOB.
135923136570
*/
135924
-static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){
136571
+static int propagateConstantExprRewriteOne(
136572
+ WhereConst *pConst,
136573
+ Expr *pExpr,
136574
+ int bIgnoreAffBlob
136575
+){
135925136576
int i;
135926
- WhereConst *pConst;
136577
+ if( pConst->pOomFault[0] ) return WRC_Prune;
135927136578
if( pExpr->op!=TK_COLUMN ) return WRC_Continue;
135928136579
if( ExprHasProperty(pExpr, EP_FixedCol|EP_FromJoin) ){
135929136580
testcase( ExprHasProperty(pExpr, EP_FixedCol) );
135930136581
testcase( ExprHasProperty(pExpr, EP_FromJoin) );
135931136582
return WRC_Continue;
135932136583
}
135933
- pConst = pWalker->u.pConst;
135934136584
for(i=0; i<pConst->nConst; i++){
135935136585
Expr *pColumn = pConst->apExpr[i*2];
135936136586
if( pColumn==pExpr ) continue;
135937136587
if( pColumn->iTable!=pExpr->iTable ) continue;
135938136588
if( pColumn->iColumn!=pExpr->iColumn ) continue;
136589
+ if( bIgnoreAffBlob && sqlite3ExprAffinity(pColumn)==SQLITE_AFF_BLOB ){
136590
+ break;
136591
+ }
135939136592
/* A match is found. Add the EP_FixedCol property */
135940136593
pConst->nChng++;
135941136594
ExprClearProperty(pExpr, EP_Leaf);
135942136595
ExprSetProperty(pExpr, EP_FixedCol);
135943136596
assert( pExpr->pLeft==0 );
135944136597
pExpr->pLeft = sqlite3ExprDup(pConst->pParse->db, pConst->apExpr[i*2+1], 0);
136598
+ if( pConst->pParse->db->mallocFailed ) return WRC_Prune;
135945136599
break;
135946136600
}
135947136601
return WRC_Prune;
135948136602
}
136603
+
136604
+/*
136605
+** This is a Walker expression callback. pExpr is a node from the WHERE
136606
+** clause of a SELECT statement. This function examines pExpr to see if
136607
+** any substitutions based on the contents of pWalker->u.pConst should
136608
+** be made to pExpr or its immediate children.
136609
+**
136610
+** A substitution is made if:
136611
+**
136612
+** + pExpr is a column with an affinity other than BLOB that matches
136613
+** one of the columns in pWalker->u.pConst, or
136614
+**
136615
+** + pExpr is a binary comparison operator (=, <=, >=, <, >) that
136616
+** uses an affinity other than TEXT and one of its immediate
136617
+** children is a column that matches one of the columns in
136618
+** pWalker->u.pConst.
136619
+*/
136620
+static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){
136621
+ WhereConst *pConst = pWalker->u.pConst;
136622
+ assert( TK_GT==TK_EQ+1 );
136623
+ assert( TK_LE==TK_EQ+2 );
136624
+ assert( TK_LT==TK_EQ+3 );
136625
+ assert( TK_GE==TK_EQ+4 );
136626
+ if( pConst->bHasAffBlob ){
136627
+ if( (pExpr->op>=TK_EQ && pExpr->op<=TK_GE)
136628
+ || pExpr->op==TK_IS
136629
+ ){
136630
+ propagateConstantExprRewriteOne(pConst, pExpr->pLeft, 0);
136631
+ if( pConst->pOomFault[0] ) return WRC_Prune;
136632
+ if( sqlite3ExprAffinity(pExpr->pLeft)!=SQLITE_AFF_TEXT ){
136633
+ propagateConstantExprRewriteOne(pConst, pExpr->pRight, 0);
136634
+ }
136635
+ }
136636
+ }
136637
+ return propagateConstantExprRewriteOne(pConst, pExpr, pConst->bHasAffBlob);
136638
+}
135949136639
135950136640
/*
135951136641
** The WHERE-clause constant propagation optimization.
135952136642
**
135953136643
** If the WHERE clause contains terms of the form COLUMN=CONSTANT or
@@ -135980,23 +136670,40 @@
135980136670
** "b=a" to "b=123" but rather the "a" in "b=a" is tagged with EP_FixedCol
135981136671
** and the "123" value is hung off of the pLeft pointer. Code generator
135982136672
** routines know to generate the constant "123" instead of looking up the
135983136673
** column value. Also, to avoid collation problems, this optimization is
135984136674
** only attempted if the "a=123" term uses the default BINARY collation.
136675
+**
136676
+** 2021-05-25 forum post 6a06202608: Another troublesome case is...
136677
+**
136678
+** CREATE TABLE t1(x);
136679
+** INSERT INTO t1 VALUES(10.0);
136680
+** SELECT 1 FROM t1 WHERE x=10 AND x LIKE 10;
136681
+**
136682
+** The query should return no rows, because the t1.x value is '10.0' not '10'
136683
+** and '10.0' is not LIKE '10'. But if we are not careful, the first WHERE
136684
+** term "x=10" will cause the second WHERE term to become "10 LIKE 10",
136685
+** resulting in a false positive. To avoid this, constant propagation for
136686
+** columns with BLOB affinity is only allowed if the constant is used with
136687
+** operators ==, <=, <, >=, >, or IS in a way that will cause the correct
136688
+** type conversions to occur. See logic associated with the bHasAffBlob flag
136689
+** for details.
135985136690
*/
135986136691
static int propagateConstants(
135987136692
Parse *pParse, /* The parsing context */
135988136693
Select *p /* The query in which to propagate constants */
135989136694
){
135990136695
WhereConst x;
135991136696
Walker w;
135992136697
int nChng = 0;
135993136698
x.pParse = pParse;
136699
+ x.pOomFault = &pParse->db->mallocFailed;
135994136700
do{
135995136701
x.nConst = 0;
135996136702
x.nChng = 0;
135997136703
x.apExpr = 0;
136704
+ x.bHasAffBlob = 0;
135998136705
findConstInWhere(&x, p->pWhere);
135999136706
if( x.nConst ){
136000136707
memset(&w, 0, sizeof(w));
136001136708
w.pParse = pParse;
136002136709
w.xExprCallback = propagateConstantExprRewrite;
@@ -136429,36 +137136,47 @@
136429137136
if( sqlite3StrICmp(zName, p->a[i].zName)==0 ){
136430137137
*ppContext = p;
136431137138
return &p->a[i];
136432137139
}
136433137140
}
137141
+ if( p->bView ) break;
136434137142
}
136435137143
return 0;
136436137144
}
136437137145
136438137146
/* The code generator maintains a stack of active WITH clauses
136439137147
** with the inner-most WITH clause being at the top of the stack.
136440137148
**
136441137149
** This routine pushes the WITH clause passed as the second argument
136442137150
** onto the top of the stack. If argument bFree is true, then this
136443
-** WITH clause will never be popped from the stack. In this case it
136444
-** should be freed along with the Parse object. In other cases, when
137151
+** WITH clause will never be popped from the stack but should instead
137152
+** be freed along with the Parse object. In other cases, when
136445137153
** bFree==0, the With object will be freed along with the SELECT
136446137154
** statement with which it is associated.
137155
+**
137156
+** This routine returns a copy of pWith. Or, if bFree is true and
137157
+** the pWith object is destroyed immediately due to an OOM condition,
137158
+** then this routine return NULL.
137159
+**
137160
+** If bFree is true, do not continue to use the pWith pointer after
137161
+** calling this routine, Instead, use only the return value.
136447137162
*/
136448
-SQLITE_PRIVATE void sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){
137163
+SQLITE_PRIVATE With *sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){
136449137164
if( pWith ){
136450
- assert( pParse->pWith!=pWith );
136451
- pWith->pOuter = pParse->pWith;
136452
- pParse->pWith = pWith;
136453137165
if( bFree ){
136454
- sqlite3ParserAddCleanup(pParse,
136455
- (void(*)(sqlite3*,void*))sqlite3WithDelete,
136456
- pWith);
136457
- testcase( pParse->earlyCleanup );
137166
+ pWith = (With*)sqlite3ParserAddCleanup(pParse,
137167
+ (void(*)(sqlite3*,void*))sqlite3WithDelete,
137168
+ pWith);
137169
+ if( pWith==0 ) return 0;
137170
+ }
137171
+ if( pParse->nErr==0 ){
137172
+ assert( pParse->pWith!=pWith );
137173
+ pWith->pOuter = pParse->pWith;
137174
+ pParse->pWith = pWith;
136458137175
}
136459137176
}
137177
+ return pWith;
136460137178
}
136461137179
136462137180
/*
136463137181
** This function checks if argument pFrom refers to a CTE declared by
136464137182
** a WITH clause on the stack currently maintained by the parser (on the
@@ -136483,15 +137201,28 @@
136483137201
136484137202
assert( pFrom->pTab==0 );
136485137203
if( pParse->pWith==0 ){
136486137204
/* There are no WITH clauses in the stack. No match is possible */
136487137205
return 0;
137206
+ }
137207
+ if( pParse->nErr ){
137208
+ /* Prior errors might have left pParse->pWith in a goofy state, so
137209
+ ** go no further. */
137210
+ return 0;
136488137211
}
136489137212
if( pFrom->zDatabase!=0 ){
136490137213
/* The FROM term contains a schema qualifier (ex: main.t1) and so
136491137214
** it cannot possibly be a CTE reference. */
136492137215
return 0;
137216
+ }
137217
+ if( pFrom->fg.notCte ){
137218
+ /* The FROM term is specifically excluded from matching a CTE.
137219
+ ** (1) It is part of a trigger that used to have zDatabase but had
137220
+ ** zDatabase removed by sqlite3FixTriggerStep().
137221
+ ** (2) This is the first term in the FROM clause of an UPDATE.
137222
+ */
137223
+ return 0;
136493137224
}
136494137225
pCte = searchWith(pParse->pWith, pFrom, &pWith);
136495137226
if( pCte ){
136496137227
sqlite3 *db = pParse->db;
136497137228
Table *pTab;
@@ -136534,10 +137265,11 @@
136534137265
pTab->iPKey = -1;
136535137266
pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
136536137267
pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid;
136537137268
pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0);
136538137269
if( db->mallocFailed ) return 2;
137270
+ pFrom->pSelect->selFlags |= SF_CopyCte;
136539137271
assert( pFrom->pSelect );
136540137272
pFrom->fg.isCte = 1;
136541137273
pFrom->u2.pCteUse = pCteUse;
136542137274
pCteUse->nUse++;
136543137275
if( pCteUse->nUse>=2 && pCteUse->eM10d==M10d_Any ){
@@ -136637,22 +137369,20 @@
136637137369
**
136638137370
** This function is used as the xSelectCallback2() callback by
136639137371
** sqlite3SelectExpand() when walking a SELECT tree to resolve table
136640137372
** names and other FROM clause elements.
136641137373
*/
136642
-static void selectPopWith(Walker *pWalker, Select *p){
137374
+SQLITE_PRIVATE void sqlite3SelectPopWith(Walker *pWalker, Select *p){
136643137375
Parse *pParse = pWalker->pParse;
136644137376
if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){
136645137377
With *pWith = findRightmost(p)->pWith;
136646137378
if( pWith!=0 ){
136647137379
assert( pParse->pWith==pWith || pParse->nErr );
136648137380
pParse->pWith = pWith->pOuter;
136649137381
}
136650137382
}
136651137383
}
136652
-#else
136653
-#define selectPopWith 0
136654137384
#endif
136655137385
136656137386
/*
136657137387
** The SrcList_item structure passed as the second argument represents a
136658137388
** sub-query in the FROM clause of a SELECT statement. This function
@@ -136735,10 +137465,19 @@
136735137465
/* Renumber selId because it has been copied from a view */
136736137466
p->selId = ++pParse->nSelect;
136737137467
}
136738137468
pTabList = p->pSrc;
136739137469
pEList = p->pEList;
137470
+ if( pParse->pWith && (p->selFlags & SF_View) ){
137471
+ if( p->pWith==0 ){
137472
+ p->pWith = (With*)sqlite3DbMallocZero(db, sizeof(With));
137473
+ if( p->pWith==0 ){
137474
+ return WRC_Abort;
137475
+ }
137476
+ }
137477
+ p->pWith->bView = 1;
137478
+ }
136740137479
sqlite3WithPush(pParse, p->pWith, 0);
136741137480
136742137481
/* Make sure cursor numbers have been assigned to all entries in
136743137482
** the FROM clause of the SELECT statement.
136744137483
*/
@@ -136795,10 +137534,11 @@
136795137534
){
136796137535
sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited",
136797137536
pTab->zName);
136798137537
}
136799137538
#ifndef SQLITE_OMIT_VIRTUALTABLE
137539
+ assert( SQLITE_VTABRISK_Normal==1 && SQLITE_VTABRISK_High==2 );
136800137540
if( IsVirtual(pTab)
136801137541
&& pFrom->fg.fromDDL
136802137542
&& ALWAYS(pTab->pVTable!=0)
136803137543
&& pTab->pVTable->eVtabRisk > ((db->flags & SQLITE_TrustedSchema)!=0)
136804137544
){
@@ -137035,11 +137775,11 @@
137035137775
w.xSelectCallback = convertCompoundSelectToSubquery;
137036137776
w.xSelectCallback2 = 0;
137037137777
sqlite3WalkSelect(&w, pSelect);
137038137778
}
137039137779
w.xSelectCallback = selectExpander;
137040
- w.xSelectCallback2 = selectPopWith;
137780
+ w.xSelectCallback2 = sqlite3SelectPopWith;
137041137781
w.eCode = 0;
137042137782
sqlite3WalkSelect(&w, pSelect);
137043137783
}
137044137784
137045137785
@@ -137622,16 +138362,15 @@
137622138362
}
137623138363
}
137624138364
}
137625138365
137626138366
if( pDest->eDest==SRT_Output ){
137627
- generateColumnNames(pParse, p);
138367
+ sqlite3GenerateColumnNames(pParse, p);
137628138368
}
137629138369
137630138370
#ifndef SQLITE_OMIT_WINDOWFUNC
137631
- rc = sqlite3WindowRewrite(pParse, p);
137632
- if( rc ){
138371
+ if( sqlite3WindowRewrite(pParse, p) ){
137633138372
assert( db->mallocFailed || pParse->nErr>0 );
137634138373
goto select_end;
137635138374
}
137636138375
#if SELECTTRACE_ENABLED
137637138376
if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){
@@ -137753,11 +138492,12 @@
137753138492
/* Do the WHERE-clause constant propagation optimization if this is
137754138493
** a join. No need to speed time on this operation for non-join queries
137755138494
** as the equivalent optimization will be handled by query planner in
137756138495
** sqlite3WhereBegin().
137757138496
*/
137758
- if( pTabList->nSrc>1
138497
+ if( p->pWhere!=0
138498
+ && p->pWhere->op==TK_AND
137759138499
&& OptimizationEnabled(db, SQLITE_PropagateConst)
137760138500
&& propagateConstants(pParse, p)
137761138501
){
137762138502
#if SELECTTRACE_ENABLED
137763138503
if( sqlite3SelectTrace & 0x100 ){
@@ -137816,23 +138556,12 @@
137816138556
/* Generate code for all sub-queries in the FROM clause
137817138557
*/
137818138558
pSub = pItem->pSelect;
137819138559
if( pSub==0 ) continue;
137820138560
137821
- /* The code for a subquery should only be generated once, though it is
137822
- ** technically harmless for it to be generated multiple times. The
137823
- ** following assert() will detect if something changes to cause
137824
- ** the same subquery to be coded multiple times, as a signal to the
137825
- ** developers to try to optimize the situation.
137826
- **
137827
- ** Update 2019-07-24:
137828
- ** See ticket https://sqlite.org/src/tktview/c52b09c7f38903b1311cec40.
137829
- ** The dbsqlfuzz fuzzer found a case where the same subquery gets
137830
- ** coded twice. So this assert() now becomes a testcase(). It should
137831
- ** be very rare, though.
137832
- */
137833
- testcase( pItem->addrFillSub!=0 );
138561
+ /* The code for a subquery should only be generated once. */
138562
+ assert( pItem->addrFillSub==0 );
137834138563
137835138564
/* Increment Parse.nHeight by the height of the largest expression
137836138565
** tree referred to by this, the parent select. The child select
137837138566
** may contain expression trees of at most
137838138567
** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit
@@ -137915,18 +138644,17 @@
137915138644
sqlite3VdbeAddOp2(v, OP_Gosub, pPrior->regReturn, pPrior->addrFillSub);
137916138645
}
137917138646
sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);
137918138647
pSub->nSelectRow = pPrior->pSelect->nSelectRow;
137919138648
}else{
137920
- /* Materalize the view. If the view is not correlated, generate a
138649
+ /* Materialize the view. If the view is not correlated, generate a
137921138650
** subroutine to do the materialization so that subsequent uses of
137922138651
** the same view can reuse the materialization. */
137923138652
int topAddr;
137924138653
int onceAddr = 0;
137925138654
int retAddr;
137926138655
137927
- testcase( pItem->addrFillSub==0 ); /* Ticket c52b09c7f38903b1311 */
137928138656
pItem->regReturn = ++pParse->nMem;
137929138657
topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn);
137930138658
pItem->addrFillSub = topAddr+1;
137931138659
if( pItem->fg.isCorrelated==0 ){
137932138660
/* If the subquery is not correlated and if we are not inside of
@@ -138344,12 +139072,14 @@
138344139072
sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);
138345139073
SELECTTRACE(1,pParse,p,("WhereBegin\n"));
138346139074
pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pGroupBy, pDistinct,
138347139075
WHERE_GROUPBY | (orderByGrp ? WHERE_SORTBYGROUP : 0) | distFlag, 0
138348139076
);
138349
- sqlite3ExprListDelete(db, pDistinct);
138350
- if( pWInfo==0 ) goto select_end;
139077
+ if( pWInfo==0 ){
139078
+ sqlite3ExprListDelete(db, pDistinct);
139079
+ goto select_end;
139080
+ }
138351139081
eDist = sqlite3WhereIsDistinct(pWInfo);
138352139082
SELECTTRACE(1,pParse,p,("WhereBegin returns\n"));
138353139083
if( sqlite3WhereIsOrdered(pWInfo)==pGroupBy->nExpr ){
138354139084
/* The optimizer is able to deliver rows in group by order so
138355139085
** we do not have to sort. The OP_OpenEphemeral table will be
@@ -138478,10 +139208,11 @@
138478139208
}else{
138479139209
SELECTTRACE(1,pParse,p,("WhereEnd\n"));
138480139210
sqlite3WhereEnd(pWInfo);
138481139211
sqlite3VdbeChangeToNoop(v, addrSortingIdx);
138482139212
}
139213
+ sqlite3ExprListDelete(db, pDistinct);
138483139214
138484139215
/* Output the final row of result
138485139216
*/
138486139217
sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);
138487139218
VdbeComment((v, "output final row"));
@@ -138692,10 +139423,12 @@
138692139423
138693139424
/* Control jumps to here if an error is encountered above, or upon
138694139425
** successful coding of the SELECT.
138695139426
*/
138696139427
select_end:
139428
+ assert( db->mallocFailed==0 || db->mallocFailed==1 );
139429
+ pParse->nErr += db->mallocFailed;
138697139430
sqlite3ExprListDelete(db, pMinMaxOrderBy);
138698139431
#ifdef SQLITE_DEBUG
138699139432
if( pAggInfo && !db->mallocFailed ){
138700139433
for(i=0; i<pAggInfo->nColumn; i++){
138701139434
Expr *pExpr = pAggInfo->aCol[i].pCExpr;
@@ -138982,37 +139715,45 @@
138982139715
if( pParse->disableTriggers ){
138983139716
return 0;
138984139717
}
138985139718
pTmpSchema = pParse->db->aDb[1].pSchema;
138986139719
p = sqliteHashFirst(&pTmpSchema->trigHash);
138987
- if( p==0 ){
138988
- return pTab->pTrigger;
138989
- }
138990139720
pList = pTab->pTrigger;
138991
- if( pTmpSchema!=pTab->pSchema ){
138992
- while( p ){
138993
- Trigger *pTrig = (Trigger *)sqliteHashData(p);
138994
- if( pTrig->pTabSchema==pTab->pSchema
138995
- && 0==sqlite3StrICmp(pTrig->table, pTab->zName)
138996
- ){
138997
- pTrig->pNext = pList;
138998
- pList = pTrig;
138999
- }else if( pTrig->op==TK_RETURNING
139721
+ while( p ){
139722
+ Trigger *pTrig = (Trigger *)sqliteHashData(p);
139723
+ if( pTrig->pTabSchema==pTab->pSchema
139724
+ && pTrig->table
139725
+ && 0==sqlite3StrICmp(pTrig->table, pTab->zName)
139726
+ && pTrig->pTabSchema!=pTmpSchema
139727
+ ){
139728
+ pTrig->pNext = pList;
139729
+ pList = pTrig;
139730
+ }else if( pTrig->op==TK_RETURNING
139000139731
#ifndef SQLITE_OMIT_VIRTUALTABLE
139001
- && pParse->db->pVtabCtx==0
139732
+ && pParse->db->pVtabCtx==0
139002139733
#endif
139003
- ){
139004
- assert( pParse->bReturning );
139005
- assert( &(pParse->u1.pReturning->retTrig) == pTrig );
139006
- pTrig->table = pTab->zName;
139007
- pTrig->pTabSchema = pTab->pSchema;
139008
- pTrig->pNext = pList;
139009
- pList = pTrig;
139010
- }
139011
- p = sqliteHashNext(p);
139012
- }
139013
- }
139734
+ ){
139735
+ assert( pParse->bReturning );
139736
+ assert( &(pParse->u1.pReturning->retTrig) == pTrig );
139737
+ pTrig->table = pTab->zName;
139738
+ pTrig->pTabSchema = pTab->pSchema;
139739
+ pTrig->pNext = pList;
139740
+ pList = pTrig;
139741
+ }
139742
+ p = sqliteHashNext(p);
139743
+ }
139744
+#if 0
139745
+ if( pList ){
139746
+ Trigger *pX;
139747
+ printf("Triggers for %s:", pTab->zName);
139748
+ for(pX=pList; pX; pX=pX->pNext){
139749
+ printf(" %s", pX->zName);
139750
+ }
139751
+ printf("\n");
139752
+ fflush(stdout);
139753
+ }
139754
+#endif
139014139755
return pList;
139015139756
}
139016139757
139017139758
/*
139018139759
** This is called by the parser when it sees a CREATE TRIGGER statement
@@ -139812,19 +140553,10 @@
139812140553
pItem->zEName = sqlite3DbStrDup(db, pList->a[i].zEName);
139813140554
pItem->eEName = pList->a[i].eEName;
139814140555
}
139815140556
}
139816140557
}
139817
- if( !db->mallocFailed ){
139818
- Vdbe *v = pParse->pVdbe;
139819
- assert( v!=0 );
139820
- sqlite3VdbeSetNumCols(v, pNew->nExpr);
139821
- for(i=0; i<pNew->nExpr; i++){
139822
- sqlite3VdbeSetColName(v, i, COLNAME_NAME, pNew->a[i].zEName,
139823
- SQLITE_TRANSIENT);
139824
- }
139825
- }
139826140558
return pNew;
139827140559
}
139828140560
139829140561
/*
139830140562
** Generate code for the RETURNING trigger. Unlike other triggers
@@ -139836,17 +140568,31 @@
139836140568
Trigger *pTrigger, /* The trigger step that defines the RETURNING */
139837140569
Table *pTab, /* The table to code triggers from */
139838140570
int regIn /* The first in an array of registers */
139839140571
){
139840140572
Vdbe *v = pParse->pVdbe;
140573
+ sqlite3 *db = pParse->db;
139841140574
ExprList *pNew;
139842140575
Returning *pReturning;
140576
+ Select sSelect;
140577
+ SrcList sFrom;
139843140578
139844140579
assert( v!=0 );
139845140580
assert( pParse->bReturning );
139846140581
pReturning = pParse->u1.pReturning;
139847140582
assert( pTrigger == &(pReturning->retTrig) );
140583
+ memset(&sSelect, 0, sizeof(sSelect));
140584
+ memset(&sFrom, 0, sizeof(sFrom));
140585
+ sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0);
140586
+ sSelect.pSrc = &sFrom;
140587
+ sFrom.nSrc = 1;
140588
+ sFrom.a[0].pTab = pTab;
140589
+ sqlite3SelectPrep(pParse, &sSelect, 0);
140590
+ if( db->mallocFailed==0 && pParse->nErr==0 ){
140591
+ sqlite3GenerateColumnNames(pParse, &sSelect);
140592
+ }
140593
+ sqlite3ExprListDelete(db, sSelect.pEList);
139848140594
pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab);
139849140595
if( pNew ){
139850140596
NameContext sNC;
139851140597
memset(&sNC, 0, sizeof(sNC));
139852140598
if( pReturning->nRetCol==0 ){
@@ -139863,17 +140609,18 @@
139863140609
int nCol = pNew->nExpr;
139864140610
int reg = pParse->nMem+1;
139865140611
pParse->nMem += nCol+2;
139866140612
pReturning->iRetReg = reg;
139867140613
for(i=0; i<nCol; i++){
139868
- sqlite3ExprCodeFactorable(pParse, pNew->a[i].pExpr, reg+i);
140614
+ Expr *pCol = pNew->a[i].pExpr;
140615
+ sqlite3ExprCodeFactorable(pParse, pCol, reg+i);
139869140616
}
139870140617
sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, i, reg+i);
139871140618
sqlite3VdbeAddOp2(v, OP_NewRowid, pReturning->iRetCur, reg+i+1);
139872140619
sqlite3VdbeAddOp3(v, OP_Insert, pReturning->iRetCur, reg+i, reg+i+1);
139873140620
}
139874
- sqlite3ExprListDelete(pParse->db, pNew);
140621
+ sqlite3ExprListDelete(db, pNew);
139875140622
pParse->eTriggerOp = 0;
139876140623
pParse->pTriggerTab = 0;
139877140624
}
139878140625
}
139879140626
@@ -140552,10 +141299,11 @@
140552141299
pSrc = sqlite3SrcListDup(db, pTabList, 0);
140553141300
pWhere2 = sqlite3ExprDup(db, pWhere, 0);
140554141301
140555141302
assert( pTabList->nSrc>1 );
140556141303
if( pSrc ){
141304
+ pSrc->a[0].fg.notCte = 1;
140557141305
pSrc->a[0].iCursor = -1;
140558141306
pSrc->a[0].pTab->nTabRef--;
140559141307
pSrc->a[0].pTab = 0;
140560141308
}
140561141309
if( pPk ){
@@ -140581,11 +141329,12 @@
140581141329
if( pLimit ){
140582141330
pGrp = sqlite3ExprListAppend(pParse, 0, sqlite3PExpr(pParse,TK_ROW,0,0));
140583141331
}
140584141332
#endif
140585141333
}
140586
- if( ALWAYS(pChanges) ){
141334
+ assert( pChanges!=0 || pParse->db->mallocFailed );
141335
+ if( pChanges ){
140587141336
for(i=0; i<pChanges->nExpr; i++){
140588141337
pList = sqlite3ExprListAppend(pParse, pList,
140589141338
sqlite3ExprDup(db, pChanges->a[i].pExpr, 0)
140590141339
);
140591141340
}
@@ -143607,10 +144356,11 @@
143607144356
pMod->pEpoTab = pTab;
143608144357
pTab->nTabRef = 1;
143609144358
pTab->pSchema = db->aDb[0].pSchema;
143610144359
assert( pTab->nModuleArg==0 );
143611144360
pTab->iPKey = -1;
144361
+ pTab->tabFlags |= TF_Eponymous;
143612144362
addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName));
143613144363
addModuleArgument(pParse, pTab, 0);
143614144364
addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName));
143615144365
rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr);
143616144366
if( rc ){
@@ -144023,12 +144773,12 @@
144023144773
WhereClause *pOrigWC; /* Original, innermost WhereClause */
144024144774
WhereClause *pWC; /* WhereClause currently being scanned */
144025144775
const char *zCollName; /* Required collating sequence, if not NULL */
144026144776
Expr *pIdxExpr; /* Search for this index expression */
144027144777
char idxaff; /* Must match this affinity, if zCollName!=NULL */
144028
- unsigned char nEquiv; /* Number of entries in aEquiv[] */
144029
- unsigned char iEquiv; /* Next unused slot in aEquiv[] */
144778
+ unsigned char nEquiv; /* Number of entries in aiCur[] and aiColumn[] */
144779
+ unsigned char iEquiv; /* Next unused slot in aiCur[] and aiColumn[] */
144030144780
u32 opMask; /* Acceptable operators */
144031144781
int k; /* Resume scanning at this->pWC->a[this->k] */
144032144782
int aiCur[11]; /* Cursors in the equivalence class */
144033144783
i16 aiColumn[11]; /* Corresponding column number in the eq-class */
144034144784
};
@@ -144333,10 +145083,11 @@
144333145083
#define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
144334145084
#define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
144335145085
#define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */
144336145086
#define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */
144337145087
#define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */
145088
+#define WHERE_TRANSCONS 0x00200000 /* Uses a transitive constraint */
144338145089
144339145090
#endif /* !defined(SQLITE_WHEREINT_H) */
144340145091
144341145092
/************** End of whereInt.h ********************************************/
144342145093
/************** Continuing where we left off in wherecode.c ******************/
@@ -144616,10 +145367,16 @@
144616145367
if( nLoop && (pTerm->wtFlags & TERM_LIKE)!=0 ){
144617145368
pTerm->wtFlags |= TERM_LIKECOND;
144618145369
}else{
144619145370
pTerm->wtFlags |= TERM_CODED;
144620145371
}
145372
+#ifdef WHERETRACE_ENABLED
145373
+ if( sqlite3WhereTrace & 0x20000 ){
145374
+ sqlite3DebugPrintf("DISABLE-");
145375
+ sqlite3WhereTermPrint(pTerm, (int)(pTerm - (pTerm->pWC->a)));
145376
+ }
145377
+#endif
144621145378
if( pTerm->iParent<0 ) break;
144622145379
pTerm = &pTerm->pWC->a[pTerm->iParent];
144623145380
assert( pTerm!=0 );
144624145381
pTerm->nChild--;
144625145382
if( pTerm->nChild!=0 ) break;
@@ -144933,11 +145690,26 @@
144933145690
pLevel->u.in.nIn = 0;
144934145691
}
144935145692
sqlite3DbFree(pParse->db, aiMap);
144936145693
#endif
144937145694
}
144938
- disableTerm(pLevel, pTerm);
145695
+
145696
+ /* As an optimization, try to disable the WHERE clause term that is
145697
+ ** driving the index as it will always be true. The correct answer is
145698
+ ** obtained regardless, but we might get the answer with fewer CPU cycles
145699
+ ** by omitting the term.
145700
+ **
145701
+ ** But do not disable the term unless we are certain that the term is
145702
+ ** not a transitive constraint. For an example of where that does not
145703
+ ** work, see https://sqlite.org/forum/forumpost/eb8613976a (2021-05-04)
145704
+ */
145705
+ if( (pLevel->pWLoop->wsFlags & WHERE_TRANSCONS)==0
145706
+ || (pTerm->eOperator & WO_EQUIV)==0
145707
+ ){
145708
+ disableTerm(pLevel, pTerm);
145709
+ }
145710
+
144939145711
return iReg;
144940145712
}
144941145713
144942145714
/*
144943145715
** Generate code that will evaluate all == and IN constraints for an
@@ -145019,10 +145791,11 @@
145019145791
zAff = sqlite3DbStrDup(pParse->db,sqlite3IndexAffinityStr(pParse->db,pIdx));
145020145792
assert( zAff!=0 || pParse->db->mallocFailed );
145021145793
145022145794
if( nSkip ){
145023145795
int iIdxCur = pLevel->iIdxCur;
145796
+ sqlite3VdbeAddOp3(v, OP_Null, 0, regBase, regBase+nSkip-1);
145024145797
sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur);
145025145798
VdbeCoverageIf(v, bRev==0);
145026145799
VdbeCoverageIf(v, bRev!=0);
145027145800
VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
145028145801
j = sqlite3VdbeAddOp0(v, OP_Goto);
@@ -145053,11 +145826,11 @@
145053145826
if( r1!=regBase+j ){
145054145827
if( nReg==1 ){
145055145828
sqlite3ReleaseTempReg(pParse, regBase);
145056145829
regBase = r1;
145057145830
}else{
145058
- sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j);
145831
+ sqlite3VdbeAddOp2(v, OP_Copy, r1, regBase+j);
145059145832
}
145060145833
}
145061145834
if( pTerm->eOperator & WO_IN ){
145062145835
if( pTerm->pExpr->flags & EP_xIsSelect ){
145063145836
/* No affinity ever needs to be (or should be) applied to a value
@@ -145070,11 +145843,11 @@
145070145843
Expr *pRight = pTerm->pExpr->pRight;
145071145844
if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){
145072145845
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
145073145846
VdbeCoverage(v);
145074145847
}
145075
- if( zAff ){
145848
+ if( pParse->db->mallocFailed==0 && pParse->nErr==0 ){
145076145849
if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){
145077145850
zAff[j] = SQLITE_AFF_BLOB;
145078145851
}
145079145852
if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){
145080145853
zAff[j] = SQLITE_AFF_BLOB;
@@ -145419,11 +146192,11 @@
145419146192
for(i=0; i<nReg; i++){
145420146193
sqlite3ExprCode(pParse, pList->a[i].pExpr, iReg+i);
145421146194
}
145422146195
}
145423146196
}else{
145424
- assert( nReg==1 );
146197
+ assert( nReg==1 || pParse->nErr );
145425146198
sqlite3ExprCode(pParse, p, iReg);
145426146199
}
145427146200
}
145428146201
145429146202
/* An instance of the IdxExprTrans object carries information about a
@@ -146046,13 +146819,11 @@
146046146819
146047146820
/* If we are doing a reverse order scan on an ascending index, or
146048146821
** a forward order scan on a descending index, interchange the
146049146822
** start and end terms (pRangeStart and pRangeEnd).
146050146823
*/
146051
- if( (nEq<pIdx->nKeyCol && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC))
146052
- || (bRev && pIdx->nKeyCol==nEq)
146053
- ){
146824
+ if( (nEq<pIdx->nColumn && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC)) ){
146054146825
SWAP(WhereTerm *, pRangeEnd, pRangeStart);
146055146826
SWAP(u8, bSeekPastNull, bStopAtNull);
146056146827
SWAP(u8, nBtm, nTop);
146057146828
}
146058146829
@@ -146469,11 +147240,11 @@
146469147240
}
146470147241
if( pAndExpr ){
146471147242
/* The extra 0x10000 bit on the opcode is masked off and does not
146472147243
** become part of the new Expr.op. However, it does make the
146473147244
** op==TK_AND comparison inside of sqlite3PExpr() false, and this
146474
- ** prevents sqlite3PExpr() from implementing AND short-circuit
147245
+ ** prevents sqlite3PExpr() from applying the AND short-circuit
146475147246
** optimization, which we do not want here. */
146476147247
pAndExpr = sqlite3PExpr(pParse, TK_AND|0x10000, 0, pAndExpr);
146477147248
}
146478147249
}
146479147250
@@ -146485,14 +147256,20 @@
146485147256
for(ii=0; ii<pOrWc->nTerm; ii++){
146486147257
WhereTerm *pOrTerm = &pOrWc->a[ii];
146487147258
if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
146488147259
WhereInfo *pSubWInfo; /* Info for single OR-term scan */
146489147260
Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
147261
+ Expr *pDelete; /* Local copy of OR clause term */
146490147262
int jmp1 = 0; /* Address of jump operation */
146491147263
testcase( (pTabItem[0].fg.jointype & JT_LEFT)!=0
146492147264
&& !ExprHasProperty(pOrExpr, EP_FromJoin)
146493147265
); /* See TH3 vtab25.400 and ticket 614b25314c766238 */
147266
+ pDelete = pOrExpr = sqlite3ExprDup(db, pOrExpr, 0);
147267
+ if( db->mallocFailed ){
147268
+ sqlite3ExprDelete(db, pDelete);
147269
+ continue;
147270
+ }
146494147271
if( pAndExpr ){
146495147272
pAndExpr->pLeft = pOrExpr;
146496147273
pOrExpr = pAndExpr;
146497147274
}
146498147275
/* Loop through table entries that match term pOrTerm. */
@@ -146603,10 +147380,11 @@
146603147380
146604147381
/* Finish the loop through table entries that match term pOrTerm. */
146605147382
sqlite3WhereEnd(pSubWInfo);
146606147383
ExplainQueryPlanPop(pParse);
146607147384
}
147385
+ sqlite3ExprDelete(db, pDelete);
146608147386
}
146609147387
}
146610147388
ExplainQueryPlanPop(pParse);
146611147389
pLevel->u.pCovidx = pCov;
146612147390
if( pCov ) pLevel->iIdxCur = iCovCur;
@@ -147320,10 +148098,11 @@
147320148098
sqlite3 *db; /* Database connection (for malloc) */
147321148099
Expr *pNew; /* New virtual expression */
147322148100
int op; /* Operator for the combined expression */
147323148101
int idxNew; /* Index in pWC of the next virtual term */
147324148102
148103
+ if( (pOne->wtFlags | pTwo->wtFlags) & TERM_VNULL ) return;
147325148104
if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
147326148105
if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
147327148106
if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
147328148107
&& (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;
147329148108
assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );
@@ -147680,11 +148459,11 @@
147680148459
assert( !ExprHasProperty(pNew, EP_xIsSelect) );
147681148460
pNew->x.pList = pList;
147682148461
idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);
147683148462
testcase( idxNew==0 );
147684148463
exprAnalyze(pSrc, pWC, idxNew);
147685
- /* pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where used again */
148464
+ /* pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where reused */
147686148465
markTermAsChild(pWC, idxNew, idxTerm);
147687148466
}else{
147688148467
sqlite3ExprListDelete(db, pList);
147689148468
}
147690148469
}
@@ -147804,10 +148583,11 @@
147804148583
assert( TK_GT+1==TK_LE && TK_GT+2==TK_LT && TK_GT+3==TK_GE );
147805148584
assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE );
147806148585
assert( op<=TK_GE );
147807148586
if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){
147808148587
pExpr = pExpr->x.pList->a[0].pExpr;
148588
+
147809148589
}
147810148590
147811148591
if( pExpr->op==TK_COLUMN ){
147812148592
aiCurCol[0] = pExpr->iTable;
147813148593
aiCurCol[1] = pExpr->iColumn;
@@ -147816,280 +148596,10 @@
147816148596
if( mPrereq==0 ) return 0; /* No table references */
147817148597
if( (mPrereq&(mPrereq-1))!=0 ) return 0; /* Refs more than one table */
147818148598
return exprMightBeIndexed2(pFrom,mPrereq,aiCurCol,pExpr);
147819148599
}
147820148600
147821
-/*
147822
-** Expression callback for exprUsesSrclist().
147823
-*/
147824
-static int exprUsesSrclistCb(Walker *p, Expr *pExpr){
147825
- if( pExpr->op==TK_COLUMN ){
147826
- SrcList *pSrc = p->u.pSrcList;
147827
- int iCsr = pExpr->iTable;
147828
- int ii;
147829
- for(ii=0; ii<pSrc->nSrc; ii++){
147830
- if( pSrc->a[ii].iCursor==iCsr ){
147831
- return p->eCode ? WRC_Abort : WRC_Continue;
147832
- }
147833
- }
147834
- return p->eCode ? WRC_Continue : WRC_Abort;
147835
- }
147836
- return WRC_Continue;
147837
-}
147838
-
147839
-/*
147840
-** Select callback for exprUsesSrclist().
147841
-*/
147842
-static int exprUsesSrclistSelectCb(Walker *NotUsed1, Select *NotUsed2){
147843
- UNUSED_PARAMETER(NotUsed1);
147844
- UNUSED_PARAMETER(NotUsed2);
147845
- return WRC_Abort;
147846
-}
147847
-
147848
-/*
147849
-** This function always returns true if expression pExpr contains
147850
-** a sub-select.
147851
-**
147852
-** If there is no sub-select in pExpr, then return true if pExpr
147853
-** contains a TK_COLUMN node for a table that is (bUses==1)
147854
-** or is not (bUses==0) in pSrc.
147855
-**
147856
-** Said another way:
147857
-**
147858
-** bUses Return Meaning
147859
-** -------- ------ ------------------------------------------------
147860
-**
147861
-** bUses==1 true pExpr contains either a sub-select or a
147862
-** TK_COLUMN referencing pSrc.
147863
-**
147864
-** bUses==1 false pExpr contains no sub-selects and all TK_COLUMN
147865
-** nodes reference tables not found in pSrc
147866
-**
147867
-** bUses==0 true pExpr contains either a sub-select or a TK_COLUMN
147868
-** that references a table not in pSrc.
147869
-**
147870
-** bUses==0 false pExpr contains no sub-selects and all TK_COLUMN
147871
-** nodes reference pSrc
147872
-*/
147873
-static int exprUsesSrclist(SrcList *pSrc, Expr *pExpr, int bUses){
147874
- Walker sWalker;
147875
- memset(&sWalker, 0, sizeof(Walker));
147876
- sWalker.eCode = bUses;
147877
- sWalker.u.pSrcList = pSrc;
147878
- sWalker.xExprCallback = exprUsesSrclistCb;
147879
- sWalker.xSelectCallback = exprUsesSrclistSelectCb;
147880
- return (sqlite3WalkExpr(&sWalker, pExpr)==WRC_Abort);
147881
-}
147882
-
147883
-/*
147884
-** Context object used by exprExistsToInIter() as it iterates through an
147885
-** expression tree.
147886
-*/
147887
-struct ExistsToInCtx {
147888
- SrcList *pSrc; /* The tables in an EXISTS(SELECT ... FROM <here> ...) */
147889
- Expr *pInLhs; /* OUT: Use this as the LHS of the IN operator */
147890
- Expr *pEq; /* OUT: The == term that include pInLhs */
147891
- Expr **ppAnd; /* OUT: The AND operator that includes pEq as a child */
147892
- Expr **ppParent; /* The AND operator currently being examined */
147893
-};
147894
-
147895
-/*
147896
-** Iterate through all AND connected nodes in the expression tree
147897
-** headed by (*ppExpr), populating the structure passed as the first
147898
-** argument with the values required by exprAnalyzeExistsFindEq().
147899
-**
147900
-** This function returns non-zero if the expression tree does not meet
147901
-** the two conditions described by the header comment for
147902
-** exprAnalyzeExistsFindEq(), or zero if it does.
147903
-*/
147904
-static int exprExistsToInIter(struct ExistsToInCtx *p, Expr **ppExpr){
147905
- Expr *pExpr = *ppExpr;
147906
- switch( pExpr->op ){
147907
- case TK_AND:
147908
- p->ppParent = ppExpr;
147909
- if( exprExistsToInIter(p, &pExpr->pLeft) ) return 1;
147910
- p->ppParent = ppExpr;
147911
- if( exprExistsToInIter(p, &pExpr->pRight) ) return 1;
147912
- break;
147913
- case TK_EQ: {
147914
- int bLeft = exprUsesSrclist(p->pSrc, pExpr->pLeft, 0);
147915
- int bRight = exprUsesSrclist(p->pSrc, pExpr->pRight, 0);
147916
- if( bLeft || bRight ){
147917
- if( (bLeft && bRight) || p->pInLhs ) return 1;
147918
- p->pInLhs = bLeft ? pExpr->pLeft : pExpr->pRight;
147919
- if( exprUsesSrclist(p->pSrc, p->pInLhs, 1) ) return 1;
147920
- p->pEq = pExpr;
147921
- p->ppAnd = p->ppParent;
147922
- }
147923
- break;
147924
- }
147925
- default:
147926
- if( exprUsesSrclist(p->pSrc, pExpr, 0) ){
147927
- return 1;
147928
- }
147929
- break;
147930
- }
147931
-
147932
- return 0;
147933
-}
147934
-
147935
-/*
147936
-** This function is used by exprAnalyzeExists() when creating virtual IN(...)
147937
-** terms equivalent to user-supplied EXIST(...) clauses. It splits the WHERE
147938
-** clause of the Select object passed as the first argument into one or more
147939
-** expressions joined by AND operators, and then tests if the following are
147940
-** true:
147941
-**
147942
-** 1. Exactly one of the AND separated terms refers to the outer
147943
-** query, and it is an == (TK_EQ) expression.
147944
-**
147945
-** 2. Only one side of the == expression refers to the outer query, and
147946
-** it does not refer to any columns from the inner query.
147947
-**
147948
-** If both these conditions are true, then a pointer to the side of the ==
147949
-** expression that refers to the outer query is returned. The caller will
147950
-** use this expression as the LHS of the IN(...) virtual term. Or, if one
147951
-** or both of the above conditions are not true, NULL is returned.
147952
-**
147953
-** If non-NULL is returned and ppEq is non-NULL, *ppEq is set to point
147954
-** to the == expression node before returning. If pppAnd is non-NULL and
147955
-** the == node is not the root of the WHERE clause, then *pppAnd is set
147956
-** to point to the pointer to the AND node that is the parent of the ==
147957
-** node within the WHERE expression tree.
147958
-*/
147959
-static Expr *exprAnalyzeExistsFindEq(
147960
- Select *pSel, /* The SELECT of the EXISTS */
147961
- Expr **ppEq, /* OUT: == node from WHERE clause */
147962
- Expr ***pppAnd /* OUT: Pointer to parent of ==, if any */
147963
-){
147964
- struct ExistsToInCtx ctx;
147965
- memset(&ctx, 0, sizeof(ctx));
147966
- ctx.pSrc = pSel->pSrc;
147967
- if( exprExistsToInIter(&ctx, &pSel->pWhere) ){
147968
- return 0;
147969
- }
147970
- if( ppEq ) *ppEq = ctx.pEq;
147971
- if( pppAnd ) *pppAnd = ctx.ppAnd;
147972
- return ctx.pInLhs;
147973
-}
147974
-
147975
-/*
147976
-** Term idxTerm of the WHERE clause passed as the second argument is an
147977
-** EXISTS expression with a correlated SELECT statement on the RHS.
147978
-** This function analyzes the SELECT statement, and if possible adds an
147979
-** equivalent "? IN(SELECT...)" virtual term to the WHERE clause.
147980
-**
147981
-** For an EXISTS term such as the following:
147982
-**
147983
-** EXISTS (SELECT ... FROM <srclist> WHERE <e1> = <e2> AND <e3>)
147984
-**
147985
-** The virtual IN() term added is:
147986
-**
147987
-** <e1> IN (SELECT <e2> FROM <srclist> WHERE <e3>)
147988
-**
147989
-** The virtual term is only added if the following conditions are met:
147990
-**
147991
-** 1. The sub-select must not be an aggregate or use window functions,
147992
-**
147993
-** 2. The sub-select must not be a compound SELECT,
147994
-**
147995
-** 3. Expression <e1> must refer to at least one column from the outer
147996
-** query, and must not refer to any column from the inner query
147997
-** (i.e. from <srclist>).
147998
-**
147999
-** 4. <e2> and <e3> must not refer to any values from the outer query.
148000
-** In other words, once <e1> has been removed, the inner query
148001
-** must not be correlated.
148002
-**
148003
-*/
148004
-static void exprAnalyzeExists(
148005
- SrcList *pSrc, /* the FROM clause */
148006
- WhereClause *pWC, /* the WHERE clause */
148007
- int idxTerm /* Index of the term to be analyzed */
148008
-){
148009
- Parse *pParse = pWC->pWInfo->pParse;
148010
- WhereTerm *pTerm = &pWC->a[idxTerm];
148011
- Expr *pExpr = pTerm->pExpr;
148012
- Select *pSel = pExpr->x.pSelect;
148013
- Expr *pDup = 0;
148014
- Expr *pEq = 0;
148015
- Expr *pRet = 0;
148016
- Expr *pInLhs = 0;
148017
- Expr **ppAnd = 0;
148018
- int idxNew;
148019
- sqlite3 *db = pParse->db;
148020
-
148021
- assert( pExpr->op==TK_EXISTS );
148022
- assert( (pExpr->flags & EP_VarSelect) && (pExpr->flags & EP_xIsSelect) );
148023
-
148024
- if( pSel->selFlags & SF_Aggregate ) return;
148025
-#ifndef SQLITE_OMIT_WINDOWFUNC
148026
- if( pSel->pWin ) return;
148027
-#endif
148028
- if( pSel->pPrior ) return;
148029
- if( pSel->pWhere==0 ) return;
148030
- if( pSel->pLimit ) return;
148031
- if( 0==exprAnalyzeExistsFindEq(pSel, 0, 0) ) return;
148032
-
148033
- pDup = sqlite3ExprDup(db, pExpr, 0);
148034
- if( db->mallocFailed ){
148035
- sqlite3ExprDelete(db, pDup);
148036
- return;
148037
- }
148038
- pSel = pDup->x.pSelect;
148039
- sqlite3ExprListDelete(db, pSel->pEList);
148040
- pSel->pEList = 0;
148041
-
148042
- pInLhs = exprAnalyzeExistsFindEq(pSel, &pEq, &ppAnd);
148043
- assert( pInLhs && pEq );
148044
- assert( pEq==pSel->pWhere || ppAnd );
148045
- if( pInLhs==pEq->pLeft ){
148046
- pRet = pEq->pRight;
148047
- }else{
148048
- CollSeq *p = sqlite3ExprCompareCollSeq(pParse, pEq);
148049
- pInLhs = sqlite3ExprAddCollateString(pParse, pInLhs, p?p->zName:"BINARY");
148050
- pRet = pEq->pLeft;
148051
- }
148052
-
148053
- assert( pDup->pLeft==0 );
148054
- pDup->op = TK_IN;
148055
- pDup->pLeft = pInLhs;
148056
- pDup->flags &= ~EP_VarSelect;
148057
- if( pRet->op==TK_VECTOR ){
148058
- pSel->pEList = pRet->x.pList;
148059
- pRet->x.pList = 0;
148060
- sqlite3ExprDelete(db, pRet);
148061
- }else{
148062
- pSel->pEList = sqlite3ExprListAppend(pParse, 0, pRet);
148063
- }
148064
- pEq->pLeft = 0;
148065
- pEq->pRight = 0;
148066
- if( ppAnd ){
148067
- Expr *pAnd = *ppAnd;
148068
- Expr *pOther = (pAnd->pLeft==pEq) ? pAnd->pRight : pAnd->pLeft;
148069
- pAnd->pLeft = pAnd->pRight = 0;
148070
- sqlite3ExprDelete(db, pAnd);
148071
- *ppAnd = pOther;
148072
- }else{
148073
- assert( pSel->pWhere==pEq );
148074
- pSel->pWhere = 0;
148075
- }
148076
- sqlite3ExprDelete(db, pEq);
148077
-
148078
-#ifdef WHERETRACE_ENABLED /* 0x20 */
148079
- if( sqlite3WhereTrace & 0x20 ){
148080
- sqlite3DebugPrintf("Convert EXISTS:\n");
148081
- sqlite3TreeViewExpr(0, pExpr, 0);
148082
- sqlite3DebugPrintf("into IN:\n");
148083
- sqlite3TreeViewExpr(0, pDup, 0);
148084
- }
148085
-#endif
148086
- idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC);
148087
- exprAnalyze(pSrc, pWC, idxNew);
148088
- markTermAsChild(pWC, idxNew, idxTerm);
148089
- pWC->a[idxTerm].wtFlags |= TERM_COPIED;
148090
-}
148091148601
148092148602
/*
148093148603
** The input to this routine is an WhereTerm structure with only the
148094148604
** "pExpr" field filled in. The job of this routine is to analyze the
148095148605
** subexpression and populate all the other fields of the WhereTerm
@@ -148185,10 +148695,11 @@
148185148695
pTerm->eOperator = operatorMask(op) & opMask;
148186148696
}
148187148697
if( op==TK_IS ) pTerm->wtFlags |= TERM_IS;
148188148698
if( pRight
148189148699
&& exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op)
148700
+ && !ExprHasProperty(pRight, EP_FixedCol)
148190148701
){
148191148702
WhereTerm *pNew;
148192148703
Expr *pDup;
148193148704
u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */
148194148705
assert( pTerm->u.x.iField==0 );
@@ -148277,20 +148788,10 @@
148277148788
assert( pWC->op==TK_AND );
148278148789
exprAnalyzeOrTerm(pSrc, pWC, idxTerm);
148279148790
pTerm = &pWC->a[idxTerm];
148280148791
}
148281148792
#endif /* SQLITE_OMIT_OR_OPTIMIZATION */
148282
-
148283
- else if( pExpr->op==TK_EXISTS ){
148284
- /* Perhaps treat an EXISTS operator as an IN operator */
148285
- if( (pExpr->flags & EP_VarSelect)!=0
148286
- && OptimizationEnabled(db, SQLITE_ExistsToIN)
148287
- ){
148288
- exprAnalyzeExists(pSrc, pWC, idxTerm);
148289
- }
148290
- }
148291
-
148292148793
/* The form "x IS NOT NULL" can sometimes be evaluated more efficiently
148293148794
** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
148294148795
** virtual term of that form.
148295148796
**
148296148797
** The virtual term must be tagged with TERM_VNULL.
@@ -148973,11 +149474,13 @@
148973149474
** If the right-hand branch of the expression is a TK_COLUMN, then return
148974149475
** a pointer to the right-hand branch. Otherwise, return NULL.
148975149476
*/
148976149477
static Expr *whereRightSubexprIsColumn(Expr *p){
148977149478
p = sqlite3ExprSkipCollateAndLikely(p->pRight);
148978
- if( ALWAYS(p!=0) && p->op==TK_COLUMN ) return p;
149479
+ if( ALWAYS(p!=0) && p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){
149480
+ return p;
149481
+ }
148979149482
return 0;
148980149483
}
148981149484
148982149485
/*
148983149486
** Advance to the next WhereTerm that matches according to the criteria
@@ -149048,10 +149551,22 @@
149048149551
testcase( pTerm->eOperator & WO_IS );
149049149552
continue;
149050149553
}
149051149554
pScan->pWC = pWC;
149052149555
pScan->k = k+1;
149556
+#ifdef WHERETRACE_ENABLED
149557
+ if( sqlite3WhereTrace & 0x20000 ){
149558
+ int ii;
149559
+ sqlite3DebugPrintf("SCAN-TERM %p: nEquiv=%d",
149560
+ pTerm, pScan->nEquiv);
149561
+ for(ii=0; ii<pScan->nEquiv; ii++){
149562
+ sqlite3DebugPrintf(" {%d:%d}",
149563
+ pScan->aiCur[ii], pScan->aiColumn[ii]);
149564
+ }
149565
+ sqlite3DebugPrintf("\n");
149566
+ }
149567
+#endif
149053149568
return pTerm;
149054149569
}
149055149570
}
149056149571
}
149057149572
pWC = pWC->pOuter;
@@ -150652,11 +151167,11 @@
150652151167
** Transfer content from the second pLoop into the first.
150653151168
*/
150654151169
static int whereLoopXfer(sqlite3 *db, WhereLoop *pTo, WhereLoop *pFrom){
150655151170
whereLoopClearUnion(db, pTo);
150656151171
if( whereLoopResize(db, pTo, pFrom->nLTerm) ){
150657
- memset(&pTo->u, 0, sizeof(pTo->u));
151172
+ memset(pTo, 0, WHERE_LOOP_XFER_SZ);
150658151173
return SQLITE_NOMEM_BKPT;
150659151174
}
150660151175
memcpy(pTo, pFrom, WHERE_LOOP_XFER_SZ);
150661151176
memcpy(pTo->aLTerm, pFrom->aLTerm, pTo->nLTerm*sizeof(pTo->aLTerm[0]));
150662151177
if( pFrom->wsFlags & WHERE_VIRTUALTABLE ){
@@ -150694,10 +151209,21 @@
150694151209
whereLoopDelete(db, p);
150695151210
}
150696151211
assert( pWInfo->pExprMods==0 );
150697151212
sqlite3DbFreeNN(db, pWInfo);
150698151213
}
151214
+
151215
+/* Undo all Expr node modifications
151216
+*/
151217
+static void whereUndoExprMods(WhereInfo *pWInfo){
151218
+ while( pWInfo->pExprMods ){
151219
+ WhereExprMod *p = pWInfo->pExprMods;
151220
+ pWInfo->pExprMods = p->pNext;
151221
+ memcpy(p->pExpr, &p->orig, sizeof(p->orig));
151222
+ sqlite3DbFree(pWInfo->pParse->db, p);
151223
+ }
151224
+}
150699151225
150700151226
/*
150701151227
** Return TRUE if all of the following are true:
150702151228
**
150703151229
** (1) X has the same or lower cost that Y
@@ -151200,10 +151726,12 @@
151200151726
opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
151201151727
}
151202151728
if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
151203151729
151204151730
assert( pNew->u.btree.nEq<pProbe->nColumn );
151731
+ assert( pNew->u.btree.nEq<pProbe->nKeyCol
151732
+ || pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY );
151205151733
151206151734
saved_nEq = pNew->u.btree.nEq;
151207151735
saved_nBtm = pNew->u.btree.nBtm;
151208151736
saved_nTop = pNew->u.btree.nTop;
151209151737
saved_nSkip = pNew->nSkip;
@@ -151282,11 +151810,11 @@
151282151810
}else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
151283151811
/* "x IN (value, value, ...)" */
151284151812
nIn = sqlite3LogEst(pExpr->x.pList->nExpr);
151285151813
}
151286151814
if( pProbe->hasStat1 && rLogSize>=10 ){
151287
- LogEst M, logK, safetyMargin;
151815
+ LogEst M, logK, x;
151288151816
/* Let:
151289151817
** N = the total number of rows in the table
151290151818
** K = the number of entries on the RHS of the IN operator
151291151819
** M = the number of rows in the table that match terms to the
151292151820
** to the left in the same index. If the IN operator is on
@@ -151305,20 +151833,29 @@
151305151833
** the index. Do not bother with this optimization on very small
151306151834
** tables (less than 2 rows) as it is pointless in that case.
151307151835
*/
151308151836
M = pProbe->aiRowLogEst[saved_nEq];
151309151837
logK = estLog(nIn);
151310
- safetyMargin = 10; /* TUNING: extra weight for indexed IN */
151311
- if( M + logK + safetyMargin < nIn + rLogSize ){
151838
+ /* TUNING v----- 10 to bias toward indexed IN */
151839
+ x = M + logK + 10 - (nIn + rLogSize);
151840
+ if( x>=0 ){
151841
+ WHERETRACE(0x40,
151842
+ ("IN operator (N=%d M=%d logK=%d nIn=%d rLogSize=%d x=%d) "
151843
+ "prefers indexed lookup\n",
151844
+ saved_nEq, M, logK, nIn, rLogSize, x));
151845
+ }else if( nInMul<2 && OptimizationEnabled(db, SQLITE_SeekScan) ){
151312151846
WHERETRACE(0x40,
151313
- ("Scan preferred over IN operator on column %d of \"%s\" (%d<%d)\n",
151314
- saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
151847
+ ("IN operator (N=%d M=%d logK=%d nIn=%d rLogSize=%d x=%d"
151848
+ " nInMul=%d) prefers skip-scan\n",
151849
+ saved_nEq, M, logK, nIn, rLogSize, x, nInMul));
151315151850
pNew->wsFlags |= WHERE_IN_SEEKSCAN;
151316151851
}else{
151317151852
WHERETRACE(0x40,
151318
- ("IN operator preferred on column %d of \"%s\" (%d>=%d)\n",
151319
- saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
151853
+ ("IN operator (N=%d M=%d logK=%d nIn=%d rLogSize=%d x=%d"
151854
+ " nInMul=%d) prefers normal scan\n",
151855
+ saved_nEq, M, logK, nIn, rLogSize, x, nInMul));
151856
+ continue;
151320151857
}
151321151858
}
151322151859
pNew->wsFlags |= WHERE_COLUMN_IN;
151323151860
}else if( eOp & (WO_EQ|WO_IS) ){
151324151861
int iCol = pProbe->aiColumn[saved_nEq];
@@ -151333,10 +151870,11 @@
151333151870
pNew->wsFlags |= WHERE_ONEROW;
151334151871
}else{
151335151872
pNew->wsFlags |= WHERE_UNQ_WANTED;
151336151873
}
151337151874
}
151875
+ if( scan.iEquiv>1 ) pNew->wsFlags |= WHERE_TRANSCONS;
151338151876
}else if( eOp & WO_ISNULL ){
151339151877
pNew->wsFlags |= WHERE_COLUMN_NULL;
151340151878
}else if( eOp & (WO_GT|WO_GE) ){
151341151879
testcase( eOp & WO_GT );
151342151880
testcase( eOp & WO_GE );
@@ -151476,10 +152014,12 @@
151476152014
pNew->nOut = nOutUnadjusted;
151477152015
}
151478152016
151479152017
if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
151480152018
&& pNew->u.btree.nEq<pProbe->nColumn
152019
+ && (pNew->u.btree.nEq<pProbe->nKeyCol ||
152020
+ pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY)
151481152021
){
151482152022
whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
151483152023
}
151484152024
pNew->nOut = saved_nOut;
151485152025
#ifdef SQLITE_ENABLE_STAT4
@@ -151597,10 +152137,11 @@
151597152137
Expr *pExpr;
151598152138
pExpr = pTerm->pExpr;
151599152139
if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
151600152140
&& (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin))
151601152141
&& sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
152142
+ && (pTerm->wtFlags & TERM_VNULL)==0
151602152143
){
151603152144
return 1;
151604152145
}
151605152146
}
151606152147
return 0;
@@ -152307,11 +152848,13 @@
152307152848
rc = whereLoopAddBtree(&sSubBuild, mPrereq);
152308152849
}
152309152850
if( rc==SQLITE_OK ){
152310152851
rc = whereLoopAddOr(&sSubBuild, mPrereq, mUnusable);
152311152852
}
152312
- assert( rc==SQLITE_OK || rc==SQLITE_DONE || sCur.n==0 );
152853
+ assert( rc==SQLITE_OK || rc==SQLITE_DONE || sCur.n==0
152854
+ || rc==SQLITE_NOMEM );
152855
+ testcase( rc==SQLITE_NOMEM && sCur.n>0 );
152313152856
testcase( rc==SQLITE_DONE );
152314152857
if( sCur.n==0 ){
152315152858
sSum.n = 0;
152316152859
break;
152317152860
}else if( once ){
@@ -152576,10 +153119,14 @@
152576153119
nKeyCol = pIndex->nKeyCol;
152577153120
nColumn = pIndex->nColumn;
152578153121
assert( nColumn==nKeyCol+1 || !HasRowid(pIndex->pTable) );
152579153122
assert( pIndex->aiColumn[nColumn-1]==XN_ROWID
152580153123
|| !HasRowid(pIndex->pTable));
153124
+ /* All relevant terms of the index must also be non-NULL in order
153125
+ ** for isOrderDistinct to be true. So the isOrderDistint value
153126
+ ** computed here might be a false positive. Corrections will be
153127
+ ** made at tag-20210426-1 below */
152581153128
isOrderDistinct = IsUniqueIndex(pIndex)
152582153129
&& (pLoop->wsFlags & WHERE_SKIPSCAN)==0;
152583153130
}
152584153131
152585153132
/* Loop through all columns of the index and deal with the ones
@@ -152643,18 +153190,22 @@
152643153190
iColumn = XN_ROWID;
152644153191
revIdx = 0;
152645153192
}
152646153193
152647153194
/* An unconstrained column that might be NULL means that this
152648
- ** WhereLoop is not well-ordered
153195
+ ** WhereLoop is not well-ordered. tag-20210426-1
152649153196
*/
152650
- if( isOrderDistinct
152651
- && iColumn>=0
152652
- && j>=pLoop->u.btree.nEq
152653
- && pIndex->pTable->aCol[iColumn].notNull==0
152654
- ){
152655
- isOrderDistinct = 0;
153197
+ if( isOrderDistinct ){
153198
+ if( iColumn>=0
153199
+ && j>=pLoop->u.btree.nEq
153200
+ && pIndex->pTable->aCol[iColumn].notNull==0
153201
+ ){
153202
+ isOrderDistinct = 0;
153203
+ }
153204
+ if( iColumn==XN_EXPR ){
153205
+ isOrderDistinct = 0;
153206
+ }
152656153207
}
152657153208
152658153209
/* Find the ORDER BY term that corresponds to the j-th column
152659153210
** of the index and mark that ORDER BY term off
152660153211
*/
@@ -152834,11 +153385,11 @@
152834153385
if( (pWInfo->wctrlFlags & WHERE_USE_LIMIT)!=0 && pWInfo->iLimit<nRow ){
152835153386
nRow = pWInfo->iLimit;
152836153387
}else if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT) ){
152837153388
/* TUNING: In the sort for a DISTINCT operator, assume that the DISTINCT
152838153389
** reduces the number of output rows by a factor of 2 */
152839
- if( nRow>10 ) nRow -= 10; assert( 10==sqlite3LogEst(2) );
153390
+ if( nRow>10 ){ nRow -= 10; assert( 10==sqlite3LogEst(2) ); }
152840153391
}
152841153392
rSortCost += estLog(nRow);
152842153393
return rSortCost;
152843153394
}
152844153395
@@ -154026,10 +154577,12 @@
154026154577
return pWInfo;
154027154578
154028154579
/* Jump here if malloc fails */
154029154580
whereBeginError:
154030154581
if( pWInfo ){
154582
+ testcase( pWInfo->pExprMods!=0 );
154583
+ whereUndoExprMods(pWInfo);
154031154584
pParse->nQueryLoop = pWInfo->savedNQueryLoop;
154032154585
whereInfoFree(db, pWInfo);
154033154586
}
154034154587
return 0;
154035154588
}
@@ -154122,10 +154675,12 @@
154122154675
if( pLoop->wsFlags & WHERE_IN_ABLE && pLevel->u.in.nIn>0 ){
154123154676
struct InLoop *pIn;
154124154677
int j;
154125154678
sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
154126154679
for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
154680
+ assert( sqlite3VdbeGetOp(v, pIn->addrInTop+1)->opcode==OP_IsNull
154681
+ || pParse->db->mallocFailed );
154127154682
sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
154128154683
if( pIn->eEndLoopOp!=OP_Noop ){
154129154684
if( pIn->nPrefix ){
154130154685
int bEarlyOut =
154131154686
(pLoop->wsFlags & WHERE_VIRTUALTABLE)==0
@@ -154146,10 +154701,15 @@
154146154701
if( bEarlyOut ){
154147154702
sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur,
154148154703
sqlite3VdbeCurrentAddr(v)+2,
154149154704
pIn->iBase, pIn->nPrefix);
154150154705
VdbeCoverage(v);
154706
+ /* Retarget the OP_IsNull against the left operand of IN so
154707
+ ** it jumps past the OP_IfNoHope. This is because the
154708
+ ** OP_IsNull also bypasses the OP_Affinity opcode that is
154709
+ ** required by OP_IfNoHope. */
154710
+ sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
154151154711
}
154152154712
}
154153154713
sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
154154154714
VdbeCoverage(v);
154155154715
VdbeCoverageIf(v, pIn->eEndLoopOp==OP_Prev);
@@ -154325,20 +154885,13 @@
154325154885
if( db->flags & SQLITE_VdbeAddopTrace ) printf("TRANSLATE complete\n");
154326154886
#endif
154327154887
}
154328154888
}
154329154889
154330
- /* Undo all Expr node modifications */
154331
- while( pWInfo->pExprMods ){
154332
- WhereExprMod *p = pWInfo->pExprMods;
154333
- pWInfo->pExprMods = p->pNext;
154334
- memcpy(p->pExpr, &p->orig, sizeof(p->orig));
154335
- sqlite3DbFree(db, p);
154336
- }
154337
-
154338154890
/* Final cleanup
154339154891
*/
154892
+ if( pWInfo->pExprMods ) whereUndoExprMods(pWInfo);
154340154893
pParse->nQueryLoop = pWInfo->savedNQueryLoop;
154341154894
whereInfoFree(db, pWInfo);
154342154895
return;
154343154896
}
154344154897
@@ -155284,10 +155837,18 @@
155284155837
){
155285155838
pExpr->op2++;
155286155839
}
155287155840
return WRC_Continue;
155288155841
}
155842
+
155843
+static int disallowAggregatesInOrderByCb(Walker *pWalker, Expr *pExpr){
155844
+ if( pExpr->op==TK_AGG_FUNCTION && pExpr->pAggInfo==0 ){
155845
+ sqlite3ErrorMsg(pWalker->pParse,
155846
+ "misuse of aggregate: %s()", pExpr->u.zToken);
155847
+ }
155848
+ return WRC_Continue;
155849
+}
155289155850
155290155851
/*
155291155852
** If the SELECT statement passed as the second argument does not invoke
155292155853
** any SQL window functions, this function is a no-op. Otherwise, it
155293155854
** rewrites the SELECT statement so that window function xStep functions
@@ -155294,11 +155855,11 @@
155294155855
** are invoked in the correct order as described under "SELECT REWRITING"
155295155856
** at the top of this file.
155296155857
*/
155297155858
SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
155298155859
int rc = SQLITE_OK;
155299
- if( p->pWin && p->pPrior==0 && (p->selFlags & SF_WinRewrite)==0 ){
155860
+ if( p->pWin && p->pPrior==0 && ALWAYS((p->selFlags & SF_WinRewrite)==0) ){
155300155861
Vdbe *v = sqlite3GetVdbe(pParse);
155301155862
sqlite3 *db = pParse->db;
155302155863
Select *pSub = 0; /* The subquery */
155303155864
SrcList *pSrc = p->pSrc;
155304155865
Expr *pWhere = p->pWhere;
@@ -155318,10 +155879,15 @@
155318155879
if( pTab==0 ){
155319155880
return sqlite3ErrorToParser(db, SQLITE_NOMEM);
155320155881
}
155321155882
sqlite3AggInfoPersistWalkerInit(&w, pParse);
155322155883
sqlite3WalkSelect(&w, p);
155884
+ if( (p->selFlags & SF_Aggregate)==0 ){
155885
+ w.xExprCallback = disallowAggregatesInOrderByCb;
155886
+ w.xSelectCallback = 0;
155887
+ sqlite3WalkExprList(&w, p->pOrderBy);
155888
+ }
155323155889
155324155890
p->pSrc = 0;
155325155891
p->pWhere = 0;
155326155892
p->pGroupBy = 0;
155327155893
p->pHaving = 0;
@@ -155914,10 +156480,11 @@
155914156480
Vdbe *pVdbe; /* VDBE object */
155915156481
int addrGosub; /* OP_Gosub to this address to return one row */
155916156482
int regGosub; /* Register used with OP_Gosub(addrGosub) */
155917156483
int regArg; /* First in array of accumulator registers */
155918156484
int eDelete; /* See above */
156485
+ int regRowid;
155919156486
155920156487
WindowCsrAndReg start;
155921156488
WindowCsrAndReg current;
155922156489
WindowCsrAndReg end;
155923156490
};
@@ -156590,20 +157157,28 @@
156590157157
addrContinue = sqlite3VdbeCurrentAddr(v);
156591157158
156592157159
/* If this is a (RANGE BETWEEN a FOLLOWING AND b FOLLOWING) or
156593157160
** (RANGE BETWEEN b PRECEDING AND a PRECEDING) frame, ensure the
156594157161
** start cursor does not advance past the end cursor within the
156595
- ** temporary table. It otherwise might, if (a>b). */
157162
+ ** temporary table. It otherwise might, if (a>b). Also ensure that,
157163
+ ** if the input cursor is still finding new rows, that the end
157164
+ ** cursor does not go past it to EOF. */
156596157165
if( pMWin->eStart==pMWin->eEnd && regCountdown
156597
- && pMWin->eFrmType==TK_RANGE && op==WINDOW_AGGINVERSE
157166
+ && pMWin->eFrmType==TK_RANGE
156598157167
){
156599157168
int regRowid1 = sqlite3GetTempReg(pParse);
156600157169
int regRowid2 = sqlite3GetTempReg(pParse);
156601
- sqlite3VdbeAddOp2(v, OP_Rowid, p->start.csr, regRowid1);
156602
- sqlite3VdbeAddOp2(v, OP_Rowid, p->end.csr, regRowid2);
156603
- sqlite3VdbeAddOp3(v, OP_Ge, regRowid2, lblDone, regRowid1);
156604
- VdbeCoverage(v);
157170
+ if( op==WINDOW_AGGINVERSE ){
157171
+ sqlite3VdbeAddOp2(v, OP_Rowid, p->start.csr, regRowid1);
157172
+ sqlite3VdbeAddOp2(v, OP_Rowid, p->end.csr, regRowid2);
157173
+ sqlite3VdbeAddOp3(v, OP_Ge, regRowid2, lblDone, regRowid1);
157174
+ VdbeCoverage(v);
157175
+ }else if( p->regRowid ){
157176
+ sqlite3VdbeAddOp2(v, OP_Rowid, p->end.csr, regRowid1);
157177
+ sqlite3VdbeAddOp3(v, OP_Ge, p->regRowid, lblDone, regRowid1);
157178
+ VdbeCoverageNeverNull(v);
157179
+ }
156605157180
sqlite3ReleaseTempReg(pParse, regRowid1);
156606157181
sqlite3ReleaseTempReg(pParse, regRowid2);
156607157182
assert( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_FOLLOWING );
156608157183
}
156609157184
@@ -157096,11 +157671,10 @@
157096157671
int addrGosubFlush = 0; /* Address of OP_Gosub to flush: */
157097157672
int addrInteger = 0; /* Address of OP_Integer */
157098157673
int addrEmpty; /* Address of OP_Rewind in flush: */
157099157674
int regNew; /* Array of registers holding new input row */
157100157675
int regRecord; /* regNew array in record form */
157101
- int regRowid; /* Rowid for regRecord in eph table */
157102157676
int regNewPeer = 0; /* Peer values for new row (part of regNew) */
157103157677
int regPeer = 0; /* Peer values for current row */
157104157678
int regFlushPart = 0; /* Register for "Gosub flush_partition" */
157105157679
WindowCodeArg s; /* Context object for sub-routines */
157106157680
int lblWhereEnd; /* Label just before sqlite3WhereEnd() code */
@@ -157168,11 +157742,11 @@
157168157742
** samve values in record form, and the rowid used to insert said record
157169157743
** into the ephemeral table. */
157170157744
regNew = pParse->nMem+1;
157171157745
pParse->nMem += nInput;
157172157746
regRecord = ++pParse->nMem;
157173
- regRowid = ++pParse->nMem;
157747
+ s.regRowid = ++pParse->nMem;
157174157748
157175157749
/* If the window frame contains an "<expr> PRECEDING" or "<expr> FOLLOWING"
157176157750
** clause, allocate registers to store the results of evaluating each
157177157751
** <expr>. */
157178157752
if( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_FOLLOWING ){
@@ -157224,13 +157798,13 @@
157224157798
VdbeComment((v, "call flush_partition"));
157225157799
sqlite3VdbeAddOp3(v, OP_Copy, regNewPart, pMWin->regPart, nPart-1);
157226157800
}
157227157801
157228157802
/* Insert the new row into the ephemeral table */
157229
- sqlite3VdbeAddOp2(v, OP_NewRowid, csrWrite, regRowid);
157230
- sqlite3VdbeAddOp3(v, OP_Insert, csrWrite, regRecord, regRowid);
157231
- addrNe = sqlite3VdbeAddOp3(v, OP_Ne, pMWin->regOne, 0, regRowid);
157803
+ sqlite3VdbeAddOp2(v, OP_NewRowid, csrWrite, s.regRowid);
157804
+ sqlite3VdbeAddOp3(v, OP_Insert, csrWrite, regRecord, s.regRowid);
157805
+ addrNe = sqlite3VdbeAddOp3(v, OP_Ne, pMWin->regOne, 0, s.regRowid);
157232157806
VdbeCoverageNeverNull(v);
157233157807
157234157808
/* This block is run for the first row of each partition */
157235157809
s.regArg = windowInitAccum(pParse, pMWin);
157236157810
@@ -157344,10 +157918,11 @@
157344157918
if( pMWin->pPartition ){
157345157919
addrInteger = sqlite3VdbeAddOp2(v, OP_Integer, 0, regFlushPart);
157346157920
sqlite3VdbeJumpHere(v, addrGosubFlush);
157347157921
}
157348157922
157923
+ s.regRowid = 0;
157349157924
addrEmpty = sqlite3VdbeAddOp1(v, OP_Rewind, csrWrite);
157350157925
VdbeCoverage(v);
157351157926
if( pMWin->eEnd==TK_PRECEDING ){
157352157927
int bRPS = (pMWin->eStart==TK_PRECEDING && pMWin->eFrmType==TK_RANGE);
157353157928
windowCodeOp(&s, WINDOW_AGGSTEP, regEnd, 0);
@@ -157817,12 +158392,13 @@
157817158392
#define TK_VECTOR 176
157818158393
#define TK_SELECT_COLUMN 177
157819158394
#define TK_IF_NULL_ROW 178
157820158395
#define TK_ASTERISK 179
157821158396
#define TK_SPAN 180
157822
-#define TK_SPACE 181
157823
-#define TK_ILLEGAL 182
158397
+#define TK_ERROR 181
158398
+#define TK_SPACE 182
158399
+#define TK_ILLEGAL 183
157824158400
#endif
157825158401
/**************** End token definitions ***************************************/
157826158402
157827158403
/* The next sections is a series of control #defines.
157828158404
** various aspects of the generated parser.
@@ -157878,33 +158454,33 @@
157878158454
#ifndef INTERFACE
157879158455
# define INTERFACE 1
157880158456
#endif
157881158457
/************* Begin control #defines *****************************************/
157882158458
#define YYCODETYPE unsigned short int
157883
-#define YYNOCODE 316
158459
+#define YYNOCODE 317
157884158460
#define YYACTIONTYPE unsigned short int
157885158461
#define YYWILDCARD 101
157886158462
#define sqlite3ParserTOKENTYPE Token
157887158463
typedef union {
157888158464
int yyinit;
157889158465
sqlite3ParserTOKENTYPE yy0;
157890
- Window* yy19;
157891
- struct TrigEvent yy50;
157892
- int yy60;
157893
- struct FrameBound yy113;
157894
- Upsert* yy178;
157895
- With* yy195;
157896
- IdList* yy288;
157897
- SrcList* yy291;
157898
- Select* yy307;
157899
- ExprList* yy338;
157900
- TriggerStep* yy483;
157901
- const char* yy528;
157902
- u8 yy570;
157903
- Expr* yy602;
157904
- Cte* yy607;
157905
- struct {int value; int mask;} yy615;
158466
+ Window* yy49;
158467
+ ExprList* yy70;
158468
+ Select* yy81;
158469
+ With* yy103;
158470
+ struct FrameBound yy117;
158471
+ struct {int value; int mask;} yy139;
158472
+ SrcList* yy153;
158473
+ TriggerStep* yy157;
158474
+ Upsert* yy190;
158475
+ struct TrigEvent yy262;
158476
+ Cte* yy329;
158477
+ int yy376;
158478
+ Expr* yy404;
158479
+ IdList* yy436;
158480
+ const char* yy504;
158481
+ u8 yy552;
157906158482
} YYMINORTYPE;
157907158483
#ifndef YYSTACKDEPTH
157908158484
#define YYSTACKDEPTH 100
157909158485
#endif
157910158486
#define sqlite3ParserARG_SDECL
@@ -157919,11 +158495,11 @@
157919158495
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
157920158496
#define YYFALLBACK 1
157921158497
#define YYNSTATE 570
157922158498
#define YYNRULE 398
157923158499
#define YYNRULE_WITH_ACTION 337
157924
-#define YYNTOKEN 183
158500
+#define YYNTOKEN 184
157925158501
#define YY_MAX_SHIFT 569
157926158502
#define YY_MIN_SHIFTREDUCE 825
157927158503
#define YY_MAX_SHIFTREDUCE 1222
157928158504
#define YY_ERROR_ACTION 1223
157929158505
#define YY_ACCEPT_ACTION 1224
@@ -157994,545 +158570,546 @@
157994158570
** yy_reduce_ofst[] For each state, the offset into yy_action for
157995158571
** shifting non-terminals after a reduce.
157996158572
** yy_default[] Default action for each state.
157997158573
**
157998158574
*********** Begin parsing tables **********************************************/
157999
-#define YY_ACTTAB_COUNT (2020)
158575
+#define YY_ACTTAB_COUNT (2023)
158000158576
static const YYACTIONTYPE yy_action[] = {
158001
- /* 0 */ 563, 1295, 563, 1274, 168, 361, 115, 112, 218, 373,
158577
+ /* 0 */ 563, 1295, 563, 1274, 168, 1257, 115, 112, 218, 373,
158002158578
/* 10 */ 563, 1295, 374, 563, 488, 563, 115, 112, 218, 406,
158003158579
/* 20 */ 1300, 1300, 41, 41, 41, 41, 514, 1504, 520, 1298,
158004
- /* 30 */ 1298, 959, 41, 41, 1257, 71, 71, 51, 51, 960,
158580
+ /* 30 */ 1298, 959, 41, 41, 1260, 71, 71, 51, 51, 960,
158005158581
/* 40 */ 557, 557, 557, 122, 123, 113, 1200, 1200, 1035, 1038,
158006158582
/* 50 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 414, 406,
158007158583
/* 60 */ 273, 273, 273, 273, 115, 112, 218, 115, 112, 218,
158008
- /* 70 */ 197, 268, 545, 560, 515, 560, 1260, 563, 385, 248,
158584
+ /* 70 */ 197, 268, 545, 560, 515, 560, 211, 563, 385, 248,
158009158585
/* 80 */ 215, 521, 399, 122, 123, 113, 1200, 1200, 1035, 1038,
158010158586
/* 90 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 540, 13,
158011158587
/* 100 */ 13, 1259, 119, 119, 119, 119, 118, 118, 117, 117,
158012
- /* 110 */ 117, 116, 441, 1176, 419, 1531, 446, 137, 512, 1539,
158013
- /* 120 */ 1545, 372, 1547, 6, 371, 1176, 1148, 1584, 1148, 406,
158014
- /* 130 */ 1545, 534, 115, 112, 218, 1267, 99, 441, 121, 121,
158588
+ /* 110 */ 117, 116, 441, 1176, 419, 197, 446, 320, 512, 1539,
158589
+ /* 120 */ 1545, 372, 1547, 6, 371, 1176, 1148, 394, 1148, 406,
158590
+ /* 130 */ 1545, 534, 115, 112, 218, 1415, 99, 30, 121, 121,
158015158591
/* 140 */ 121, 121, 119, 119, 119, 119, 118, 118, 117, 117,
158016158592
/* 150 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038,
158017
- /* 160 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 197, 1176,
158018
- /* 170 */ 1177, 1178, 241, 304, 554, 501, 498, 497, 473, 124,
158019
- /* 180 */ 394, 1176, 1177, 1178, 1176, 496, 119, 119, 119, 119,
158020
- /* 190 */ 118, 118, 117, 117, 117, 116, 441, 139, 540, 406,
158593
+ /* 160 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 31, 1176,
158594
+ /* 170 */ 1177, 1178, 241, 357, 1558, 501, 498, 497, 317, 124,
158595
+ /* 180 */ 319, 1176, 1177, 1178, 1176, 496, 119, 119, 119, 119,
158596
+ /* 190 */ 118, 118, 117, 117, 117, 116, 441, 139, 96, 406,
158021158597
/* 200 */ 121, 121, 121, 121, 114, 117, 117, 117, 116, 441,
158022158598
/* 210 */ 541, 1532, 119, 119, 119, 119, 118, 118, 117, 117,
158023158599
/* 220 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038,
158024
- /* 230 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 406, 320,
158025
- /* 240 */ 1176, 1177, 1178, 81, 342, 1590, 396, 80, 119, 119,
158026
- /* 250 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 1176,
158027
- /* 260 */ 211, 450, 122, 123, 113, 1200, 1200, 1035, 1038, 1028,
158028
- /* 270 */ 1028, 120, 120, 121, 121, 121, 121, 251, 450, 449,
158029
- /* 280 */ 273, 273, 119, 119, 119, 119, 118, 118, 117, 117,
158030
- /* 290 */ 117, 116, 441, 560, 1224, 1, 1, 569, 2, 1228,
158031
- /* 300 */ 317, 1176, 319, 1561, 305, 337, 140, 340, 406, 430,
158032
- /* 310 */ 469, 1533, 1197, 1308, 348, 1176, 1177, 1178, 168, 462,
158600
+ /* 230 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 406, 441,
158601
+ /* 240 */ 1176, 1177, 1178, 81, 439, 439, 439, 80, 119, 119,
158602
+ /* 250 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 488,
158603
+ /* 260 */ 1176, 318, 122, 123, 113, 1200, 1200, 1035, 1038, 1028,
158604
+ /* 270 */ 1028, 120, 120, 121, 121, 121, 121, 493, 1025, 1025,
158605
+ /* 280 */ 1036, 1039, 119, 119, 119, 119, 118, 118, 117, 117,
158606
+ /* 290 */ 117, 116, 441, 1584, 995, 1224, 1, 1, 569, 2,
158607
+ /* 300 */ 1228, 1267, 137, 1503, 245, 305, 473, 140, 406, 860,
158608
+ /* 310 */ 561, 1176, 914, 914, 1308, 359, 1176, 1177, 1178, 462,
158033158609
/* 320 */ 330, 119, 119, 119, 119, 118, 118, 117, 117, 117,
158034158610
/* 330 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028,
158035
- /* 340 */ 1028, 120, 120, 121, 121, 121, 121, 273, 273, 563,
158036
- /* 350 */ 83, 450, 416, 1564, 569, 2, 1228, 1176, 1177, 1178,
158037
- /* 360 */ 560, 305, 471, 140, 944, 995, 860, 563, 467, 1197,
158038
- /* 370 */ 1308, 13, 13, 137, 229, 118, 118, 117, 117, 117,
158039
- /* 380 */ 116, 441, 96, 318, 946, 504, 424, 361, 562, 71,
158040
- /* 390 */ 71, 119, 119, 119, 119, 118, 118, 117, 117, 117,
158041
- /* 400 */ 116, 441, 427, 205, 273, 273, 445, 1015, 259, 276,
158042
- /* 410 */ 356, 507, 351, 506, 246, 406, 959, 560, 328, 344,
158043
- /* 420 */ 347, 315, 860, 1006, 960, 126, 545, 1005, 313, 304,
158044
- /* 430 */ 554, 229, 538, 1539, 148, 544, 281, 6, 203, 122,
158611
+ /* 340 */ 1028, 120, 120, 121, 121, 121, 121, 328, 273, 273,
158612
+ /* 350 */ 1015, 83, 1029, 425, 1564, 569, 2, 1228, 304, 554,
158613
+ /* 360 */ 925, 560, 305, 944, 140, 860, 1006, 1176, 1177, 1178,
158614
+ /* 370 */ 1005, 1308, 411, 213, 511, 229, 119, 119, 119, 119,
158615
+ /* 380 */ 118, 118, 117, 117, 117, 116, 441, 519, 347, 116,
158616
+ /* 390 */ 441, 119, 119, 119, 119, 118, 118, 117, 117, 117,
158617
+ /* 400 */ 116, 441, 1005, 1005, 1007, 273, 273, 445, 563, 16,
158618
+ /* 410 */ 16, 1590, 563, 1540, 563, 406, 1176, 6, 560, 344,
158619
+ /* 420 */ 182, 118, 118, 117, 117, 117, 116, 441, 416, 142,
158620
+ /* 430 */ 71, 71, 229, 563, 71, 71, 55, 55, 203, 122,
158045158621
/* 440 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120,
158046
- /* 450 */ 121, 121, 121, 121, 563, 217, 563, 12, 406, 1005,
158047
- /* 460 */ 1005, 1007, 502, 445, 119, 119, 119, 119, 118, 118,
158048
- /* 470 */ 117, 117, 117, 116, 441, 452, 71, 71, 70, 70,
158049
- /* 480 */ 944, 137, 122, 123, 113, 1200, 1200, 1035, 1038, 1028,
158050
- /* 490 */ 1028, 120, 120, 121, 121, 121, 121, 1530, 119, 119,
158051
- /* 500 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 403,
158052
- /* 510 */ 402, 241, 1176, 545, 501, 498, 497, 1468, 1143, 451,
158053
- /* 520 */ 267, 267, 513, 1540, 496, 142, 1176, 6, 406, 530,
158054
- /* 530 */ 194, 1143, 864, 560, 1143, 461, 182, 304, 554, 32,
158055
- /* 540 */ 379, 119, 119, 119, 119, 118, 118, 117, 117, 117,
158622
+ /* 450 */ 121, 121, 121, 121, 217, 13, 13, 1176, 406, 568,
158623
+ /* 460 */ 1400, 1228, 502, 137, 445, 168, 305, 545, 140, 1180,
158624
+ /* 470 */ 424, 545, 1176, 1177, 1178, 1308, 544, 438, 437, 944,
158625
+ /* 480 */ 513, 452, 122, 123, 113, 1200, 1200, 1035, 1038, 1028,
158626
+ /* 490 */ 1028, 120, 120, 121, 121, 121, 121, 315, 119, 119,
158627
+ /* 500 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 273,
158628
+ /* 510 */ 273, 1143, 416, 1176, 1177, 1178, 543, 563, 1143, 304,
158629
+ /* 520 */ 554, 1561, 560, 1207, 1143, 1207, 1180, 1143, 406, 530,
158630
+ /* 530 */ 421, 1143, 864, 183, 1143, 143, 229, 562, 32, 71,
158631
+ /* 540 */ 71, 119, 119, 119, 119, 118, 118, 117, 117, 117,
158056158632
/* 550 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028,
158057
- /* 560 */ 1028, 120, 120, 121, 121, 121, 121, 406, 1176, 1177,
158058
- /* 570 */ 1178, 857, 568, 1176, 1228, 925, 1176, 454, 361, 305,
158059
- /* 580 */ 189, 140, 1176, 1177, 1178, 519, 529, 404, 1308, 183,
158633
+ /* 560 */ 1028, 120, 120, 121, 121, 121, 121, 406, 445, 241,
158634
+ /* 570 */ 1176, 857, 501, 498, 497, 1176, 526, 189, 245, 538,
158635
+ /* 580 */ 1539, 282, 496, 370, 6, 563, 529, 477, 5, 279,
158060158636
/* 590 */ 1015, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028,
158061
- /* 600 */ 120, 120, 121, 121, 121, 121, 1006, 16, 16, 370,
158637
+ /* 600 */ 120, 120, 121, 121, 121, 121, 1006, 13, 13, 1414,
158062158638
/* 610 */ 1005, 119, 119, 119, 119, 118, 118, 117, 117, 117,
158063
- /* 620 */ 116, 441, 273, 273, 1537, 150, 1176, 98, 6, 1176,
158064
- /* 630 */ 1177, 1178, 1176, 1177, 1178, 560, 380, 406, 376, 438,
158065
- /* 640 */ 437, 1161, 1005, 1005, 1007, 1025, 1025, 1036, 1039, 229,
158639
+ /* 620 */ 116, 441, 426, 273, 273, 1176, 1176, 1177, 1178, 1619,
158640
+ /* 630 */ 392, 1176, 1177, 1178, 1176, 342, 560, 406, 525, 361,
158641
+ /* 640 */ 430, 1161, 1005, 1005, 1007, 348, 411, 357, 1558, 488,
158066158642
/* 650 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
158067158643
/* 660 */ 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028,
158068
- /* 670 */ 120, 120, 121, 121, 121, 121, 406, 1143, 1619, 392,
158069
- /* 680 */ 1016, 445, 1176, 1177, 1178, 1207, 525, 1207, 1530, 995,
158070
- /* 690 */ 1143, 304, 554, 1143, 5, 563, 543, 3, 361, 216,
158644
+ /* 670 */ 120, 120, 121, 121, 121, 121, 406, 830, 831, 832,
158645
+ /* 680 */ 1016, 1176, 1177, 1178, 396, 285, 148, 1312, 304, 554,
158646
+ /* 690 */ 1176, 1177, 1178, 1467, 216, 3, 337, 137, 340, 560,
158071158647
/* 700 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120,
158072
- /* 710 */ 120, 121, 121, 121, 121, 143, 563, 13, 13, 1029,
158648
+ /* 710 */ 120, 121, 121, 121, 121, 563, 504, 946, 273, 273,
158073158649
/* 720 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
158074
- /* 730 */ 441, 1176, 426, 563, 1176, 563, 274, 274, 13, 13,
158075
- /* 740 */ 1078, 1176, 328, 457, 316, 147, 406, 211, 361, 560,
158076
- /* 750 */ 1000, 213, 511, 293, 477, 55, 55, 71, 71, 119,
158650
+ /* 730 */ 441, 560, 1176, 427, 563, 451, 98, 13, 13, 259,
158651
+ /* 740 */ 276, 356, 507, 351, 506, 246, 406, 361, 469, 1530,
158652
+ /* 750 */ 1000, 347, 293, 304, 554, 1589, 71, 71, 889, 119,
158077158653
/* 760 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441,
158078158654
/* 770 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120,
158079
- /* 780 */ 120, 121, 121, 121, 121, 406, 455, 1176, 1177, 1178,
158080
- /* 790 */ 1176, 1177, 1178, 471, 526, 149, 404, 1176, 1177, 1178,
158081
- /* 800 */ 105, 270, 103, 563, 944, 563, 116, 441, 1530, 122,
158655
+ /* 780 */ 120, 121, 121, 121, 121, 406, 1143, 1078, 1176, 1177,
158656
+ /* 790 */ 1178, 416, 1080, 300, 150, 995, 1080, 361, 361, 1143,
158657
+ /* 800 */ 361, 378, 1143, 477, 563, 244, 243, 242, 1278, 122,
158082158658
/* 810 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120,
158083
- /* 820 */ 121, 121, 121, 121, 945, 13, 13, 13, 13, 119,
158659
+ /* 820 */ 121, 121, 121, 121, 563, 880, 13, 13, 483, 119,
158084158660
/* 830 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441,
158085
- /* 840 */ 191, 563, 192, 563, 416, 439, 439, 439, 1083, 1083,
158086
- /* 850 */ 485, 561, 285, 914, 914, 406, 462, 330, 1530, 830,
158087
- /* 860 */ 831, 832, 206, 71, 71, 71, 71, 286, 119, 119,
158661
+ /* 840 */ 1176, 191, 540, 563, 147, 149, 13, 13, 328, 457,
158662
+ /* 850 */ 316, 1083, 1083, 485, 1537, 406, 505, 1530, 6, 1514,
158663
+ /* 860 */ 284, 192, 1277, 145, 881, 71, 71, 488, 119, 119,
158088158664
/* 870 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 122,
158089158665
/* 880 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120,
158090
- /* 890 */ 121, 121, 121, 121, 563, 217, 563, 1122, 1617, 406,
158091
- /* 900 */ 300, 1617, 301, 416, 1278, 1473, 244, 243, 242, 1249,
158092
- /* 910 */ 412, 556, 412, 282, 842, 279, 71, 71, 71, 71,
158093
- /* 920 */ 944, 1415, 1473, 1475, 101, 113, 1200, 1200, 1035, 1038,
158666
+ /* 890 */ 121, 121, 121, 121, 563, 471, 1176, 1177, 1178, 406,
158667
+ /* 900 */ 852, 327, 301, 462, 330, 1516, 270, 1530, 1530, 944,
158668
+ /* 910 */ 1531, 1307, 313, 9, 842, 251, 71, 71, 477, 428,
158669
+ /* 920 */ 146, 488, 38, 945, 101, 113, 1200, 1200, 1035, 1038,
158094158670
/* 930 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 119, 119,
158095
- /* 940 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 273,
158096
- /* 950 */ 273, 1099, 563, 436, 1143, 440, 563, 1122, 1618, 357,
158097
- /* 960 */ 1558, 1618, 560, 546, 488, 197, 1100, 1143, 378, 290,
158098
- /* 970 */ 1143, 1306, 284, 460, 71, 71, 1120, 405, 13, 13,
158099
- /* 980 */ 145, 1101, 119, 119, 119, 119, 118, 118, 117, 117,
158100
- /* 990 */ 117, 116, 441, 542, 104, 1473, 509, 273, 273, 294,
158101
- /* 1000 */ 1514, 294, 900, 273, 273, 273, 273, 563, 1503, 563,
158102
- /* 1010 */ 560, 545, 901, 464, 406, 1058, 560, 852, 560, 198,
158103
- /* 1020 */ 547, 1080, 920, 404, 1400, 1080, 146, 919, 38, 56,
158104
- /* 1030 */ 56, 15, 15, 563, 406, 12, 1120, 471, 122, 123,
158671
+ /* 940 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 563,
158672
+ /* 950 */ 1197, 1099, 563, 436, 563, 1533, 563, 852, 1122, 1617,
158673
+ /* 960 */ 454, 290, 1617, 546, 251, 1303, 1100, 267, 267, 281,
158674
+ /* 970 */ 404, 70, 70, 460, 71, 71, 71, 71, 13, 13,
158675
+ /* 980 */ 560, 1101, 119, 119, 119, 119, 118, 118, 117, 117,
158676
+ /* 990 */ 117, 116, 441, 542, 104, 273, 273, 273, 273, 1197,
158677
+ /* 1000 */ 217, 1468, 900, 471, 450, 563, 1473, 1197, 560, 447,
158678
+ /* 1010 */ 560, 545, 901, 440, 406, 1058, 292, 274, 274, 198,
158679
+ /* 1020 */ 547, 450, 449, 1473, 1475, 944, 455, 56, 56, 410,
158680
+ /* 1030 */ 560, 1122, 1618, 379, 406, 1618, 404, 1120, 122, 123,
158105158681
/* 1040 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121,
158106
- /* 1050 */ 121, 121, 121, 1460, 406, 43, 43, 483, 122, 123,
158682
+ /* 1050 */ 121, 121, 121, 1460, 406, 12, 1197, 1512, 122, 123,
158107158683
/* 1060 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121,
158108
- /* 1070 */ 121, 121, 121, 563, 852, 9, 471, 251, 122, 111,
158684
+ /* 1070 */ 121, 121, 121, 308, 471, 126, 359, 286, 122, 111,
158109158685
/* 1080 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121,
158110
- /* 1090 */ 121, 121, 121, 563, 421, 57, 57, 119, 119, 119,
158111
- /* 1100 */ 119, 118, 118, 117, 117, 117, 116, 441, 1176, 493,
158112
- /* 1110 */ 563, 289, 1197, 478, 1516, 44, 44, 119, 119, 119,
158113
- /* 1120 */ 119, 118, 118, 117, 117, 117, 116, 441, 880, 563,
158114
- /* 1130 */ 536, 563, 58, 58, 488, 1414, 245, 119, 119, 119,
158115
- /* 1140 */ 119, 118, 118, 117, 117, 117, 116, 441, 563, 535,
158116
- /* 1150 */ 291, 59, 59, 60, 60, 438, 437, 406, 1154, 505,
158117
- /* 1160 */ 304, 554, 477, 1204, 1176, 1177, 1178, 881, 1206, 1197,
158118
- /* 1170 */ 61, 61, 1246, 357, 1558, 1538, 1205, 563, 1467, 6,
158119
- /* 1180 */ 1176, 488, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028,
158120
- /* 1190 */ 120, 120, 121, 121, 121, 121, 1400, 1143, 410, 62,
158121
- /* 1200 */ 62, 1207, 1099, 1207, 411, 447, 273, 273, 537, 1154,
158122
- /* 1210 */ 1143, 108, 555, 1143, 4, 391, 1220, 1100, 1512, 560,
158123
- /* 1220 */ 347, 516, 428, 548, 308, 1307, 1536, 1077, 558, 1077,
158124
- /* 1230 */ 6, 488, 1101, 1400, 488, 309, 1176, 1177, 1178, 563,
158686
+ /* 1090 */ 121, 121, 121, 309, 450, 471, 1473, 119, 119, 119,
158687
+ /* 1100 */ 119, 118, 118, 117, 117, 117, 116, 441, 1176, 563,
158688
+ /* 1110 */ 1120, 482, 563, 312, 433, 479, 197, 119, 119, 119,
158689
+ /* 1120 */ 119, 118, 118, 117, 117, 117, 116, 441, 405, 12,
158690
+ /* 1130 */ 536, 15, 15, 478, 43, 43, 509, 119, 119, 119,
158691
+ /* 1140 */ 119, 118, 118, 117, 117, 117, 116, 441, 289, 535,
158692
+ /* 1150 */ 294, 563, 294, 391, 1220, 438, 437, 406, 1154, 403,
158693
+ /* 1160 */ 402, 1400, 920, 1204, 1176, 1177, 1178, 919, 1206, 291,
158694
+ /* 1170 */ 1306, 1249, 412, 57, 57, 488, 1205, 563, 556, 412,
158695
+ /* 1180 */ 1176, 1344, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028,
158696
+ /* 1190 */ 120, 120, 121, 121, 121, 121, 1400, 1143, 563, 44,
158697
+ /* 1200 */ 44, 1207, 194, 1207, 273, 273, 1400, 461, 537, 1154,
158698
+ /* 1210 */ 1143, 108, 555, 1143, 4, 391, 1121, 560, 1538, 335,
158699
+ /* 1220 */ 58, 58, 6, 1246, 1099, 380, 1400, 376, 558, 1536,
158700
+ /* 1230 */ 563, 422, 1221, 6, 304, 554, 1176, 1177, 1178, 1100,
158125158701
/* 1240 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
158126
- /* 1250 */ 441, 442, 278, 551, 563, 273, 273, 273, 273, 563,
158127
- /* 1260 */ 327, 45, 45, 552, 563, 528, 422, 563, 560, 1400,
158128
- /* 1270 */ 560, 108, 555, 137, 4, 1303, 46, 46, 335, 563,
158129
- /* 1280 */ 482, 47, 47, 477, 479, 307, 49, 49, 558, 50,
158130
- /* 1290 */ 50, 563, 1015, 563, 1221, 563, 1400, 563, 106, 106,
158131
- /* 1300 */ 8, 63, 63, 423, 563, 107, 312, 442, 565, 564,
158132
- /* 1310 */ 563, 442, 1005, 64, 64, 65, 65, 14, 14, 66,
158133
- /* 1320 */ 66, 391, 1121, 552, 1312, 1180, 128, 128, 563, 304,
158134
- /* 1330 */ 554, 563, 67, 67, 563, 359, 560, 532, 563, 484,
158135
- /* 1340 */ 563, 1196, 531, 222, 1005, 1005, 1007, 1008, 27, 522,
158136
- /* 1350 */ 52, 52, 1015, 68, 68, 563, 69, 69, 106, 106,
158137
- /* 1360 */ 53, 53, 156, 156, 563, 107, 434, 442, 565, 564,
158138
- /* 1370 */ 272, 215, 1005, 425, 563, 359, 563, 157, 157, 563,
158139
- /* 1380 */ 1535, 292, 1180, 98, 6, 1344, 76, 76, 1215, 475,
158140
- /* 1390 */ 413, 169, 226, 563, 245, 563, 54, 54, 72, 72,
158141
- /* 1400 */ 1221, 129, 129, 1343, 1005, 1005, 1007, 1008, 27, 1563,
158142
- /* 1410 */ 1165, 444, 456, 433, 277, 73, 73, 130, 130, 389,
158143
- /* 1420 */ 389, 388, 262, 386, 1165, 444, 839, 1519, 277, 108,
158144
- /* 1430 */ 555, 321, 4, 389, 389, 388, 262, 386, 563, 223,
158145
- /* 1440 */ 839, 311, 468, 84, 202, 523, 558, 1492, 303, 310,
158146
- /* 1450 */ 563, 110, 404, 223, 563, 311, 206, 30, 404, 277,
158147
- /* 1460 */ 131, 131, 411, 310, 389, 389, 388, 262, 386, 442,
158148
- /* 1470 */ 920, 839, 127, 127, 563, 919, 155, 155, 1491, 225,
158149
- /* 1480 */ 563, 552, 871, 563, 223, 476, 311, 161, 31, 563,
158150
- /* 1490 */ 135, 563, 480, 225, 310, 532, 154, 154, 332, 17,
158151
- /* 1500 */ 533, 161, 136, 136, 135, 134, 134, 224, 228, 355,
158152
- /* 1510 */ 1015, 132, 132, 133, 133, 1589, 106, 106, 889, 354,
158153
- /* 1520 */ 563, 224, 563, 107, 225, 442, 565, 564, 1117, 275,
158154
- /* 1530 */ 1005, 393, 161, 518, 563, 135, 108, 555, 417, 4,
158155
- /* 1540 */ 1340, 407, 75, 75, 77, 77, 304, 554, 867, 563,
158156
- /* 1550 */ 336, 563, 224, 558, 463, 407, 74, 74, 465, 1065,
158157
- /* 1560 */ 304, 554, 1005, 1005, 1007, 1008, 27, 962, 963, 543,
158158
- /* 1570 */ 448, 42, 42, 48, 48, 326, 442, 325, 98, 997,
158159
- /* 1580 */ 470, 287, 250, 250, 448, 1009, 407, 472, 552, 339,
158160
- /* 1590 */ 250, 304, 554, 879, 878, 331, 108, 555, 98, 4,
158161
- /* 1600 */ 1277, 494, 532, 345, 247, 867, 98, 531, 341, 886,
158162
- /* 1610 */ 887, 1126, 1076, 558, 1076, 448, 1065, 1015, 1061, 953,
158163
- /* 1620 */ 343, 247, 250, 106, 106, 1291, 917, 1276, 850, 110,
158164
- /* 1630 */ 107, 144, 442, 565, 564, 918, 442, 1005, 110, 1275,
158165
- /* 1640 */ 350, 360, 1009, 1331, 1352, 299, 1399, 1577, 552, 1327,
158166
- /* 1650 */ 1552, 550, 1338, 549, 1405, 1256, 1248, 1237, 1236, 1238,
158167
- /* 1660 */ 1571, 489, 265, 200, 1324, 363, 365, 367, 11, 1005,
158168
- /* 1670 */ 1005, 1007, 1008, 27, 390, 221, 1386, 1015, 280, 1391,
158169
- /* 1680 */ 1381, 208, 323, 106, 106, 924, 1374, 453, 283, 324,
158170
- /* 1690 */ 107, 474, 442, 565, 564, 1390, 499, 1005, 212, 288,
158171
- /* 1700 */ 1274, 397, 353, 108, 555, 195, 4, 1464, 369, 1463,
158172
- /* 1710 */ 1574, 1215, 1212, 329, 553, 171, 207, 383, 1511, 196,
158173
- /* 1720 */ 558, 254, 1509, 415, 100, 555, 83, 4, 204, 1005,
158174
- /* 1730 */ 1005, 1007, 1008, 27, 219, 79, 82, 1469, 180, 166,
158175
- /* 1740 */ 173, 558, 458, 442, 175, 176, 177, 178, 35, 1387,
158176
- /* 1750 */ 492, 459, 231, 1395, 96, 552, 1393, 1392, 395, 184,
158177
- /* 1760 */ 481, 466, 36, 235, 442, 89, 398, 266, 487, 1480,
158178
- /* 1770 */ 1458, 237, 188, 338, 508, 429, 552, 490, 400, 238,
158179
- /* 1780 */ 334, 1239, 239, 1294, 1015, 1293, 1292, 1285, 91, 871,
158180
- /* 1790 */ 106, 106, 213, 431, 1588, 432, 524, 107, 517, 442,
158181
- /* 1800 */ 565, 564, 401, 1264, 1005, 1015, 1263, 1587, 352, 1262,
158182
- /* 1810 */ 1557, 106, 106, 1586, 1284, 297, 298, 358, 107, 1335,
158183
- /* 1820 */ 442, 565, 564, 95, 362, 1005, 253, 252, 435, 125,
158184
- /* 1830 */ 543, 10, 1444, 1543, 377, 1542, 1005, 1005, 1007, 1008,
158185
- /* 1840 */ 27, 302, 102, 97, 527, 1336, 260, 1317, 364, 1245,
158186
- /* 1850 */ 1334, 34, 566, 1171, 366, 381, 375, 1005, 1005, 1007,
158187
- /* 1860 */ 1008, 27, 1333, 1359, 368, 1316, 199, 382, 261, 263,
158188
- /* 1870 */ 264, 1358, 158, 1496, 141, 1497, 1495, 567, 1234, 1229,
158189
- /* 1880 */ 1494, 295, 159, 209, 210, 78, 826, 443, 201, 306,
158190
- /* 1890 */ 220, 1075, 138, 1073, 160, 314, 162, 172, 1196, 174,
158191
- /* 1900 */ 903, 227, 230, 322, 1089, 179, 163, 164, 418, 85,
158192
- /* 1910 */ 420, 181, 170, 408, 409, 86, 87, 165, 88, 1092,
158193
- /* 1920 */ 232, 233, 1088, 151, 18, 234, 1081, 250, 333, 185,
158194
- /* 1930 */ 1209, 486, 236, 186, 37, 841, 491, 354, 240, 346,
158195
- /* 1940 */ 503, 187, 90, 167, 19, 495, 20, 869, 500, 349,
158196
- /* 1950 */ 92, 882, 296, 152, 93, 510, 1127, 1159, 153, 1041,
158197
- /* 1960 */ 214, 1128, 39, 94, 269, 271, 952, 190, 947, 110,
158198
- /* 1970 */ 1149, 1145, 1153, 249, 1133, 1147, 7, 33, 21, 193,
158199
- /* 1980 */ 22, 23, 24, 25, 1152, 539, 98, 1056, 26, 1042,
158200
- /* 1990 */ 1040, 1044, 1098, 1045, 1097, 256, 255, 28, 40, 387,
158201
- /* 2000 */ 1010, 851, 109, 29, 1167, 559, 384, 257, 913, 258,
158202
- /* 2010 */ 1166, 1579, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1578,
158702
+ /* 1250 */ 441, 442, 59, 59, 1101, 516, 1535, 273, 273, 563,
158703
+ /* 1260 */ 6, 563, 110, 552, 563, 528, 423, 413, 169, 548,
158704
+ /* 1270 */ 560, 108, 555, 137, 4, 551, 484, 272, 215, 222,
158705
+ /* 1280 */ 211, 60, 60, 61, 61, 98, 62, 62, 558, 273,
158706
+ /* 1290 */ 273, 563, 1015, 467, 1221, 563, 434, 563, 106, 106,
158707
+ /* 1300 */ 8, 920, 560, 273, 273, 107, 919, 442, 565, 564,
158708
+ /* 1310 */ 563, 442, 1005, 45, 45, 464, 560, 46, 46, 47,
158709
+ /* 1320 */ 47, 84, 202, 552, 1215, 404, 468, 563, 205, 304,
158710
+ /* 1330 */ 554, 563, 49, 49, 563, 522, 404, 532, 563, 867,
158711
+ /* 1340 */ 563, 105, 531, 103, 1005, 1005, 1007, 1008, 27, 50,
158712
+ /* 1350 */ 50, 563, 1015, 63, 63, 475, 64, 64, 106, 106,
158713
+ /* 1360 */ 65, 65, 14, 14, 17, 107, 563, 442, 565, 564,
158714
+ /* 1370 */ 563, 303, 1005, 66, 66, 563, 226, 563, 959, 563,
158715
+ /* 1380 */ 543, 404, 1196, 1343, 871, 278, 960, 456, 128, 128,
158716
+ /* 1390 */ 563, 1065, 67, 67, 563, 206, 867, 52, 52, 68,
158717
+ /* 1400 */ 68, 69, 69, 417, 1005, 1005, 1007, 1008, 27, 1563,
158718
+ /* 1410 */ 1165, 444, 53, 53, 277, 1519, 156, 156, 307, 389,
158719
+ /* 1420 */ 389, 388, 262, 386, 1165, 444, 839, 321, 277, 108,
158720
+ /* 1430 */ 555, 523, 4, 389, 389, 388, 262, 386, 563, 223,
158721
+ /* 1440 */ 839, 311, 326, 1492, 1117, 98, 558, 393, 1065, 310,
158722
+ /* 1450 */ 563, 476, 563, 223, 563, 311, 879, 878, 1009, 277,
158723
+ /* 1460 */ 157, 157, 463, 310, 389, 389, 388, 262, 386, 442,
158724
+ /* 1470 */ 518, 839, 76, 76, 54, 54, 72, 72, 355, 225,
158725
+ /* 1480 */ 563, 552, 275, 563, 223, 325, 311, 161, 354, 465,
158726
+ /* 1490 */ 135, 563, 228, 225, 310, 532, 563, 206, 886, 887,
158727
+ /* 1500 */ 533, 161, 129, 129, 135, 73, 73, 224, 962, 963,
158728
+ /* 1510 */ 1015, 563, 287, 130, 130, 1009, 106, 106, 131, 131,
158729
+ /* 1520 */ 563, 224, 563, 107, 225, 442, 565, 564, 997, 1276,
158730
+ /* 1530 */ 1005, 250, 161, 127, 127, 135, 108, 555, 1077, 4,
158731
+ /* 1540 */ 1077, 407, 155, 155, 154, 154, 304, 554, 1126, 563,
158732
+ /* 1550 */ 1331, 563, 224, 558, 470, 407, 563, 250, 563, 1491,
158733
+ /* 1560 */ 304, 554, 1005, 1005, 1007, 1008, 27, 563, 480, 332,
158734
+ /* 1570 */ 448, 136, 136, 134, 134, 1340, 442, 336, 132, 132,
158735
+ /* 1580 */ 133, 133, 563, 1076, 448, 1076, 407, 563, 552, 75,
158736
+ /* 1590 */ 75, 304, 554, 339, 341, 343, 108, 555, 563, 4,
158737
+ /* 1600 */ 1577, 299, 532, 563, 77, 77, 1291, 531, 472, 74,
158738
+ /* 1610 */ 74, 250, 1275, 558, 350, 448, 331, 1015, 360, 98,
158739
+ /* 1620 */ 42, 42, 1352, 106, 106, 48, 48, 1399, 494, 1327,
158740
+ /* 1630 */ 107, 247, 442, 565, 564, 345, 442, 1005, 98, 1061,
158741
+ /* 1640 */ 953, 917, 247, 250, 110, 1552, 550, 850, 552, 918,
158742
+ /* 1650 */ 144, 1338, 110, 549, 1405, 1256, 1248, 1237, 1236, 1238,
158743
+ /* 1660 */ 1571, 1324, 208, 390, 489, 265, 363, 200, 365, 1005,
158744
+ /* 1670 */ 1005, 1007, 1008, 27, 11, 280, 221, 1015, 323, 474,
158745
+ /* 1680 */ 1274, 367, 212, 106, 106, 924, 1386, 324, 288, 1381,
158746
+ /* 1690 */ 107, 453, 442, 565, 564, 283, 329, 1005, 1391, 499,
158747
+ /* 1700 */ 353, 1374, 1464, 108, 555, 1463, 4, 1574, 1390, 397,
158748
+ /* 1710 */ 1215, 171, 254, 369, 383, 207, 195, 196, 1511, 553,
158749
+ /* 1720 */ 558, 1509, 415, 1212, 100, 555, 83, 4, 204, 1005,
158750
+ /* 1730 */ 1005, 1007, 1008, 27, 180, 166, 173, 219, 79, 82,
158751
+ /* 1740 */ 458, 558, 175, 442, 35, 1387, 176, 459, 177, 178,
158752
+ /* 1750 */ 492, 231, 96, 1469, 395, 552, 1393, 1392, 36, 466,
158753
+ /* 1760 */ 1395, 184, 398, 481, 442, 1458, 235, 89, 1480, 487,
158754
+ /* 1770 */ 266, 334, 237, 188, 490, 400, 552, 338, 238, 508,
158755
+ /* 1780 */ 1239, 239, 1294, 1293, 1015, 1292, 1285, 429, 91, 871,
158756
+ /* 1790 */ 106, 106, 1588, 213, 401, 1587, 431, 107, 1264, 442,
158757
+ /* 1800 */ 565, 564, 1263, 352, 1005, 1015, 1262, 1586, 1557, 517,
158758
+ /* 1810 */ 432, 106, 106, 1284, 297, 298, 358, 524, 107, 1335,
158759
+ /* 1820 */ 442, 565, 564, 95, 1336, 1005, 252, 253, 435, 125,
158760
+ /* 1830 */ 543, 1543, 10, 1444, 377, 1542, 1005, 1005, 1007, 1008,
158761
+ /* 1840 */ 27, 97, 527, 375, 362, 102, 260, 364, 381, 1317,
158762
+ /* 1850 */ 382, 1334, 366, 1245, 1333, 1316, 368, 1005, 1005, 1007,
158763
+ /* 1860 */ 1008, 27, 1359, 1358, 34, 199, 1171, 566, 261, 263,
158764
+ /* 1870 */ 264, 567, 1234, 158, 1229, 141, 295, 159, 1496, 302,
158765
+ /* 1880 */ 1497, 1495, 1494, 160, 826, 209, 443, 201, 306, 210,
158766
+ /* 1890 */ 78, 220, 1075, 138, 1073, 314, 162, 172, 1196, 227,
158767
+ /* 1900 */ 174, 903, 322, 230, 1089, 179, 163, 164, 418, 408,
158768
+ /* 1910 */ 409, 170, 181, 85, 86, 420, 87, 165, 1092, 88,
158769
+ /* 1920 */ 233, 232, 1088, 151, 18, 234, 1081, 250, 333, 1209,
158770
+ /* 1930 */ 185, 486, 236, 186, 37, 841, 491, 354, 240, 346,
158771
+ /* 1940 */ 495, 187, 90, 869, 19, 20, 500, 503, 349, 92,
158772
+ /* 1950 */ 167, 152, 296, 882, 93, 510, 94, 1159, 153, 1041,
158773
+ /* 1960 */ 1128, 39, 214, 269, 1127, 271, 249, 952, 190, 947,
158774
+ /* 1970 */ 110, 1149, 21, 7, 1153, 22, 1145, 23, 1147, 24,
158775
+ /* 1980 */ 1133, 25, 1152, 33, 539, 193, 26, 1056, 98, 1042,
158776
+ /* 1990 */ 1040, 1044, 1098, 1045, 1097, 256, 255, 28, 40, 257,
158777
+ /* 2000 */ 1010, 851, 109, 29, 913, 559, 384, 387, 258, 1167,
158778
+ /* 2010 */ 1166, 1225, 1225, 1225, 1579, 1225, 1225, 1225, 1225, 1225,
158779
+ /* 2020 */ 1225, 1225, 1578,
158203158780
};
158204158781
static const YYCODETYPE yy_lookahead[] = {
158205
- /* 0 */ 191, 220, 191, 222, 191, 191, 271, 272, 273, 216,
158206
- /* 10 */ 191, 230, 216, 191, 191, 191, 271, 272, 273, 19,
158207
- /* 20 */ 232, 233, 213, 214, 213, 214, 202, 292, 202, 232,
158208
- /* 30 */ 233, 31, 213, 214, 213, 213, 214, 213, 214, 39,
158209
- /* 40 */ 207, 208, 209, 43, 44, 45, 46, 47, 48, 49,
158210
- /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 235, 19,
158211
- /* 60 */ 236, 237, 236, 237, 271, 272, 273, 271, 272, 273,
158212
- /* 70 */ 191, 210, 250, 249, 250, 249, 213, 191, 199, 253,
158213
- /* 80 */ 254, 259, 203, 43, 44, 45, 46, 47, 48, 49,
158214
- /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 191, 213,
158215
- /* 100 */ 214, 213, 102, 103, 104, 105, 106, 107, 108, 109,
158216
- /* 110 */ 110, 111, 112, 59, 228, 301, 293, 81, 305, 306,
158217
- /* 120 */ 311, 312, 311, 310, 313, 59, 86, 212, 88, 19,
158218
- /* 130 */ 311, 312, 271, 272, 273, 220, 26, 112, 54, 55,
158782
+ /* 0 */ 192, 221, 192, 223, 192, 214, 272, 273, 274, 217,
158783
+ /* 10 */ 192, 231, 217, 192, 192, 192, 272, 273, 274, 19,
158784
+ /* 20 */ 233, 234, 214, 215, 214, 215, 203, 293, 203, 233,
158785
+ /* 30 */ 234, 31, 214, 215, 214, 214, 215, 214, 215, 39,
158786
+ /* 40 */ 208, 209, 210, 43, 44, 45, 46, 47, 48, 49,
158787
+ /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 236, 19,
158788
+ /* 60 */ 237, 238, 237, 238, 272, 273, 274, 272, 273, 274,
158789
+ /* 70 */ 192, 211, 251, 250, 251, 250, 26, 192, 200, 254,
158790
+ /* 80 */ 255, 260, 204, 43, 44, 45, 46, 47, 48, 49,
158791
+ /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 192, 214,
158792
+ /* 100 */ 215, 214, 102, 103, 104, 105, 106, 107, 108, 109,
158793
+ /* 110 */ 110, 111, 112, 59, 229, 192, 294, 16, 306, 307,
158794
+ /* 120 */ 312, 313, 312, 311, 314, 59, 86, 204, 88, 19,
158795
+ /* 130 */ 312, 313, 272, 273, 274, 271, 26, 22, 54, 55,
158219158796
/* 140 */ 56, 57, 102, 103, 104, 105, 106, 107, 108, 109,
158220158797
/* 150 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49,
158221
- /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 191, 115,
158222
- /* 170 */ 116, 117, 118, 137, 138, 121, 122, 123, 191, 69,
158223
- /* 180 */ 203, 115, 116, 117, 59, 131, 102, 103, 104, 105,
158224
- /* 190 */ 106, 107, 108, 109, 110, 111, 112, 72, 191, 19,
158798
+ /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 53, 115,
158799
+ /* 170 */ 116, 117, 118, 309, 310, 121, 122, 123, 77, 69,
158800
+ /* 180 */ 79, 115, 116, 117, 59, 131, 102, 103, 104, 105,
158801
+ /* 190 */ 106, 107, 108, 109, 110, 111, 112, 72, 148, 19,
158225158802
/* 200 */ 54, 55, 56, 57, 58, 108, 109, 110, 111, 112,
158226
- /* 210 */ 303, 304, 102, 103, 104, 105, 106, 107, 108, 109,
158803
+ /* 210 */ 304, 305, 102, 103, 104, 105, 106, 107, 108, 109,
158227158804
/* 220 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49,
158228
- /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 16,
158229
- /* 240 */ 115, 116, 117, 24, 16, 227, 202, 67, 102, 103,
158230
- /* 250 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 59,
158231
- /* 260 */ 26, 191, 43, 44, 45, 46, 47, 48, 49, 50,
158232
- /* 270 */ 51, 52, 53, 54, 55, 56, 57, 24, 208, 209,
158233
- /* 280 */ 236, 237, 102, 103, 104, 105, 106, 107, 108, 109,
158234
- /* 290 */ 110, 111, 112, 249, 183, 184, 185, 186, 187, 188,
158235
- /* 300 */ 77, 59, 79, 191, 193, 77, 195, 79, 19, 19,
158236
- /* 310 */ 266, 304, 59, 202, 24, 115, 116, 117, 191, 127,
158805
+ /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 112,
158806
+ /* 240 */ 115, 116, 117, 24, 208, 209, 210, 67, 102, 103,
158807
+ /* 250 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 192,
158808
+ /* 260 */ 59, 160, 43, 44, 45, 46, 47, 48, 49, 50,
158809
+ /* 270 */ 51, 52, 53, 54, 55, 56, 57, 19, 46, 47,
158810
+ /* 280 */ 48, 49, 102, 103, 104, 105, 106, 107, 108, 109,
158811
+ /* 290 */ 110, 111, 112, 213, 73, 184, 185, 186, 187, 188,
158812
+ /* 300 */ 189, 221, 81, 236, 46, 194, 192, 196, 19, 59,
158813
+ /* 310 */ 133, 59, 135, 136, 203, 192, 115, 116, 117, 127,
158237158814
/* 320 */ 128, 102, 103, 104, 105, 106, 107, 108, 109, 110,
158238158815
/* 330 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50,
158239
- /* 340 */ 51, 52, 53, 54, 55, 56, 57, 236, 237, 191,
158240
- /* 350 */ 150, 281, 191, 185, 186, 187, 188, 115, 116, 117,
158241
- /* 360 */ 249, 193, 191, 195, 26, 73, 59, 191, 114, 116,
158242
- /* 370 */ 202, 213, 214, 81, 263, 106, 107, 108, 109, 110,
158243
- /* 380 */ 111, 112, 148, 160, 142, 95, 228, 191, 191, 213,
158244
- /* 390 */ 214, 102, 103, 104, 105, 106, 107, 108, 109, 110,
158245
- /* 400 */ 111, 112, 112, 149, 236, 237, 295, 100, 118, 119,
158246
- /* 410 */ 120, 121, 122, 123, 124, 19, 31, 249, 126, 23,
158247
- /* 420 */ 130, 260, 115, 116, 39, 22, 250, 120, 191, 137,
158248
- /* 430 */ 138, 263, 305, 306, 238, 259, 265, 310, 149, 43,
158816
+ /* 340 */ 51, 52, 53, 54, 55, 56, 57, 126, 237, 238,
158817
+ /* 350 */ 100, 150, 120, 230, 186, 187, 188, 189, 137, 138,
158818
+ /* 360 */ 108, 250, 194, 26, 196, 115, 116, 115, 116, 117,
158819
+ /* 370 */ 120, 203, 114, 164, 165, 264, 102, 103, 104, 105,
158820
+ /* 380 */ 106, 107, 108, 109, 110, 111, 112, 192, 130, 111,
158821
+ /* 390 */ 112, 102, 103, 104, 105, 106, 107, 108, 109, 110,
158822
+ /* 400 */ 111, 112, 152, 153, 154, 237, 238, 296, 192, 214,
158823
+ /* 410 */ 215, 228, 192, 307, 192, 19, 59, 311, 250, 23,
158824
+ /* 420 */ 22, 106, 107, 108, 109, 110, 111, 112, 192, 72,
158825
+ /* 430 */ 214, 215, 264, 192, 214, 215, 214, 215, 149, 43,
158249158826
/* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
158250
- /* 450 */ 54, 55, 56, 57, 191, 117, 191, 210, 19, 152,
158251
- /* 460 */ 153, 154, 23, 295, 102, 103, 104, 105, 106, 107,
158252
- /* 470 */ 108, 109, 110, 111, 112, 266, 213, 214, 213, 214,
158253
- /* 480 */ 142, 81, 43, 44, 45, 46, 47, 48, 49, 50,
158254
- /* 490 */ 51, 52, 53, 54, 55, 56, 57, 301, 102, 103,
158255
- /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 106,
158256
- /* 510 */ 107, 118, 59, 250, 121, 122, 123, 280, 76, 119,
158257
- /* 520 */ 236, 237, 259, 306, 131, 72, 59, 310, 19, 87,
158258
- /* 530 */ 283, 89, 23, 249, 92, 288, 22, 137, 138, 22,
158259
- /* 540 */ 275, 102, 103, 104, 105, 106, 107, 108, 109, 110,
158827
+ /* 450 */ 54, 55, 56, 57, 117, 214, 215, 59, 19, 187,
158828
+ /* 460 */ 192, 189, 23, 81, 296, 192, 194, 251, 196, 59,
158829
+ /* 470 */ 229, 251, 115, 116, 117, 203, 260, 106, 107, 142,
158830
+ /* 480 */ 260, 267, 43, 44, 45, 46, 47, 48, 49, 50,
158831
+ /* 490 */ 51, 52, 53, 54, 55, 56, 57, 261, 102, 103,
158832
+ /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 237,
158833
+ /* 510 */ 238, 76, 192, 115, 116, 117, 144, 192, 76, 137,
158834
+ /* 520 */ 138, 192, 250, 152, 89, 154, 116, 92, 19, 87,
158835
+ /* 530 */ 262, 89, 23, 22, 92, 163, 264, 192, 22, 214,
158836
+ /* 540 */ 215, 102, 103, 104, 105, 106, 107, 108, 109, 110,
158260158837
/* 550 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50,
158261
- /* 560 */ 51, 52, 53, 54, 55, 56, 57, 19, 115, 116,
158262
- /* 570 */ 117, 23, 186, 59, 188, 108, 59, 241, 191, 193,
158263
- /* 580 */ 26, 195, 115, 116, 117, 191, 144, 251, 202, 22,
158838
+ /* 560 */ 51, 52, 53, 54, 55, 56, 57, 19, 296, 118,
158839
+ /* 570 */ 59, 23, 121, 122, 123, 59, 251, 26, 46, 306,
158840
+ /* 580 */ 307, 261, 131, 192, 311, 192, 144, 192, 22, 203,
158264158841
/* 590 */ 100, 43, 44, 45, 46, 47, 48, 49, 50, 51,
158265
- /* 600 */ 52, 53, 54, 55, 56, 57, 116, 213, 214, 191,
158842
+ /* 600 */ 52, 53, 54, 55, 56, 57, 116, 214, 215, 271,
158266158843
/* 610 */ 120, 102, 103, 104, 105, 106, 107, 108, 109, 110,
158267
- /* 620 */ 111, 112, 236, 237, 306, 238, 59, 26, 310, 115,
158268
- /* 630 */ 116, 117, 115, 116, 117, 249, 246, 19, 248, 106,
158269
- /* 640 */ 107, 23, 152, 153, 154, 46, 47, 48, 49, 263,
158844
+ /* 620 */ 111, 112, 229, 237, 238, 59, 115, 116, 117, 299,
158845
+ /* 630 */ 300, 115, 116, 117, 59, 16, 250, 19, 192, 192,
158846
+ /* 640 */ 19, 23, 152, 153, 154, 24, 114, 309, 310, 192,
158270158847
/* 650 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
158271158848
/* 660 */ 112, 43, 44, 45, 46, 47, 48, 49, 50, 51,
158272
- /* 670 */ 52, 53, 54, 55, 56, 57, 19, 76, 298, 299,
158273
- /* 680 */ 23, 295, 115, 116, 117, 152, 191, 154, 301, 73,
158274
- /* 690 */ 89, 137, 138, 92, 22, 191, 144, 22, 191, 191,
158849
+ /* 670 */ 52, 53, 54, 55, 56, 57, 19, 7, 8, 9,
158850
+ /* 680 */ 23, 115, 116, 117, 203, 290, 239, 238, 137, 138,
158851
+ /* 690 */ 115, 116, 117, 236, 192, 22, 77, 81, 79, 250,
158275158852
/* 700 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
158276
- /* 710 */ 53, 54, 55, 56, 57, 163, 191, 213, 214, 120,
158853
+ /* 710 */ 53, 54, 55, 56, 57, 192, 95, 142, 237, 238,
158277158854
/* 720 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
158278
- /* 730 */ 112, 59, 228, 191, 59, 191, 236, 237, 213, 214,
158279
- /* 740 */ 11, 59, 126, 127, 128, 238, 19, 26, 191, 249,
158280
- /* 750 */ 23, 164, 165, 228, 191, 213, 214, 213, 214, 102,
158855
+ /* 730 */ 112, 250, 59, 112, 192, 119, 26, 214, 215, 118,
158856
+ /* 740 */ 119, 120, 121, 122, 123, 124, 19, 192, 267, 302,
158857
+ /* 750 */ 23, 130, 229, 137, 138, 23, 214, 215, 26, 102,
158281158858
/* 760 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
158282158859
/* 770 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
158283
- /* 780 */ 53, 54, 55, 56, 57, 19, 241, 115, 116, 117,
158284
- /* 790 */ 115, 116, 117, 191, 250, 238, 251, 115, 116, 117,
158285
- /* 800 */ 157, 23, 159, 191, 26, 191, 111, 112, 301, 43,
158860
+ /* 780 */ 53, 54, 55, 56, 57, 19, 76, 11, 115, 116,
158861
+ /* 790 */ 117, 192, 29, 251, 239, 73, 33, 192, 192, 89,
158862
+ /* 800 */ 192, 192, 92, 192, 192, 126, 127, 128, 224, 43,
158286158863
/* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
158287
- /* 820 */ 54, 55, 56, 57, 142, 213, 214, 213, 214, 102,
158864
+ /* 820 */ 54, 55, 56, 57, 192, 35, 214, 215, 65, 102,
158288158865
/* 830 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
158289
- /* 840 */ 228, 191, 228, 191, 191, 207, 208, 209, 126, 127,
158290
- /* 850 */ 128, 133, 289, 135, 136, 19, 127, 128, 301, 7,
158291
- /* 860 */ 8, 9, 141, 213, 214, 213, 214, 265, 102, 103,
158866
+ /* 840 */ 59, 229, 192, 192, 239, 239, 214, 215, 126, 127,
158867
+ /* 850 */ 128, 126, 127, 128, 307, 19, 66, 302, 311, 192,
158868
+ /* 860 */ 261, 229, 224, 22, 74, 214, 215, 192, 102, 103,
158292158869
/* 870 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 43,
158293158870
/* 880 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
158294
- /* 890 */ 54, 55, 56, 57, 191, 117, 191, 22, 23, 19,
158295
- /* 900 */ 250, 26, 250, 191, 223, 191, 126, 127, 128, 205,
158296
- /* 910 */ 206, 205, 206, 260, 21, 202, 213, 214, 213, 214,
158297
- /* 920 */ 142, 270, 208, 209, 158, 45, 46, 47, 48, 49,
158871
+ /* 890 */ 54, 55, 56, 57, 192, 192, 115, 116, 117, 19,
158872
+ /* 900 */ 59, 290, 251, 127, 128, 192, 23, 302, 302, 26,
158873
+ /* 910 */ 302, 236, 192, 22, 21, 24, 214, 215, 192, 129,
158874
+ /* 920 */ 22, 192, 24, 142, 158, 45, 46, 47, 48, 49,
158298158875
/* 930 */ 50, 51, 52, 53, 54, 55, 56, 57, 102, 103,
158299
- /* 940 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 236,
158300
- /* 950 */ 237, 12, 191, 250, 76, 250, 191, 22, 23, 308,
158301
- /* 960 */ 309, 26, 249, 202, 191, 191, 27, 89, 191, 202,
158302
- /* 970 */ 92, 202, 260, 80, 213, 214, 101, 203, 213, 214,
158303
- /* 980 */ 22, 42, 102, 103, 104, 105, 106, 107, 108, 109,
158304
- /* 990 */ 110, 111, 112, 228, 158, 281, 108, 236, 237, 225,
158305
- /* 1000 */ 191, 227, 63, 236, 237, 236, 237, 191, 235, 191,
158306
- /* 1010 */ 249, 250, 73, 241, 19, 122, 249, 59, 249, 24,
158307
- /* 1020 */ 259, 29, 134, 251, 191, 33, 22, 139, 24, 213,
158308
- /* 1030 */ 214, 213, 214, 191, 19, 210, 101, 191, 43, 44,
158876
+ /* 940 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 192,
158877
+ /* 950 */ 59, 12, 192, 251, 192, 305, 192, 116, 22, 23,
158878
+ /* 960 */ 242, 203, 26, 203, 24, 236, 27, 237, 238, 266,
158879
+ /* 970 */ 252, 214, 215, 80, 214, 215, 214, 215, 214, 215,
158880
+ /* 980 */ 250, 42, 102, 103, 104, 105, 106, 107, 108, 109,
158881
+ /* 990 */ 110, 111, 112, 229, 158, 237, 238, 237, 238, 59,
158882
+ /* 1000 */ 117, 281, 63, 192, 192, 192, 192, 116, 250, 192,
158883
+ /* 1010 */ 250, 251, 73, 251, 19, 122, 290, 237, 238, 24,
158884
+ /* 1020 */ 260, 209, 210, 209, 210, 142, 242, 214, 215, 197,
158885
+ /* 1030 */ 250, 22, 23, 276, 19, 26, 252, 101, 43, 44,
158309158886
/* 1040 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
158310
- /* 1050 */ 55, 56, 57, 160, 19, 213, 214, 65, 43, 44,
158887
+ /* 1050 */ 55, 56, 57, 160, 19, 211, 116, 192, 43, 44,
158311158888
/* 1060 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
158312
- /* 1070 */ 55, 56, 57, 191, 116, 22, 191, 24, 43, 44,
158889
+ /* 1070 */ 55, 56, 57, 192, 192, 22, 192, 266, 43, 44,
158313158890
/* 1080 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
158314
- /* 1090 */ 55, 56, 57, 191, 261, 213, 214, 102, 103, 104,
158315
- /* 1100 */ 105, 106, 107, 108, 109, 110, 111, 112, 59, 19,
158316
- /* 1110 */ 191, 265, 59, 288, 191, 213, 214, 102, 103, 104,
158317
- /* 1120 */ 105, 106, 107, 108, 109, 110, 111, 112, 35, 191,
158318
- /* 1130 */ 66, 191, 213, 214, 191, 270, 46, 102, 103, 104,
158319
- /* 1140 */ 105, 106, 107, 108, 109, 110, 111, 112, 191, 85,
158320
- /* 1150 */ 265, 213, 214, 213, 214, 106, 107, 19, 94, 66,
158321
- /* 1160 */ 137, 138, 191, 114, 115, 116, 117, 74, 119, 116,
158322
- /* 1170 */ 213, 214, 202, 308, 309, 306, 127, 191, 235, 310,
158323
- /* 1180 */ 59, 191, 44, 45, 46, 47, 48, 49, 50, 51,
158324
- /* 1190 */ 52, 53, 54, 55, 56, 57, 191, 76, 196, 213,
158325
- /* 1200 */ 214, 152, 12, 154, 114, 191, 236, 237, 87, 145,
158326
- /* 1210 */ 89, 19, 20, 92, 22, 22, 23, 27, 191, 249,
158327
- /* 1220 */ 130, 202, 129, 202, 191, 235, 306, 152, 36, 154,
158328
- /* 1230 */ 310, 191, 42, 191, 191, 191, 115, 116, 117, 191,
158891
+ /* 1090 */ 55, 56, 57, 192, 282, 192, 282, 102, 103, 104,
158892
+ /* 1100 */ 105, 106, 107, 108, 109, 110, 111, 112, 59, 192,
158893
+ /* 1110 */ 101, 279, 192, 192, 230, 283, 192, 102, 103, 104,
158894
+ /* 1120 */ 105, 106, 107, 108, 109, 110, 111, 112, 204, 211,
158895
+ /* 1130 */ 66, 214, 215, 289, 214, 215, 108, 102, 103, 104,
158896
+ /* 1140 */ 105, 106, 107, 108, 109, 110, 111, 112, 266, 85,
158897
+ /* 1150 */ 226, 192, 228, 22, 23, 106, 107, 19, 94, 106,
158898
+ /* 1160 */ 107, 192, 134, 114, 115, 116, 117, 139, 119, 266,
158899
+ /* 1170 */ 203, 206, 207, 214, 215, 192, 127, 192, 206, 207,
158900
+ /* 1180 */ 59, 192, 44, 45, 46, 47, 48, 49, 50, 51,
158901
+ /* 1190 */ 52, 53, 54, 55, 56, 57, 192, 76, 192, 214,
158902
+ /* 1200 */ 215, 152, 284, 154, 237, 238, 192, 289, 87, 145,
158903
+ /* 1210 */ 89, 19, 20, 92, 22, 22, 23, 250, 307, 236,
158904
+ /* 1220 */ 214, 215, 311, 203, 12, 247, 192, 249, 36, 307,
158905
+ /* 1230 */ 192, 262, 101, 311, 137, 138, 115, 116, 117, 27,
158329158906
/* 1240 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
158330
- /* 1250 */ 112, 59, 99, 63, 191, 236, 237, 236, 237, 191,
158331
- /* 1260 */ 289, 213, 214, 71, 191, 144, 261, 191, 249, 191,
158332
- /* 1270 */ 249, 19, 20, 81, 22, 235, 213, 214, 235, 191,
158333
- /* 1280 */ 278, 213, 214, 191, 282, 132, 213, 214, 36, 213,
158334
- /* 1290 */ 214, 191, 100, 191, 101, 191, 191, 191, 106, 107,
158335
- /* 1300 */ 48, 213, 214, 261, 191, 113, 191, 115, 116, 117,
158336
- /* 1310 */ 191, 59, 120, 213, 214, 213, 214, 213, 214, 213,
158337
- /* 1320 */ 214, 22, 23, 71, 237, 59, 213, 214, 191, 137,
158338
- /* 1330 */ 138, 191, 213, 214, 191, 191, 249, 85, 191, 261,
158339
- /* 1340 */ 191, 26, 90, 15, 152, 153, 154, 155, 156, 19,
158340
- /* 1350 */ 213, 214, 100, 213, 214, 191, 213, 214, 106, 107,
158341
- /* 1360 */ 213, 214, 213, 214, 191, 113, 261, 115, 116, 117,
158342
- /* 1370 */ 253, 254, 120, 229, 191, 191, 191, 213, 214, 191,
158343
- /* 1380 */ 306, 289, 116, 26, 310, 191, 213, 214, 60, 19,
158344
- /* 1390 */ 296, 297, 24, 191, 46, 191, 213, 214, 213, 214,
158345
- /* 1400 */ 101, 213, 214, 191, 152, 153, 154, 155, 156, 0,
158346
- /* 1410 */ 1, 2, 191, 229, 5, 213, 214, 213, 214, 10,
158347
- /* 1420 */ 11, 12, 13, 14, 1, 2, 17, 191, 5, 19,
158348
- /* 1430 */ 20, 191, 22, 10, 11, 12, 13, 14, 191, 30,
158349
- /* 1440 */ 17, 32, 241, 148, 149, 115, 36, 191, 241, 40,
158350
- /* 1450 */ 191, 26, 251, 30, 191, 32, 141, 22, 251, 5,
158351
- /* 1460 */ 213, 214, 114, 40, 10, 11, 12, 13, 14, 59,
158352
- /* 1470 */ 134, 17, 213, 214, 191, 139, 213, 214, 191, 70,
158353
- /* 1480 */ 191, 71, 125, 191, 30, 115, 32, 78, 53, 191,
158354
- /* 1490 */ 81, 191, 191, 70, 40, 85, 213, 214, 191, 22,
158355
- /* 1500 */ 90, 78, 213, 214, 81, 213, 214, 98, 140, 120,
158356
- /* 1510 */ 100, 213, 214, 213, 214, 23, 106, 107, 26, 130,
158357
- /* 1520 */ 191, 98, 191, 113, 70, 115, 116, 117, 23, 22,
158358
- /* 1530 */ 120, 26, 78, 19, 191, 81, 19, 20, 61, 22,
158359
- /* 1540 */ 191, 132, 213, 214, 213, 214, 137, 138, 59, 191,
158360
- /* 1550 */ 191, 191, 98, 36, 128, 132, 213, 214, 128, 59,
158361
- /* 1560 */ 137, 138, 152, 153, 154, 155, 156, 83, 84, 144,
158362
- /* 1570 */ 161, 213, 214, 213, 214, 23, 59, 151, 26, 23,
158363
- /* 1580 */ 23, 151, 26, 26, 161, 59, 132, 23, 71, 191,
158364
- /* 1590 */ 26, 137, 138, 119, 120, 23, 19, 20, 26, 22,
158365
- /* 1600 */ 223, 23, 85, 23, 26, 116, 26, 90, 191, 7,
158366
- /* 1610 */ 8, 97, 152, 36, 154, 161, 116, 100, 23, 23,
158367
- /* 1620 */ 191, 26, 26, 106, 107, 191, 23, 223, 23, 26,
158368
- /* 1630 */ 113, 26, 115, 116, 117, 23, 59, 120, 26, 191,
158369
- /* 1640 */ 191, 191, 116, 255, 191, 252, 191, 140, 71, 191,
158370
- /* 1650 */ 315, 233, 191, 191, 191, 191, 191, 191, 191, 191,
158371
- /* 1660 */ 191, 285, 284, 239, 252, 252, 252, 252, 240, 152,
158372
- /* 1670 */ 153, 154, 155, 156, 189, 294, 268, 100, 242, 268,
158373
- /* 1680 */ 264, 211, 290, 106, 107, 108, 264, 256, 256, 243,
158374
- /* 1690 */ 113, 290, 115, 116, 117, 268, 217, 120, 226, 243,
158375
- /* 1700 */ 222, 268, 216, 19, 20, 246, 22, 216, 256, 216,
158376
- /* 1710 */ 194, 60, 38, 242, 277, 294, 240, 242, 198, 246,
158377
- /* 1720 */ 36, 140, 198, 198, 19, 20, 150, 22, 149, 152,
158378
- /* 1730 */ 153, 154, 155, 156, 294, 291, 291, 280, 22, 43,
158379
- /* 1740 */ 231, 36, 18, 59, 234, 234, 234, 234, 267, 269,
158380
- /* 1750 */ 18, 198, 197, 231, 148, 71, 269, 269, 243, 231,
158381
- /* 1760 */ 198, 243, 267, 197, 59, 157, 243, 198, 62, 287,
158382
- /* 1770 */ 243, 197, 22, 198, 114, 64, 71, 218, 218, 197,
158383
- /* 1780 */ 286, 198, 197, 215, 100, 215, 215, 224, 22, 125,
158384
- /* 1790 */ 106, 107, 164, 24, 221, 112, 143, 113, 302, 115,
158385
- /* 1800 */ 116, 117, 218, 215, 120, 100, 217, 221, 215, 215,
158386
- /* 1810 */ 309, 106, 107, 215, 224, 279, 279, 218, 113, 258,
158387
- /* 1820 */ 115, 116, 117, 114, 257, 120, 91, 198, 82, 147,
158388
- /* 1830 */ 144, 22, 274, 314, 198, 314, 152, 153, 154, 155,
158389
- /* 1840 */ 156, 276, 157, 146, 145, 258, 25, 247, 257, 201,
158390
- /* 1850 */ 258, 26, 200, 13, 257, 244, 246, 152, 153, 154,
158391
- /* 1860 */ 155, 156, 258, 262, 257, 247, 245, 243, 192, 192,
158392
- /* 1870 */ 6, 262, 204, 210, 219, 210, 210, 190, 190, 190,
158393
- /* 1880 */ 210, 219, 204, 211, 211, 210, 4, 3, 22, 162,
158394
- /* 1890 */ 15, 23, 16, 23, 204, 138, 129, 150, 26, 141,
158395
- /* 1900 */ 20, 24, 143, 16, 1, 141, 129, 129, 61, 53,
158396
- /* 1910 */ 37, 150, 297, 300, 300, 53, 53, 129, 53, 115,
158397
- /* 1920 */ 34, 140, 1, 5, 22, 114, 68, 26, 160, 68,
158398
- /* 1930 */ 75, 41, 140, 114, 24, 20, 19, 130, 124, 23,
158399
- /* 1940 */ 96, 22, 22, 37, 22, 67, 22, 59, 67, 24,
158400
- /* 1950 */ 22, 28, 67, 23, 148, 22, 97, 23, 23, 23,
158401
- /* 1960 */ 140, 23, 22, 26, 23, 23, 115, 22, 142, 26,
158402
- /* 1970 */ 75, 88, 75, 34, 23, 86, 44, 22, 34, 26,
158403
- /* 1980 */ 34, 34, 34, 34, 93, 24, 26, 23, 34, 23,
158404
- /* 1990 */ 23, 23, 23, 11, 23, 22, 26, 22, 22, 15,
158405
- /* 2000 */ 23, 23, 22, 22, 1, 26, 23, 140, 134, 140,
158406
- /* 2010 */ 1, 140, 316, 316, 316, 316, 316, 316, 316, 140,
158407
- /* 2020 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158408
- /* 2030 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158409
- /* 2040 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158410
- /* 2050 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158411
- /* 2060 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158412
- /* 2070 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158413
- /* 2080 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158414
- /* 2090 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158415
- /* 2100 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158416
- /* 2110 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158417
- /* 2120 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158418
- /* 2130 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158419
- /* 2140 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158420
- /* 2150 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158421
- /* 2160 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158422
- /* 2170 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158423
- /* 2180 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158424
- /* 2190 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158425
- /* 2200 */ 316, 316, 316,
158907
+ /* 1250 */ 112, 59, 214, 215, 42, 203, 307, 237, 238, 192,
158908
+ /* 1260 */ 311, 192, 26, 71, 192, 144, 262, 297, 298, 203,
158909
+ /* 1270 */ 250, 19, 20, 81, 22, 63, 262, 254, 255, 15,
158910
+ /* 1280 */ 26, 214, 215, 214, 215, 26, 214, 215, 36, 237,
158911
+ /* 1290 */ 238, 192, 100, 114, 101, 192, 262, 192, 106, 107,
158912
+ /* 1300 */ 48, 134, 250, 237, 238, 113, 139, 115, 116, 117,
158913
+ /* 1310 */ 192, 59, 120, 214, 215, 242, 250, 214, 215, 214,
158914
+ /* 1320 */ 215, 148, 149, 71, 60, 252, 242, 192, 149, 137,
158915
+ /* 1330 */ 138, 192, 214, 215, 192, 19, 252, 85, 192, 59,
158916
+ /* 1340 */ 192, 157, 90, 159, 152, 153, 154, 155, 156, 214,
158917
+ /* 1350 */ 215, 192, 100, 214, 215, 19, 214, 215, 106, 107,
158918
+ /* 1360 */ 214, 215, 214, 215, 22, 113, 192, 115, 116, 117,
158919
+ /* 1370 */ 192, 242, 120, 214, 215, 192, 24, 192, 31, 192,
158920
+ /* 1380 */ 144, 252, 26, 192, 125, 99, 39, 192, 214, 215,
158921
+ /* 1390 */ 192, 59, 214, 215, 192, 141, 116, 214, 215, 214,
158922
+ /* 1400 */ 215, 214, 215, 61, 152, 153, 154, 155, 156, 0,
158923
+ /* 1410 */ 1, 2, 214, 215, 5, 192, 214, 215, 132, 10,
158924
+ /* 1420 */ 11, 12, 13, 14, 1, 2, 17, 192, 5, 19,
158925
+ /* 1430 */ 20, 115, 22, 10, 11, 12, 13, 14, 192, 30,
158926
+ /* 1440 */ 17, 32, 23, 192, 23, 26, 36, 26, 116, 40,
158927
+ /* 1450 */ 192, 115, 192, 30, 192, 32, 119, 120, 59, 5,
158928
+ /* 1460 */ 214, 215, 128, 40, 10, 11, 12, 13, 14, 59,
158929
+ /* 1470 */ 19, 17, 214, 215, 214, 215, 214, 215, 120, 70,
158930
+ /* 1480 */ 192, 71, 22, 192, 30, 151, 32, 78, 130, 128,
158931
+ /* 1490 */ 81, 192, 140, 70, 40, 85, 192, 141, 7, 8,
158932
+ /* 1500 */ 90, 78, 214, 215, 81, 214, 215, 98, 83, 84,
158933
+ /* 1510 */ 100, 192, 151, 214, 215, 116, 106, 107, 214, 215,
158934
+ /* 1520 */ 192, 98, 192, 113, 70, 115, 116, 117, 23, 224,
158935
+ /* 1530 */ 120, 26, 78, 214, 215, 81, 19, 20, 152, 22,
158936
+ /* 1540 */ 154, 132, 214, 215, 214, 215, 137, 138, 97, 192,
158937
+ /* 1550 */ 256, 192, 98, 36, 23, 132, 192, 26, 192, 192,
158938
+ /* 1560 */ 137, 138, 152, 153, 154, 155, 156, 192, 192, 192,
158939
+ /* 1570 */ 161, 214, 215, 214, 215, 192, 59, 192, 214, 215,
158940
+ /* 1580 */ 214, 215, 192, 152, 161, 154, 132, 192, 71, 214,
158941
+ /* 1590 */ 215, 137, 138, 192, 192, 192, 19, 20, 192, 22,
158942
+ /* 1600 */ 140, 253, 85, 192, 214, 215, 192, 90, 23, 214,
158943
+ /* 1610 */ 215, 26, 192, 36, 192, 161, 23, 100, 192, 26,
158944
+ /* 1620 */ 214, 215, 192, 106, 107, 214, 215, 192, 23, 192,
158945
+ /* 1630 */ 113, 26, 115, 116, 117, 23, 59, 120, 26, 23,
158946
+ /* 1640 */ 23, 23, 26, 26, 26, 316, 234, 23, 71, 23,
158947
+ /* 1650 */ 26, 192, 26, 192, 192, 192, 192, 192, 192, 192,
158948
+ /* 1660 */ 192, 253, 212, 190, 286, 285, 253, 240, 253, 152,
158949
+ /* 1670 */ 153, 154, 155, 156, 241, 243, 295, 100, 291, 291,
158950
+ /* 1680 */ 223, 253, 227, 106, 107, 108, 269, 244, 244, 265,
158951
+ /* 1690 */ 113, 257, 115, 116, 117, 257, 243, 120, 269, 218,
158952
+ /* 1700 */ 217, 265, 217, 19, 20, 217, 22, 195, 269, 269,
158953
+ /* 1710 */ 60, 295, 140, 257, 243, 241, 247, 247, 199, 278,
158954
+ /* 1720 */ 36, 199, 199, 38, 19, 20, 150, 22, 149, 152,
158955
+ /* 1730 */ 153, 154, 155, 156, 22, 43, 232, 295, 292, 292,
158956
+ /* 1740 */ 18, 36, 235, 59, 268, 270, 235, 199, 235, 235,
158957
+ /* 1750 */ 18, 198, 148, 281, 244, 71, 270, 270, 268, 244,
158958
+ /* 1760 */ 232, 232, 244, 199, 59, 244, 198, 157, 288, 62,
158959
+ /* 1770 */ 199, 287, 198, 22, 219, 219, 71, 199, 198, 114,
158960
+ /* 1780 */ 199, 198, 216, 216, 100, 216, 225, 64, 22, 125,
158961
+ /* 1790 */ 106, 107, 222, 164, 219, 222, 24, 113, 216, 115,
158962
+ /* 1800 */ 116, 117, 218, 216, 120, 100, 216, 216, 310, 303,
158963
+ /* 1810 */ 112, 106, 107, 225, 280, 280, 219, 143, 113, 259,
158964
+ /* 1820 */ 115, 116, 117, 114, 259, 120, 199, 91, 82, 147,
158965
+ /* 1830 */ 144, 315, 22, 275, 199, 315, 152, 153, 154, 155,
158966
+ /* 1840 */ 156, 146, 145, 247, 258, 157, 25, 258, 245, 248,
158967
+ /* 1850 */ 244, 259, 258, 202, 259, 248, 258, 152, 153, 154,
158968
+ /* 1860 */ 155, 156, 263, 263, 26, 246, 13, 201, 193, 193,
158969
+ /* 1870 */ 6, 191, 191, 205, 191, 220, 220, 205, 211, 277,
158970
+ /* 1880 */ 211, 211, 211, 205, 4, 212, 3, 22, 162, 212,
158971
+ /* 1890 */ 211, 15, 23, 16, 23, 138, 129, 150, 26, 24,
158972
+ /* 1900 */ 141, 20, 16, 143, 1, 141, 129, 129, 61, 301,
158973
+ /* 1910 */ 301, 298, 150, 53, 53, 37, 53, 129, 115, 53,
158974
+ /* 1920 */ 140, 34, 1, 5, 22, 114, 68, 26, 160, 75,
158975
+ /* 1930 */ 68, 41, 140, 114, 24, 20, 19, 130, 124, 23,
158976
+ /* 1940 */ 67, 22, 22, 59, 22, 22, 67, 96, 24, 22,
158977
+ /* 1950 */ 37, 23, 67, 28, 148, 22, 26, 23, 23, 23,
158978
+ /* 1960 */ 23, 22, 140, 23, 97, 23, 34, 115, 22, 142,
158979
+ /* 1970 */ 26, 75, 34, 44, 75, 34, 88, 34, 86, 34,
158980
+ /* 1980 */ 23, 34, 93, 22, 24, 26, 34, 23, 26, 23,
158981
+ /* 1990 */ 23, 23, 23, 11, 23, 22, 26, 22, 22, 140,
158982
+ /* 2000 */ 23, 23, 22, 22, 134, 26, 23, 15, 140, 1,
158983
+ /* 2010 */ 1, 317, 317, 317, 140, 317, 317, 317, 317, 317,
158984
+ /* 2020 */ 317, 317, 140, 317, 317, 317, 317, 317, 317, 317,
158985
+ /* 2030 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158986
+ /* 2040 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158987
+ /* 2050 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158988
+ /* 2060 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158989
+ /* 2070 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158990
+ /* 2080 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158991
+ /* 2090 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158992
+ /* 2100 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158993
+ /* 2110 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158994
+ /* 2120 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158995
+ /* 2130 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158996
+ /* 2140 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158997
+ /* 2150 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158998
+ /* 2160 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158999
+ /* 2170 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
159000
+ /* 2180 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
159001
+ /* 2190 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
159002
+ /* 2200 */ 317, 317, 317, 317, 317, 317, 317,
158426159003
};
158427159004
#define YY_SHIFT_COUNT (569)
158428159005
#define YY_SHIFT_MIN (0)
158429159006
#define YY_SHIFT_MAX (2009)
158430159007
static const unsigned short int yy_shift_ofst[] = {
158431
- /* 0 */ 1423, 1409, 1454, 1192, 1192, 36, 1252, 1410, 1517, 1684,
158432
- /* 10 */ 1684, 1684, 292, 0, 0, 180, 1015, 1684, 1684, 1684,
159008
+ /* 0 */ 1423, 1409, 1454, 1192, 1192, 382, 1252, 1410, 1517, 1684,
159009
+ /* 10 */ 1684, 1684, 221, 0, 0, 180, 1015, 1684, 1684, 1684,
158433159010
/* 20 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
158434
- /* 30 */ 1049, 1049, 1121, 1121, 54, 400, 36, 36, 36, 36,
158435
- /* 40 */ 36, 40, 110, 219, 289, 396, 439, 509, 548, 618,
159011
+ /* 30 */ 1049, 1049, 1121, 1121, 54, 616, 382, 382, 382, 382,
159012
+ /* 40 */ 382, 40, 110, 219, 289, 396, 439, 509, 548, 618,
158436159013
/* 50 */ 657, 727, 766, 836, 995, 1015, 1015, 1015, 1015, 1015,
158437159014
/* 60 */ 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015,
158438159015
/* 70 */ 1015, 1015, 1015, 1035, 1015, 1138, 880, 880, 1577, 1684,
158439159016
/* 80 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
158440159017
/* 90 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
158441159018
/* 100 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
158442159019
/* 110 */ 1684, 1684, 1684, 1705, 1684, 1684, 1684, 1684, 1684, 1684,
158443159020
/* 120 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 146, 84, 84,
158444
- /* 130 */ 84, 84, 84, 362, 269, 125, 97, 453, 66, 66,
158445
- /* 140 */ 893, 1090, 66, 66, 533, 533, 66, 554, 554, 554,
158446
- /* 150 */ 554, 192, 587, 587, 695, 25, 2020, 2020, 290, 290,
158447
- /* 160 */ 290, 200, 514, 514, 514, 514, 939, 939, 442, 875,
158448
- /* 170 */ 935, 66, 66, 66, 66, 66, 66, 66, 66, 66,
159021
+ /* 130 */ 84, 84, 84, 274, 315, 125, 97, 357, 66, 66,
159022
+ /* 140 */ 893, 258, 66, 66, 371, 371, 66, 551, 551, 551,
159023
+ /* 150 */ 551, 192, 209, 209, 278, 127, 2023, 2023, 621, 621,
159024
+ /* 160 */ 621, 201, 398, 398, 398, 398, 939, 939, 442, 936,
159025
+ /* 170 */ 1009, 66, 66, 66, 66, 66, 66, 66, 66, 66,
158449159026
/* 180 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
158450
- /* 190 */ 66, 601, 601, 66, 729, 878, 878, 1266, 1266, 552,
158451
- /* 200 */ 1023, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 307, 490,
158452
- /* 210 */ 490, 567, 393, 517, 467, 672, 242, 682, 675, 66,
158453
- /* 220 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 616,
159027
+ /* 190 */ 66, 710, 710, 66, 776, 435, 435, 410, 410, 372,
159028
+ /* 200 */ 1097, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 250, 490,
159029
+ /* 210 */ 490, 511, 451, 516, 252, 566, 575, 781, 673, 66,
159030
+ /* 220 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 722,
158454159031
/* 230 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
158455
- /* 240 */ 66, 66, 1093, 1093, 1093, 66, 66, 66, 778, 66,
158456
- /* 250 */ 66, 66, 1053, 1064, 66, 66, 1190, 66, 66, 66,
158457
- /* 260 */ 66, 66, 66, 66, 66, 722, 992, 718, 253, 253,
158458
- /* 270 */ 253, 253, 338, 718, 718, 888, 403, 852, 1328, 254,
158459
- /* 280 */ 1295, 721, 1330, 1295, 1330, 1370, 234, 254, 254, 234,
158460
- /* 290 */ 254, 721, 1370, 1357, 1492, 1348, 385, 385, 385, 1330,
158461
- /* 300 */ 1425, 1425, 643, 1315, 1336, 1004, 1651, 1651, 1581, 1581,
158462
- /* 310 */ 1674, 1674, 1581, 1576, 1579, 1716, 1696, 1724, 1724, 1724,
158463
- /* 320 */ 1724, 1581, 1732, 1606, 1579, 1579, 1606, 1716, 1696, 1606,
158464
- /* 330 */ 1696, 1606, 1581, 1732, 1608, 1706, 1581, 1732, 1750, 1581,
158465
- /* 340 */ 1732, 1581, 1732, 1750, 1660, 1660, 1660, 1711, 1766, 1766,
158466
- /* 350 */ 1750, 1660, 1664, 1660, 1711, 1660, 1660, 1628, 1769, 1683,
158467
- /* 360 */ 1683, 1750, 1653, 1709, 1653, 1709, 1653, 1709, 1653, 1709,
158468
- /* 370 */ 1581, 1735, 1735, 1746, 1746, 1682, 1686, 1809, 1581, 1685,
158469
- /* 380 */ 1682, 1697, 1699, 1606, 1821, 1825, 1840, 1840, 1864, 1864,
158470
- /* 390 */ 1864, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020,
158471
- /* 400 */ 2020, 2020, 2020, 2020, 2020, 2020, 599, 223, 1193, 1299,
158472
- /* 410 */ 228, 780, 958, 1505, 1153, 1435, 1368, 1426, 1430, 1552,
158473
- /* 420 */ 1477, 1556, 1557, 1564, 1572, 1578, 1580, 1489, 1474, 1602,
158474
- /* 430 */ 1389, 1514, 1500, 1595, 1596, 1484, 1603, 1075, 1460, 1605,
158475
- /* 440 */ 1612, 1526, 1507, 1882, 1884, 1866, 1727, 1875, 1876, 1868,
158476
- /* 450 */ 1870, 1757, 1747, 1767, 1872, 1872, 1877, 1758, 1880, 1759,
158477
- /* 460 */ 1887, 1903, 1764, 1777, 1872, 1778, 1847, 1873, 1872, 1761,
158478
- /* 470 */ 1856, 1862, 1863, 1865, 1788, 1804, 1886, 1781, 1921, 1918,
158479
- /* 480 */ 1902, 1811, 1768, 1858, 1901, 1861, 1855, 1890, 1792, 1819,
158480
- /* 490 */ 1910, 1915, 1917, 1807, 1814, 1919, 1878, 1920, 1922, 1916,
158481
- /* 500 */ 1924, 1881, 1888, 1925, 1844, 1923, 1928, 1885, 1906, 1930,
158482
- /* 510 */ 1806, 1933, 1934, 1935, 1936, 1937, 1938, 1940, 1859, 1820,
158483
- /* 520 */ 1941, 1942, 1851, 1939, 1945, 1826, 1943, 1944, 1946, 1947,
158484
- /* 530 */ 1948, 1883, 1895, 1889, 1932, 1897, 1891, 1949, 1951, 1955,
158485
- /* 540 */ 1961, 1953, 1960, 1954, 1964, 1943, 1966, 1967, 1968, 1969,
159032
+ /* 240 */ 66, 66, 790, 790, 790, 66, 66, 66, 883, 66,
159033
+ /* 250 */ 66, 66, 891, 1064, 66, 66, 1212, 66, 66, 66,
159034
+ /* 260 */ 66, 66, 66, 66, 66, 725, 763, 177, 940, 940,
159035
+ /* 270 */ 940, 940, 337, 177, 177, 1028, 1053, 670, 1264, 1179,
159036
+ /* 280 */ 1173, 1254, 1316, 1173, 1316, 1336, 50, 1179, 1179, 50,
159037
+ /* 290 */ 1179, 1254, 1336, 1259, 732, 532, 1347, 1347, 1347, 1316,
159038
+ /* 300 */ 1236, 1236, 1184, 1356, 1167, 898, 1650, 1650, 1572, 1572,
159039
+ /* 310 */ 1685, 1685, 1572, 1576, 1579, 1712, 1692, 1722, 1722, 1722,
159040
+ /* 320 */ 1722, 1572, 1732, 1604, 1579, 1579, 1604, 1712, 1692, 1604,
159041
+ /* 330 */ 1692, 1604, 1572, 1732, 1610, 1707, 1572, 1732, 1751, 1572,
159042
+ /* 340 */ 1732, 1572, 1732, 1751, 1665, 1665, 1665, 1723, 1766, 1766,
159043
+ /* 350 */ 1751, 1665, 1664, 1665, 1723, 1665, 1665, 1629, 1772, 1698,
159044
+ /* 360 */ 1698, 1751, 1674, 1709, 1674, 1709, 1674, 1709, 1674, 1709,
159045
+ /* 370 */ 1572, 1736, 1736, 1746, 1746, 1682, 1686, 1810, 1572, 1688,
159046
+ /* 380 */ 1682, 1695, 1697, 1604, 1821, 1838, 1853, 1853, 1864, 1864,
159047
+ /* 390 */ 1864, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023,
159048
+ /* 400 */ 2023, 2023, 2023, 2023, 2023, 2023, 232, 101, 1131, 1193,
159049
+ /* 410 */ 619, 679, 841, 1421, 1286, 115, 1352, 1334, 1361, 1419,
159050
+ /* 420 */ 1342, 1505, 1531, 1585, 1593, 1605, 1612, 1280, 1337, 1491,
159051
+ /* 430 */ 1358, 1451, 1332, 1616, 1617, 1425, 1618, 1386, 1431, 1624,
159052
+ /* 440 */ 1626, 1399, 1460, 1880, 1883, 1865, 1726, 1876, 1877, 1869,
159053
+ /* 450 */ 1871, 1757, 1747, 1767, 1872, 1872, 1875, 1759, 1881, 1760,
159054
+ /* 460 */ 1886, 1903, 1764, 1777, 1872, 1778, 1847, 1878, 1872, 1762,
159055
+ /* 470 */ 1860, 1861, 1863, 1866, 1788, 1803, 1887, 1780, 1921, 1918,
159056
+ /* 480 */ 1902, 1811, 1768, 1858, 1901, 1862, 1854, 1890, 1792, 1819,
159057
+ /* 490 */ 1910, 1915, 1917, 1807, 1814, 1919, 1873, 1920, 1922, 1916,
159058
+ /* 500 */ 1923, 1879, 1884, 1924, 1851, 1925, 1927, 1885, 1913, 1928,
159059
+ /* 510 */ 1806, 1933, 1934, 1935, 1936, 1930, 1937, 1939, 1867, 1822,
159060
+ /* 520 */ 1940, 1942, 1852, 1932, 1946, 1827, 1944, 1938, 1941, 1943,
159061
+ /* 530 */ 1945, 1888, 1896, 1892, 1929, 1899, 1889, 1947, 1957, 1961,
159062
+ /* 540 */ 1960, 1959, 1962, 1952, 1964, 1944, 1966, 1967, 1968, 1969,
158486159063
/* 550 */ 1970, 1971, 1973, 1982, 1975, 1976, 1977, 1978, 1980, 1981,
158487
- /* 560 */ 1979, 1874, 1867, 1869, 1871, 1879, 1983, 1984, 2003, 2009,
159064
+ /* 560 */ 1979, 1870, 1859, 1868, 1874, 1882, 1983, 1992, 2008, 2009,
158488159065
};
158489159066
#define YY_REDUCE_COUNT (405)
158490
-#define YY_REDUCE_MIN (-265)
158491
-#define YY_REDUCE_MAX (1690)
159067
+#define YY_REDUCE_MIN (-266)
159068
+#define YY_REDUCE_MAX (1683)
158492159069
static const short yy_reduce_ofst[] = {
158493
- /* 0 */ 111, 168, 386, 761, -176, -174, -191, -189, -181, -178,
158494
- /* 10 */ 176, 263, 44, -207, -204, -265, -139, -114, 158, 504,
158495
- /* 20 */ 525, 544, 612, 614, 650, 652, 765, 265, 703, 705,
158496
- /* 30 */ 70, 714, -187, 127, 774, 713, 767, 769, 970, 1019,
158497
- /* 40 */ 1021, -255, -255, -255, -255, -255, -255, -255, -255, -255,
158498
- /* 50 */ -255, -255, -255, -255, -255, -255, -255, -255, -255, -255,
158499
- /* 60 */ -255, -255, -255, -255, -255, -255, -255, -255, -255, -255,
158500
- /* 70 */ -255, -255, -255, -255, -255, -255, -255, -255, 394, 542,
158501
- /* 80 */ 816, 818, 842, 882, 902, 919, 938, 940, 957, 986,
158502
- /* 90 */ 1048, 1063, 1068, 1073, 1076, 1088, 1100, 1102, 1104, 1106,
158503
- /* 100 */ 1113, 1119, 1137, 1140, 1143, 1147, 1149, 1164, 1173, 1183,
158504
- /* 110 */ 1185, 1188, 1202, 1204, 1247, 1259, 1263, 1283, 1289, 1292,
158505
- /* 120 */ 1298, 1300, 1329, 1331, 1343, 1358, 1360, -255, -255, -255,
158506
- /* 130 */ -255, -255, -255, -255, -255, 196, -255, 387, -177, 507,
158507
- /* 140 */ 1002, -219, 557, -93, -167, 638, -121, 284, 500, 284,
158508
- /* 150 */ 500, 247, 651, 865, -255, -255, -255, -255, -85, -85,
158509
- /* 160 */ -85, 237, 171, 602, 846, 885, -212, -203, 217, 380,
158510
- /* 170 */ 380, -23, 161, 653, 712, 773, 943, 990, 1040, 563,
158511
- /* 180 */ 833, 971, 1005, 1042, 1092, 1078, 1043, 1144, 1184, -186,
158512
- /* 190 */ 1105, 318, 869, 7, 825, 920, 1074, 704, 706, 390,
158513
- /* 200 */ 1087, 1094, 336, 545, 772, 1201, 1117, 1207, -179, -137,
158514
- /* 210 */ -112, -13, 18, 112, 197, 418, 495, 508, 777, 809,
158515
- /* 220 */ 923, 1014, 1027, 1033, 1044, 1115, 1194, 1212, 1221, 209,
158516
- /* 230 */ 1236, 1240, 1256, 1287, 1301, 1307, 1349, 1359, 1398, 1417,
158517
- /* 240 */ 1429, 1434, 681, 1377, 1404, 1448, 1449, 1450, 1388, 1453,
158518
- /* 250 */ 1455, 1458, 1393, 1335, 1461, 1462, 1418, 1463, 197, 1464,
158519
- /* 260 */ 1465, 1466, 1467, 1468, 1469, 1376, 1378, 1424, 1412, 1413,
158520
- /* 270 */ 1414, 1415, 1388, 1424, 1424, 1428, 1470, 1485, 1381, 1408,
158521
- /* 280 */ 1416, 1436, 1431, 1422, 1432, 1392, 1446, 1411, 1427, 1456,
158522
- /* 290 */ 1433, 1471, 1401, 1479, 1472, 1478, 1486, 1491, 1493, 1452,
158523
- /* 300 */ 1459, 1473, 1437, 1475, 1476, 1516, 1421, 1440, 1520, 1524,
158524
- /* 310 */ 1444, 1445, 1525, 1457, 1480, 1481, 1509, 1510, 1511, 1512,
158525
- /* 320 */ 1513, 1553, 1555, 1515, 1487, 1488, 1518, 1495, 1522, 1523,
158526
- /* 330 */ 1528, 1527, 1562, 1566, 1482, 1494, 1569, 1574, 1559, 1575,
158527
- /* 340 */ 1582, 1583, 1585, 1560, 1568, 1570, 1571, 1563, 1573, 1586,
158528
- /* 350 */ 1584, 1588, 1589, 1593, 1590, 1594, 1598, 1501, 1496, 1536,
158529
- /* 360 */ 1537, 1599, 1561, 1567, 1587, 1591, 1592, 1597, 1604, 1607,
158530
- /* 370 */ 1629, 1519, 1521, 1601, 1609, 1600, 1610, 1558, 1636, 1565,
158531
- /* 380 */ 1618, 1621, 1611, 1624, 1648, 1652, 1676, 1677, 1687, 1688,
158532
- /* 390 */ 1689, 1613, 1614, 1615, 1668, 1663, 1665, 1666, 1670, 1678,
158533
- /* 400 */ 1655, 1662, 1672, 1673, 1675, 1690,
159070
+ /* 0 */ 111, 168, 272, 760, -177, -175, -192, -190, -182, -179,
159071
+ /* 10 */ 216, 220, 481, -208, -205, -266, -140, -115, 241, 393,
159072
+ /* 20 */ 523, 325, 612, 632, 542, 651, 764, 757, 702, 762,
159073
+ /* 30 */ 812, 814, -188, 273, 924, 386, 758, 967, 1020, 1052,
159074
+ /* 40 */ 1066, -256, -256, -256, -256, -256, -256, -256, -256, -256,
159075
+ /* 50 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256,
159076
+ /* 60 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256,
159077
+ /* 70 */ -256, -256, -256, -256, -256, -256, -256, -256, 195, 222,
159078
+ /* 80 */ 813, 917, 920, 959, 985, 1006, 1038, 1067, 1069, 1072,
159079
+ /* 90 */ 1099, 1103, 1105, 1118, 1135, 1139, 1142, 1146, 1148, 1159,
159080
+ /* 100 */ 1174, 1178, 1183, 1185, 1187, 1198, 1202, 1246, 1258, 1260,
159081
+ /* 110 */ 1262, 1288, 1291, 1299, 1304, 1319, 1328, 1330, 1357, 1359,
159082
+ /* 120 */ 1364, 1366, 1375, 1390, 1395, 1406, 1411, -256, -256, -256,
159083
+ /* 130 */ -256, -256, -256, -256, -256, 447, -256, 555, -178, 605,
159084
+ /* 140 */ 832, -220, 606, -94, -168, 36, -122, 730, 780, 730,
159085
+ /* 150 */ 780, 918, -136, 338, -256, -256, -256, -256, 80, 80,
159086
+ /* 160 */ 80, 720, 703, 811, 882, 903, -213, -204, 106, 330,
159087
+ /* 170 */ 330, -77, 236, 320, 599, 67, 457, 675, 729, 395,
159088
+ /* 180 */ 268, 611, 969, 1004, 726, 1014, 983, 123, 884, 608,
159089
+ /* 190 */ 1034, 547, 911, 650, 844, 922, 949, 965, 972, 978,
159090
+ /* 200 */ 449, 970, 718, 784, 1073, 1084, 1023, 1129, -209, -180,
159091
+ /* 210 */ -113, 114, 183, 329, 345, 391, 446, 502, 609, 667,
159092
+ /* 220 */ 713, 817, 865, 881, 901, 921, 989, 1191, 1195, 214,
159093
+ /* 230 */ 1223, 1235, 1251, 1367, 1376, 1377, 1383, 1385, 1401, 1402,
159094
+ /* 240 */ 1403, 1414, 584, 638, 1305, 1420, 1422, 1426, 1294, 1430,
159095
+ /* 250 */ 1435, 1437, 1348, 1329, 1459, 1461, 1412, 1462, 345, 1463,
159096
+ /* 260 */ 1464, 1465, 1466, 1467, 1468, 1378, 1380, 1427, 1408, 1413,
159097
+ /* 270 */ 1415, 1428, 1294, 1427, 1427, 1433, 1450, 1473, 1381, 1417,
159098
+ /* 280 */ 1424, 1432, 1434, 1436, 1438, 1387, 1443, 1429, 1439, 1444,
159099
+ /* 290 */ 1440, 1453, 1388, 1481, 1455, 1457, 1483, 1485, 1488, 1456,
159100
+ /* 300 */ 1469, 1470, 1441, 1471, 1474, 1512, 1416, 1442, 1519, 1522,
159101
+ /* 310 */ 1446, 1447, 1523, 1472, 1475, 1476, 1504, 1507, 1511, 1513,
159102
+ /* 320 */ 1514, 1548, 1553, 1510, 1486, 1487, 1515, 1490, 1528, 1518,
159103
+ /* 330 */ 1529, 1521, 1564, 1568, 1480, 1484, 1571, 1574, 1555, 1578,
159104
+ /* 340 */ 1580, 1581, 1583, 1556, 1566, 1567, 1569, 1561, 1570, 1573,
159105
+ /* 350 */ 1575, 1582, 1584, 1587, 1588, 1590, 1591, 1498, 1506, 1534,
159106
+ /* 360 */ 1535, 1597, 1560, 1586, 1565, 1589, 1592, 1594, 1595, 1598,
159107
+ /* 370 */ 1627, 1516, 1520, 1599, 1600, 1601, 1596, 1558, 1635, 1602,
159108
+ /* 380 */ 1607, 1619, 1603, 1606, 1651, 1666, 1675, 1676, 1680, 1681,
159109
+ /* 390 */ 1683, 1608, 1609, 1613, 1668, 1667, 1669, 1670, 1671, 1672,
159110
+ /* 400 */ 1655, 1656, 1673, 1677, 1679, 1678,
158534159111
};
158535159112
static const YYACTIONTYPE yy_default[] = {
158536159113
/* 0 */ 1623, 1623, 1623, 1453, 1223, 1332, 1223, 1223, 1223, 1453,
158537159114
/* 10 */ 1453, 1453, 1223, 1362, 1362, 1506, 1254, 1223, 1223, 1223,
158538159115
/* 20 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1452, 1223, 1223,
@@ -158788,10 +159365,11 @@
158788159365
0, /* VECTOR => nothing */
158789159366
0, /* SELECT_COLUMN => nothing */
158790159367
0, /* IF_NULL_ROW => nothing */
158791159368
0, /* ASTERISK => nothing */
158792159369
0, /* SPAN => nothing */
159370
+ 0, /* ERROR => nothing */
158793159371
0, /* SPACE => nothing */
158794159372
0, /* ILLEGAL => nothing */
158795159373
};
158796159374
#endif /* YYFALLBACK */
158797159375
@@ -159059,145 +159637,146 @@
159059159637
/* 176 */ "VECTOR",
159060159638
/* 177 */ "SELECT_COLUMN",
159061159639
/* 178 */ "IF_NULL_ROW",
159062159640
/* 179 */ "ASTERISK",
159063159641
/* 180 */ "SPAN",
159064
- /* 181 */ "SPACE",
159065
- /* 182 */ "ILLEGAL",
159066
- /* 183 */ "input",
159067
- /* 184 */ "cmdlist",
159068
- /* 185 */ "ecmd",
159069
- /* 186 */ "cmdx",
159070
- /* 187 */ "explain",
159071
- /* 188 */ "cmd",
159072
- /* 189 */ "transtype",
159073
- /* 190 */ "trans_opt",
159074
- /* 191 */ "nm",
159075
- /* 192 */ "savepoint_opt",
159076
- /* 193 */ "create_table",
159077
- /* 194 */ "create_table_args",
159078
- /* 195 */ "createkw",
159079
- /* 196 */ "temp",
159080
- /* 197 */ "ifnotexists",
159081
- /* 198 */ "dbnm",
159082
- /* 199 */ "columnlist",
159083
- /* 200 */ "conslist_opt",
159084
- /* 201 */ "table_options",
159085
- /* 202 */ "select",
159086
- /* 203 */ "columnname",
159087
- /* 204 */ "carglist",
159088
- /* 205 */ "typetoken",
159089
- /* 206 */ "typename",
159090
- /* 207 */ "signed",
159091
- /* 208 */ "plus_num",
159092
- /* 209 */ "minus_num",
159093
- /* 210 */ "scanpt",
159094
- /* 211 */ "scantok",
159095
- /* 212 */ "ccons",
159096
- /* 213 */ "term",
159097
- /* 214 */ "expr",
159098
- /* 215 */ "onconf",
159099
- /* 216 */ "sortorder",
159100
- /* 217 */ "autoinc",
159101
- /* 218 */ "eidlist_opt",
159102
- /* 219 */ "refargs",
159103
- /* 220 */ "defer_subclause",
159104
- /* 221 */ "generated",
159105
- /* 222 */ "refarg",
159106
- /* 223 */ "refact",
159107
- /* 224 */ "init_deferred_pred_opt",
159108
- /* 225 */ "conslist",
159109
- /* 226 */ "tconscomma",
159110
- /* 227 */ "tcons",
159111
- /* 228 */ "sortlist",
159112
- /* 229 */ "eidlist",
159113
- /* 230 */ "defer_subclause_opt",
159114
- /* 231 */ "orconf",
159115
- /* 232 */ "resolvetype",
159116
- /* 233 */ "raisetype",
159117
- /* 234 */ "ifexists",
159118
- /* 235 */ "fullname",
159119
- /* 236 */ "selectnowith",
159120
- /* 237 */ "oneselect",
159121
- /* 238 */ "wqlist",
159122
- /* 239 */ "multiselect_op",
159123
- /* 240 */ "distinct",
159124
- /* 241 */ "selcollist",
159125
- /* 242 */ "from",
159126
- /* 243 */ "where_opt",
159127
- /* 244 */ "groupby_opt",
159128
- /* 245 */ "having_opt",
159129
- /* 246 */ "orderby_opt",
159130
- /* 247 */ "limit_opt",
159131
- /* 248 */ "window_clause",
159132
- /* 249 */ "values",
159133
- /* 250 */ "nexprlist",
159134
- /* 251 */ "sclp",
159135
- /* 252 */ "as",
159136
- /* 253 */ "seltablist",
159137
- /* 254 */ "stl_prefix",
159138
- /* 255 */ "joinop",
159139
- /* 256 */ "indexed_opt",
159140
- /* 257 */ "on_opt",
159141
- /* 258 */ "using_opt",
159142
- /* 259 */ "exprlist",
159143
- /* 260 */ "xfullname",
159144
- /* 261 */ "idlist",
159145
- /* 262 */ "nulls",
159146
- /* 263 */ "with",
159147
- /* 264 */ "where_opt_ret",
159148
- /* 265 */ "setlist",
159149
- /* 266 */ "insert_cmd",
159150
- /* 267 */ "idlist_opt",
159151
- /* 268 */ "upsert",
159152
- /* 269 */ "returning",
159153
- /* 270 */ "filter_over",
159154
- /* 271 */ "likeop",
159155
- /* 272 */ "between_op",
159156
- /* 273 */ "in_op",
159157
- /* 274 */ "paren_exprlist",
159158
- /* 275 */ "case_operand",
159159
- /* 276 */ "case_exprlist",
159160
- /* 277 */ "case_else",
159161
- /* 278 */ "uniqueflag",
159162
- /* 279 */ "collate",
159163
- /* 280 */ "vinto",
159164
- /* 281 */ "nmnum",
159165
- /* 282 */ "trigger_decl",
159166
- /* 283 */ "trigger_cmd_list",
159167
- /* 284 */ "trigger_time",
159168
- /* 285 */ "trigger_event",
159169
- /* 286 */ "foreach_clause",
159170
- /* 287 */ "when_clause",
159171
- /* 288 */ "trigger_cmd",
159172
- /* 289 */ "trnm",
159173
- /* 290 */ "tridxby",
159174
- /* 291 */ "database_kw_opt",
159175
- /* 292 */ "key_opt",
159176
- /* 293 */ "add_column_fullname",
159177
- /* 294 */ "kwcolumn_opt",
159178
- /* 295 */ "create_vtab",
159179
- /* 296 */ "vtabarglist",
159180
- /* 297 */ "vtabarg",
159181
- /* 298 */ "vtabargtoken",
159182
- /* 299 */ "lp",
159183
- /* 300 */ "anylist",
159184
- /* 301 */ "wqitem",
159185
- /* 302 */ "wqas",
159186
- /* 303 */ "windowdefn_list",
159187
- /* 304 */ "windowdefn",
159188
- /* 305 */ "window",
159189
- /* 306 */ "frame_opt",
159190
- /* 307 */ "part_opt",
159191
- /* 308 */ "filter_clause",
159192
- /* 309 */ "over_clause",
159193
- /* 310 */ "range_or_rows",
159194
- /* 311 */ "frame_bound",
159195
- /* 312 */ "frame_bound_s",
159196
- /* 313 */ "frame_bound_e",
159197
- /* 314 */ "frame_exclude_opt",
159198
- /* 315 */ "frame_exclude",
159642
+ /* 181 */ "ERROR",
159643
+ /* 182 */ "SPACE",
159644
+ /* 183 */ "ILLEGAL",
159645
+ /* 184 */ "input",
159646
+ /* 185 */ "cmdlist",
159647
+ /* 186 */ "ecmd",
159648
+ /* 187 */ "cmdx",
159649
+ /* 188 */ "explain",
159650
+ /* 189 */ "cmd",
159651
+ /* 190 */ "transtype",
159652
+ /* 191 */ "trans_opt",
159653
+ /* 192 */ "nm",
159654
+ /* 193 */ "savepoint_opt",
159655
+ /* 194 */ "create_table",
159656
+ /* 195 */ "create_table_args",
159657
+ /* 196 */ "createkw",
159658
+ /* 197 */ "temp",
159659
+ /* 198 */ "ifnotexists",
159660
+ /* 199 */ "dbnm",
159661
+ /* 200 */ "columnlist",
159662
+ /* 201 */ "conslist_opt",
159663
+ /* 202 */ "table_options",
159664
+ /* 203 */ "select",
159665
+ /* 204 */ "columnname",
159666
+ /* 205 */ "carglist",
159667
+ /* 206 */ "typetoken",
159668
+ /* 207 */ "typename",
159669
+ /* 208 */ "signed",
159670
+ /* 209 */ "plus_num",
159671
+ /* 210 */ "minus_num",
159672
+ /* 211 */ "scanpt",
159673
+ /* 212 */ "scantok",
159674
+ /* 213 */ "ccons",
159675
+ /* 214 */ "term",
159676
+ /* 215 */ "expr",
159677
+ /* 216 */ "onconf",
159678
+ /* 217 */ "sortorder",
159679
+ /* 218 */ "autoinc",
159680
+ /* 219 */ "eidlist_opt",
159681
+ /* 220 */ "refargs",
159682
+ /* 221 */ "defer_subclause",
159683
+ /* 222 */ "generated",
159684
+ /* 223 */ "refarg",
159685
+ /* 224 */ "refact",
159686
+ /* 225 */ "init_deferred_pred_opt",
159687
+ /* 226 */ "conslist",
159688
+ /* 227 */ "tconscomma",
159689
+ /* 228 */ "tcons",
159690
+ /* 229 */ "sortlist",
159691
+ /* 230 */ "eidlist",
159692
+ /* 231 */ "defer_subclause_opt",
159693
+ /* 232 */ "orconf",
159694
+ /* 233 */ "resolvetype",
159695
+ /* 234 */ "raisetype",
159696
+ /* 235 */ "ifexists",
159697
+ /* 236 */ "fullname",
159698
+ /* 237 */ "selectnowith",
159699
+ /* 238 */ "oneselect",
159700
+ /* 239 */ "wqlist",
159701
+ /* 240 */ "multiselect_op",
159702
+ /* 241 */ "distinct",
159703
+ /* 242 */ "selcollist",
159704
+ /* 243 */ "from",
159705
+ /* 244 */ "where_opt",
159706
+ /* 245 */ "groupby_opt",
159707
+ /* 246 */ "having_opt",
159708
+ /* 247 */ "orderby_opt",
159709
+ /* 248 */ "limit_opt",
159710
+ /* 249 */ "window_clause",
159711
+ /* 250 */ "values",
159712
+ /* 251 */ "nexprlist",
159713
+ /* 252 */ "sclp",
159714
+ /* 253 */ "as",
159715
+ /* 254 */ "seltablist",
159716
+ /* 255 */ "stl_prefix",
159717
+ /* 256 */ "joinop",
159718
+ /* 257 */ "indexed_opt",
159719
+ /* 258 */ "on_opt",
159720
+ /* 259 */ "using_opt",
159721
+ /* 260 */ "exprlist",
159722
+ /* 261 */ "xfullname",
159723
+ /* 262 */ "idlist",
159724
+ /* 263 */ "nulls",
159725
+ /* 264 */ "with",
159726
+ /* 265 */ "where_opt_ret",
159727
+ /* 266 */ "setlist",
159728
+ /* 267 */ "insert_cmd",
159729
+ /* 268 */ "idlist_opt",
159730
+ /* 269 */ "upsert",
159731
+ /* 270 */ "returning",
159732
+ /* 271 */ "filter_over",
159733
+ /* 272 */ "likeop",
159734
+ /* 273 */ "between_op",
159735
+ /* 274 */ "in_op",
159736
+ /* 275 */ "paren_exprlist",
159737
+ /* 276 */ "case_operand",
159738
+ /* 277 */ "case_exprlist",
159739
+ /* 278 */ "case_else",
159740
+ /* 279 */ "uniqueflag",
159741
+ /* 280 */ "collate",
159742
+ /* 281 */ "vinto",
159743
+ /* 282 */ "nmnum",
159744
+ /* 283 */ "trigger_decl",
159745
+ /* 284 */ "trigger_cmd_list",
159746
+ /* 285 */ "trigger_time",
159747
+ /* 286 */ "trigger_event",
159748
+ /* 287 */ "foreach_clause",
159749
+ /* 288 */ "when_clause",
159750
+ /* 289 */ "trigger_cmd",
159751
+ /* 290 */ "trnm",
159752
+ /* 291 */ "tridxby",
159753
+ /* 292 */ "database_kw_opt",
159754
+ /* 293 */ "key_opt",
159755
+ /* 294 */ "add_column_fullname",
159756
+ /* 295 */ "kwcolumn_opt",
159757
+ /* 296 */ "create_vtab",
159758
+ /* 297 */ "vtabarglist",
159759
+ /* 298 */ "vtabarg",
159760
+ /* 299 */ "vtabargtoken",
159761
+ /* 300 */ "lp",
159762
+ /* 301 */ "anylist",
159763
+ /* 302 */ "wqitem",
159764
+ /* 303 */ "wqas",
159765
+ /* 304 */ "windowdefn_list",
159766
+ /* 305 */ "windowdefn",
159767
+ /* 306 */ "window",
159768
+ /* 307 */ "frame_opt",
159769
+ /* 308 */ "part_opt",
159770
+ /* 309 */ "filter_clause",
159771
+ /* 310 */ "over_clause",
159772
+ /* 311 */ "range_or_rows",
159773
+ /* 312 */ "frame_bound",
159774
+ /* 313 */ "frame_bound_s",
159775
+ /* 314 */ "frame_bound_e",
159776
+ /* 315 */ "frame_exclude_opt",
159777
+ /* 316 */ "frame_exclude",
159199159778
};
159200159779
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
159201159780
159202159781
#ifndef NDEBUG
159203159782
/* For tracing reduce actions, the names of all rules are required.
@@ -159724,103 +160303,103 @@
159724160303
** Note: during a reduce, the only symbols destroyed are those
159725160304
** which appear on the RHS of the rule, but which are *not* used
159726160305
** inside the C code.
159727160306
*/
159728160307
/********* Begin destructor definitions ***************************************/
159729
- case 202: /* select */
159730
- case 236: /* selectnowith */
159731
- case 237: /* oneselect */
159732
- case 249: /* values */
159733
-{
159734
-sqlite3SelectDelete(pParse->db, (yypminor->yy307));
159735
-}
159736
- break;
159737
- case 213: /* term */
159738
- case 214: /* expr */
159739
- case 243: /* where_opt */
159740
- case 245: /* having_opt */
159741
- case 257: /* on_opt */
159742
- case 264: /* where_opt_ret */
159743
- case 275: /* case_operand */
159744
- case 277: /* case_else */
159745
- case 280: /* vinto */
159746
- case 287: /* when_clause */
159747
- case 292: /* key_opt */
159748
- case 308: /* filter_clause */
159749
-{
159750
-sqlite3ExprDelete(pParse->db, (yypminor->yy602));
159751
-}
159752
- break;
159753
- case 218: /* eidlist_opt */
159754
- case 228: /* sortlist */
159755
- case 229: /* eidlist */
159756
- case 241: /* selcollist */
159757
- case 244: /* groupby_opt */
159758
- case 246: /* orderby_opt */
159759
- case 250: /* nexprlist */
159760
- case 251: /* sclp */
159761
- case 259: /* exprlist */
159762
- case 265: /* setlist */
159763
- case 274: /* paren_exprlist */
159764
- case 276: /* case_exprlist */
159765
- case 307: /* part_opt */
159766
-{
159767
-sqlite3ExprListDelete(pParse->db, (yypminor->yy338));
159768
-}
159769
- break;
159770
- case 235: /* fullname */
159771
- case 242: /* from */
159772
- case 253: /* seltablist */
159773
- case 254: /* stl_prefix */
159774
- case 260: /* xfullname */
159775
-{
159776
-sqlite3SrcListDelete(pParse->db, (yypminor->yy291));
159777
-}
159778
- break;
159779
- case 238: /* wqlist */
159780
-{
159781
-sqlite3WithDelete(pParse->db, (yypminor->yy195));
159782
-}
159783
- break;
159784
- case 248: /* window_clause */
159785
- case 303: /* windowdefn_list */
159786
-{
159787
-sqlite3WindowListDelete(pParse->db, (yypminor->yy19));
159788
-}
159789
- break;
159790
- case 258: /* using_opt */
159791
- case 261: /* idlist */
159792
- case 267: /* idlist_opt */
159793
-{
159794
-sqlite3IdListDelete(pParse->db, (yypminor->yy288));
159795
-}
159796
- break;
159797
- case 270: /* filter_over */
159798
- case 304: /* windowdefn */
159799
- case 305: /* window */
159800
- case 306: /* frame_opt */
159801
- case 309: /* over_clause */
159802
-{
159803
-sqlite3WindowDelete(pParse->db, (yypminor->yy19));
159804
-}
159805
- break;
159806
- case 283: /* trigger_cmd_list */
159807
- case 288: /* trigger_cmd */
159808
-{
159809
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy483));
159810
-}
159811
- break;
159812
- case 285: /* trigger_event */
159813
-{
159814
-sqlite3IdListDelete(pParse->db, (yypminor->yy50).b);
159815
-}
159816
- break;
159817
- case 311: /* frame_bound */
159818
- case 312: /* frame_bound_s */
159819
- case 313: /* frame_bound_e */
159820
-{
159821
-sqlite3ExprDelete(pParse->db, (yypminor->yy113).pExpr);
160308
+ case 203: /* select */
160309
+ case 237: /* selectnowith */
160310
+ case 238: /* oneselect */
160311
+ case 250: /* values */
160312
+{
160313
+sqlite3SelectDelete(pParse->db, (yypminor->yy81));
160314
+}
160315
+ break;
160316
+ case 214: /* term */
160317
+ case 215: /* expr */
160318
+ case 244: /* where_opt */
160319
+ case 246: /* having_opt */
160320
+ case 258: /* on_opt */
160321
+ case 265: /* where_opt_ret */
160322
+ case 276: /* case_operand */
160323
+ case 278: /* case_else */
160324
+ case 281: /* vinto */
160325
+ case 288: /* when_clause */
160326
+ case 293: /* key_opt */
160327
+ case 309: /* filter_clause */
160328
+{
160329
+sqlite3ExprDelete(pParse->db, (yypminor->yy404));
160330
+}
160331
+ break;
160332
+ case 219: /* eidlist_opt */
160333
+ case 229: /* sortlist */
160334
+ case 230: /* eidlist */
160335
+ case 242: /* selcollist */
160336
+ case 245: /* groupby_opt */
160337
+ case 247: /* orderby_opt */
160338
+ case 251: /* nexprlist */
160339
+ case 252: /* sclp */
160340
+ case 260: /* exprlist */
160341
+ case 266: /* setlist */
160342
+ case 275: /* paren_exprlist */
160343
+ case 277: /* case_exprlist */
160344
+ case 308: /* part_opt */
160345
+{
160346
+sqlite3ExprListDelete(pParse->db, (yypminor->yy70));
160347
+}
160348
+ break;
160349
+ case 236: /* fullname */
160350
+ case 243: /* from */
160351
+ case 254: /* seltablist */
160352
+ case 255: /* stl_prefix */
160353
+ case 261: /* xfullname */
160354
+{
160355
+sqlite3SrcListDelete(pParse->db, (yypminor->yy153));
160356
+}
160357
+ break;
160358
+ case 239: /* wqlist */
160359
+{
160360
+sqlite3WithDelete(pParse->db, (yypminor->yy103));
160361
+}
160362
+ break;
160363
+ case 249: /* window_clause */
160364
+ case 304: /* windowdefn_list */
160365
+{
160366
+sqlite3WindowListDelete(pParse->db, (yypminor->yy49));
160367
+}
160368
+ break;
160369
+ case 259: /* using_opt */
160370
+ case 262: /* idlist */
160371
+ case 268: /* idlist_opt */
160372
+{
160373
+sqlite3IdListDelete(pParse->db, (yypminor->yy436));
160374
+}
160375
+ break;
160376
+ case 271: /* filter_over */
160377
+ case 305: /* windowdefn */
160378
+ case 306: /* window */
160379
+ case 307: /* frame_opt */
160380
+ case 310: /* over_clause */
160381
+{
160382
+sqlite3WindowDelete(pParse->db, (yypminor->yy49));
160383
+}
160384
+ break;
160385
+ case 284: /* trigger_cmd_list */
160386
+ case 289: /* trigger_cmd */
160387
+{
160388
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy157));
160389
+}
160390
+ break;
160391
+ case 286: /* trigger_event */
160392
+{
160393
+sqlite3IdListDelete(pParse->db, (yypminor->yy262).b);
160394
+}
160395
+ break;
160396
+ case 312: /* frame_bound */
160397
+ case 313: /* frame_bound_s */
160398
+ case 314: /* frame_bound_e */
160399
+{
160400
+sqlite3ExprDelete(pParse->db, (yypminor->yy117).pExpr);
159822160401
}
159823160402
break;
159824160403
/********* End destructor definitions *****************************************/
159825160404
default: break; /* If no destructor action specified: do nothing */
159826160405
}
@@ -160107,408 +160686,408 @@
160107160686
}
160108160687
160109160688
/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
160110160689
** of that rule */
160111160690
static const YYCODETYPE yyRuleInfoLhs[] = {
160112
- 187, /* (0) explain ::= EXPLAIN */
160113
- 187, /* (1) explain ::= EXPLAIN QUERY PLAN */
160114
- 186, /* (2) cmdx ::= cmd */
160115
- 188, /* (3) cmd ::= BEGIN transtype trans_opt */
160116
- 189, /* (4) transtype ::= */
160117
- 189, /* (5) transtype ::= DEFERRED */
160118
- 189, /* (6) transtype ::= IMMEDIATE */
160119
- 189, /* (7) transtype ::= EXCLUSIVE */
160120
- 188, /* (8) cmd ::= COMMIT|END trans_opt */
160121
- 188, /* (9) cmd ::= ROLLBACK trans_opt */
160122
- 188, /* (10) cmd ::= SAVEPOINT nm */
160123
- 188, /* (11) cmd ::= RELEASE savepoint_opt nm */
160124
- 188, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
160125
- 193, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
160126
- 195, /* (14) createkw ::= CREATE */
160127
- 197, /* (15) ifnotexists ::= */
160128
- 197, /* (16) ifnotexists ::= IF NOT EXISTS */
160129
- 196, /* (17) temp ::= TEMP */
160130
- 196, /* (18) temp ::= */
160131
- 194, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
160132
- 194, /* (20) create_table_args ::= AS select */
160133
- 201, /* (21) table_options ::= */
160134
- 201, /* (22) table_options ::= WITHOUT nm */
160135
- 203, /* (23) columnname ::= nm typetoken */
160136
- 205, /* (24) typetoken ::= */
160137
- 205, /* (25) typetoken ::= typename LP signed RP */
160138
- 205, /* (26) typetoken ::= typename LP signed COMMA signed RP */
160139
- 206, /* (27) typename ::= typename ID|STRING */
160140
- 210, /* (28) scanpt ::= */
160141
- 211, /* (29) scantok ::= */
160142
- 212, /* (30) ccons ::= CONSTRAINT nm */
160143
- 212, /* (31) ccons ::= DEFAULT scantok term */
160144
- 212, /* (32) ccons ::= DEFAULT LP expr RP */
160145
- 212, /* (33) ccons ::= DEFAULT PLUS scantok term */
160146
- 212, /* (34) ccons ::= DEFAULT MINUS scantok term */
160147
- 212, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */
160148
- 212, /* (36) ccons ::= NOT NULL onconf */
160149
- 212, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */
160150
- 212, /* (38) ccons ::= UNIQUE onconf */
160151
- 212, /* (39) ccons ::= CHECK LP expr RP */
160152
- 212, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
160153
- 212, /* (41) ccons ::= defer_subclause */
160154
- 212, /* (42) ccons ::= COLLATE ID|STRING */
160155
- 221, /* (43) generated ::= LP expr RP */
160156
- 221, /* (44) generated ::= LP expr RP ID */
160157
- 217, /* (45) autoinc ::= */
160158
- 217, /* (46) autoinc ::= AUTOINCR */
160159
- 219, /* (47) refargs ::= */
160160
- 219, /* (48) refargs ::= refargs refarg */
160161
- 222, /* (49) refarg ::= MATCH nm */
160162
- 222, /* (50) refarg ::= ON INSERT refact */
160163
- 222, /* (51) refarg ::= ON DELETE refact */
160164
- 222, /* (52) refarg ::= ON UPDATE refact */
160165
- 223, /* (53) refact ::= SET NULL */
160166
- 223, /* (54) refact ::= SET DEFAULT */
160167
- 223, /* (55) refact ::= CASCADE */
160168
- 223, /* (56) refact ::= RESTRICT */
160169
- 223, /* (57) refact ::= NO ACTION */
160170
- 220, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
160171
- 220, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
160172
- 224, /* (60) init_deferred_pred_opt ::= */
160173
- 224, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */
160174
- 224, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
160175
- 200, /* (63) conslist_opt ::= */
160176
- 226, /* (64) tconscomma ::= COMMA */
160177
- 227, /* (65) tcons ::= CONSTRAINT nm */
160178
- 227, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
160179
- 227, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */
160180
- 227, /* (68) tcons ::= CHECK LP expr RP onconf */
160181
- 227, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
160182
- 230, /* (70) defer_subclause_opt ::= */
160183
- 215, /* (71) onconf ::= */
160184
- 215, /* (72) onconf ::= ON CONFLICT resolvetype */
160185
- 231, /* (73) orconf ::= */
160186
- 231, /* (74) orconf ::= OR resolvetype */
160187
- 232, /* (75) resolvetype ::= IGNORE */
160188
- 232, /* (76) resolvetype ::= REPLACE */
160189
- 188, /* (77) cmd ::= DROP TABLE ifexists fullname */
160190
- 234, /* (78) ifexists ::= IF EXISTS */
160191
- 234, /* (79) ifexists ::= */
160192
- 188, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
160193
- 188, /* (81) cmd ::= DROP VIEW ifexists fullname */
160194
- 188, /* (82) cmd ::= select */
160195
- 202, /* (83) select ::= WITH wqlist selectnowith */
160196
- 202, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */
160197
- 202, /* (85) select ::= selectnowith */
160198
- 236, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */
160199
- 239, /* (87) multiselect_op ::= UNION */
160200
- 239, /* (88) multiselect_op ::= UNION ALL */
160201
- 239, /* (89) multiselect_op ::= EXCEPT|INTERSECT */
160202
- 237, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
160203
- 237, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
160204
- 249, /* (92) values ::= VALUES LP nexprlist RP */
160205
- 249, /* (93) values ::= values COMMA LP nexprlist RP */
160206
- 240, /* (94) distinct ::= DISTINCT */
160207
- 240, /* (95) distinct ::= ALL */
160208
- 240, /* (96) distinct ::= */
160209
- 251, /* (97) sclp ::= */
160210
- 241, /* (98) selcollist ::= sclp scanpt expr scanpt as */
160211
- 241, /* (99) selcollist ::= sclp scanpt STAR */
160212
- 241, /* (100) selcollist ::= sclp scanpt nm DOT STAR */
160213
- 252, /* (101) as ::= AS nm */
160214
- 252, /* (102) as ::= */
160215
- 242, /* (103) from ::= */
160216
- 242, /* (104) from ::= FROM seltablist */
160217
- 254, /* (105) stl_prefix ::= seltablist joinop */
160218
- 254, /* (106) stl_prefix ::= */
160219
- 253, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
160220
- 253, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
160221
- 253, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
160222
- 253, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
160223
- 198, /* (111) dbnm ::= */
160224
- 198, /* (112) dbnm ::= DOT nm */
160225
- 235, /* (113) fullname ::= nm */
160226
- 235, /* (114) fullname ::= nm DOT nm */
160227
- 260, /* (115) xfullname ::= nm */
160228
- 260, /* (116) xfullname ::= nm DOT nm */
160229
- 260, /* (117) xfullname ::= nm DOT nm AS nm */
160230
- 260, /* (118) xfullname ::= nm AS nm */
160231
- 255, /* (119) joinop ::= COMMA|JOIN */
160232
- 255, /* (120) joinop ::= JOIN_KW JOIN */
160233
- 255, /* (121) joinop ::= JOIN_KW nm JOIN */
160234
- 255, /* (122) joinop ::= JOIN_KW nm nm JOIN */
160235
- 257, /* (123) on_opt ::= ON expr */
160236
- 257, /* (124) on_opt ::= */
160237
- 256, /* (125) indexed_opt ::= */
160238
- 256, /* (126) indexed_opt ::= INDEXED BY nm */
160239
- 256, /* (127) indexed_opt ::= NOT INDEXED */
160240
- 258, /* (128) using_opt ::= USING LP idlist RP */
160241
- 258, /* (129) using_opt ::= */
160242
- 246, /* (130) orderby_opt ::= */
160243
- 246, /* (131) orderby_opt ::= ORDER BY sortlist */
160244
- 228, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */
160245
- 228, /* (133) sortlist ::= expr sortorder nulls */
160246
- 216, /* (134) sortorder ::= ASC */
160247
- 216, /* (135) sortorder ::= DESC */
160248
- 216, /* (136) sortorder ::= */
160249
- 262, /* (137) nulls ::= NULLS FIRST */
160250
- 262, /* (138) nulls ::= NULLS LAST */
160251
- 262, /* (139) nulls ::= */
160252
- 244, /* (140) groupby_opt ::= */
160253
- 244, /* (141) groupby_opt ::= GROUP BY nexprlist */
160254
- 245, /* (142) having_opt ::= */
160255
- 245, /* (143) having_opt ::= HAVING expr */
160256
- 247, /* (144) limit_opt ::= */
160257
- 247, /* (145) limit_opt ::= LIMIT expr */
160258
- 247, /* (146) limit_opt ::= LIMIT expr OFFSET expr */
160259
- 247, /* (147) limit_opt ::= LIMIT expr COMMA expr */
160260
- 188, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
160261
- 243, /* (149) where_opt ::= */
160262
- 243, /* (150) where_opt ::= WHERE expr */
160263
- 264, /* (151) where_opt_ret ::= */
160264
- 264, /* (152) where_opt_ret ::= WHERE expr */
160265
- 264, /* (153) where_opt_ret ::= RETURNING selcollist */
160266
- 264, /* (154) where_opt_ret ::= WHERE expr RETURNING selcollist */
160267
- 188, /* (155) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
160268
- 265, /* (156) setlist ::= setlist COMMA nm EQ expr */
160269
- 265, /* (157) setlist ::= setlist COMMA LP idlist RP EQ expr */
160270
- 265, /* (158) setlist ::= nm EQ expr */
160271
- 265, /* (159) setlist ::= LP idlist RP EQ expr */
160272
- 188, /* (160) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
160273
- 188, /* (161) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
160274
- 268, /* (162) upsert ::= */
160275
- 268, /* (163) upsert ::= RETURNING selcollist */
160276
- 268, /* (164) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
160277
- 268, /* (165) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
160278
- 268, /* (166) upsert ::= ON CONFLICT DO NOTHING returning */
160279
- 268, /* (167) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
160280
- 269, /* (168) returning ::= RETURNING selcollist */
160281
- 266, /* (169) insert_cmd ::= INSERT orconf */
160282
- 266, /* (170) insert_cmd ::= REPLACE */
160283
- 267, /* (171) idlist_opt ::= */
160284
- 267, /* (172) idlist_opt ::= LP idlist RP */
160285
- 261, /* (173) idlist ::= idlist COMMA nm */
160286
- 261, /* (174) idlist ::= nm */
160287
- 214, /* (175) expr ::= LP expr RP */
160288
- 214, /* (176) expr ::= ID|INDEXED */
160289
- 214, /* (177) expr ::= JOIN_KW */
160290
- 214, /* (178) expr ::= nm DOT nm */
160291
- 214, /* (179) expr ::= nm DOT nm DOT nm */
160292
- 213, /* (180) term ::= NULL|FLOAT|BLOB */
160293
- 213, /* (181) term ::= STRING */
160294
- 213, /* (182) term ::= INTEGER */
160295
- 214, /* (183) expr ::= VARIABLE */
160296
- 214, /* (184) expr ::= expr COLLATE ID|STRING */
160297
- 214, /* (185) expr ::= CAST LP expr AS typetoken RP */
160298
- 214, /* (186) expr ::= ID|INDEXED LP distinct exprlist RP */
160299
- 214, /* (187) expr ::= ID|INDEXED LP STAR RP */
160300
- 214, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
160301
- 214, /* (189) expr ::= ID|INDEXED LP STAR RP filter_over */
160302
- 213, /* (190) term ::= CTIME_KW */
160303
- 214, /* (191) expr ::= LP nexprlist COMMA expr RP */
160304
- 214, /* (192) expr ::= expr AND expr */
160305
- 214, /* (193) expr ::= expr OR expr */
160306
- 214, /* (194) expr ::= expr LT|GT|GE|LE expr */
160307
- 214, /* (195) expr ::= expr EQ|NE expr */
160308
- 214, /* (196) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
160309
- 214, /* (197) expr ::= expr PLUS|MINUS expr */
160310
- 214, /* (198) expr ::= expr STAR|SLASH|REM expr */
160311
- 214, /* (199) expr ::= expr CONCAT expr */
160312
- 271, /* (200) likeop ::= NOT LIKE_KW|MATCH */
160313
- 214, /* (201) expr ::= expr likeop expr */
160314
- 214, /* (202) expr ::= expr likeop expr ESCAPE expr */
160315
- 214, /* (203) expr ::= expr ISNULL|NOTNULL */
160316
- 214, /* (204) expr ::= expr NOT NULL */
160317
- 214, /* (205) expr ::= expr IS expr */
160318
- 214, /* (206) expr ::= expr IS NOT expr */
160319
- 214, /* (207) expr ::= NOT expr */
160320
- 214, /* (208) expr ::= BITNOT expr */
160321
- 214, /* (209) expr ::= PLUS|MINUS expr */
160322
- 272, /* (210) between_op ::= BETWEEN */
160323
- 272, /* (211) between_op ::= NOT BETWEEN */
160324
- 214, /* (212) expr ::= expr between_op expr AND expr */
160325
- 273, /* (213) in_op ::= IN */
160326
- 273, /* (214) in_op ::= NOT IN */
160327
- 214, /* (215) expr ::= expr in_op LP exprlist RP */
160328
- 214, /* (216) expr ::= LP select RP */
160329
- 214, /* (217) expr ::= expr in_op LP select RP */
160330
- 214, /* (218) expr ::= expr in_op nm dbnm paren_exprlist */
160331
- 214, /* (219) expr ::= EXISTS LP select RP */
160332
- 214, /* (220) expr ::= CASE case_operand case_exprlist case_else END */
160333
- 276, /* (221) case_exprlist ::= case_exprlist WHEN expr THEN expr */
160334
- 276, /* (222) case_exprlist ::= WHEN expr THEN expr */
160335
- 277, /* (223) case_else ::= ELSE expr */
160336
- 277, /* (224) case_else ::= */
160337
- 275, /* (225) case_operand ::= expr */
160338
- 275, /* (226) case_operand ::= */
160339
- 259, /* (227) exprlist ::= */
160340
- 250, /* (228) nexprlist ::= nexprlist COMMA expr */
160341
- 250, /* (229) nexprlist ::= expr */
160342
- 274, /* (230) paren_exprlist ::= */
160343
- 274, /* (231) paren_exprlist ::= LP exprlist RP */
160344
- 188, /* (232) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
160345
- 278, /* (233) uniqueflag ::= UNIQUE */
160346
- 278, /* (234) uniqueflag ::= */
160347
- 218, /* (235) eidlist_opt ::= */
160348
- 218, /* (236) eidlist_opt ::= LP eidlist RP */
160349
- 229, /* (237) eidlist ::= eidlist COMMA nm collate sortorder */
160350
- 229, /* (238) eidlist ::= nm collate sortorder */
160351
- 279, /* (239) collate ::= */
160352
- 279, /* (240) collate ::= COLLATE ID|STRING */
160353
- 188, /* (241) cmd ::= DROP INDEX ifexists fullname */
160354
- 188, /* (242) cmd ::= VACUUM vinto */
160355
- 188, /* (243) cmd ::= VACUUM nm vinto */
160356
- 280, /* (244) vinto ::= INTO expr */
160357
- 280, /* (245) vinto ::= */
160358
- 188, /* (246) cmd ::= PRAGMA nm dbnm */
160359
- 188, /* (247) cmd ::= PRAGMA nm dbnm EQ nmnum */
160360
- 188, /* (248) cmd ::= PRAGMA nm dbnm LP nmnum RP */
160361
- 188, /* (249) cmd ::= PRAGMA nm dbnm EQ minus_num */
160362
- 188, /* (250) cmd ::= PRAGMA nm dbnm LP minus_num RP */
160363
- 208, /* (251) plus_num ::= PLUS INTEGER|FLOAT */
160364
- 209, /* (252) minus_num ::= MINUS INTEGER|FLOAT */
160365
- 188, /* (253) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
160366
- 282, /* (254) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
160367
- 284, /* (255) trigger_time ::= BEFORE|AFTER */
160368
- 284, /* (256) trigger_time ::= INSTEAD OF */
160369
- 284, /* (257) trigger_time ::= */
160370
- 285, /* (258) trigger_event ::= DELETE|INSERT */
160371
- 285, /* (259) trigger_event ::= UPDATE */
160372
- 285, /* (260) trigger_event ::= UPDATE OF idlist */
160373
- 287, /* (261) when_clause ::= */
160374
- 287, /* (262) when_clause ::= WHEN expr */
160375
- 283, /* (263) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
160376
- 283, /* (264) trigger_cmd_list ::= trigger_cmd SEMI */
160377
- 289, /* (265) trnm ::= nm DOT nm */
160378
- 290, /* (266) tridxby ::= INDEXED BY nm */
160379
- 290, /* (267) tridxby ::= NOT INDEXED */
160380
- 288, /* (268) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
160381
- 288, /* (269) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
160382
- 288, /* (270) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
160383
- 288, /* (271) trigger_cmd ::= scanpt select scanpt */
160384
- 214, /* (272) expr ::= RAISE LP IGNORE RP */
160385
- 214, /* (273) expr ::= RAISE LP raisetype COMMA nm RP */
160386
- 233, /* (274) raisetype ::= ROLLBACK */
160387
- 233, /* (275) raisetype ::= ABORT */
160388
- 233, /* (276) raisetype ::= FAIL */
160389
- 188, /* (277) cmd ::= DROP TRIGGER ifexists fullname */
160390
- 188, /* (278) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
160391
- 188, /* (279) cmd ::= DETACH database_kw_opt expr */
160392
- 292, /* (280) key_opt ::= */
160393
- 292, /* (281) key_opt ::= KEY expr */
160394
- 188, /* (282) cmd ::= REINDEX */
160395
- 188, /* (283) cmd ::= REINDEX nm dbnm */
160396
- 188, /* (284) cmd ::= ANALYZE */
160397
- 188, /* (285) cmd ::= ANALYZE nm dbnm */
160398
- 188, /* (286) cmd ::= ALTER TABLE fullname RENAME TO nm */
160399
- 188, /* (287) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
160400
- 188, /* (288) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
160401
- 293, /* (289) add_column_fullname ::= fullname */
160402
- 188, /* (290) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
160403
- 188, /* (291) cmd ::= create_vtab */
160404
- 188, /* (292) cmd ::= create_vtab LP vtabarglist RP */
160405
- 295, /* (293) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
160406
- 297, /* (294) vtabarg ::= */
160407
- 298, /* (295) vtabargtoken ::= ANY */
160408
- 298, /* (296) vtabargtoken ::= lp anylist RP */
160409
- 299, /* (297) lp ::= LP */
160410
- 263, /* (298) with ::= WITH wqlist */
160411
- 263, /* (299) with ::= WITH RECURSIVE wqlist */
160412
- 302, /* (300) wqas ::= AS */
160413
- 302, /* (301) wqas ::= AS MATERIALIZED */
160414
- 302, /* (302) wqas ::= AS NOT MATERIALIZED */
160415
- 301, /* (303) wqitem ::= nm eidlist_opt wqas LP select RP */
160416
- 238, /* (304) wqlist ::= wqitem */
160417
- 238, /* (305) wqlist ::= wqlist COMMA wqitem */
160418
- 303, /* (306) windowdefn_list ::= windowdefn */
160419
- 303, /* (307) windowdefn_list ::= windowdefn_list COMMA windowdefn */
160420
- 304, /* (308) windowdefn ::= nm AS LP window RP */
160421
- 305, /* (309) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
160422
- 305, /* (310) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
160423
- 305, /* (311) window ::= ORDER BY sortlist frame_opt */
160424
- 305, /* (312) window ::= nm ORDER BY sortlist frame_opt */
160425
- 305, /* (313) window ::= frame_opt */
160426
- 305, /* (314) window ::= nm frame_opt */
160427
- 306, /* (315) frame_opt ::= */
160428
- 306, /* (316) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
160429
- 306, /* (317) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
160430
- 310, /* (318) range_or_rows ::= RANGE|ROWS|GROUPS */
160431
- 312, /* (319) frame_bound_s ::= frame_bound */
160432
- 312, /* (320) frame_bound_s ::= UNBOUNDED PRECEDING */
160433
- 313, /* (321) frame_bound_e ::= frame_bound */
160434
- 313, /* (322) frame_bound_e ::= UNBOUNDED FOLLOWING */
160435
- 311, /* (323) frame_bound ::= expr PRECEDING|FOLLOWING */
160436
- 311, /* (324) frame_bound ::= CURRENT ROW */
160437
- 314, /* (325) frame_exclude_opt ::= */
160438
- 314, /* (326) frame_exclude_opt ::= EXCLUDE frame_exclude */
160439
- 315, /* (327) frame_exclude ::= NO OTHERS */
160440
- 315, /* (328) frame_exclude ::= CURRENT ROW */
160441
- 315, /* (329) frame_exclude ::= GROUP|TIES */
160442
- 248, /* (330) window_clause ::= WINDOW windowdefn_list */
160443
- 270, /* (331) filter_over ::= filter_clause over_clause */
160444
- 270, /* (332) filter_over ::= over_clause */
160445
- 270, /* (333) filter_over ::= filter_clause */
160446
- 309, /* (334) over_clause ::= OVER LP window RP */
160447
- 309, /* (335) over_clause ::= OVER nm */
160448
- 308, /* (336) filter_clause ::= FILTER LP WHERE expr RP */
160449
- 183, /* (337) input ::= cmdlist */
160450
- 184, /* (338) cmdlist ::= cmdlist ecmd */
160451
- 184, /* (339) cmdlist ::= ecmd */
160452
- 185, /* (340) ecmd ::= SEMI */
160453
- 185, /* (341) ecmd ::= cmdx SEMI */
160454
- 185, /* (342) ecmd ::= explain cmdx SEMI */
160455
- 190, /* (343) trans_opt ::= */
160456
- 190, /* (344) trans_opt ::= TRANSACTION */
160457
- 190, /* (345) trans_opt ::= TRANSACTION nm */
160458
- 192, /* (346) savepoint_opt ::= SAVEPOINT */
160459
- 192, /* (347) savepoint_opt ::= */
160460
- 188, /* (348) cmd ::= create_table create_table_args */
160461
- 199, /* (349) columnlist ::= columnlist COMMA columnname carglist */
160462
- 199, /* (350) columnlist ::= columnname carglist */
160463
- 191, /* (351) nm ::= ID|INDEXED */
160464
- 191, /* (352) nm ::= STRING */
160465
- 191, /* (353) nm ::= JOIN_KW */
160466
- 205, /* (354) typetoken ::= typename */
160467
- 206, /* (355) typename ::= ID|STRING */
160468
- 207, /* (356) signed ::= plus_num */
160469
- 207, /* (357) signed ::= minus_num */
160470
- 204, /* (358) carglist ::= carglist ccons */
160471
- 204, /* (359) carglist ::= */
160472
- 212, /* (360) ccons ::= NULL onconf */
160473
- 212, /* (361) ccons ::= GENERATED ALWAYS AS generated */
160474
- 212, /* (362) ccons ::= AS generated */
160475
- 200, /* (363) conslist_opt ::= COMMA conslist */
160476
- 225, /* (364) conslist ::= conslist tconscomma tcons */
160477
- 225, /* (365) conslist ::= tcons */
160478
- 226, /* (366) tconscomma ::= */
160479
- 230, /* (367) defer_subclause_opt ::= defer_subclause */
160480
- 232, /* (368) resolvetype ::= raisetype */
160481
- 236, /* (369) selectnowith ::= oneselect */
160482
- 237, /* (370) oneselect ::= values */
160483
- 251, /* (371) sclp ::= selcollist COMMA */
160484
- 252, /* (372) as ::= ID|STRING */
160485
- 269, /* (373) returning ::= */
160486
- 214, /* (374) expr ::= term */
160487
- 271, /* (375) likeop ::= LIKE_KW|MATCH */
160488
- 259, /* (376) exprlist ::= nexprlist */
160489
- 281, /* (377) nmnum ::= plus_num */
160490
- 281, /* (378) nmnum ::= nm */
160491
- 281, /* (379) nmnum ::= ON */
160492
- 281, /* (380) nmnum ::= DELETE */
160493
- 281, /* (381) nmnum ::= DEFAULT */
160494
- 208, /* (382) plus_num ::= INTEGER|FLOAT */
160495
- 286, /* (383) foreach_clause ::= */
160496
- 286, /* (384) foreach_clause ::= FOR EACH ROW */
160497
- 289, /* (385) trnm ::= nm */
160498
- 290, /* (386) tridxby ::= */
160499
- 291, /* (387) database_kw_opt ::= DATABASE */
160500
- 291, /* (388) database_kw_opt ::= */
160501
- 294, /* (389) kwcolumn_opt ::= */
160502
- 294, /* (390) kwcolumn_opt ::= COLUMNKW */
160503
- 296, /* (391) vtabarglist ::= vtabarg */
160504
- 296, /* (392) vtabarglist ::= vtabarglist COMMA vtabarg */
160505
- 297, /* (393) vtabarg ::= vtabarg vtabargtoken */
160506
- 300, /* (394) anylist ::= */
160507
- 300, /* (395) anylist ::= anylist LP anylist RP */
160508
- 300, /* (396) anylist ::= anylist ANY */
160509
- 263, /* (397) with ::= */
160691
+ 188, /* (0) explain ::= EXPLAIN */
160692
+ 188, /* (1) explain ::= EXPLAIN QUERY PLAN */
160693
+ 187, /* (2) cmdx ::= cmd */
160694
+ 189, /* (3) cmd ::= BEGIN transtype trans_opt */
160695
+ 190, /* (4) transtype ::= */
160696
+ 190, /* (5) transtype ::= DEFERRED */
160697
+ 190, /* (6) transtype ::= IMMEDIATE */
160698
+ 190, /* (7) transtype ::= EXCLUSIVE */
160699
+ 189, /* (8) cmd ::= COMMIT|END trans_opt */
160700
+ 189, /* (9) cmd ::= ROLLBACK trans_opt */
160701
+ 189, /* (10) cmd ::= SAVEPOINT nm */
160702
+ 189, /* (11) cmd ::= RELEASE savepoint_opt nm */
160703
+ 189, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
160704
+ 194, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
160705
+ 196, /* (14) createkw ::= CREATE */
160706
+ 198, /* (15) ifnotexists ::= */
160707
+ 198, /* (16) ifnotexists ::= IF NOT EXISTS */
160708
+ 197, /* (17) temp ::= TEMP */
160709
+ 197, /* (18) temp ::= */
160710
+ 195, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
160711
+ 195, /* (20) create_table_args ::= AS select */
160712
+ 202, /* (21) table_options ::= */
160713
+ 202, /* (22) table_options ::= WITHOUT nm */
160714
+ 204, /* (23) columnname ::= nm typetoken */
160715
+ 206, /* (24) typetoken ::= */
160716
+ 206, /* (25) typetoken ::= typename LP signed RP */
160717
+ 206, /* (26) typetoken ::= typename LP signed COMMA signed RP */
160718
+ 207, /* (27) typename ::= typename ID|STRING */
160719
+ 211, /* (28) scanpt ::= */
160720
+ 212, /* (29) scantok ::= */
160721
+ 213, /* (30) ccons ::= CONSTRAINT nm */
160722
+ 213, /* (31) ccons ::= DEFAULT scantok term */
160723
+ 213, /* (32) ccons ::= DEFAULT LP expr RP */
160724
+ 213, /* (33) ccons ::= DEFAULT PLUS scantok term */
160725
+ 213, /* (34) ccons ::= DEFAULT MINUS scantok term */
160726
+ 213, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */
160727
+ 213, /* (36) ccons ::= NOT NULL onconf */
160728
+ 213, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */
160729
+ 213, /* (38) ccons ::= UNIQUE onconf */
160730
+ 213, /* (39) ccons ::= CHECK LP expr RP */
160731
+ 213, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
160732
+ 213, /* (41) ccons ::= defer_subclause */
160733
+ 213, /* (42) ccons ::= COLLATE ID|STRING */
160734
+ 222, /* (43) generated ::= LP expr RP */
160735
+ 222, /* (44) generated ::= LP expr RP ID */
160736
+ 218, /* (45) autoinc ::= */
160737
+ 218, /* (46) autoinc ::= AUTOINCR */
160738
+ 220, /* (47) refargs ::= */
160739
+ 220, /* (48) refargs ::= refargs refarg */
160740
+ 223, /* (49) refarg ::= MATCH nm */
160741
+ 223, /* (50) refarg ::= ON INSERT refact */
160742
+ 223, /* (51) refarg ::= ON DELETE refact */
160743
+ 223, /* (52) refarg ::= ON UPDATE refact */
160744
+ 224, /* (53) refact ::= SET NULL */
160745
+ 224, /* (54) refact ::= SET DEFAULT */
160746
+ 224, /* (55) refact ::= CASCADE */
160747
+ 224, /* (56) refact ::= RESTRICT */
160748
+ 224, /* (57) refact ::= NO ACTION */
160749
+ 221, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
160750
+ 221, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
160751
+ 225, /* (60) init_deferred_pred_opt ::= */
160752
+ 225, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */
160753
+ 225, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
160754
+ 201, /* (63) conslist_opt ::= */
160755
+ 227, /* (64) tconscomma ::= COMMA */
160756
+ 228, /* (65) tcons ::= CONSTRAINT nm */
160757
+ 228, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
160758
+ 228, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */
160759
+ 228, /* (68) tcons ::= CHECK LP expr RP onconf */
160760
+ 228, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
160761
+ 231, /* (70) defer_subclause_opt ::= */
160762
+ 216, /* (71) onconf ::= */
160763
+ 216, /* (72) onconf ::= ON CONFLICT resolvetype */
160764
+ 232, /* (73) orconf ::= */
160765
+ 232, /* (74) orconf ::= OR resolvetype */
160766
+ 233, /* (75) resolvetype ::= IGNORE */
160767
+ 233, /* (76) resolvetype ::= REPLACE */
160768
+ 189, /* (77) cmd ::= DROP TABLE ifexists fullname */
160769
+ 235, /* (78) ifexists ::= IF EXISTS */
160770
+ 235, /* (79) ifexists ::= */
160771
+ 189, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
160772
+ 189, /* (81) cmd ::= DROP VIEW ifexists fullname */
160773
+ 189, /* (82) cmd ::= select */
160774
+ 203, /* (83) select ::= WITH wqlist selectnowith */
160775
+ 203, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */
160776
+ 203, /* (85) select ::= selectnowith */
160777
+ 237, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */
160778
+ 240, /* (87) multiselect_op ::= UNION */
160779
+ 240, /* (88) multiselect_op ::= UNION ALL */
160780
+ 240, /* (89) multiselect_op ::= EXCEPT|INTERSECT */
160781
+ 238, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
160782
+ 238, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
160783
+ 250, /* (92) values ::= VALUES LP nexprlist RP */
160784
+ 250, /* (93) values ::= values COMMA LP nexprlist RP */
160785
+ 241, /* (94) distinct ::= DISTINCT */
160786
+ 241, /* (95) distinct ::= ALL */
160787
+ 241, /* (96) distinct ::= */
160788
+ 252, /* (97) sclp ::= */
160789
+ 242, /* (98) selcollist ::= sclp scanpt expr scanpt as */
160790
+ 242, /* (99) selcollist ::= sclp scanpt STAR */
160791
+ 242, /* (100) selcollist ::= sclp scanpt nm DOT STAR */
160792
+ 253, /* (101) as ::= AS nm */
160793
+ 253, /* (102) as ::= */
160794
+ 243, /* (103) from ::= */
160795
+ 243, /* (104) from ::= FROM seltablist */
160796
+ 255, /* (105) stl_prefix ::= seltablist joinop */
160797
+ 255, /* (106) stl_prefix ::= */
160798
+ 254, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
160799
+ 254, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
160800
+ 254, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
160801
+ 254, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
160802
+ 199, /* (111) dbnm ::= */
160803
+ 199, /* (112) dbnm ::= DOT nm */
160804
+ 236, /* (113) fullname ::= nm */
160805
+ 236, /* (114) fullname ::= nm DOT nm */
160806
+ 261, /* (115) xfullname ::= nm */
160807
+ 261, /* (116) xfullname ::= nm DOT nm */
160808
+ 261, /* (117) xfullname ::= nm DOT nm AS nm */
160809
+ 261, /* (118) xfullname ::= nm AS nm */
160810
+ 256, /* (119) joinop ::= COMMA|JOIN */
160811
+ 256, /* (120) joinop ::= JOIN_KW JOIN */
160812
+ 256, /* (121) joinop ::= JOIN_KW nm JOIN */
160813
+ 256, /* (122) joinop ::= JOIN_KW nm nm JOIN */
160814
+ 258, /* (123) on_opt ::= ON expr */
160815
+ 258, /* (124) on_opt ::= */
160816
+ 257, /* (125) indexed_opt ::= */
160817
+ 257, /* (126) indexed_opt ::= INDEXED BY nm */
160818
+ 257, /* (127) indexed_opt ::= NOT INDEXED */
160819
+ 259, /* (128) using_opt ::= USING LP idlist RP */
160820
+ 259, /* (129) using_opt ::= */
160821
+ 247, /* (130) orderby_opt ::= */
160822
+ 247, /* (131) orderby_opt ::= ORDER BY sortlist */
160823
+ 229, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */
160824
+ 229, /* (133) sortlist ::= expr sortorder nulls */
160825
+ 217, /* (134) sortorder ::= ASC */
160826
+ 217, /* (135) sortorder ::= DESC */
160827
+ 217, /* (136) sortorder ::= */
160828
+ 263, /* (137) nulls ::= NULLS FIRST */
160829
+ 263, /* (138) nulls ::= NULLS LAST */
160830
+ 263, /* (139) nulls ::= */
160831
+ 245, /* (140) groupby_opt ::= */
160832
+ 245, /* (141) groupby_opt ::= GROUP BY nexprlist */
160833
+ 246, /* (142) having_opt ::= */
160834
+ 246, /* (143) having_opt ::= HAVING expr */
160835
+ 248, /* (144) limit_opt ::= */
160836
+ 248, /* (145) limit_opt ::= LIMIT expr */
160837
+ 248, /* (146) limit_opt ::= LIMIT expr OFFSET expr */
160838
+ 248, /* (147) limit_opt ::= LIMIT expr COMMA expr */
160839
+ 189, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
160840
+ 244, /* (149) where_opt ::= */
160841
+ 244, /* (150) where_opt ::= WHERE expr */
160842
+ 265, /* (151) where_opt_ret ::= */
160843
+ 265, /* (152) where_opt_ret ::= WHERE expr */
160844
+ 265, /* (153) where_opt_ret ::= RETURNING selcollist */
160845
+ 265, /* (154) where_opt_ret ::= WHERE expr RETURNING selcollist */
160846
+ 189, /* (155) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
160847
+ 266, /* (156) setlist ::= setlist COMMA nm EQ expr */
160848
+ 266, /* (157) setlist ::= setlist COMMA LP idlist RP EQ expr */
160849
+ 266, /* (158) setlist ::= nm EQ expr */
160850
+ 266, /* (159) setlist ::= LP idlist RP EQ expr */
160851
+ 189, /* (160) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
160852
+ 189, /* (161) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
160853
+ 269, /* (162) upsert ::= */
160854
+ 269, /* (163) upsert ::= RETURNING selcollist */
160855
+ 269, /* (164) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
160856
+ 269, /* (165) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
160857
+ 269, /* (166) upsert ::= ON CONFLICT DO NOTHING returning */
160858
+ 269, /* (167) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
160859
+ 270, /* (168) returning ::= RETURNING selcollist */
160860
+ 267, /* (169) insert_cmd ::= INSERT orconf */
160861
+ 267, /* (170) insert_cmd ::= REPLACE */
160862
+ 268, /* (171) idlist_opt ::= */
160863
+ 268, /* (172) idlist_opt ::= LP idlist RP */
160864
+ 262, /* (173) idlist ::= idlist COMMA nm */
160865
+ 262, /* (174) idlist ::= nm */
160866
+ 215, /* (175) expr ::= LP expr RP */
160867
+ 215, /* (176) expr ::= ID|INDEXED */
160868
+ 215, /* (177) expr ::= JOIN_KW */
160869
+ 215, /* (178) expr ::= nm DOT nm */
160870
+ 215, /* (179) expr ::= nm DOT nm DOT nm */
160871
+ 214, /* (180) term ::= NULL|FLOAT|BLOB */
160872
+ 214, /* (181) term ::= STRING */
160873
+ 214, /* (182) term ::= INTEGER */
160874
+ 215, /* (183) expr ::= VARIABLE */
160875
+ 215, /* (184) expr ::= expr COLLATE ID|STRING */
160876
+ 215, /* (185) expr ::= CAST LP expr AS typetoken RP */
160877
+ 215, /* (186) expr ::= ID|INDEXED LP distinct exprlist RP */
160878
+ 215, /* (187) expr ::= ID|INDEXED LP STAR RP */
160879
+ 215, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
160880
+ 215, /* (189) expr ::= ID|INDEXED LP STAR RP filter_over */
160881
+ 214, /* (190) term ::= CTIME_KW */
160882
+ 215, /* (191) expr ::= LP nexprlist COMMA expr RP */
160883
+ 215, /* (192) expr ::= expr AND expr */
160884
+ 215, /* (193) expr ::= expr OR expr */
160885
+ 215, /* (194) expr ::= expr LT|GT|GE|LE expr */
160886
+ 215, /* (195) expr ::= expr EQ|NE expr */
160887
+ 215, /* (196) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
160888
+ 215, /* (197) expr ::= expr PLUS|MINUS expr */
160889
+ 215, /* (198) expr ::= expr STAR|SLASH|REM expr */
160890
+ 215, /* (199) expr ::= expr CONCAT expr */
160891
+ 272, /* (200) likeop ::= NOT LIKE_KW|MATCH */
160892
+ 215, /* (201) expr ::= expr likeop expr */
160893
+ 215, /* (202) expr ::= expr likeop expr ESCAPE expr */
160894
+ 215, /* (203) expr ::= expr ISNULL|NOTNULL */
160895
+ 215, /* (204) expr ::= expr NOT NULL */
160896
+ 215, /* (205) expr ::= expr IS expr */
160897
+ 215, /* (206) expr ::= expr IS NOT expr */
160898
+ 215, /* (207) expr ::= NOT expr */
160899
+ 215, /* (208) expr ::= BITNOT expr */
160900
+ 215, /* (209) expr ::= PLUS|MINUS expr */
160901
+ 273, /* (210) between_op ::= BETWEEN */
160902
+ 273, /* (211) between_op ::= NOT BETWEEN */
160903
+ 215, /* (212) expr ::= expr between_op expr AND expr */
160904
+ 274, /* (213) in_op ::= IN */
160905
+ 274, /* (214) in_op ::= NOT IN */
160906
+ 215, /* (215) expr ::= expr in_op LP exprlist RP */
160907
+ 215, /* (216) expr ::= LP select RP */
160908
+ 215, /* (217) expr ::= expr in_op LP select RP */
160909
+ 215, /* (218) expr ::= expr in_op nm dbnm paren_exprlist */
160910
+ 215, /* (219) expr ::= EXISTS LP select RP */
160911
+ 215, /* (220) expr ::= CASE case_operand case_exprlist case_else END */
160912
+ 277, /* (221) case_exprlist ::= case_exprlist WHEN expr THEN expr */
160913
+ 277, /* (222) case_exprlist ::= WHEN expr THEN expr */
160914
+ 278, /* (223) case_else ::= ELSE expr */
160915
+ 278, /* (224) case_else ::= */
160916
+ 276, /* (225) case_operand ::= expr */
160917
+ 276, /* (226) case_operand ::= */
160918
+ 260, /* (227) exprlist ::= */
160919
+ 251, /* (228) nexprlist ::= nexprlist COMMA expr */
160920
+ 251, /* (229) nexprlist ::= expr */
160921
+ 275, /* (230) paren_exprlist ::= */
160922
+ 275, /* (231) paren_exprlist ::= LP exprlist RP */
160923
+ 189, /* (232) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
160924
+ 279, /* (233) uniqueflag ::= UNIQUE */
160925
+ 279, /* (234) uniqueflag ::= */
160926
+ 219, /* (235) eidlist_opt ::= */
160927
+ 219, /* (236) eidlist_opt ::= LP eidlist RP */
160928
+ 230, /* (237) eidlist ::= eidlist COMMA nm collate sortorder */
160929
+ 230, /* (238) eidlist ::= nm collate sortorder */
160930
+ 280, /* (239) collate ::= */
160931
+ 280, /* (240) collate ::= COLLATE ID|STRING */
160932
+ 189, /* (241) cmd ::= DROP INDEX ifexists fullname */
160933
+ 189, /* (242) cmd ::= VACUUM vinto */
160934
+ 189, /* (243) cmd ::= VACUUM nm vinto */
160935
+ 281, /* (244) vinto ::= INTO expr */
160936
+ 281, /* (245) vinto ::= */
160937
+ 189, /* (246) cmd ::= PRAGMA nm dbnm */
160938
+ 189, /* (247) cmd ::= PRAGMA nm dbnm EQ nmnum */
160939
+ 189, /* (248) cmd ::= PRAGMA nm dbnm LP nmnum RP */
160940
+ 189, /* (249) cmd ::= PRAGMA nm dbnm EQ minus_num */
160941
+ 189, /* (250) cmd ::= PRAGMA nm dbnm LP minus_num RP */
160942
+ 209, /* (251) plus_num ::= PLUS INTEGER|FLOAT */
160943
+ 210, /* (252) minus_num ::= MINUS INTEGER|FLOAT */
160944
+ 189, /* (253) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
160945
+ 283, /* (254) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
160946
+ 285, /* (255) trigger_time ::= BEFORE|AFTER */
160947
+ 285, /* (256) trigger_time ::= INSTEAD OF */
160948
+ 285, /* (257) trigger_time ::= */
160949
+ 286, /* (258) trigger_event ::= DELETE|INSERT */
160950
+ 286, /* (259) trigger_event ::= UPDATE */
160951
+ 286, /* (260) trigger_event ::= UPDATE OF idlist */
160952
+ 288, /* (261) when_clause ::= */
160953
+ 288, /* (262) when_clause ::= WHEN expr */
160954
+ 284, /* (263) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
160955
+ 284, /* (264) trigger_cmd_list ::= trigger_cmd SEMI */
160956
+ 290, /* (265) trnm ::= nm DOT nm */
160957
+ 291, /* (266) tridxby ::= INDEXED BY nm */
160958
+ 291, /* (267) tridxby ::= NOT INDEXED */
160959
+ 289, /* (268) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
160960
+ 289, /* (269) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
160961
+ 289, /* (270) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
160962
+ 289, /* (271) trigger_cmd ::= scanpt select scanpt */
160963
+ 215, /* (272) expr ::= RAISE LP IGNORE RP */
160964
+ 215, /* (273) expr ::= RAISE LP raisetype COMMA nm RP */
160965
+ 234, /* (274) raisetype ::= ROLLBACK */
160966
+ 234, /* (275) raisetype ::= ABORT */
160967
+ 234, /* (276) raisetype ::= FAIL */
160968
+ 189, /* (277) cmd ::= DROP TRIGGER ifexists fullname */
160969
+ 189, /* (278) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
160970
+ 189, /* (279) cmd ::= DETACH database_kw_opt expr */
160971
+ 293, /* (280) key_opt ::= */
160972
+ 293, /* (281) key_opt ::= KEY expr */
160973
+ 189, /* (282) cmd ::= REINDEX */
160974
+ 189, /* (283) cmd ::= REINDEX nm dbnm */
160975
+ 189, /* (284) cmd ::= ANALYZE */
160976
+ 189, /* (285) cmd ::= ANALYZE nm dbnm */
160977
+ 189, /* (286) cmd ::= ALTER TABLE fullname RENAME TO nm */
160978
+ 189, /* (287) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
160979
+ 189, /* (288) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
160980
+ 294, /* (289) add_column_fullname ::= fullname */
160981
+ 189, /* (290) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
160982
+ 189, /* (291) cmd ::= create_vtab */
160983
+ 189, /* (292) cmd ::= create_vtab LP vtabarglist RP */
160984
+ 296, /* (293) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
160985
+ 298, /* (294) vtabarg ::= */
160986
+ 299, /* (295) vtabargtoken ::= ANY */
160987
+ 299, /* (296) vtabargtoken ::= lp anylist RP */
160988
+ 300, /* (297) lp ::= LP */
160989
+ 264, /* (298) with ::= WITH wqlist */
160990
+ 264, /* (299) with ::= WITH RECURSIVE wqlist */
160991
+ 303, /* (300) wqas ::= AS */
160992
+ 303, /* (301) wqas ::= AS MATERIALIZED */
160993
+ 303, /* (302) wqas ::= AS NOT MATERIALIZED */
160994
+ 302, /* (303) wqitem ::= nm eidlist_opt wqas LP select RP */
160995
+ 239, /* (304) wqlist ::= wqitem */
160996
+ 239, /* (305) wqlist ::= wqlist COMMA wqitem */
160997
+ 304, /* (306) windowdefn_list ::= windowdefn */
160998
+ 304, /* (307) windowdefn_list ::= windowdefn_list COMMA windowdefn */
160999
+ 305, /* (308) windowdefn ::= nm AS LP window RP */
161000
+ 306, /* (309) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
161001
+ 306, /* (310) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
161002
+ 306, /* (311) window ::= ORDER BY sortlist frame_opt */
161003
+ 306, /* (312) window ::= nm ORDER BY sortlist frame_opt */
161004
+ 306, /* (313) window ::= frame_opt */
161005
+ 306, /* (314) window ::= nm frame_opt */
161006
+ 307, /* (315) frame_opt ::= */
161007
+ 307, /* (316) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
161008
+ 307, /* (317) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
161009
+ 311, /* (318) range_or_rows ::= RANGE|ROWS|GROUPS */
161010
+ 313, /* (319) frame_bound_s ::= frame_bound */
161011
+ 313, /* (320) frame_bound_s ::= UNBOUNDED PRECEDING */
161012
+ 314, /* (321) frame_bound_e ::= frame_bound */
161013
+ 314, /* (322) frame_bound_e ::= UNBOUNDED FOLLOWING */
161014
+ 312, /* (323) frame_bound ::= expr PRECEDING|FOLLOWING */
161015
+ 312, /* (324) frame_bound ::= CURRENT ROW */
161016
+ 315, /* (325) frame_exclude_opt ::= */
161017
+ 315, /* (326) frame_exclude_opt ::= EXCLUDE frame_exclude */
161018
+ 316, /* (327) frame_exclude ::= NO OTHERS */
161019
+ 316, /* (328) frame_exclude ::= CURRENT ROW */
161020
+ 316, /* (329) frame_exclude ::= GROUP|TIES */
161021
+ 249, /* (330) window_clause ::= WINDOW windowdefn_list */
161022
+ 271, /* (331) filter_over ::= filter_clause over_clause */
161023
+ 271, /* (332) filter_over ::= over_clause */
161024
+ 271, /* (333) filter_over ::= filter_clause */
161025
+ 310, /* (334) over_clause ::= OVER LP window RP */
161026
+ 310, /* (335) over_clause ::= OVER nm */
161027
+ 309, /* (336) filter_clause ::= FILTER LP WHERE expr RP */
161028
+ 184, /* (337) input ::= cmdlist */
161029
+ 185, /* (338) cmdlist ::= cmdlist ecmd */
161030
+ 185, /* (339) cmdlist ::= ecmd */
161031
+ 186, /* (340) ecmd ::= SEMI */
161032
+ 186, /* (341) ecmd ::= cmdx SEMI */
161033
+ 186, /* (342) ecmd ::= explain cmdx SEMI */
161034
+ 191, /* (343) trans_opt ::= */
161035
+ 191, /* (344) trans_opt ::= TRANSACTION */
161036
+ 191, /* (345) trans_opt ::= TRANSACTION nm */
161037
+ 193, /* (346) savepoint_opt ::= SAVEPOINT */
161038
+ 193, /* (347) savepoint_opt ::= */
161039
+ 189, /* (348) cmd ::= create_table create_table_args */
161040
+ 200, /* (349) columnlist ::= columnlist COMMA columnname carglist */
161041
+ 200, /* (350) columnlist ::= columnname carglist */
161042
+ 192, /* (351) nm ::= ID|INDEXED */
161043
+ 192, /* (352) nm ::= STRING */
161044
+ 192, /* (353) nm ::= JOIN_KW */
161045
+ 206, /* (354) typetoken ::= typename */
161046
+ 207, /* (355) typename ::= ID|STRING */
161047
+ 208, /* (356) signed ::= plus_num */
161048
+ 208, /* (357) signed ::= minus_num */
161049
+ 205, /* (358) carglist ::= carglist ccons */
161050
+ 205, /* (359) carglist ::= */
161051
+ 213, /* (360) ccons ::= NULL onconf */
161052
+ 213, /* (361) ccons ::= GENERATED ALWAYS AS generated */
161053
+ 213, /* (362) ccons ::= AS generated */
161054
+ 201, /* (363) conslist_opt ::= COMMA conslist */
161055
+ 226, /* (364) conslist ::= conslist tconscomma tcons */
161056
+ 226, /* (365) conslist ::= tcons */
161057
+ 227, /* (366) tconscomma ::= */
161058
+ 231, /* (367) defer_subclause_opt ::= defer_subclause */
161059
+ 233, /* (368) resolvetype ::= raisetype */
161060
+ 237, /* (369) selectnowith ::= oneselect */
161061
+ 238, /* (370) oneselect ::= values */
161062
+ 252, /* (371) sclp ::= selcollist COMMA */
161063
+ 253, /* (372) as ::= ID|STRING */
161064
+ 270, /* (373) returning ::= */
161065
+ 215, /* (374) expr ::= term */
161066
+ 272, /* (375) likeop ::= LIKE_KW|MATCH */
161067
+ 260, /* (376) exprlist ::= nexprlist */
161068
+ 282, /* (377) nmnum ::= plus_num */
161069
+ 282, /* (378) nmnum ::= nm */
161070
+ 282, /* (379) nmnum ::= ON */
161071
+ 282, /* (380) nmnum ::= DELETE */
161072
+ 282, /* (381) nmnum ::= DEFAULT */
161073
+ 209, /* (382) plus_num ::= INTEGER|FLOAT */
161074
+ 287, /* (383) foreach_clause ::= */
161075
+ 287, /* (384) foreach_clause ::= FOR EACH ROW */
161076
+ 290, /* (385) trnm ::= nm */
161077
+ 291, /* (386) tridxby ::= */
161078
+ 292, /* (387) database_kw_opt ::= DATABASE */
161079
+ 292, /* (388) database_kw_opt ::= */
161080
+ 295, /* (389) kwcolumn_opt ::= */
161081
+ 295, /* (390) kwcolumn_opt ::= COLUMNKW */
161082
+ 297, /* (391) vtabarglist ::= vtabarg */
161083
+ 297, /* (392) vtabarglist ::= vtabarglist COMMA vtabarg */
161084
+ 298, /* (393) vtabarg ::= vtabarg vtabargtoken */
161085
+ 301, /* (394) anylist ::= */
161086
+ 301, /* (395) anylist ::= anylist LP anylist RP */
161087
+ 301, /* (396) anylist ::= anylist ANY */
161088
+ 264, /* (397) with ::= */
160510161089
};
160511161090
160512161091
/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
160513161092
** of symbols on the right-hand side of that rule. */
160514161093
static const signed char yyRuleInfoNRhs[] = {
@@ -160959,20 +161538,20 @@
160959161538
break;
160960161539
case 2: /* cmdx ::= cmd */
160961161540
{ sqlite3FinishCoding(pParse); }
160962161541
break;
160963161542
case 3: /* cmd ::= BEGIN transtype trans_opt */
160964
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy60);}
161543
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy376);}
160965161544
break;
160966161545
case 4: /* transtype ::= */
160967
-{yymsp[1].minor.yy60 = TK_DEFERRED;}
161546
+{yymsp[1].minor.yy376 = TK_DEFERRED;}
160968161547
break;
160969161548
case 5: /* transtype ::= DEFERRED */
160970161549
case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
160971161550
case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
160972161551
case 318: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==318);
160973
-{yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-X*/}
161552
+{yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-X*/}
160974161553
break;
160975161554
case 8: /* cmd ::= COMMIT|END trans_opt */
160976161555
case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
160977161556
{sqlite3EndTransaction(pParse,yymsp[-1].major);}
160978161557
break;
@@ -160991,11 +161570,11 @@
160991161570
sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
160992161571
}
160993161572
break;
160994161573
case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
160995161574
{
160996
- sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy60,0,0,yymsp[-2].minor.yy60);
161575
+ sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy376,0,0,yymsp[-2].minor.yy376);
160997161576
}
160998161577
break;
160999161578
case 14: /* createkw ::= CREATE */
161000161579
{disableLookaside(pParse);}
161001161580
break;
@@ -161006,36 +161585,35 @@
161006161585
case 60: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==60);
161007161586
case 70: /* defer_subclause_opt ::= */ yytestcase(yyruleno==70);
161008161587
case 79: /* ifexists ::= */ yytestcase(yyruleno==79);
161009161588
case 96: /* distinct ::= */ yytestcase(yyruleno==96);
161010161589
case 239: /* collate ::= */ yytestcase(yyruleno==239);
161011
-{yymsp[1].minor.yy60 = 0;}
161590
+{yymsp[1].minor.yy376 = 0;}
161012161591
break;
161013161592
case 16: /* ifnotexists ::= IF NOT EXISTS */
161014
-{yymsp[-2].minor.yy60 = 1;}
161593
+{yymsp[-2].minor.yy376 = 1;}
161015161594
break;
161016161595
case 17: /* temp ::= TEMP */
161017
- case 46: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==46);
161018
-{yymsp[0].minor.yy60 = 1;}
161596
+{yymsp[0].minor.yy376 = pParse->db->init.busy==0;}
161019161597
break;
161020161598
case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
161021161599
{
161022
- sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy60,0);
161600
+ sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy376,0);
161023161601
}
161024161602
break;
161025161603
case 20: /* create_table_args ::= AS select */
161026161604
{
161027
- sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy307);
161028
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy307);
161605
+ sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy81);
161606
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy81);
161029161607
}
161030161608
break;
161031161609
case 22: /* table_options ::= WITHOUT nm */
161032161610
{
161033161611
if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
161034
- yymsp[-1].minor.yy60 = TF_WithoutRowid | TF_NoVisibleRowid;
161612
+ yymsp[-1].minor.yy376 = TF_WithoutRowid | TF_NoVisibleRowid;
161035161613
}else{
161036
- yymsp[-1].minor.yy60 = 0;
161614
+ yymsp[-1].minor.yy376 = 0;
161037161615
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
161038161616
}
161039161617
}
161040161618
break;
161041161619
case 23: /* columnname ::= nm typetoken */
@@ -161060,11 +161638,11 @@
161060161638
{yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
161061161639
break;
161062161640
case 28: /* scanpt ::= */
161063161641
{
161064161642
assert( yyLookahead!=YYNOCODE );
161065
- yymsp[1].minor.yy528 = yyLookaheadToken.z;
161643
+ yymsp[1].minor.yy504 = yyLookaheadToken.z;
161066161644
}
161067161645
break;
161068161646
case 29: /* scantok ::= */
161069161647
{
161070161648
assert( yyLookahead!=YYNOCODE );
@@ -161074,21 +161652,21 @@
161074161652
case 30: /* ccons ::= CONSTRAINT nm */
161075161653
case 65: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==65);
161076161654
{pParse->constraintName = yymsp[0].minor.yy0;}
161077161655
break;
161078161656
case 31: /* ccons ::= DEFAULT scantok term */
161079
-{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy602,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
161657
+{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy404,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
161080161658
break;
161081161659
case 32: /* ccons ::= DEFAULT LP expr RP */
161082
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy602,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
161660
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy404,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
161083161661
break;
161084161662
case 33: /* ccons ::= DEFAULT PLUS scantok term */
161085
-{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy602,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
161663
+{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy404,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
161086161664
break;
161087161665
case 34: /* ccons ::= DEFAULT MINUS scantok term */
161088161666
{
161089
- Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy602, 0);
161667
+ Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy404, 0);
161090161668
sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
161091161669
}
161092161670
break;
161093161671
case 35: /* ccons ::= DEFAULT scantok ID|INDEXED */
161094161672
{
@@ -161099,256 +161677,259 @@
161099161677
}
161100161678
sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
161101161679
}
161102161680
break;
161103161681
case 36: /* ccons ::= NOT NULL onconf */
161104
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy60);}
161682
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy376);}
161105161683
break;
161106161684
case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
161107
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy60,yymsp[0].minor.yy60,yymsp[-2].minor.yy60);}
161685
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy376,yymsp[0].minor.yy376,yymsp[-2].minor.yy376);}
161108161686
break;
161109161687
case 38: /* ccons ::= UNIQUE onconf */
161110
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy60,0,0,0,0,
161688
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy376,0,0,0,0,
161111161689
SQLITE_IDXTYPE_UNIQUE);}
161112161690
break;
161113161691
case 39: /* ccons ::= CHECK LP expr RP */
161114
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy602,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
161692
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy404,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
161115161693
break;
161116161694
case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */
161117
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy338,yymsp[0].minor.yy60);}
161695
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy70,yymsp[0].minor.yy376);}
161118161696
break;
161119161697
case 41: /* ccons ::= defer_subclause */
161120
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy60);}
161698
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy376);}
161121161699
break;
161122161700
case 42: /* ccons ::= COLLATE ID|STRING */
161123161701
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
161124161702
break;
161125161703
case 43: /* generated ::= LP expr RP */
161126
-{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy602,0);}
161704
+{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy404,0);}
161127161705
break;
161128161706
case 44: /* generated ::= LP expr RP ID */
161129
-{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy602,&yymsp[0].minor.yy0);}
161707
+{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy404,&yymsp[0].minor.yy0);}
161708
+ break;
161709
+ case 46: /* autoinc ::= AUTOINCR */
161710
+{yymsp[0].minor.yy376 = 1;}
161130161711
break;
161131161712
case 47: /* refargs ::= */
161132
-{ yymsp[1].minor.yy60 = OE_None*0x0101; /* EV: R-19803-45884 */}
161713
+{ yymsp[1].minor.yy376 = OE_None*0x0101; /* EV: R-19803-45884 */}
161133161714
break;
161134161715
case 48: /* refargs ::= refargs refarg */
161135
-{ yymsp[-1].minor.yy60 = (yymsp[-1].minor.yy60 & ~yymsp[0].minor.yy615.mask) | yymsp[0].minor.yy615.value; }
161716
+{ yymsp[-1].minor.yy376 = (yymsp[-1].minor.yy376 & ~yymsp[0].minor.yy139.mask) | yymsp[0].minor.yy139.value; }
161136161717
break;
161137161718
case 49: /* refarg ::= MATCH nm */
161138
-{ yymsp[-1].minor.yy615.value = 0; yymsp[-1].minor.yy615.mask = 0x000000; }
161719
+{ yymsp[-1].minor.yy139.value = 0; yymsp[-1].minor.yy139.mask = 0x000000; }
161139161720
break;
161140161721
case 50: /* refarg ::= ON INSERT refact */
161141
-{ yymsp[-2].minor.yy615.value = 0; yymsp[-2].minor.yy615.mask = 0x000000; }
161722
+{ yymsp[-2].minor.yy139.value = 0; yymsp[-2].minor.yy139.mask = 0x000000; }
161142161723
break;
161143161724
case 51: /* refarg ::= ON DELETE refact */
161144
-{ yymsp[-2].minor.yy615.value = yymsp[0].minor.yy60; yymsp[-2].minor.yy615.mask = 0x0000ff; }
161725
+{ yymsp[-2].minor.yy139.value = yymsp[0].minor.yy376; yymsp[-2].minor.yy139.mask = 0x0000ff; }
161145161726
break;
161146161727
case 52: /* refarg ::= ON UPDATE refact */
161147
-{ yymsp[-2].minor.yy615.value = yymsp[0].minor.yy60<<8; yymsp[-2].minor.yy615.mask = 0x00ff00; }
161728
+{ yymsp[-2].minor.yy139.value = yymsp[0].minor.yy376<<8; yymsp[-2].minor.yy139.mask = 0x00ff00; }
161148161729
break;
161149161730
case 53: /* refact ::= SET NULL */
161150
-{ yymsp[-1].minor.yy60 = OE_SetNull; /* EV: R-33326-45252 */}
161731
+{ yymsp[-1].minor.yy376 = OE_SetNull; /* EV: R-33326-45252 */}
161151161732
break;
161152161733
case 54: /* refact ::= SET DEFAULT */
161153
-{ yymsp[-1].minor.yy60 = OE_SetDflt; /* EV: R-33326-45252 */}
161734
+{ yymsp[-1].minor.yy376 = OE_SetDflt; /* EV: R-33326-45252 */}
161154161735
break;
161155161736
case 55: /* refact ::= CASCADE */
161156
-{ yymsp[0].minor.yy60 = OE_Cascade; /* EV: R-33326-45252 */}
161737
+{ yymsp[0].minor.yy376 = OE_Cascade; /* EV: R-33326-45252 */}
161157161738
break;
161158161739
case 56: /* refact ::= RESTRICT */
161159
-{ yymsp[0].minor.yy60 = OE_Restrict; /* EV: R-33326-45252 */}
161740
+{ yymsp[0].minor.yy376 = OE_Restrict; /* EV: R-33326-45252 */}
161160161741
break;
161161161742
case 57: /* refact ::= NO ACTION */
161162
-{ yymsp[-1].minor.yy60 = OE_None; /* EV: R-33326-45252 */}
161743
+{ yymsp[-1].minor.yy376 = OE_None; /* EV: R-33326-45252 */}
161163161744
break;
161164161745
case 58: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
161165
-{yymsp[-2].minor.yy60 = 0;}
161746
+{yymsp[-2].minor.yy376 = 0;}
161166161747
break;
161167161748
case 59: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
161168161749
case 74: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==74);
161169161750
case 169: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==169);
161170
-{yymsp[-1].minor.yy60 = yymsp[0].minor.yy60;}
161751
+{yymsp[-1].minor.yy376 = yymsp[0].minor.yy376;}
161171161752
break;
161172161753
case 61: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
161173161754
case 78: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==78);
161174161755
case 211: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==211);
161175161756
case 214: /* in_op ::= NOT IN */ yytestcase(yyruleno==214);
161176161757
case 240: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==240);
161177
-{yymsp[-1].minor.yy60 = 1;}
161758
+{yymsp[-1].minor.yy376 = 1;}
161178161759
break;
161179161760
case 62: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
161180
-{yymsp[-1].minor.yy60 = 0;}
161761
+{yymsp[-1].minor.yy376 = 0;}
161181161762
break;
161182161763
case 64: /* tconscomma ::= COMMA */
161183161764
{pParse->constraintName.n = 0;}
161184161765
break;
161185161766
case 66: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
161186
-{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy338,yymsp[0].minor.yy60,yymsp[-2].minor.yy60,0);}
161767
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy70,yymsp[0].minor.yy376,yymsp[-2].minor.yy376,0);}
161187161768
break;
161188161769
case 67: /* tcons ::= UNIQUE LP sortlist RP onconf */
161189
-{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy338,yymsp[0].minor.yy60,0,0,0,0,
161770
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy70,yymsp[0].minor.yy376,0,0,0,0,
161190161771
SQLITE_IDXTYPE_UNIQUE);}
161191161772
break;
161192161773
case 68: /* tcons ::= CHECK LP expr RP onconf */
161193
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy602,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
161774
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy404,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
161194161775
break;
161195161776
case 69: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
161196161777
{
161197
- sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy338, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy338, yymsp[-1].minor.yy60);
161198
- sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy60);
161778
+ sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy70, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy70, yymsp[-1].minor.yy376);
161779
+ sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy376);
161199161780
}
161200161781
break;
161201161782
case 71: /* onconf ::= */
161202161783
case 73: /* orconf ::= */ yytestcase(yyruleno==73);
161203
-{yymsp[1].minor.yy60 = OE_Default;}
161784
+{yymsp[1].minor.yy376 = OE_Default;}
161204161785
break;
161205161786
case 72: /* onconf ::= ON CONFLICT resolvetype */
161206
-{yymsp[-2].minor.yy60 = yymsp[0].minor.yy60;}
161787
+{yymsp[-2].minor.yy376 = yymsp[0].minor.yy376;}
161207161788
break;
161208161789
case 75: /* resolvetype ::= IGNORE */
161209
-{yymsp[0].minor.yy60 = OE_Ignore;}
161790
+{yymsp[0].minor.yy376 = OE_Ignore;}
161210161791
break;
161211161792
case 76: /* resolvetype ::= REPLACE */
161212161793
case 170: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==170);
161213
-{yymsp[0].minor.yy60 = OE_Replace;}
161794
+{yymsp[0].minor.yy376 = OE_Replace;}
161214161795
break;
161215161796
case 77: /* cmd ::= DROP TABLE ifexists fullname */
161216161797
{
161217
- sqlite3DropTable(pParse, yymsp[0].minor.yy291, 0, yymsp[-1].minor.yy60);
161798
+ sqlite3DropTable(pParse, yymsp[0].minor.yy153, 0, yymsp[-1].minor.yy376);
161218161799
}
161219161800
break;
161220161801
case 80: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
161221161802
{
161222
- sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy338, yymsp[0].minor.yy307, yymsp[-7].minor.yy60, yymsp[-5].minor.yy60);
161803
+ sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy70, yymsp[0].minor.yy81, yymsp[-7].minor.yy376, yymsp[-5].minor.yy376);
161223161804
}
161224161805
break;
161225161806
case 81: /* cmd ::= DROP VIEW ifexists fullname */
161226161807
{
161227
- sqlite3DropTable(pParse, yymsp[0].minor.yy291, 1, yymsp[-1].minor.yy60);
161808
+ sqlite3DropTable(pParse, yymsp[0].minor.yy153, 1, yymsp[-1].minor.yy376);
161228161809
}
161229161810
break;
161230161811
case 82: /* cmd ::= select */
161231161812
{
161232161813
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0};
161233
- sqlite3Select(pParse, yymsp[0].minor.yy307, &dest);
161234
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy307);
161814
+ sqlite3Select(pParse, yymsp[0].minor.yy81, &dest);
161815
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy81);
161235161816
}
161236161817
break;
161237161818
case 83: /* select ::= WITH wqlist selectnowith */
161238
-{yymsp[-2].minor.yy307 = attachWithToSelect(pParse,yymsp[0].minor.yy307,yymsp[-1].minor.yy195);}
161819
+{yymsp[-2].minor.yy81 = attachWithToSelect(pParse,yymsp[0].minor.yy81,yymsp[-1].minor.yy103);}
161239161820
break;
161240161821
case 84: /* select ::= WITH RECURSIVE wqlist selectnowith */
161241
-{yymsp[-3].minor.yy307 = attachWithToSelect(pParse,yymsp[0].minor.yy307,yymsp[-1].minor.yy195);}
161822
+{yymsp[-3].minor.yy81 = attachWithToSelect(pParse,yymsp[0].minor.yy81,yymsp[-1].minor.yy103);}
161242161823
break;
161243161824
case 85: /* select ::= selectnowith */
161244161825
{
161245
- Select *p = yymsp[0].minor.yy307;
161826
+ Select *p = yymsp[0].minor.yy81;
161246161827
if( p ){
161247161828
parserDoubleLinkSelect(pParse, p);
161248161829
}
161249
- yymsp[0].minor.yy307 = p; /*A-overwrites-X*/
161830
+ yymsp[0].minor.yy81 = p; /*A-overwrites-X*/
161250161831
}
161251161832
break;
161252161833
case 86: /* selectnowith ::= selectnowith multiselect_op oneselect */
161253161834
{
161254
- Select *pRhs = yymsp[0].minor.yy307;
161255
- Select *pLhs = yymsp[-2].minor.yy307;
161835
+ Select *pRhs = yymsp[0].minor.yy81;
161836
+ Select *pLhs = yymsp[-2].minor.yy81;
161256161837
if( pRhs && pRhs->pPrior ){
161257161838
SrcList *pFrom;
161258161839
Token x;
161259161840
x.n = 0;
161260161841
parserDoubleLinkSelect(pParse, pRhs);
161261161842
pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
161262161843
pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
161263161844
}
161264161845
if( pRhs ){
161265
- pRhs->op = (u8)yymsp[-1].minor.yy60;
161846
+ pRhs->op = (u8)yymsp[-1].minor.yy376;
161266161847
pRhs->pPrior = pLhs;
161267161848
if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
161268161849
pRhs->selFlags &= ~SF_MultiValue;
161269
- if( yymsp[-1].minor.yy60!=TK_ALL ) pParse->hasCompound = 1;
161850
+ if( yymsp[-1].minor.yy376!=TK_ALL ) pParse->hasCompound = 1;
161270161851
}else{
161271161852
sqlite3SelectDelete(pParse->db, pLhs);
161272161853
}
161273
- yymsp[-2].minor.yy307 = pRhs;
161854
+ yymsp[-2].minor.yy81 = pRhs;
161274161855
}
161275161856
break;
161276161857
case 87: /* multiselect_op ::= UNION */
161277161858
case 89: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==89);
161278
-{yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-OP*/}
161859
+{yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-OP*/}
161279161860
break;
161280161861
case 88: /* multiselect_op ::= UNION ALL */
161281
-{yymsp[-1].minor.yy60 = TK_ALL;}
161862
+{yymsp[-1].minor.yy376 = TK_ALL;}
161282161863
break;
161283161864
case 90: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
161284161865
{
161285
- yymsp[-8].minor.yy307 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy338,yymsp[-5].minor.yy291,yymsp[-4].minor.yy602,yymsp[-3].minor.yy338,yymsp[-2].minor.yy602,yymsp[-1].minor.yy338,yymsp[-7].minor.yy60,yymsp[0].minor.yy602);
161866
+ yymsp[-8].minor.yy81 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy70,yymsp[-5].minor.yy153,yymsp[-4].minor.yy404,yymsp[-3].minor.yy70,yymsp[-2].minor.yy404,yymsp[-1].minor.yy70,yymsp[-7].minor.yy376,yymsp[0].minor.yy404);
161286161867
}
161287161868
break;
161288161869
case 91: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
161289161870
{
161290
- yymsp[-9].minor.yy307 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy338,yymsp[-6].minor.yy291,yymsp[-5].minor.yy602,yymsp[-4].minor.yy338,yymsp[-3].minor.yy602,yymsp[-1].minor.yy338,yymsp[-8].minor.yy60,yymsp[0].minor.yy602);
161291
- if( yymsp[-9].minor.yy307 ){
161292
- yymsp[-9].minor.yy307->pWinDefn = yymsp[-2].minor.yy19;
161871
+ yymsp[-9].minor.yy81 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy70,yymsp[-6].minor.yy153,yymsp[-5].minor.yy404,yymsp[-4].minor.yy70,yymsp[-3].minor.yy404,yymsp[-1].minor.yy70,yymsp[-8].minor.yy376,yymsp[0].minor.yy404);
161872
+ if( yymsp[-9].minor.yy81 ){
161873
+ yymsp[-9].minor.yy81->pWinDefn = yymsp[-2].minor.yy49;
161293161874
}else{
161294
- sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy19);
161875
+ sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy49);
161295161876
}
161296161877
}
161297161878
break;
161298161879
case 92: /* values ::= VALUES LP nexprlist RP */
161299161880
{
161300
- yymsp[-3].minor.yy307 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy338,0,0,0,0,0,SF_Values,0);
161881
+ yymsp[-3].minor.yy81 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy70,0,0,0,0,0,SF_Values,0);
161301161882
}
161302161883
break;
161303161884
case 93: /* values ::= values COMMA LP nexprlist RP */
161304161885
{
161305
- Select *pRight, *pLeft = yymsp[-4].minor.yy307;
161306
- pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy338,0,0,0,0,0,SF_Values|SF_MultiValue,0);
161886
+ Select *pRight, *pLeft = yymsp[-4].minor.yy81;
161887
+ pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy70,0,0,0,0,0,SF_Values|SF_MultiValue,0);
161307161888
if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
161308161889
if( pRight ){
161309161890
pRight->op = TK_ALL;
161310161891
pRight->pPrior = pLeft;
161311
- yymsp[-4].minor.yy307 = pRight;
161892
+ yymsp[-4].minor.yy81 = pRight;
161312161893
}else{
161313
- yymsp[-4].minor.yy307 = pLeft;
161894
+ yymsp[-4].minor.yy81 = pLeft;
161314161895
}
161315161896
}
161316161897
break;
161317161898
case 94: /* distinct ::= DISTINCT */
161318
-{yymsp[0].minor.yy60 = SF_Distinct;}
161899
+{yymsp[0].minor.yy376 = SF_Distinct;}
161319161900
break;
161320161901
case 95: /* distinct ::= ALL */
161321
-{yymsp[0].minor.yy60 = SF_All;}
161902
+{yymsp[0].minor.yy376 = SF_All;}
161322161903
break;
161323161904
case 97: /* sclp ::= */
161324161905
case 130: /* orderby_opt ::= */ yytestcase(yyruleno==130);
161325161906
case 140: /* groupby_opt ::= */ yytestcase(yyruleno==140);
161326161907
case 227: /* exprlist ::= */ yytestcase(yyruleno==227);
161327161908
case 230: /* paren_exprlist ::= */ yytestcase(yyruleno==230);
161328161909
case 235: /* eidlist_opt ::= */ yytestcase(yyruleno==235);
161329
-{yymsp[1].minor.yy338 = 0;}
161910
+{yymsp[1].minor.yy70 = 0;}
161330161911
break;
161331161912
case 98: /* selcollist ::= sclp scanpt expr scanpt as */
161332161913
{
161333
- yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy338, yymsp[-2].minor.yy602);
161334
- if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy338, &yymsp[0].minor.yy0, 1);
161335
- sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy338,yymsp[-3].minor.yy528,yymsp[-1].minor.yy528);
161914
+ yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy70, yymsp[-2].minor.yy404);
161915
+ if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy70, &yymsp[0].minor.yy0, 1);
161916
+ sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy70,yymsp[-3].minor.yy504,yymsp[-1].minor.yy504);
161336161917
}
161337161918
break;
161338161919
case 99: /* selcollist ::= sclp scanpt STAR */
161339161920
{
161340161921
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
161341
- yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy338, p);
161922
+ yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy70, p);
161342161923
}
161343161924
break;
161344161925
case 100: /* selcollist ::= sclp scanpt nm DOT STAR */
161345161926
{
161346161927
Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
161347161928
Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
161348161929
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
161349
- yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, pDot);
161930
+ yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, pDot);
161350161931
}
161351161932
break;
161352161933
case 101: /* as ::= AS nm */
161353161934
case 112: /* dbnm ::= DOT nm */ yytestcase(yyruleno==112);
161354161935
case 251: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==251);
@@ -161355,49 +161936,49 @@
161355161936
case 252: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==252);
161356161937
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
161357161938
break;
161358161939
case 103: /* from ::= */
161359161940
case 106: /* stl_prefix ::= */ yytestcase(yyruleno==106);
161360
-{yymsp[1].minor.yy291 = 0;}
161941
+{yymsp[1].minor.yy153 = 0;}
161361161942
break;
161362161943
case 104: /* from ::= FROM seltablist */
161363161944
{
161364
- yymsp[-1].minor.yy291 = yymsp[0].minor.yy291;
161365
- sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy291);
161945
+ yymsp[-1].minor.yy153 = yymsp[0].minor.yy153;
161946
+ sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy153);
161366161947
}
161367161948
break;
161368161949
case 105: /* stl_prefix ::= seltablist joinop */
161369161950
{
161370
- if( ALWAYS(yymsp[-1].minor.yy291 && yymsp[-1].minor.yy291->nSrc>0) ) yymsp[-1].minor.yy291->a[yymsp[-1].minor.yy291->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy60;
161951
+ if( ALWAYS(yymsp[-1].minor.yy153 && yymsp[-1].minor.yy153->nSrc>0) ) yymsp[-1].minor.yy153->a[yymsp[-1].minor.yy153->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy376;
161371161952
}
161372161953
break;
161373161954
case 107: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
161374161955
{
161375
- yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy602,yymsp[0].minor.yy288);
161376
- sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy291, &yymsp[-2].minor.yy0);
161956
+ yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy404,yymsp[0].minor.yy436);
161957
+ sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy153, &yymsp[-2].minor.yy0);
161377161958
}
161378161959
break;
161379161960
case 108: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
161380161961
{
161381
- yymsp[-8].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy291,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy602,yymsp[0].minor.yy288);
161382
- sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy291, yymsp[-4].minor.yy338);
161962
+ yymsp[-8].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy153,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy404,yymsp[0].minor.yy436);
161963
+ sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy153, yymsp[-4].minor.yy70);
161383161964
}
161384161965
break;
161385161966
case 109: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
161386161967
{
161387
- yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy307,yymsp[-1].minor.yy602,yymsp[0].minor.yy288);
161968
+ yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy81,yymsp[-1].minor.yy404,yymsp[0].minor.yy436);
161388161969
}
161389161970
break;
161390161971
case 110: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
161391161972
{
161392
- if( yymsp[-6].minor.yy291==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy602==0 && yymsp[0].minor.yy288==0 ){
161393
- yymsp[-6].minor.yy291 = yymsp[-4].minor.yy291;
161394
- }else if( yymsp[-4].minor.yy291->nSrc==1 ){
161395
- yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy602,yymsp[0].minor.yy288);
161396
- if( yymsp[-6].minor.yy291 ){
161397
- SrcItem *pNew = &yymsp[-6].minor.yy291->a[yymsp[-6].minor.yy291->nSrc-1];
161398
- SrcItem *pOld = yymsp[-4].minor.yy291->a;
161973
+ if( yymsp[-6].minor.yy153==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy404==0 && yymsp[0].minor.yy436==0 ){
161974
+ yymsp[-6].minor.yy153 = yymsp[-4].minor.yy153;
161975
+ }else if( yymsp[-4].minor.yy153->nSrc==1 ){
161976
+ yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy404,yymsp[0].minor.yy436);
161977
+ if( yymsp[-6].minor.yy153 ){
161978
+ SrcItem *pNew = &yymsp[-6].minor.yy153->a[yymsp[-6].minor.yy153->nSrc-1];
161979
+ SrcItem *pOld = yymsp[-4].minor.yy153->a;
161399161980
pNew->zName = pOld->zName;
161400161981
pNew->zDatabase = pOld->zDatabase;
161401161982
pNew->pSelect = pOld->pSelect;
161402161983
if( pOld->fg.isTabFunc ){
161403161984
pNew->u1.pFuncArg = pOld->u1.pFuncArg;
@@ -161406,240 +161987,240 @@
161406161987
pNew->fg.isTabFunc = 1;
161407161988
}
161408161989
pOld->zName = pOld->zDatabase = 0;
161409161990
pOld->pSelect = 0;
161410161991
}
161411
- sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy291);
161992
+ sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy153);
161412161993
}else{
161413161994
Select *pSubquery;
161414
- sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy291);
161415
- pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy291,0,0,0,0,SF_NestedFrom,0);
161416
- yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy602,yymsp[0].minor.yy288);
161995
+ sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy153);
161996
+ pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy153,0,0,0,0,SF_NestedFrom,0);
161997
+ yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy404,yymsp[0].minor.yy436);
161417161998
}
161418161999
}
161419162000
break;
161420162001
case 111: /* dbnm ::= */
161421162002
case 125: /* indexed_opt ::= */ yytestcase(yyruleno==125);
161422162003
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
161423162004
break;
161424162005
case 113: /* fullname ::= nm */
161425162006
{
161426
- yylhsminor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
161427
- if( IN_RENAME_OBJECT && yylhsminor.yy291 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy291->a[0].zName, &yymsp[0].minor.yy0);
162007
+ yylhsminor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
162008
+ if( IN_RENAME_OBJECT && yylhsminor.yy153 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy153->a[0].zName, &yymsp[0].minor.yy0);
161428162009
}
161429
- yymsp[0].minor.yy291 = yylhsminor.yy291;
162010
+ yymsp[0].minor.yy153 = yylhsminor.yy153;
161430162011
break;
161431162012
case 114: /* fullname ::= nm DOT nm */
161432162013
{
161433
- yylhsminor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
161434
- if( IN_RENAME_OBJECT && yylhsminor.yy291 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy291->a[0].zName, &yymsp[0].minor.yy0);
162014
+ yylhsminor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
162015
+ if( IN_RENAME_OBJECT && yylhsminor.yy153 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy153->a[0].zName, &yymsp[0].minor.yy0);
161435162016
}
161436
- yymsp[-2].minor.yy291 = yylhsminor.yy291;
162017
+ yymsp[-2].minor.yy153 = yylhsminor.yy153;
161437162018
break;
161438162019
case 115: /* xfullname ::= nm */
161439
-{yymsp[0].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
162020
+{yymsp[0].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
161440162021
break;
161441162022
case 116: /* xfullname ::= nm DOT nm */
161442
-{yymsp[-2].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
162023
+{yymsp[-2].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
161443162024
break;
161444162025
case 117: /* xfullname ::= nm DOT nm AS nm */
161445162026
{
161446
- yymsp[-4].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
161447
- if( yymsp[-4].minor.yy291 ) yymsp[-4].minor.yy291->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
162027
+ yymsp[-4].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
162028
+ if( yymsp[-4].minor.yy153 ) yymsp[-4].minor.yy153->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
161448162029
}
161449162030
break;
161450162031
case 118: /* xfullname ::= nm AS nm */
161451162032
{
161452
- yymsp[-2].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
161453
- if( yymsp[-2].minor.yy291 ) yymsp[-2].minor.yy291->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
162033
+ yymsp[-2].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
162034
+ if( yymsp[-2].minor.yy153 ) yymsp[-2].minor.yy153->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
161454162035
}
161455162036
break;
161456162037
case 119: /* joinop ::= COMMA|JOIN */
161457
-{ yymsp[0].minor.yy60 = JT_INNER; }
162038
+{ yymsp[0].minor.yy376 = JT_INNER; }
161458162039
break;
161459162040
case 120: /* joinop ::= JOIN_KW JOIN */
161460
-{yymsp[-1].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
162041
+{yymsp[-1].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
161461162042
break;
161462162043
case 121: /* joinop ::= JOIN_KW nm JOIN */
161463
-{yymsp[-2].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
162044
+{yymsp[-2].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
161464162045
break;
161465162046
case 122: /* joinop ::= JOIN_KW nm nm JOIN */
161466
-{yymsp[-3].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
162047
+{yymsp[-3].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
161467162048
break;
161468162049
case 123: /* on_opt ::= ON expr */
161469162050
case 143: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==143);
161470162051
case 150: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==150);
161471162052
case 152: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==152);
161472162053
case 223: /* case_else ::= ELSE expr */ yytestcase(yyruleno==223);
161473162054
case 244: /* vinto ::= INTO expr */ yytestcase(yyruleno==244);
161474
-{yymsp[-1].minor.yy602 = yymsp[0].minor.yy602;}
162055
+{yymsp[-1].minor.yy404 = yymsp[0].minor.yy404;}
161475162056
break;
161476162057
case 124: /* on_opt ::= */
161477162058
case 142: /* having_opt ::= */ yytestcase(yyruleno==142);
161478162059
case 144: /* limit_opt ::= */ yytestcase(yyruleno==144);
161479162060
case 149: /* where_opt ::= */ yytestcase(yyruleno==149);
161480162061
case 151: /* where_opt_ret ::= */ yytestcase(yyruleno==151);
161481162062
case 224: /* case_else ::= */ yytestcase(yyruleno==224);
161482162063
case 226: /* case_operand ::= */ yytestcase(yyruleno==226);
161483162064
case 245: /* vinto ::= */ yytestcase(yyruleno==245);
161484
-{yymsp[1].minor.yy602 = 0;}
162065
+{yymsp[1].minor.yy404 = 0;}
161485162066
break;
161486162067
case 126: /* indexed_opt ::= INDEXED BY nm */
161487162068
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
161488162069
break;
161489162070
case 127: /* indexed_opt ::= NOT INDEXED */
161490162071
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
161491162072
break;
161492162073
case 128: /* using_opt ::= USING LP idlist RP */
161493
-{yymsp[-3].minor.yy288 = yymsp[-1].minor.yy288;}
162074
+{yymsp[-3].minor.yy436 = yymsp[-1].minor.yy436;}
161494162075
break;
161495162076
case 129: /* using_opt ::= */
161496162077
case 171: /* idlist_opt ::= */ yytestcase(yyruleno==171);
161497
-{yymsp[1].minor.yy288 = 0;}
162078
+{yymsp[1].minor.yy436 = 0;}
161498162079
break;
161499162080
case 131: /* orderby_opt ::= ORDER BY sortlist */
161500162081
case 141: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==141);
161501
-{yymsp[-2].minor.yy338 = yymsp[0].minor.yy338;}
162082
+{yymsp[-2].minor.yy70 = yymsp[0].minor.yy70;}
161502162083
break;
161503162084
case 132: /* sortlist ::= sortlist COMMA expr sortorder nulls */
161504162085
{
161505
- yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338,yymsp[-2].minor.yy602);
161506
- sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy338,yymsp[-1].minor.yy60,yymsp[0].minor.yy60);
162086
+ yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70,yymsp[-2].minor.yy404);
162087
+ sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy70,yymsp[-1].minor.yy376,yymsp[0].minor.yy376);
161507162088
}
161508162089
break;
161509162090
case 133: /* sortlist ::= expr sortorder nulls */
161510162091
{
161511
- yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy602); /*A-overwrites-Y*/
161512
- sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy338,yymsp[-1].minor.yy60,yymsp[0].minor.yy60);
162092
+ yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy404); /*A-overwrites-Y*/
162093
+ sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy70,yymsp[-1].minor.yy376,yymsp[0].minor.yy376);
161513162094
}
161514162095
break;
161515162096
case 134: /* sortorder ::= ASC */
161516
-{yymsp[0].minor.yy60 = SQLITE_SO_ASC;}
162097
+{yymsp[0].minor.yy376 = SQLITE_SO_ASC;}
161517162098
break;
161518162099
case 135: /* sortorder ::= DESC */
161519
-{yymsp[0].minor.yy60 = SQLITE_SO_DESC;}
162100
+{yymsp[0].minor.yy376 = SQLITE_SO_DESC;}
161520162101
break;
161521162102
case 136: /* sortorder ::= */
161522162103
case 139: /* nulls ::= */ yytestcase(yyruleno==139);
161523
-{yymsp[1].minor.yy60 = SQLITE_SO_UNDEFINED;}
162104
+{yymsp[1].minor.yy376 = SQLITE_SO_UNDEFINED;}
161524162105
break;
161525162106
case 137: /* nulls ::= NULLS FIRST */
161526
-{yymsp[-1].minor.yy60 = SQLITE_SO_ASC;}
162107
+{yymsp[-1].minor.yy376 = SQLITE_SO_ASC;}
161527162108
break;
161528162109
case 138: /* nulls ::= NULLS LAST */
161529
-{yymsp[-1].minor.yy60 = SQLITE_SO_DESC;}
162110
+{yymsp[-1].minor.yy376 = SQLITE_SO_DESC;}
161530162111
break;
161531162112
case 145: /* limit_opt ::= LIMIT expr */
161532
-{yymsp[-1].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy602,0);}
162113
+{yymsp[-1].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy404,0);}
161533162114
break;
161534162115
case 146: /* limit_opt ::= LIMIT expr OFFSET expr */
161535
-{yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);}
162116
+{yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);}
161536162117
break;
161537162118
case 147: /* limit_opt ::= LIMIT expr COMMA expr */
161538
-{yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy602,yymsp[-2].minor.yy602);}
162119
+{yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy404,yymsp[-2].minor.yy404);}
161539162120
break;
161540162121
case 148: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
161541162122
{
161542
- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy291, &yymsp[-1].minor.yy0);
161543
- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy291,yymsp[0].minor.yy602,0,0);
162123
+ sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy153, &yymsp[-1].minor.yy0);
162124
+ sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy153,yymsp[0].minor.yy404,0,0);
161544162125
}
161545162126
break;
161546162127
case 153: /* where_opt_ret ::= RETURNING selcollist */
161547
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy338); yymsp[-1].minor.yy602 = 0;}
162128
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy70); yymsp[-1].minor.yy404 = 0;}
161548162129
break;
161549162130
case 154: /* where_opt_ret ::= WHERE expr RETURNING selcollist */
161550
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy338); yymsp[-3].minor.yy602 = yymsp[-2].minor.yy602;}
162131
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy70); yymsp[-3].minor.yy404 = yymsp[-2].minor.yy404;}
161551162132
break;
161552162133
case 155: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
161553162134
{
161554
- sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy291, &yymsp[-4].minor.yy0);
161555
- sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy338,"set list");
161556
- yymsp[-5].minor.yy291 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy291, yymsp[-1].minor.yy291);
161557
- sqlite3Update(pParse,yymsp[-5].minor.yy291,yymsp[-2].minor.yy338,yymsp[0].minor.yy602,yymsp[-6].minor.yy60,0,0,0);
162135
+ sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy153, &yymsp[-4].minor.yy0);
162136
+ sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy70,"set list");
162137
+ yymsp[-5].minor.yy153 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy153, yymsp[-1].minor.yy153);
162138
+ sqlite3Update(pParse,yymsp[-5].minor.yy153,yymsp[-2].minor.yy70,yymsp[0].minor.yy404,yymsp[-6].minor.yy376,0,0,0);
161558162139
}
161559162140
break;
161560162141
case 156: /* setlist ::= setlist COMMA nm EQ expr */
161561162142
{
161562
- yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy338, yymsp[0].minor.yy602);
161563
- sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy338, &yymsp[-2].minor.yy0, 1);
162143
+ yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy70, yymsp[0].minor.yy404);
162144
+ sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy70, &yymsp[-2].minor.yy0, 1);
161564162145
}
161565162146
break;
161566162147
case 157: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
161567162148
{
161568
- yymsp[-6].minor.yy338 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy338, yymsp[-3].minor.yy288, yymsp[0].minor.yy602);
162149
+ yymsp[-6].minor.yy70 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy70, yymsp[-3].minor.yy436, yymsp[0].minor.yy404);
161569162150
}
161570162151
break;
161571162152
case 158: /* setlist ::= nm EQ expr */
161572162153
{
161573
- yylhsminor.yy338 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy602);
161574
- sqlite3ExprListSetName(pParse, yylhsminor.yy338, &yymsp[-2].minor.yy0, 1);
162154
+ yylhsminor.yy70 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy404);
162155
+ sqlite3ExprListSetName(pParse, yylhsminor.yy70, &yymsp[-2].minor.yy0, 1);
161575162156
}
161576
- yymsp[-2].minor.yy338 = yylhsminor.yy338;
162157
+ yymsp[-2].minor.yy70 = yylhsminor.yy70;
161577162158
break;
161578162159
case 159: /* setlist ::= LP idlist RP EQ expr */
161579162160
{
161580
- yymsp[-4].minor.yy338 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy288, yymsp[0].minor.yy602);
162161
+ yymsp[-4].minor.yy70 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy436, yymsp[0].minor.yy404);
161581162162
}
161582162163
break;
161583162164
case 160: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
161584162165
{
161585
- sqlite3Insert(pParse, yymsp[-3].minor.yy291, yymsp[-1].minor.yy307, yymsp[-2].minor.yy288, yymsp[-5].minor.yy60, yymsp[0].minor.yy178);
162166
+ sqlite3Insert(pParse, yymsp[-3].minor.yy153, yymsp[-1].minor.yy81, yymsp[-2].minor.yy436, yymsp[-5].minor.yy376, yymsp[0].minor.yy190);
161586162167
}
161587162168
break;
161588162169
case 161: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
161589162170
{
161590
- sqlite3Insert(pParse, yymsp[-4].minor.yy291, 0, yymsp[-3].minor.yy288, yymsp[-6].minor.yy60, 0);
162171
+ sqlite3Insert(pParse, yymsp[-4].minor.yy153, 0, yymsp[-3].minor.yy436, yymsp[-6].minor.yy376, 0);
161591162172
}
161592162173
break;
161593162174
case 162: /* upsert ::= */
161594
-{ yymsp[1].minor.yy178 = 0; }
162175
+{ yymsp[1].minor.yy190 = 0; }
161595162176
break;
161596162177
case 163: /* upsert ::= RETURNING selcollist */
161597
-{ yymsp[-1].minor.yy178 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy338); }
162178
+{ yymsp[-1].minor.yy190 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy70); }
161598162179
break;
161599162180
case 164: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
161600
-{ yymsp[-11].minor.yy178 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy338,yymsp[-6].minor.yy602,yymsp[-2].minor.yy338,yymsp[-1].minor.yy602,yymsp[0].minor.yy178);}
162181
+{ yymsp[-11].minor.yy190 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy70,yymsp[-6].minor.yy404,yymsp[-2].minor.yy70,yymsp[-1].minor.yy404,yymsp[0].minor.yy190);}
161601162182
break;
161602162183
case 165: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
161603
-{ yymsp[-8].minor.yy178 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy338,yymsp[-3].minor.yy602,0,0,yymsp[0].minor.yy178); }
162184
+{ yymsp[-8].minor.yy190 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy70,yymsp[-3].minor.yy404,0,0,yymsp[0].minor.yy190); }
161604162185
break;
161605162186
case 166: /* upsert ::= ON CONFLICT DO NOTHING returning */
161606
-{ yymsp[-4].minor.yy178 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
162187
+{ yymsp[-4].minor.yy190 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
161607162188
break;
161608162189
case 167: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
161609
-{ yymsp[-7].minor.yy178 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy338,yymsp[-1].minor.yy602,0);}
162190
+{ yymsp[-7].minor.yy190 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy70,yymsp[-1].minor.yy404,0);}
161610162191
break;
161611162192
case 168: /* returning ::= RETURNING selcollist */
161612
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy338);}
162193
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy70);}
161613162194
break;
161614162195
case 172: /* idlist_opt ::= LP idlist RP */
161615
-{yymsp[-2].minor.yy288 = yymsp[-1].minor.yy288;}
162196
+{yymsp[-2].minor.yy436 = yymsp[-1].minor.yy436;}
161616162197
break;
161617162198
case 173: /* idlist ::= idlist COMMA nm */
161618
-{yymsp[-2].minor.yy288 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy288,&yymsp[0].minor.yy0);}
162199
+{yymsp[-2].minor.yy436 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy436,&yymsp[0].minor.yy0);}
161619162200
break;
161620162201
case 174: /* idlist ::= nm */
161621
-{yymsp[0].minor.yy288 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
162202
+{yymsp[0].minor.yy436 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
161622162203
break;
161623162204
case 175: /* expr ::= LP expr RP */
161624
-{yymsp[-2].minor.yy602 = yymsp[-1].minor.yy602;}
162205
+{yymsp[-2].minor.yy404 = yymsp[-1].minor.yy404;}
161625162206
break;
161626162207
case 176: /* expr ::= ID|INDEXED */
161627162208
case 177: /* expr ::= JOIN_KW */ yytestcase(yyruleno==177);
161628
-{yymsp[0].minor.yy602=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
162209
+{yymsp[0].minor.yy404=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
161629162210
break;
161630162211
case 178: /* expr ::= nm DOT nm */
161631162212
{
161632162213
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
161633162214
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
161634162215
if( IN_RENAME_OBJECT ){
161635162216
sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
161636162217
sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
161637162218
}
161638
- yylhsminor.yy602 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
162219
+ yylhsminor.yy404 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
161639162220
}
161640
- yymsp[-2].minor.yy602 = yylhsminor.yy602;
162221
+ yymsp[-2].minor.yy404 = yylhsminor.yy404;
161641162222
break;
161642162223
case 179: /* expr ::= nm DOT nm DOT nm */
161643162224
{
161644162225
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
161645162226
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
@@ -161647,322 +162228,322 @@
161647162228
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
161648162229
if( IN_RENAME_OBJECT ){
161649162230
sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
161650162231
sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
161651162232
}
161652
- yylhsminor.yy602 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
162233
+ yylhsminor.yy404 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
161653162234
}
161654
- yymsp[-4].minor.yy602 = yylhsminor.yy602;
162235
+ yymsp[-4].minor.yy404 = yylhsminor.yy404;
161655162236
break;
161656162237
case 180: /* term ::= NULL|FLOAT|BLOB */
161657162238
case 181: /* term ::= STRING */ yytestcase(yyruleno==181);
161658
-{yymsp[0].minor.yy602=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
162239
+{yymsp[0].minor.yy404=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
161659162240
break;
161660162241
case 182: /* term ::= INTEGER */
161661162242
{
161662
- yylhsminor.yy602 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
162243
+ yylhsminor.yy404 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
161663162244
}
161664
- yymsp[0].minor.yy602 = yylhsminor.yy602;
162245
+ yymsp[0].minor.yy404 = yylhsminor.yy404;
161665162246
break;
161666162247
case 183: /* expr ::= VARIABLE */
161667162248
{
161668162249
if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
161669162250
u32 n = yymsp[0].minor.yy0.n;
161670
- yymsp[0].minor.yy602 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
161671
- sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy602, n);
162251
+ yymsp[0].minor.yy404 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
162252
+ sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy404, n);
161672162253
}else{
161673162254
/* When doing a nested parse, one can include terms in an expression
161674162255
** that look like this: #1 #2 ... These terms refer to registers
161675162256
** in the virtual machine. #N is the N-th register. */
161676162257
Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
161677162258
assert( t.n>=2 );
161678162259
if( pParse->nested==0 ){
161679162260
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
161680
- yymsp[0].minor.yy602 = 0;
162261
+ yymsp[0].minor.yy404 = 0;
161681162262
}else{
161682
- yymsp[0].minor.yy602 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
161683
- if( yymsp[0].minor.yy602 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy602->iTable);
162263
+ yymsp[0].minor.yy404 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
162264
+ if( yymsp[0].minor.yy404 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy404->iTable);
161684162265
}
161685162266
}
161686162267
}
161687162268
break;
161688162269
case 184: /* expr ::= expr COLLATE ID|STRING */
161689162270
{
161690
- yymsp[-2].minor.yy602 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy602, &yymsp[0].minor.yy0, 1);
162271
+ yymsp[-2].minor.yy404 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy404, &yymsp[0].minor.yy0, 1);
161691162272
}
161692162273
break;
161693162274
case 185: /* expr ::= CAST LP expr AS typetoken RP */
161694162275
{
161695
- yymsp[-5].minor.yy602 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
161696
- sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy602, yymsp[-3].minor.yy602, 0);
162276
+ yymsp[-5].minor.yy404 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
162277
+ sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy404, yymsp[-3].minor.yy404, 0);
161697162278
}
161698162279
break;
161699162280
case 186: /* expr ::= ID|INDEXED LP distinct exprlist RP */
161700162281
{
161701
- yylhsminor.yy602 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy338, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy60);
162282
+ yylhsminor.yy404 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy70, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy376);
161702162283
}
161703
- yymsp[-4].minor.yy602 = yylhsminor.yy602;
162284
+ yymsp[-4].minor.yy404 = yylhsminor.yy404;
161704162285
break;
161705162286
case 187: /* expr ::= ID|INDEXED LP STAR RP */
161706162287
{
161707
- yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
162288
+ yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
161708162289
}
161709
- yymsp[-3].minor.yy602 = yylhsminor.yy602;
162290
+ yymsp[-3].minor.yy404 = yylhsminor.yy404;
161710162291
break;
161711162292
case 188: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
161712162293
{
161713
- yylhsminor.yy602 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy338, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy60);
161714
- sqlite3WindowAttach(pParse, yylhsminor.yy602, yymsp[0].minor.yy19);
162294
+ yylhsminor.yy404 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy70, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy376);
162295
+ sqlite3WindowAttach(pParse, yylhsminor.yy404, yymsp[0].minor.yy49);
161715162296
}
161716
- yymsp[-5].minor.yy602 = yylhsminor.yy602;
162297
+ yymsp[-5].minor.yy404 = yylhsminor.yy404;
161717162298
break;
161718162299
case 189: /* expr ::= ID|INDEXED LP STAR RP filter_over */
161719162300
{
161720
- yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
161721
- sqlite3WindowAttach(pParse, yylhsminor.yy602, yymsp[0].minor.yy19);
162301
+ yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
162302
+ sqlite3WindowAttach(pParse, yylhsminor.yy404, yymsp[0].minor.yy49);
161722162303
}
161723
- yymsp[-4].minor.yy602 = yylhsminor.yy602;
162304
+ yymsp[-4].minor.yy404 = yylhsminor.yy404;
161724162305
break;
161725162306
case 190: /* term ::= CTIME_KW */
161726162307
{
161727
- yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
162308
+ yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
161728162309
}
161729
- yymsp[0].minor.yy602 = yylhsminor.yy602;
162310
+ yymsp[0].minor.yy404 = yylhsminor.yy404;
161730162311
break;
161731162312
case 191: /* expr ::= LP nexprlist COMMA expr RP */
161732162313
{
161733
- ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy338, yymsp[-1].minor.yy602);
161734
- yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
161735
- if( yymsp[-4].minor.yy602 ){
161736
- yymsp[-4].minor.yy602->x.pList = pList;
162314
+ ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy70, yymsp[-1].minor.yy404);
162315
+ yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
162316
+ if( yymsp[-4].minor.yy404 ){
162317
+ yymsp[-4].minor.yy404->x.pList = pList;
161737162318
if( ALWAYS(pList->nExpr) ){
161738
- yymsp[-4].minor.yy602->flags |= pList->a[0].pExpr->flags & EP_Propagate;
162319
+ yymsp[-4].minor.yy404->flags |= pList->a[0].pExpr->flags & EP_Propagate;
161739162320
}
161740162321
}else{
161741162322
sqlite3ExprListDelete(pParse->db, pList);
161742162323
}
161743162324
}
161744162325
break;
161745162326
case 192: /* expr ::= expr AND expr */
161746
-{yymsp[-2].minor.yy602=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);}
162327
+{yymsp[-2].minor.yy404=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);}
161747162328
break;
161748162329
case 193: /* expr ::= expr OR expr */
161749162330
case 194: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==194);
161750162331
case 195: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==195);
161751162332
case 196: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==196);
161752162333
case 197: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==197);
161753162334
case 198: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==198);
161754162335
case 199: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==199);
161755
-{yymsp[-2].minor.yy602=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);}
162336
+{yymsp[-2].minor.yy404=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);}
161756162337
break;
161757162338
case 200: /* likeop ::= NOT LIKE_KW|MATCH */
161758162339
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
161759162340
break;
161760162341
case 201: /* expr ::= expr likeop expr */
161761162342
{
161762162343
ExprList *pList;
161763162344
int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
161764162345
yymsp[-1].minor.yy0.n &= 0x7fffffff;
161765
- pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy602);
161766
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy602);
161767
- yymsp[-2].minor.yy602 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
161768
- if( bNot ) yymsp[-2].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy602, 0);
161769
- if( yymsp[-2].minor.yy602 ) yymsp[-2].minor.yy602->flags |= EP_InfixFunc;
162346
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy404);
162347
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy404);
162348
+ yymsp[-2].minor.yy404 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
162349
+ if( bNot ) yymsp[-2].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy404, 0);
162350
+ if( yymsp[-2].minor.yy404 ) yymsp[-2].minor.yy404->flags |= EP_InfixFunc;
161770162351
}
161771162352
break;
161772162353
case 202: /* expr ::= expr likeop expr ESCAPE expr */
161773162354
{
161774162355
ExprList *pList;
161775162356
int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
161776162357
yymsp[-3].minor.yy0.n &= 0x7fffffff;
161777
- pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602);
161778
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy602);
161779
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy602);
161780
- yymsp[-4].minor.yy602 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
161781
- if( bNot ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0);
161782
- if( yymsp[-4].minor.yy602 ) yymsp[-4].minor.yy602->flags |= EP_InfixFunc;
162358
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404);
162359
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy404);
162360
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy404);
162361
+ yymsp[-4].minor.yy404 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
162362
+ if( bNot ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
162363
+ if( yymsp[-4].minor.yy404 ) yymsp[-4].minor.yy404->flags |= EP_InfixFunc;
161783162364
}
161784162365
break;
161785162366
case 203: /* expr ::= expr ISNULL|NOTNULL */
161786
-{yymsp[-1].minor.yy602 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy602,0);}
162367
+{yymsp[-1].minor.yy404 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy404,0);}
161787162368
break;
161788162369
case 204: /* expr ::= expr NOT NULL */
161789
-{yymsp[-2].minor.yy602 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy602,0);}
162370
+{yymsp[-2].minor.yy404 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy404,0);}
161790162371
break;
161791162372
case 205: /* expr ::= expr IS expr */
161792162373
{
161793
- yymsp[-2].minor.yy602 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);
161794
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy602, yymsp[-2].minor.yy602, TK_ISNULL);
162374
+ yymsp[-2].minor.yy404 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);
162375
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy404, yymsp[-2].minor.yy404, TK_ISNULL);
161795162376
}
161796162377
break;
161797162378
case 206: /* expr ::= expr IS NOT expr */
161798162379
{
161799
- yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy602,yymsp[0].minor.yy602);
161800
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy602, yymsp[-3].minor.yy602, TK_NOTNULL);
162380
+ yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy404,yymsp[0].minor.yy404);
162381
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy404, yymsp[-3].minor.yy404, TK_NOTNULL);
161801162382
}
161802162383
break;
161803162384
case 207: /* expr ::= NOT expr */
161804162385
case 208: /* expr ::= BITNOT expr */ yytestcase(yyruleno==208);
161805
-{yymsp[-1].minor.yy602 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy602, 0);/*A-overwrites-B*/}
162386
+{yymsp[-1].minor.yy404 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy404, 0);/*A-overwrites-B*/}
161806162387
break;
161807162388
case 209: /* expr ::= PLUS|MINUS expr */
161808162389
{
161809
- yymsp[-1].minor.yy602 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy602, 0);
162390
+ yymsp[-1].minor.yy404 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy404, 0);
161810162391
/*A-overwrites-B*/
161811162392
}
161812162393
break;
161813162394
case 210: /* between_op ::= BETWEEN */
161814162395
case 213: /* in_op ::= IN */ yytestcase(yyruleno==213);
161815
-{yymsp[0].minor.yy60 = 0;}
162396
+{yymsp[0].minor.yy376 = 0;}
161816162397
break;
161817162398
case 212: /* expr ::= expr between_op expr AND expr */
161818162399
{
161819
- ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602);
161820
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy602);
161821
- yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy602, 0);
161822
- if( yymsp[-4].minor.yy602 ){
161823
- yymsp[-4].minor.yy602->x.pList = pList;
162400
+ ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404);
162401
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy404);
162402
+ yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy404, 0);
162403
+ if( yymsp[-4].minor.yy404 ){
162404
+ yymsp[-4].minor.yy404->x.pList = pList;
161824162405
}else{
161825162406
sqlite3ExprListDelete(pParse->db, pList);
161826162407
}
161827
- if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0);
162408
+ if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
161828162409
}
161829162410
break;
161830162411
case 215: /* expr ::= expr in_op LP exprlist RP */
161831162412
{
161832
- if( yymsp[-1].minor.yy338==0 ){
162413
+ if( yymsp[-1].minor.yy70==0 ){
161833162414
/* Expressions of the form
161834162415
**
161835162416
** expr1 IN ()
161836162417
** expr1 NOT IN ()
161837162418
**
161838162419
** simplify to constants 0 (false) and 1 (true), respectively,
161839162420
** regardless of the value of expr1.
161840162421
*/
161841
- sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy602);
161842
- yymsp[-4].minor.yy602 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy60 ? "1" : "0");
161843
- }else if( yymsp[-1].minor.yy338->nExpr==1 && sqlite3ExprIsConstant(yymsp[-1].minor.yy338->a[0].pExpr) ){
161844
- Expr *pRHS = yymsp[-1].minor.yy338->a[0].pExpr;
161845
- yymsp[-1].minor.yy338->a[0].pExpr = 0;
161846
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy338);
162422
+ sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy404);
162423
+ yymsp[-4].minor.yy404 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy376 ? "1" : "0");
162424
+ }else if( yymsp[-1].minor.yy70->nExpr==1 && sqlite3ExprIsConstant(yymsp[-1].minor.yy70->a[0].pExpr) ){
162425
+ Expr *pRHS = yymsp[-1].minor.yy70->a[0].pExpr;
162426
+ yymsp[-1].minor.yy70->a[0].pExpr = 0;
162427
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70);
161847162428
pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
161848
- yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy602, pRHS);
161849
- if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0);
161850
- }else{
161851
- yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0);
161852
- if( yymsp[-4].minor.yy602 ){
161853
- yymsp[-4].minor.yy602->x.pList = yymsp[-1].minor.yy338;
161854
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy602);
161855
- }else{
161856
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy338);
161857
- }
161858
- if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0);
162429
+ yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy404, pRHS);
162430
+ if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
162431
+ }else{
162432
+ yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0);
162433
+ if( yymsp[-4].minor.yy404 ){
162434
+ yymsp[-4].minor.yy404->x.pList = yymsp[-1].minor.yy70;
162435
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy404);
162436
+ }else{
162437
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70);
162438
+ }
162439
+ if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
161859162440
}
161860162441
}
161861162442
break;
161862162443
case 216: /* expr ::= LP select RP */
161863162444
{
161864
- yymsp[-2].minor.yy602 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
161865
- sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy602, yymsp[-1].minor.yy307);
162445
+ yymsp[-2].minor.yy404 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
162446
+ sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy404, yymsp[-1].minor.yy81);
161866162447
}
161867162448
break;
161868162449
case 217: /* expr ::= expr in_op LP select RP */
161869162450
{
161870
- yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0);
161871
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy602, yymsp[-1].minor.yy307);
161872
- if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0);
162451
+ yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0);
162452
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy404, yymsp[-1].minor.yy81);
162453
+ if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
161873162454
}
161874162455
break;
161875162456
case 218: /* expr ::= expr in_op nm dbnm paren_exprlist */
161876162457
{
161877162458
SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
161878162459
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
161879
- if( yymsp[0].minor.yy338 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy338);
161880
- yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0);
161881
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy602, pSelect);
161882
- if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0);
162460
+ if( yymsp[0].minor.yy70 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy70);
162461
+ yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0);
162462
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy404, pSelect);
162463
+ if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
161883162464
}
161884162465
break;
161885162466
case 219: /* expr ::= EXISTS LP select RP */
161886162467
{
161887162468
Expr *p;
161888
- p = yymsp[-3].minor.yy602 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
161889
- sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy307);
162469
+ p = yymsp[-3].minor.yy404 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
162470
+ sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy81);
161890162471
}
161891162472
break;
161892162473
case 220: /* expr ::= CASE case_operand case_exprlist case_else END */
161893162474
{
161894
- yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy602, 0);
161895
- if( yymsp[-4].minor.yy602 ){
161896
- yymsp[-4].minor.yy602->x.pList = yymsp[-1].minor.yy602 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy338,yymsp[-1].minor.yy602) : yymsp[-2].minor.yy338;
161897
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy602);
162475
+ yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy404, 0);
162476
+ if( yymsp[-4].minor.yy404 ){
162477
+ yymsp[-4].minor.yy404->x.pList = yymsp[-1].minor.yy404 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy70,yymsp[-1].minor.yy404) : yymsp[-2].minor.yy70;
162478
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy404);
161898162479
}else{
161899
- sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy338);
161900
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy602);
162480
+ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy70);
162481
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy404);
161901162482
}
161902162483
}
161903162484
break;
161904162485
case 221: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
161905162486
{
161906
- yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, yymsp[-2].minor.yy602);
161907
- yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, yymsp[0].minor.yy602);
162487
+ yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, yymsp[-2].minor.yy404);
162488
+ yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, yymsp[0].minor.yy404);
161908162489
}
161909162490
break;
161910162491
case 222: /* case_exprlist ::= WHEN expr THEN expr */
161911162492
{
161912
- yymsp[-3].minor.yy338 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602);
161913
- yymsp[-3].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy338, yymsp[0].minor.yy602);
162493
+ yymsp[-3].minor.yy70 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404);
162494
+ yymsp[-3].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy70, yymsp[0].minor.yy404);
161914162495
}
161915162496
break;
161916162497
case 225: /* case_operand ::= expr */
161917
-{yymsp[0].minor.yy602 = yymsp[0].minor.yy602; /*A-overwrites-X*/}
162498
+{yymsp[0].minor.yy404 = yymsp[0].minor.yy404; /*A-overwrites-X*/}
161918162499
break;
161919162500
case 228: /* nexprlist ::= nexprlist COMMA expr */
161920
-{yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy338,yymsp[0].minor.yy602);}
162501
+{yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy70,yymsp[0].minor.yy404);}
161921162502
break;
161922162503
case 229: /* nexprlist ::= expr */
161923
-{yymsp[0].minor.yy338 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy602); /*A-overwrites-Y*/}
162504
+{yymsp[0].minor.yy70 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy404); /*A-overwrites-Y*/}
161924162505
break;
161925162506
case 231: /* paren_exprlist ::= LP exprlist RP */
161926162507
case 236: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==236);
161927
-{yymsp[-2].minor.yy338 = yymsp[-1].minor.yy338;}
162508
+{yymsp[-2].minor.yy70 = yymsp[-1].minor.yy70;}
161928162509
break;
161929162510
case 232: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
161930162511
{
161931162512
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
161932
- sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy338, yymsp[-10].minor.yy60,
161933
- &yymsp[-11].minor.yy0, yymsp[0].minor.yy602, SQLITE_SO_ASC, yymsp[-8].minor.yy60, SQLITE_IDXTYPE_APPDEF);
162513
+ sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy70, yymsp[-10].minor.yy376,
162514
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy404, SQLITE_SO_ASC, yymsp[-8].minor.yy376, SQLITE_IDXTYPE_APPDEF);
161934162515
if( IN_RENAME_OBJECT && pParse->pNewIndex ){
161935162516
sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
161936162517
}
161937162518
}
161938162519
break;
161939162520
case 233: /* uniqueflag ::= UNIQUE */
161940162521
case 275: /* raisetype ::= ABORT */ yytestcase(yyruleno==275);
161941
-{yymsp[0].minor.yy60 = OE_Abort;}
162522
+{yymsp[0].minor.yy376 = OE_Abort;}
161942162523
break;
161943162524
case 234: /* uniqueflag ::= */
161944
-{yymsp[1].minor.yy60 = OE_None;}
162525
+{yymsp[1].minor.yy376 = OE_None;}
161945162526
break;
161946162527
case 237: /* eidlist ::= eidlist COMMA nm collate sortorder */
161947162528
{
161948
- yymsp[-4].minor.yy338 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy338, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy60, yymsp[0].minor.yy60);
162529
+ yymsp[-4].minor.yy70 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy70, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy376, yymsp[0].minor.yy376);
161949162530
}
161950162531
break;
161951162532
case 238: /* eidlist ::= nm collate sortorder */
161952162533
{
161953
- yymsp[-2].minor.yy338 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy60, yymsp[0].minor.yy60); /*A-overwrites-Y*/
162534
+ yymsp[-2].minor.yy70 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy376, yymsp[0].minor.yy376); /*A-overwrites-Y*/
161954162535
}
161955162536
break;
161956162537
case 241: /* cmd ::= DROP INDEX ifexists fullname */
161957
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy291, yymsp[-1].minor.yy60);}
162538
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy153, yymsp[-1].minor.yy376);}
161958162539
break;
161959162540
case 242: /* cmd ::= VACUUM vinto */
161960
-{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy602);}
162541
+{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy404);}
161961162542
break;
161962162543
case 243: /* cmd ::= VACUUM nm vinto */
161963
-{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy602);}
162544
+{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy404);}
161964162545
break;
161965162546
case 246: /* cmd ::= PRAGMA nm dbnm */
161966162547
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
161967162548
break;
161968162549
case 247: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
@@ -161980,54 +162561,54 @@
161980162561
case 253: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
161981162562
{
161982162563
Token all;
161983162564
all.z = yymsp[-3].minor.yy0.z;
161984162565
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
161985
- sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy483, &all);
162566
+ sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy157, &all);
161986162567
}
161987162568
break;
161988162569
case 254: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
161989162570
{
161990
- sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy60, yymsp[-4].minor.yy50.a, yymsp[-4].minor.yy50.b, yymsp[-2].minor.yy291, yymsp[0].minor.yy602, yymsp[-10].minor.yy60, yymsp[-8].minor.yy60);
162571
+ sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy376, yymsp[-4].minor.yy262.a, yymsp[-4].minor.yy262.b, yymsp[-2].minor.yy153, yymsp[0].minor.yy404, yymsp[-10].minor.yy376, yymsp[-8].minor.yy376);
161991162572
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
161992162573
}
161993162574
break;
161994162575
case 255: /* trigger_time ::= BEFORE|AFTER */
161995
-{ yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-X*/ }
162576
+{ yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-X*/ }
161996162577
break;
161997162578
case 256: /* trigger_time ::= INSTEAD OF */
161998
-{ yymsp[-1].minor.yy60 = TK_INSTEAD;}
162579
+{ yymsp[-1].minor.yy376 = TK_INSTEAD;}
161999162580
break;
162000162581
case 257: /* trigger_time ::= */
162001
-{ yymsp[1].minor.yy60 = TK_BEFORE; }
162582
+{ yymsp[1].minor.yy376 = TK_BEFORE; }
162002162583
break;
162003162584
case 258: /* trigger_event ::= DELETE|INSERT */
162004162585
case 259: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==259);
162005
-{yymsp[0].minor.yy50.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy50.b = 0;}
162586
+{yymsp[0].minor.yy262.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy262.b = 0;}
162006162587
break;
162007162588
case 260: /* trigger_event ::= UPDATE OF idlist */
162008
-{yymsp[-2].minor.yy50.a = TK_UPDATE; yymsp[-2].minor.yy50.b = yymsp[0].minor.yy288;}
162589
+{yymsp[-2].minor.yy262.a = TK_UPDATE; yymsp[-2].minor.yy262.b = yymsp[0].minor.yy436;}
162009162590
break;
162010162591
case 261: /* when_clause ::= */
162011162592
case 280: /* key_opt ::= */ yytestcase(yyruleno==280);
162012
-{ yymsp[1].minor.yy602 = 0; }
162593
+{ yymsp[1].minor.yy404 = 0; }
162013162594
break;
162014162595
case 262: /* when_clause ::= WHEN expr */
162015162596
case 281: /* key_opt ::= KEY expr */ yytestcase(yyruleno==281);
162016
-{ yymsp[-1].minor.yy602 = yymsp[0].minor.yy602; }
162597
+{ yymsp[-1].minor.yy404 = yymsp[0].minor.yy404; }
162017162598
break;
162018162599
case 263: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
162019162600
{
162020
- assert( yymsp[-2].minor.yy483!=0 );
162021
- yymsp[-2].minor.yy483->pLast->pNext = yymsp[-1].minor.yy483;
162022
- yymsp[-2].minor.yy483->pLast = yymsp[-1].minor.yy483;
162601
+ assert( yymsp[-2].minor.yy157!=0 );
162602
+ yymsp[-2].minor.yy157->pLast->pNext = yymsp[-1].minor.yy157;
162603
+ yymsp[-2].minor.yy157->pLast = yymsp[-1].minor.yy157;
162023162604
}
162024162605
break;
162025162606
case 264: /* trigger_cmd_list ::= trigger_cmd SEMI */
162026162607
{
162027
- assert( yymsp[-1].minor.yy483!=0 );
162028
- yymsp[-1].minor.yy483->pLast = yymsp[-1].minor.yy483;
162608
+ assert( yymsp[-1].minor.yy157!=0 );
162609
+ yymsp[-1].minor.yy157->pLast = yymsp[-1].minor.yy157;
162029162610
}
162030162611
break;
162031162612
case 265: /* trnm ::= nm DOT nm */
162032162613
{
162033162614
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
@@ -162049,62 +162630,62 @@
162049162630
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
162050162631
"within triggers");
162051162632
}
162052162633
break;
162053162634
case 268: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
162054
-{yylhsminor.yy483 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy291, yymsp[-3].minor.yy338, yymsp[-1].minor.yy602, yymsp[-7].minor.yy60, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy528);}
162055
- yymsp[-8].minor.yy483 = yylhsminor.yy483;
162635
+{yylhsminor.yy157 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy153, yymsp[-3].minor.yy70, yymsp[-1].minor.yy404, yymsp[-7].minor.yy376, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy504);}
162636
+ yymsp[-8].minor.yy157 = yylhsminor.yy157;
162056162637
break;
162057162638
case 269: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
162058162639
{
162059
- yylhsminor.yy483 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy288,yymsp[-2].minor.yy307,yymsp[-6].minor.yy60,yymsp[-1].minor.yy178,yymsp[-7].minor.yy528,yymsp[0].minor.yy528);/*yylhsminor.yy483-overwrites-yymsp[-6].minor.yy60*/
162640
+ yylhsminor.yy157 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy436,yymsp[-2].minor.yy81,yymsp[-6].minor.yy376,yymsp[-1].minor.yy190,yymsp[-7].minor.yy504,yymsp[0].minor.yy504);/*yylhsminor.yy157-overwrites-yymsp[-6].minor.yy376*/
162060162641
}
162061
- yymsp[-7].minor.yy483 = yylhsminor.yy483;
162642
+ yymsp[-7].minor.yy157 = yylhsminor.yy157;
162062162643
break;
162063162644
case 270: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
162064
-{yylhsminor.yy483 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy602, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy528);}
162065
- yymsp[-5].minor.yy483 = yylhsminor.yy483;
162645
+{yylhsminor.yy157 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy404, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy504);}
162646
+ yymsp[-5].minor.yy157 = yylhsminor.yy157;
162066162647
break;
162067162648
case 271: /* trigger_cmd ::= scanpt select scanpt */
162068
-{yylhsminor.yy483 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy307, yymsp[-2].minor.yy528, yymsp[0].minor.yy528); /*yylhsminor.yy483-overwrites-yymsp[-1].minor.yy307*/}
162069
- yymsp[-2].minor.yy483 = yylhsminor.yy483;
162649
+{yylhsminor.yy157 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy81, yymsp[-2].minor.yy504, yymsp[0].minor.yy504); /*yylhsminor.yy157-overwrites-yymsp[-1].minor.yy81*/}
162650
+ yymsp[-2].minor.yy157 = yylhsminor.yy157;
162070162651
break;
162071162652
case 272: /* expr ::= RAISE LP IGNORE RP */
162072162653
{
162073
- yymsp[-3].minor.yy602 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
162074
- if( yymsp[-3].minor.yy602 ){
162075
- yymsp[-3].minor.yy602->affExpr = OE_Ignore;
162654
+ yymsp[-3].minor.yy404 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
162655
+ if( yymsp[-3].minor.yy404 ){
162656
+ yymsp[-3].minor.yy404->affExpr = OE_Ignore;
162076162657
}
162077162658
}
162078162659
break;
162079162660
case 273: /* expr ::= RAISE LP raisetype COMMA nm RP */
162080162661
{
162081
- yymsp[-5].minor.yy602 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
162082
- if( yymsp[-5].minor.yy602 ) {
162083
- yymsp[-5].minor.yy602->affExpr = (char)yymsp[-3].minor.yy60;
162662
+ yymsp[-5].minor.yy404 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
162663
+ if( yymsp[-5].minor.yy404 ) {
162664
+ yymsp[-5].minor.yy404->affExpr = (char)yymsp[-3].minor.yy376;
162084162665
}
162085162666
}
162086162667
break;
162087162668
case 274: /* raisetype ::= ROLLBACK */
162088
-{yymsp[0].minor.yy60 = OE_Rollback;}
162669
+{yymsp[0].minor.yy376 = OE_Rollback;}
162089162670
break;
162090162671
case 276: /* raisetype ::= FAIL */
162091
-{yymsp[0].minor.yy60 = OE_Fail;}
162672
+{yymsp[0].minor.yy376 = OE_Fail;}
162092162673
break;
162093162674
case 277: /* cmd ::= DROP TRIGGER ifexists fullname */
162094162675
{
162095
- sqlite3DropTrigger(pParse,yymsp[0].minor.yy291,yymsp[-1].minor.yy60);
162676
+ sqlite3DropTrigger(pParse,yymsp[0].minor.yy153,yymsp[-1].minor.yy376);
162096162677
}
162097162678
break;
162098162679
case 278: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
162099162680
{
162100
- sqlite3Attach(pParse, yymsp[-3].minor.yy602, yymsp[-1].minor.yy602, yymsp[0].minor.yy602);
162681
+ sqlite3Attach(pParse, yymsp[-3].minor.yy404, yymsp[-1].minor.yy404, yymsp[0].minor.yy404);
162101162682
}
162102162683
break;
162103162684
case 279: /* cmd ::= DETACH database_kw_opt expr */
162104162685
{
162105
- sqlite3Detach(pParse, yymsp[0].minor.yy602);
162686
+ sqlite3Detach(pParse, yymsp[0].minor.yy404);
162106162687
}
162107162688
break;
162108162689
case 282: /* cmd ::= REINDEX */
162109162690
{sqlite3Reindex(pParse, 0, 0);}
162110162691
break;
@@ -162117,11 +162698,11 @@
162117162698
case 285: /* cmd ::= ANALYZE nm dbnm */
162118162699
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
162119162700
break;
162120162701
case 286: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
162121162702
{
162122
- sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy291,&yymsp[0].minor.yy0);
162703
+ sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy153,&yymsp[0].minor.yy0);
162123162704
}
162124162705
break;
162125162706
case 287: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
162126162707
{
162127162708
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
@@ -162128,22 +162709,22 @@
162128162709
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
162129162710
}
162130162711
break;
162131162712
case 288: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
162132162713
{
162133
- sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy291, &yymsp[0].minor.yy0);
162714
+ sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy153, &yymsp[0].minor.yy0);
162134162715
}
162135162716
break;
162136162717
case 289: /* add_column_fullname ::= fullname */
162137162718
{
162138162719
disableLookaside(pParse);
162139
- sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy291);
162720
+ sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy153);
162140162721
}
162141162722
break;
162142162723
case 290: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
162143162724
{
162144
- sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy291, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
162725
+ sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy153, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
162145162726
}
162146162727
break;
162147162728
case 291: /* cmd ::= create_vtab */
162148162729
{sqlite3VtabFinishParse(pParse,0);}
162149162730
break;
@@ -162150,11 +162731,11 @@
162150162731
case 292: /* cmd ::= create_vtab LP vtabarglist RP */
162151162732
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
162152162733
break;
162153162734
case 293: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
162154162735
{
162155
- sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy60);
162736
+ sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy376);
162156162737
}
162157162738
break;
162158162739
case 294: /* vtabarg ::= */
162159162740
{sqlite3VtabArgInit(pParse);}
162160162741
break;
@@ -162163,176 +162744,180 @@
162163162744
case 297: /* lp ::= LP */ yytestcase(yyruleno==297);
162164162745
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
162165162746
break;
162166162747
case 298: /* with ::= WITH wqlist */
162167162748
case 299: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==299);
162168
-{ sqlite3WithPush(pParse, yymsp[0].minor.yy195, 1); }
162749
+{ sqlite3WithPush(pParse, yymsp[0].minor.yy103, 1); }
162169162750
break;
162170162751
case 300: /* wqas ::= AS */
162171
-{yymsp[0].minor.yy570 = M10d_Any;}
162752
+{yymsp[0].minor.yy552 = M10d_Any;}
162172162753
break;
162173162754
case 301: /* wqas ::= AS MATERIALIZED */
162174
-{yymsp[-1].minor.yy570 = M10d_Yes;}
162755
+{yymsp[-1].minor.yy552 = M10d_Yes;}
162175162756
break;
162176162757
case 302: /* wqas ::= AS NOT MATERIALIZED */
162177
-{yymsp[-2].minor.yy570 = M10d_No;}
162758
+{yymsp[-2].minor.yy552 = M10d_No;}
162178162759
break;
162179162760
case 303: /* wqitem ::= nm eidlist_opt wqas LP select RP */
162180162761
{
162181
- yymsp[-5].minor.yy607 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy338, yymsp[-1].minor.yy307, yymsp[-3].minor.yy570); /*A-overwrites-X*/
162762
+ yymsp[-5].minor.yy329 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy70, yymsp[-1].minor.yy81, yymsp[-3].minor.yy552); /*A-overwrites-X*/
162182162763
}
162183162764
break;
162184162765
case 304: /* wqlist ::= wqitem */
162185162766
{
162186
- yymsp[0].minor.yy195 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy607); /*A-overwrites-X*/
162767
+ yymsp[0].minor.yy103 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy329); /*A-overwrites-X*/
162187162768
}
162188162769
break;
162189162770
case 305: /* wqlist ::= wqlist COMMA wqitem */
162190162771
{
162191
- yymsp[-2].minor.yy195 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy195, yymsp[0].minor.yy607);
162772
+ yymsp[-2].minor.yy103 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy103, yymsp[0].minor.yy329);
162192162773
}
162193162774
break;
162194162775
case 306: /* windowdefn_list ::= windowdefn */
162195
-{ yylhsminor.yy19 = yymsp[0].minor.yy19; }
162196
- yymsp[0].minor.yy19 = yylhsminor.yy19;
162776
+{ yylhsminor.yy49 = yymsp[0].minor.yy49; }
162777
+ yymsp[0].minor.yy49 = yylhsminor.yy49;
162197162778
break;
162198162779
case 307: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
162199162780
{
162200
- assert( yymsp[0].minor.yy19!=0 );
162201
- sqlite3WindowChain(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy19);
162202
- yymsp[0].minor.yy19->pNextWin = yymsp[-2].minor.yy19;
162203
- yylhsminor.yy19 = yymsp[0].minor.yy19;
162781
+ assert( yymsp[0].minor.yy49!=0 );
162782
+ sqlite3WindowChain(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy49);
162783
+ yymsp[0].minor.yy49->pNextWin = yymsp[-2].minor.yy49;
162784
+ yylhsminor.yy49 = yymsp[0].minor.yy49;
162204162785
}
162205
- yymsp[-2].minor.yy19 = yylhsminor.yy19;
162786
+ yymsp[-2].minor.yy49 = yylhsminor.yy49;
162206162787
break;
162207162788
case 308: /* windowdefn ::= nm AS LP window RP */
162208162789
{
162209
- if( ALWAYS(yymsp[-1].minor.yy19) ){
162210
- yymsp[-1].minor.yy19->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
162790
+ if( ALWAYS(yymsp[-1].minor.yy49) ){
162791
+ yymsp[-1].minor.yy49->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
162211162792
}
162212
- yylhsminor.yy19 = yymsp[-1].minor.yy19;
162793
+ yylhsminor.yy49 = yymsp[-1].minor.yy49;
162213162794
}
162214
- yymsp[-4].minor.yy19 = yylhsminor.yy19;
162795
+ yymsp[-4].minor.yy49 = yylhsminor.yy49;
162215162796
break;
162216162797
case 309: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
162217162798
{
162218
- yymsp[-4].minor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy338, yymsp[-1].minor.yy338, 0);
162799
+ yymsp[-4].minor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy70, yymsp[-1].minor.yy70, 0);
162219162800
}
162220162801
break;
162221162802
case 310: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
162222162803
{
162223
- yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy338, yymsp[-1].minor.yy338, &yymsp[-5].minor.yy0);
162804
+ yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy70, yymsp[-1].minor.yy70, &yymsp[-5].minor.yy0);
162224162805
}
162225
- yymsp[-5].minor.yy19 = yylhsminor.yy19;
162806
+ yymsp[-5].minor.yy49 = yylhsminor.yy49;
162226162807
break;
162227162808
case 311: /* window ::= ORDER BY sortlist frame_opt */
162228162809
{
162229
- yymsp[-3].minor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, yymsp[-1].minor.yy338, 0);
162810
+ yymsp[-3].minor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, yymsp[-1].minor.yy70, 0);
162230162811
}
162231162812
break;
162232162813
case 312: /* window ::= nm ORDER BY sortlist frame_opt */
162233162814
{
162234
- yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, yymsp[-1].minor.yy338, &yymsp[-4].minor.yy0);
162815
+ yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, yymsp[-1].minor.yy70, &yymsp[-4].minor.yy0);
162235162816
}
162236
- yymsp[-4].minor.yy19 = yylhsminor.yy19;
162817
+ yymsp[-4].minor.yy49 = yylhsminor.yy49;
162237162818
break;
162238162819
case 313: /* window ::= frame_opt */
162239162820
case 332: /* filter_over ::= over_clause */ yytestcase(yyruleno==332);
162240162821
{
162241
- yylhsminor.yy19 = yymsp[0].minor.yy19;
162822
+ yylhsminor.yy49 = yymsp[0].minor.yy49;
162242162823
}
162243
- yymsp[0].minor.yy19 = yylhsminor.yy19;
162824
+ yymsp[0].minor.yy49 = yylhsminor.yy49;
162244162825
break;
162245162826
case 314: /* window ::= nm frame_opt */
162246162827
{
162247
- yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, 0, &yymsp[-1].minor.yy0);
162828
+ yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, 0, &yymsp[-1].minor.yy0);
162248162829
}
162249
- yymsp[-1].minor.yy19 = yylhsminor.yy19;
162830
+ yymsp[-1].minor.yy49 = yylhsminor.yy49;
162250162831
break;
162251162832
case 315: /* frame_opt ::= */
162252162833
{
162253
- yymsp[1].minor.yy19 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
162834
+ yymsp[1].minor.yy49 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
162254162835
}
162255162836
break;
162256162837
case 316: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
162257162838
{
162258
- yylhsminor.yy19 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy60, yymsp[-1].minor.yy113.eType, yymsp[-1].minor.yy113.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy570);
162839
+ yylhsminor.yy49 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy376, yymsp[-1].minor.yy117.eType, yymsp[-1].minor.yy117.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy552);
162259162840
}
162260
- yymsp[-2].minor.yy19 = yylhsminor.yy19;
162841
+ yymsp[-2].minor.yy49 = yylhsminor.yy49;
162261162842
break;
162262162843
case 317: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
162263162844
{
162264
- yylhsminor.yy19 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy60, yymsp[-3].minor.yy113.eType, yymsp[-3].minor.yy113.pExpr, yymsp[-1].minor.yy113.eType, yymsp[-1].minor.yy113.pExpr, yymsp[0].minor.yy570);
162845
+ yylhsminor.yy49 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy376, yymsp[-3].minor.yy117.eType, yymsp[-3].minor.yy117.pExpr, yymsp[-1].minor.yy117.eType, yymsp[-1].minor.yy117.pExpr, yymsp[0].minor.yy552);
162265162846
}
162266
- yymsp[-5].minor.yy19 = yylhsminor.yy19;
162847
+ yymsp[-5].minor.yy49 = yylhsminor.yy49;
162267162848
break;
162268162849
case 319: /* frame_bound_s ::= frame_bound */
162269162850
case 321: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==321);
162270
-{yylhsminor.yy113 = yymsp[0].minor.yy113;}
162271
- yymsp[0].minor.yy113 = yylhsminor.yy113;
162851
+{yylhsminor.yy117 = yymsp[0].minor.yy117;}
162852
+ yymsp[0].minor.yy117 = yylhsminor.yy117;
162272162853
break;
162273162854
case 320: /* frame_bound_s ::= UNBOUNDED PRECEDING */
162274162855
case 322: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==322);
162275162856
case 324: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==324);
162276
-{yylhsminor.yy113.eType = yymsp[-1].major; yylhsminor.yy113.pExpr = 0;}
162277
- yymsp[-1].minor.yy113 = yylhsminor.yy113;
162857
+{yylhsminor.yy117.eType = yymsp[-1].major; yylhsminor.yy117.pExpr = 0;}
162858
+ yymsp[-1].minor.yy117 = yylhsminor.yy117;
162278162859
break;
162279162860
case 323: /* frame_bound ::= expr PRECEDING|FOLLOWING */
162280
-{yylhsminor.yy113.eType = yymsp[0].major; yylhsminor.yy113.pExpr = yymsp[-1].minor.yy602;}
162281
- yymsp[-1].minor.yy113 = yylhsminor.yy113;
162861
+{yylhsminor.yy117.eType = yymsp[0].major; yylhsminor.yy117.pExpr = yymsp[-1].minor.yy404;}
162862
+ yymsp[-1].minor.yy117 = yylhsminor.yy117;
162282162863
break;
162283162864
case 325: /* frame_exclude_opt ::= */
162284
-{yymsp[1].minor.yy570 = 0;}
162865
+{yymsp[1].minor.yy552 = 0;}
162285162866
break;
162286162867
case 326: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
162287
-{yymsp[-1].minor.yy570 = yymsp[0].minor.yy570;}
162868
+{yymsp[-1].minor.yy552 = yymsp[0].minor.yy552;}
162288162869
break;
162289162870
case 327: /* frame_exclude ::= NO OTHERS */
162290162871
case 328: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==328);
162291
-{yymsp[-1].minor.yy570 = yymsp[-1].major; /*A-overwrites-X*/}
162872
+{yymsp[-1].minor.yy552 = yymsp[-1].major; /*A-overwrites-X*/}
162292162873
break;
162293162874
case 329: /* frame_exclude ::= GROUP|TIES */
162294
-{yymsp[0].minor.yy570 = yymsp[0].major; /*A-overwrites-X*/}
162875
+{yymsp[0].minor.yy552 = yymsp[0].major; /*A-overwrites-X*/}
162295162876
break;
162296162877
case 330: /* window_clause ::= WINDOW windowdefn_list */
162297
-{ yymsp[-1].minor.yy19 = yymsp[0].minor.yy19; }
162878
+{ yymsp[-1].minor.yy49 = yymsp[0].minor.yy49; }
162298162879
break;
162299162880
case 331: /* filter_over ::= filter_clause over_clause */
162300162881
{
162301
- yymsp[0].minor.yy19->pFilter = yymsp[-1].minor.yy602;
162302
- yylhsminor.yy19 = yymsp[0].minor.yy19;
162882
+ if( yymsp[0].minor.yy49 ){
162883
+ yymsp[0].minor.yy49->pFilter = yymsp[-1].minor.yy404;
162884
+ }else{
162885
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy404);
162886
+ }
162887
+ yylhsminor.yy49 = yymsp[0].minor.yy49;
162303162888
}
162304
- yymsp[-1].minor.yy19 = yylhsminor.yy19;
162889
+ yymsp[-1].minor.yy49 = yylhsminor.yy49;
162305162890
break;
162306162891
case 333: /* filter_over ::= filter_clause */
162307162892
{
162308
- yylhsminor.yy19 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
162309
- if( yylhsminor.yy19 ){
162310
- yylhsminor.yy19->eFrmType = TK_FILTER;
162311
- yylhsminor.yy19->pFilter = yymsp[0].minor.yy602;
162893
+ yylhsminor.yy49 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
162894
+ if( yylhsminor.yy49 ){
162895
+ yylhsminor.yy49->eFrmType = TK_FILTER;
162896
+ yylhsminor.yy49->pFilter = yymsp[0].minor.yy404;
162312162897
}else{
162313
- sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy602);
162898
+ sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy404);
162314162899
}
162315162900
}
162316
- yymsp[0].minor.yy19 = yylhsminor.yy19;
162901
+ yymsp[0].minor.yy49 = yylhsminor.yy49;
162317162902
break;
162318162903
case 334: /* over_clause ::= OVER LP window RP */
162319162904
{
162320
- yymsp[-3].minor.yy19 = yymsp[-1].minor.yy19;
162321
- assert( yymsp[-3].minor.yy19!=0 );
162905
+ yymsp[-3].minor.yy49 = yymsp[-1].minor.yy49;
162906
+ assert( yymsp[-3].minor.yy49!=0 );
162322162907
}
162323162908
break;
162324162909
case 335: /* over_clause ::= OVER nm */
162325162910
{
162326
- yymsp[-1].minor.yy19 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
162327
- if( yymsp[-1].minor.yy19 ){
162328
- yymsp[-1].minor.yy19->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
162911
+ yymsp[-1].minor.yy49 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
162912
+ if( yymsp[-1].minor.yy49 ){
162913
+ yymsp[-1].minor.yy49->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
162329162914
}
162330162915
}
162331162916
break;
162332162917
case 336: /* filter_clause ::= FILTER LP WHERE expr RP */
162333
-{ yymsp[-4].minor.yy602 = yymsp[-1].minor.yy602; }
162918
+{ yymsp[-4].minor.yy404 = yymsp[-1].minor.yy404; }
162334162919
break;
162335162920
default:
162336162921
/* (337) input ::= cmdlist */ yytestcase(yyruleno==337);
162337162922
/* (338) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==338);
162338162923
/* (339) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=339);
@@ -162795,10 +163380,11 @@
162795163380
#define CC_TILDA 25 /* '~' */
162796163381
#define CC_DOT 26 /* '.' */
162797163382
#define CC_ID 27 /* unicode characters usable in IDs */
162798163383
#define CC_ILLEGAL 28 /* Illegal character */
162799163384
#define CC_NUL 29 /* 0x00 */
163385
+#define CC_BOM 30 /* First byte of UTF8 BOM: 0xEF 0xBB 0xBF */
162800163386
162801163387
static const unsigned char aiClass[] = {
162802163388
#ifdef SQLITE_ASCII
162803163389
/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
162804163390
/* 0x */ 29, 28, 28, 28, 28, 28, 28, 28, 28, 7, 7, 28, 7, 7, 28, 28,
@@ -162807,18 +163393,18 @@
162807163393
/* 3x */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 19, 12, 14, 13, 6,
162808163394
/* 4x */ 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
162809163395
/* 5x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 9, 28, 28, 28, 2,
162810163396
/* 6x */ 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
162811163397
/* 7x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 28, 10, 28, 25, 28,
162812
-/* 8x */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162813
-/* 9x */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162814
-/* Ax */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162815
-/* Bx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162816
-/* Cx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162817
-/* Dx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162818
-/* Ex */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162819
-/* Fx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
163398
+/* 8x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
163399
+/* 9x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
163400
+/* Ax */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
163401
+/* Bx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
163402
+/* Cx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
163403
+/* Dx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
163404
+/* Ex */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 30,
163405
+/* Fx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27
162820163406
#endif
162821163407
#ifdef SQLITE_EBCDIC
162822163408
/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
162823163409
/* 0x */ 29, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 7, 7, 28, 28,
162824163410
/* 1x */ 28, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
@@ -163757,10 +164343,18 @@
163757164343
** SQL keywords start with the letter 'x'. Fall through */
163758164344
/* no break */ deliberate_fall_through
163759164345
}
163760164346
case CC_KYWD:
163761164347
case CC_ID: {
164348
+ i = 1;
164349
+ break;
164350
+ }
164351
+ case CC_BOM: {
164352
+ if( z[1]==0xbb && z[2]==0xbf ){
164353
+ *tokenType = TK_SPACE;
164354
+ return 3;
164355
+ }
163762164356
i = 1;
163763164357
break;
163764164358
}
163765164359
case CC_NUL: {
163766164360
*tokenType = TK_ILLEGAL;
@@ -164776,11 +165370,11 @@
164776165370
}
164777165371
if( rc==SQLITE_OK ){
164778165372
sqlite3GlobalConfig.isPCacheInit = 1;
164779165373
rc = sqlite3OsInit();
164780165374
}
164781
-#ifdef SQLITE_ENABLE_DESERIALIZE
165375
+#ifndef SQLITE_OMIT_DESERIALIZE
164782165376
if( rc==SQLITE_OK ){
164783165377
rc = sqlite3MemdbInit();
164784165378
}
164785165379
#endif
164786165380
if( rc==SQLITE_OK ){
@@ -165191,16 +165785,16 @@
165191165785
sqlite3GlobalConfig.szSorterRef = (u32)iVal;
165192165786
break;
165193165787
}
165194165788
#endif /* SQLITE_ENABLE_SORTER_REFERENCES */
165195165789
165196
-#ifdef SQLITE_ENABLE_DESERIALIZE
165790
+#ifndef SQLITE_OMIT_DESERIALIZE
165197165791
case SQLITE_CONFIG_MEMDB_MAXSIZE: {
165198165792
sqlite3GlobalConfig.mxMemdbSize = va_arg(ap, sqlite3_int64);
165199165793
break;
165200165794
}
165201
-#endif /* SQLITE_ENABLE_DESERIALIZE */
165795
+#endif /* SQLITE_OMIT_DESERIALIZE */
165202165796
165203165797
default: {
165204165798
rc = SQLITE_ERROR;
165205165799
break;
165206165800
}
@@ -165745,11 +166339,11 @@
165745166339
}
165746166340
165747166341
/*
165748166342
** Two variations on the public interface for closing a database
165749166343
** connection. The sqlite3_close() version returns SQLITE_BUSY and
165750
-** leaves the connection option if there are unfinalized prepared
166344
+** leaves the connection open if there are unfinalized prepared
165751166345
** statements or unfinished sqlite3_backups. The sqlite3_close_v2()
165752166346
** version forces the connection to become a zombie if there are
165753166347
** unclosed resources, and arranges for deallocation when the last
165754166348
** prepare statement or sqlite3_backup closes.
165755166349
*/
@@ -166355,10 +166949,14 @@
166355166949
assert( !db->mallocFailed );
166356166950
return SQLITE_BUSY;
166357166951
}else{
166358166952
sqlite3ExpirePreparedStatements(db, 0);
166359166953
}
166954
+ }else if( xSFunc==0 && xFinal==0 ){
166955
+ /* Trying to delete a function that does not exist. This is a no-op.
166956
+ ** https://sqlite.org/forum/forumpost/726219164b */
166957
+ return SQLITE_OK;
166360166958
}
166361166959
166362166960
p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1);
166363166961
assert(p || db->mallocFailed);
166364166962
if( !p ){
@@ -168750,10 +169348,40 @@
168750169348
case 2: *ptr = sqlite3WhereTrace; break;
168751169349
case 3: sqlite3WhereTrace = *ptr; break;
168752169350
}
168753169351
break;
168754169352
}
169353
+
169354
+#ifdef SQLITE_DEBUG
169355
+ /* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue)
169356
+ **
169357
+ ** If "id" is an integer between 1 and SQLITE_NTUNE then set the value
169358
+ ** of the id-th tuning parameter to *piValue. If "id" is between -1
169359
+ ** and -SQLITE_NTUNE, then write the current value of the (-id)-th
169360
+ ** tuning parameter into *piValue.
169361
+ **
169362
+ ** Tuning parameters are for use during transient development builds,
169363
+ ** to help find the best values for constants in the query planner.
169364
+ ** Access tuning parameters using the Tuning(ID) macro. Set the
169365
+ ** parameters in the CLI using ".testctrl tune ID VALUE".
169366
+ **
169367
+ ** Transient use only. Tuning parameters should not be used in
169368
+ ** checked-in code.
169369
+ */
169370
+ case SQLITE_TESTCTRL_TUNE: {
169371
+ int id = va_arg(ap, int);
169372
+ int *piValue = va_arg(ap, int*);
169373
+ if( id>0 && id<=SQLITE_NTUNE ){
169374
+ Tuning(id) = *piValue;
169375
+ }else if( id<0 && id>=-SQLITE_NTUNE ){
169376
+ *piValue = Tuning(-id);
169377
+ }else{
169378
+ rc = SQLITE_NOTFOUND;
169379
+ }
169380
+ break;
169381
+ }
169382
+#endif
168755169383
}
168756169384
va_end(ap);
168757169385
#endif /* SQLITE_UNTESTABLE */
168758169386
return rc;
168759169387
}
@@ -172321,11 +172949,11 @@
172321172949
const char *zCsr = zNode; /* Cursor to iterate through node */
172322172950
const char *zEnd = &zCsr[nNode];/* End of interior node buffer */
172323172951
char *zBuffer = 0; /* Buffer to load terms into */
172324172952
i64 nAlloc = 0; /* Size of allocated buffer */
172325172953
int isFirstTerm = 1; /* True when processing first term on page */
172326
- sqlite3_int64 iChild; /* Block id of child node to descend to */
172954
+ u64 iChild; /* Block id of child node to descend to */
172327172955
int nBuffer = 0; /* Total term size */
172328172956
172329172957
/* Skip over the 'height' varint that occurs at the start of every
172330172958
** interior node. Then load the blockid of the left-child of the b-tree
172331172959
** node into variable iChild.
@@ -172337,12 +172965,12 @@
172337172965
** either more than 20 bytes of allocated space following the nNode bytes of
172338172966
** contents, or two zero bytes. Or, if the node is read from the %_segments
172339172967
** table, then there are always 20 bytes of zeroed padding following the
172340172968
** nNode bytes of content (see sqlite3Fts3ReadBlock() for details).
172341172969
*/
172342
- zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);
172343
- zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);
172970
+ zCsr += sqlite3Fts3GetVarintU(zCsr, &iChild);
172971
+ zCsr += sqlite3Fts3GetVarintU(zCsr, &iChild);
172344172972
if( zCsr>zEnd ){
172345172973
return FTS_CORRUPT_VTAB;
172346172974
}
172347172975
172348172976
while( zCsr<zEnd && (piFirst || piLast) ){
@@ -172391,24 +173019,24 @@
172391173019
** If the interior node term is larger than the specified term, then
172392173020
** the tree headed by iChild may contain the specified term.
172393173021
*/
172394173022
cmp = memcmp(zTerm, zBuffer, (nBuffer>nTerm ? nTerm : nBuffer));
172395173023
if( piFirst && (cmp<0 || (cmp==0 && nBuffer>nTerm)) ){
172396
- *piFirst = iChild;
173024
+ *piFirst = (i64)iChild;
172397173025
piFirst = 0;
172398173026
}
172399173027
172400173028
if( piLast && cmp<0 ){
172401
- *piLast = iChild;
173029
+ *piLast = (i64)iChild;
172402173030
piLast = 0;
172403173031
}
172404173032
172405173033
iChild++;
172406173034
};
172407173035
172408
- if( piFirst ) *piFirst = iChild;
172409
- if( piLast ) *piLast = iChild;
173036
+ if( piFirst ) *piFirst = (i64)iChild;
173037
+ if( piLast ) *piLast = (i64)iChild;
172410173038
172411173039
finish_scan:
172412173040
sqlite3_free(zBuffer);
172413173041
return rc;
172414173042
}
@@ -175552,20 +176180,19 @@
175552176180
175553176181
/* Determine which, if any, tokens in the expression should be deferred. */
175554176182
#ifndef SQLITE_DISABLE_FTS4_DEFERRED
175555176183
if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){
175556176184
Fts3TokenAndCost *aTC;
175557
- Fts3Expr **apOr;
175558176185
aTC = (Fts3TokenAndCost *)sqlite3_malloc64(
175559176186
sizeof(Fts3TokenAndCost) * nToken
175560176187
+ sizeof(Fts3Expr *) * nOr * 2
175561176188
);
175562
- apOr = (Fts3Expr **)&aTC[nToken];
175563176189
175564176190
if( !aTC ){
175565176191
rc = SQLITE_NOMEM;
175566176192
}else{
176193
+ Fts3Expr **apOr = (Fts3Expr **)&aTC[nToken];
175567176194
int ii;
175568176195
Fts3TokenAndCost *pTC = aTC;
175569176196
Fts3Expr **ppOr = apOr;
175570176197
175571176198
fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);
@@ -176937,10 +177564,11 @@
176937177564
/* In case this cursor is being reused, close and zero it. */
176938177565
testcase(pCsr->filter.zTerm);
176939177566
sqlite3Fts3SegReaderFinish(&pCsr->csr);
176940177567
sqlite3_free((void *)pCsr->filter.zTerm);
176941177568
sqlite3_free(pCsr->aStat);
177569
+ sqlite3_free(pCsr->zStop);
176942177570
memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr);
176943177571
176944177572
pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;
176945177573
if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN;
176946177574
@@ -182458,11 +183086,11 @@
182458183086
rc = (pLhs->aNode==0) - (pRhs->aNode==0);
182459183087
}
182460183088
if( rc==0 ){
182461183089
rc = pRhs->iIdx - pLhs->iIdx;
182462183090
}
182463
- assert( rc!=0 );
183091
+ assert_fts3_nc( rc!=0 );
182464183092
return rc;
182465183093
}
182466183094
182467183095
/*
182468183096
** A different comparison function for SegReader structures. In this
@@ -182654,12 +183282,12 @@
182654183282
int nPrev, /* Size of buffer zPrev in bytes */
182655183283
const char *zNext, /* Buffer containing next term */
182656183284
int nNext /* Size of buffer zNext in bytes */
182657183285
){
182658183286
int n;
182659
- UNUSED_PARAMETER(nNext);
182660
- for(n=0; n<nPrev && zPrev[n]==zNext[n]; n++);
183287
+ for(n=0; n<nPrev && n<nNext && zPrev[n]==zNext[n]; n++);
183288
+ assert_fts3_nc( n<nNext );
182661183289
return n;
182662183290
}
182663183291
182664183292
/*
182665183293
** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger
@@ -183654,11 +184282,11 @@
183654184282
iDelta = (i64)((u64)iDocid - (u64)iPrev);
183655184283
}
183656184284
183657184285
nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
183658184286
183659
- rc = fts3GrowSegReaderBuffer(pCsr, nByte+nDoclist);
184287
+ rc = fts3GrowSegReaderBuffer(pCsr, nByte+nDoclist+FTS3_NODE_PADDING);
183660184288
if( rc ) return rc;
183661184289
183662184290
if( isFirst ){
183663184291
char *a = &pCsr->aBuffer[nDoclist];
183664184292
int nWrite;
@@ -186468,10 +187096,14 @@
186468187096
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
186469187097
186470187098
/* #include <string.h> */
186471187099
/* #include <assert.h> */
186472187100
187101
+#ifndef SQLITE_AMALGAMATION
187102
+typedef sqlite3_int64 i64;
187103
+#endif
187104
+
186473187105
/*
186474187106
** Characters that may appear in the second argument to matchinfo().
186475187107
*/
186476187108
#define FTS3_MATCHINFO_NPHRASE 'p' /* 1 value */
186477187109
#define FTS3_MATCHINFO_NCOL 'c' /* 1 value */
@@ -186518,13 +187150,13 @@
186518187150
};
186519187151
186520187152
struct SnippetPhrase {
186521187153
int nToken; /* Number of tokens in phrase */
186522187154
char *pList; /* Pointer to start of phrase position list */
186523
- int iHead; /* Next value in position list */
187155
+ i64 iHead; /* Next value in position list */
186524187156
char *pHead; /* Position list data following iHead */
186525
- int iTail; /* Next value in trailing position list */
187157
+ i64 iTail; /* Next value in trailing position list */
186526187158
char *pTail; /* Position list data following iTail */
186527187159
};
186528187160
186529187161
struct SnippetFragment {
186530187162
int iCol; /* Column snippet is extracted from */
@@ -186685,11 +187317,11 @@
186685187317
** When this function is called, *pp points to the start of an element of
186686187318
** the list. *piPos contains the value of the previous entry in the list.
186687187319
** After it returns, *piPos contains the value of the next element of the
186688187320
** list and *pp is advanced to the following varint.
186689187321
*/
186690
-static void fts3GetDeltaPosition(char **pp, int *piPos){
187322
+static void fts3GetDeltaPosition(char **pp, i64 *piPos){
186691187323
int iVal;
186692187324
*pp += fts3GetVarint32(*pp, &iVal);
186693187325
*piPos += (iVal-2);
186694187326
}
186695187327
@@ -186794,14 +187426,14 @@
186794187426
/*
186795187427
** Advance the position list iterator specified by the first two
186796187428
** arguments so that it points to the first element with a value greater
186797187429
** than or equal to parameter iNext.
186798187430
*/
186799
-static void fts3SnippetAdvance(char **ppIter, int *piIter, int iNext){
187431
+static void fts3SnippetAdvance(char **ppIter, i64 *piIter, int iNext){
186800187432
char *pIter = *ppIter;
186801187433
if( pIter ){
186802
- int iIter = *piIter;
187434
+ i64 iIter = *piIter;
186803187435
186804187436
while( iIter<iNext ){
186805187437
if( 0==(*pIter & 0xFE) ){
186806187438
iIter = -1;
186807187439
pIter = 0;
@@ -186880,11 +187512,11 @@
186880187512
186881187513
for(i=0; i<pIter->nPhrase; i++){
186882187514
SnippetPhrase *pPhrase = &pIter->aPhrase[i];
186883187515
if( pPhrase->pTail ){
186884187516
char *pCsr = pPhrase->pTail;
186885
- int iCsr = pPhrase->iTail;
187517
+ i64 iCsr = pPhrase->iTail;
186886187518
186887187519
while( iCsr<(iStart+pIter->nSnippet) && iCsr>=iStart ){
186888187520
int j;
186889187521
u64 mPhrase = (u64)1 << (i%64);
186890187522
u64 mPos = (u64)1 << (iCsr - iStart);
@@ -186926,11 +187558,11 @@
186926187558
186927187559
pPhrase->nToken = pExpr->pPhrase->nToken;
186928187560
rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr);
186929187561
assert( rc==SQLITE_OK || pCsr==0 );
186930187562
if( pCsr ){
186931
- int iFirst = 0;
187563
+ i64 iFirst = 0;
186932187564
pPhrase->pList = pCsr;
186933187565
fts3GetDeltaPosition(&pCsr, &iFirst);
186934187566
if( iFirst<0 ){
186935187567
rc = FTS_CORRUPT_VTAB;
186936187568
}else{
@@ -187990,12 +188622,12 @@
187990188622
typedef struct TermOffset TermOffset;
187991188623
typedef struct TermOffsetCtx TermOffsetCtx;
187992188624
187993188625
struct TermOffset {
187994188626
char *pList; /* Position-list */
187995
- int iPos; /* Position just read from pList */
187996
- int iOff; /* Offset of this term from read positions */
188627
+ i64 iPos; /* Position just read from pList */
188628
+ i64 iOff; /* Offset of this term from read positions */
187997188629
};
187998188630
187999188631
struct TermOffsetCtx {
188000188632
Fts3Cursor *pCsr;
188001188633
int iCol; /* Column of table to populate aTerm for */
@@ -188010,11 +188642,11 @@
188010188642
static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){
188011188643
TermOffsetCtx *p = (TermOffsetCtx *)ctx;
188012188644
int nTerm; /* Number of tokens in phrase */
188013188645
int iTerm; /* For looping through nTerm phrase terms */
188014188646
char *pList; /* Pointer to position list for phrase */
188015
- int iPos = 0; /* First position in position-list */
188647
+ i64 iPos = 0; /* First position in position-list */
188016188648
int rc;
188017188649
188018188650
UNUSED_PARAMETER(iPhrase);
188019188651
rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pList);
188020188652
nTerm = pExpr->pPhrase->nToken;
@@ -189287,11 +189919,11 @@
189287189919
** any double-quotes or backslash characters contained within the
189288189920
** string.
189289189921
*/
189290189922
static void jsonAppendString(JsonString *p, const char *zIn, u32 N){
189291189923
u32 i;
189292
- if( (N+p->nUsed+2 >= p->nAlloc) && jsonGrow(p,N+2)!=0 ) return;
189924
+ if( zIn==0 || ((N+p->nUsed+2 >= p->nAlloc) && jsonGrow(p,N+2)!=0) ) return;
189293189925
p->zBuf[p->nUsed++] = '"';
189294189926
for(i=0; i<N; i++){
189295189927
unsigned char c = ((unsigned const char*)zIn)[i];
189296189928
if( c=='"' || c=='\\' ){
189297189929
json_simple_escape:
@@ -190886,12 +191518,12 @@
190886191518
if( pStr->zBuf==0 ){
190887191519
jsonInit(pStr, ctx);
190888191520
jsonAppendChar(pStr, '[');
190889191521
}else if( pStr->nUsed>1 ){
190890191522
jsonAppendChar(pStr, ',');
190891
- pStr->pCtx = ctx;
190892191523
}
191524
+ pStr->pCtx = ctx;
190893191525
jsonAppendValue(pStr, argv[0]);
190894191526
}
190895191527
}
190896191528
static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){
190897191529
JsonString *pStr;
@@ -190947,26 +191579,27 @@
190947191579
/* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will
190948191580
** always have been called to initalize it */
190949191581
if( NEVER(!pStr) ) return;
190950191582
#endif
190951191583
z = pStr->zBuf;
190952
- for(i=1; (c = z[i])!=',' || inStr || nNest; i++){
190953
- if( i>=pStr->nUsed ){
190954
- pStr->nUsed = 1;
190955
- return;
190956
- }
191584
+ for(i=1; i<pStr->nUsed && ((c = z[i])!=',' || inStr || nNest); i++){
190957191585
if( c=='"' ){
190958191586
inStr = !inStr;
190959191587
}else if( c=='\\' ){
190960191588
i++;
190961191589
}else if( !inStr ){
190962191590
if( c=='{' || c=='[' ) nNest++;
190963191591
if( c=='}' || c==']' ) nNest--;
190964191592
}
190965191593
}
190966
- pStr->nUsed -= i;
190967
- memmove(&z[1], &z[i+1], (size_t)pStr->nUsed-1);
191594
+ if( i<pStr->nUsed ){
191595
+ pStr->nUsed -= i;
191596
+ memmove(&z[1], &z[i+1], (size_t)pStr->nUsed-1);
191597
+ z[pStr->nUsed] = 0;
191598
+ }else{
191599
+ pStr->nUsed = 1;
191600
+ }
190968191601
}
190969191602
#else
190970191603
# define jsonGroupInverse 0
190971191604
#endif
190972191605
@@ -190990,12 +191623,12 @@
190990191623
if( pStr->zBuf==0 ){
190991191624
jsonInit(pStr, ctx);
190992191625
jsonAppendChar(pStr, '{');
190993191626
}else if( pStr->nUsed>1 ){
190994191627
jsonAppendChar(pStr, ',');
190995
- pStr->pCtx = ctx;
190996191628
}
191629
+ pStr->pCtx = ctx;
190997191630
z = (const char*)sqlite3_value_text(argv[0]);
190998191631
n = (u32)sqlite3_value_bytes(argv[0]);
190999191632
jsonAppendString(pStr, z, n);
191000191633
jsonAppendChar(pStr, ':');
191001191634
jsonAppendValue(pStr, argv[1]);
@@ -195512,15 +196145,20 @@
195512196145
*/
195513196146
static void rtreedepth(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){
195514196147
UNUSED_PARAMETER(nArg);
195515196148
if( sqlite3_value_type(apArg[0])!=SQLITE_BLOB
195516196149
|| sqlite3_value_bytes(apArg[0])<2
196150
+
195517196151
){
195518196152
sqlite3_result_error(ctx, "Invalid argument to rtreedepth()", -1);
195519196153
}else{
195520196154
u8 *zBlob = (u8 *)sqlite3_value_blob(apArg[0]);
195521
- sqlite3_result_int(ctx, readInt16(zBlob));
196155
+ if( zBlob ){
196156
+ sqlite3_result_int(ctx, readInt16(zBlob));
196157
+ }else{
196158
+ sqlite3_result_error_nomem(ctx);
196159
+ }
195522196160
}
195523196161
}
195524196162
195525196163
/*
195526196164
** Context object passed between the various routines that make up the
@@ -201039,11 +201677,13 @@
201039201677
);
201040201678
if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSel) ){
201041201679
zSep = "";
201042201680
for(iCol=0; iCol<pIter->nCol; iCol++){
201043201681
const char *zQuoted = (const char*)sqlite3_column_text(pSel, iCol);
201044
- if( zQuoted[0]=='N' ){
201682
+ if( zQuoted==0 ){
201683
+ p->rc = SQLITE_NOMEM;
201684
+ }else if( zQuoted[0]=='N' ){
201045201685
bFailed = 1;
201046201686
break;
201047201687
}
201048201688
zVector = rbuMPrintf(p, "%z%s%s", zVector, zSep, zQuoted);
201049201689
zSep = ", ";
@@ -204411,32 +205051,18 @@
204411205051
}
204412205052
else if( flags & SQLITE_OPEN_WAL ){
204413205053
rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName, 0);
204414205054
if( pDb ){
204415205055
if( pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){
204416
- /* This call is to open a *-wal file. Intead, open the *-oal. This
204417
- ** code ensures that the string passed to xOpen() is terminated by a
204418
- ** pair of '\0' bytes in case the VFS attempts to extract a URI
204419
- ** parameter from it. */
204420
- const char *zBase = zName;
204421
- size_t nCopy;
204422
- char *zCopy;
205056
+ /* This call is to open a *-wal file. Intead, open the *-oal. */
205057
+ size_t nOpen;
204423205058
if( rbuIsVacuum(pDb->pRbu) ){
204424
- zBase = sqlite3_db_filename(pDb->pRbu->dbRbu, "main");
204425
- zBase = sqlite3_filename_wal(zBase);
204426
- }
204427
- nCopy = strlen(zBase);
204428
- zCopy = sqlite3_malloc64(nCopy+2);
204429
- if( zCopy ){
204430
- memcpy(zCopy, zBase, nCopy);
204431
- zCopy[nCopy-3] = 'o';
204432
- zCopy[nCopy] = '\0';
204433
- zCopy[nCopy+1] = '\0';
204434
- zOpen = (const char*)(pFd->zDel = zCopy);
204435
- }else{
204436
- rc = SQLITE_NOMEM;
204437
- }
205059
+ zOpen = sqlite3_db_filename(pDb->pRbu->dbRbu, "main");
205060
+ zOpen = sqlite3_filename_wal(zOpen);
205061
+ }
205062
+ nOpen = strlen(zOpen);
205063
+ ((char*)zOpen)[nOpen-3] = 'o';
204438205064
pFd->pRbu = pDb->pRbu;
204439205065
}
204440205066
pDb->pWalFd = pFd;
204441205067
}
204442205068
}
@@ -206045,17 +206671,19 @@
206045206671
** Session handle structure.
206046206672
*/
206047206673
struct sqlite3_session {
206048206674
sqlite3 *db; /* Database handle session is attached to */
206049206675
char *zDb; /* Name of database session is attached to */
206676
+ int bEnableSize; /* True if changeset_size() enabled */
206050206677
int bEnable; /* True if currently recording */
206051206678
int bIndirect; /* True if all changes are indirect */
206052206679
int bAutoAttach; /* True to auto-attach tables */
206053206680
int rc; /* Non-zero if an error has occurred */
206054206681
void *pFilterCtx; /* First argument to pass to xTableFilter */
206055206682
int (*xTableFilter)(void *pCtx, const char *zTab);
206056206683
i64 nMalloc; /* Number of bytes of data allocated */
206684
+ i64 nMaxChangesetSize;
206057206685
sqlite3_value *pZeroBlob; /* Value containing X'' */
206058206686
sqlite3_session *pNext; /* Next session object on same db. */
206059206687
SessionTable *pTable; /* List of attached tables */
206060206688
SessionHook hook; /* APIs to grab new and old data with */
206061206689
};
@@ -206294,12 +206922,13 @@
206294206922
/*
206295206923
** For each row modified during a session, there exists a single instance of
206296206924
** this structure stored in a SessionTable.aChange[] hash table.
206297206925
*/
206298206926
struct SessionChange {
206299
- int op; /* One of UPDATE, DELETE, INSERT */
206300
- int bIndirect; /* True if this change is "indirect" */
206927
+ u8 op; /* One of UPDATE, DELETE, INSERT */
206928
+ u8 bIndirect; /* True if this change is "indirect" */
206929
+ int nMaxSize; /* Max size of eventual changeset record */
206301206930
int nRecord; /* Number of bytes in buffer aRecord[] */
206302206931
u8 *aRecord; /* Buffer containing old.* record */
206303206932
SessionChange *pNext; /* For hash-table collisions */
206304206933
};
206305206934
@@ -207124,10 +207753,16 @@
207124207753
}
207125207754
}
207126207755
if( 0==sqlite3_stricmp("sqlite_stat1", pTab->zName) ){
207127207756
pTab->bStat1 = 1;
207128207757
}
207758
+
207759
+ if( pSession->bEnableSize ){
207760
+ pSession->nMaxChangesetSize += (
207761
+ 1 + sessionVarintLen(pTab->nCol) + pTab->nCol + strlen(pTab->zName)+1
207762
+ );
207763
+ }
207129207764
}
207130207765
}
207131207766
return (pSession->rc || pTab->abPK==0);
207132207767
}
207133207768
@@ -207169,10 +207804,107 @@
207169207804
static int sessionStat1Depth(void *pCtx){
207170207805
SessionStat1Ctx *p = (SessionStat1Ctx*)pCtx;
207171207806
return p->hook.xDepth(p->hook.pCtx);
207172207807
}
207173207808
207809
+static int sessionUpdateMaxSize(
207810
+ int op,
207811
+ sqlite3_session *pSession, /* Session object pTab is attached to */
207812
+ SessionTable *pTab, /* Table that change applies to */
207813
+ SessionChange *pC /* Update pC->nMaxSize */
207814
+){
207815
+ i64 nNew = 2;
207816
+ if( pC->op==SQLITE_INSERT ){
207817
+ if( op!=SQLITE_DELETE ){
207818
+ int ii;
207819
+ for(ii=0; ii<pTab->nCol; ii++){
207820
+ sqlite3_value *p = 0;
207821
+ pSession->hook.xNew(pSession->hook.pCtx, ii, &p);
207822
+ sessionSerializeValue(0, p, &nNew);
207823
+ }
207824
+ }
207825
+ }else if( op==SQLITE_DELETE ){
207826
+ nNew += pC->nRecord;
207827
+ if( sqlite3_preupdate_blobwrite(pSession->db)>=0 ){
207828
+ nNew += pC->nRecord;
207829
+ }
207830
+ }else{
207831
+ int ii;
207832
+ u8 *pCsr = pC->aRecord;
207833
+ for(ii=0; ii<pTab->nCol; ii++){
207834
+ int bChanged = 1;
207835
+ int nOld = 0;
207836
+ int eType;
207837
+ sqlite3_value *p = 0;
207838
+ pSession->hook.xNew(pSession->hook.pCtx, ii, &p);
207839
+ if( p==0 ){
207840
+ return SQLITE_NOMEM;
207841
+ }
207842
+
207843
+ eType = *pCsr++;
207844
+ switch( eType ){
207845
+ case SQLITE_NULL:
207846
+ bChanged = sqlite3_value_type(p)!=SQLITE_NULL;
207847
+ break;
207848
+
207849
+ case SQLITE_FLOAT:
207850
+ case SQLITE_INTEGER: {
207851
+ if( eType==sqlite3_value_type(p) ){
207852
+ sqlite3_int64 iVal = sessionGetI64(pCsr);
207853
+ if( eType==SQLITE_INTEGER ){
207854
+ bChanged = (iVal!=sqlite3_value_int64(p));
207855
+ }else{
207856
+ double dVal;
207857
+ memcpy(&dVal, &iVal, 8);
207858
+ bChanged = (dVal!=sqlite3_value_double(p));
207859
+ }
207860
+ }
207861
+ nOld = 8;
207862
+ pCsr += 8;
207863
+ break;
207864
+ }
207865
+
207866
+ default: {
207867
+ int nByte;
207868
+ nOld = sessionVarintGet(pCsr, &nByte);
207869
+ pCsr += nOld;
207870
+ nOld += nByte;
207871
+ assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB );
207872
+ if( eType==sqlite3_value_type(p)
207873
+ && nByte==sqlite3_value_bytes(p)
207874
+ && (nByte==0 || 0==memcmp(pCsr, sqlite3_value_blob(p), nByte))
207875
+ ){
207876
+ bChanged = 0;
207877
+ }
207878
+ pCsr += nByte;
207879
+ break;
207880
+ }
207881
+ }
207882
+
207883
+ if( bChanged && pTab->abPK[ii] ){
207884
+ nNew = pC->nRecord + 2;
207885
+ break;
207886
+ }
207887
+
207888
+ if( bChanged ){
207889
+ nNew += 1 + nOld;
207890
+ sessionSerializeValue(0, p, &nNew);
207891
+ }else if( pTab->abPK[ii] ){
207892
+ nNew += 2 + nOld;
207893
+ }else{
207894
+ nNew += 2;
207895
+ }
207896
+ }
207897
+ }
207898
+
207899
+ if( nNew>pC->nMaxSize ){
207900
+ int nIncr = nNew - pC->nMaxSize;
207901
+ pC->nMaxSize = nNew;
207902
+ pSession->nMaxChangesetSize += nIncr;
207903
+ }
207904
+ return SQLITE_OK;
207905
+}
207174207906
207175207907
/*
207176207908
** This function is only called from with a pre-update-hook reporting a
207177207909
** change on table pTab (attached to session pSession). The type of change
207178207910
** (UPDATE, INSERT, DELETE) is specified by the first argument.
@@ -207242,11 +207974,10 @@
207242207974
207243207975
if( pC==0 ){
207244207976
/* Create a new change object containing all the old values (if
207245207977
** this is an SQLITE_UPDATE or SQLITE_DELETE), or just the PK
207246207978
** values (if this is an INSERT). */
207247
- SessionChange *pChange; /* New change object */
207248207979
sqlite3_int64 nByte; /* Number of bytes to allocate */
207249207980
int i; /* Used to iterate through columns */
207250207981
207251207982
assert( rc==SQLITE_OK );
207252207983
pTab->nEntry++;
@@ -207268,17 +207999,17 @@
207268207999
rc = sessionSerializeValue(0, p, &nByte);
207269208000
if( rc!=SQLITE_OK ) goto error_out;
207270208001
}
207271208002
207272208003
/* Allocate the change object */
207273
- pChange = (SessionChange *)sessionMalloc64(pSession, nByte);
207274
- if( !pChange ){
208004
+ pC = (SessionChange *)sessionMalloc64(pSession, nByte);
208005
+ if( !pC ){
207275208006
rc = SQLITE_NOMEM;
207276208007
goto error_out;
207277208008
}else{
207278
- memset(pChange, 0, sizeof(SessionChange));
207279
- pChange->aRecord = (u8 *)&pChange[1];
208009
+ memset(pC, 0, sizeof(SessionChange));
208010
+ pC->aRecord = (u8 *)&pC[1];
207280208011
}
207281208012
207282208013
/* Populate the change object. None of the preupdate_old(),
207283208014
** preupdate_new() or SerializeValue() calls below may fail as all
207284208015
** required values and encodings have already been cached in memory.
@@ -207289,21 +208020,21 @@
207289208020
if( op!=SQLITE_INSERT ){
207290208021
pSession->hook.xOld(pSession->hook.pCtx, i, &p);
207291208022
}else if( pTab->abPK[i] ){
207292208023
pSession->hook.xNew(pSession->hook.pCtx, i, &p);
207293208024
}
207294
- sessionSerializeValue(&pChange->aRecord[nByte], p, &nByte);
208025
+ sessionSerializeValue(&pC->aRecord[nByte], p, &nByte);
207295208026
}
207296208027
207297208028
/* Add the change to the hash-table */
207298208029
if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){
207299
- pChange->bIndirect = 1;
208030
+ pC->bIndirect = 1;
207300208031
}
207301
- pChange->nRecord = nByte;
207302
- pChange->op = op;
207303
- pChange->pNext = pTab->apChange[iHash];
207304
- pTab->apChange[iHash] = pChange;
208032
+ pC->nRecord = nByte;
208033
+ pC->op = op;
208034
+ pC->pNext = pTab->apChange[iHash];
208035
+ pTab->apChange[iHash] = pC;
207305208036
207306208037
}else if( pC->bIndirect ){
207307208038
/* If the existing change is considered "indirect", but this current
207308208039
** change is "direct", mark the change object as direct. */
207309208040
if( pSession->hook.xDepth(pSession->hook.pCtx)==0
@@ -207310,11 +208041,17 @@
207310208041
&& pSession->bIndirect==0
207311208042
){
207312208043
pC->bIndirect = 0;
207313208044
}
207314208045
}
208046
+
208047
+ assert( rc==SQLITE_OK );
208048
+ if( pSession->bEnableSize ){
208049
+ rc = sessionUpdateMaxSize(op, pSession, pTab, pC);
208050
+ }
207315208051
}
208052
+
207316208053
207317208054
/* If an error has occurred, mark the session object as failed. */
207318208055
error_out:
207319208056
if( pTab->bStat1 ){
207320208057
pSession->hook = stat1.hook;
@@ -207866,17 +208603,33 @@
207866208603
** If not, use sqlite3_realloc() to grow the buffer so that there is.
207867208604
**
207868208605
** If successful, return zero. Otherwise, if an OOM condition is encountered,
207869208606
** set *pRc to SQLITE_NOMEM and return non-zero.
207870208607
*/
207871
-static int sessionBufferGrow(SessionBuffer *p, size_t nByte, int *pRc){
207872
- if( *pRc==SQLITE_OK && (size_t)(p->nAlloc-p->nBuf)<nByte ){
208608
+static int sessionBufferGrow(SessionBuffer *p, i64 nByte, int *pRc){
208609
+#define SESSION_MAX_BUFFER_SZ (0x7FFFFF00 - 1)
208610
+ i64 nReq = p->nBuf + nByte;
208611
+ if( *pRc==SQLITE_OK && nReq>p->nAlloc ){
207873208612
u8 *aNew;
207874208613
i64 nNew = p->nAlloc ? p->nAlloc : 128;
208614
+
207875208615
do {
207876208616
nNew = nNew*2;
207877
- }while( (size_t)(nNew-p->nBuf)<nByte );
208617
+ }while( nNew<nReq );
208618
+
208619
+ /* The value of SESSION_MAX_BUFFER_SZ is copied from the implementation
208620
+ ** of sqlite3_realloc64(). Allocations greater than this size in bytes
208621
+ ** always fail. It is used here to ensure that this routine can always
208622
+ ** allocate up to this limit - instead of up to the largest power of
208623
+ ** two smaller than the limit. */
208624
+ if( nNew>SESSION_MAX_BUFFER_SZ ){
208625
+ nNew = SESSION_MAX_BUFFER_SZ;
208626
+ if( nNew<nReq ){
208627
+ *pRc = SQLITE_NOMEM;
208628
+ return 1;
208629
+ }
208630
+ }
207878208631
207879208632
aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew);
207880208633
if( 0==aNew ){
207881208634
*pRc = SQLITE_NOMEM;
207882208635
}else{
@@ -208523,11 +209276,15 @@
208523209276
SQLITE_API int sqlite3session_changeset(
208524209277
sqlite3_session *pSession, /* Session object */
208525209278
int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
208526209279
void **ppChangeset /* OUT: Buffer containing changeset */
208527209280
){
208528
- return sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset, ppChangeset);
209281
+ int rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset,ppChangeset);
209282
+ assert( rc || pnChangeset==0
209283
+ || pSession->bEnableSize==0 || *pnChangeset<=pSession->nMaxChangesetSize
209284
+ );
209285
+ return rc;
208529209286
}
208530209287
208531209288
/*
208532209289
** Streaming version of sqlite3session_changeset().
208533209290
*/
@@ -208614,10 +209371,43 @@
208614209371
** Return the amount of heap memory in use.
208615209372
*/
208616209373
SQLITE_API sqlite3_int64 sqlite3session_memory_used(sqlite3_session *pSession){
208617209374
return pSession->nMalloc;
208618209375
}
209376
+
209377
+/*
209378
+** Configure the session object passed as the first argument.
209379
+*/
209380
+SQLITE_API int sqlite3session_object_config(sqlite3_session *pSession, int op, void *pArg){
209381
+ int rc = SQLITE_OK;
209382
+ switch( op ){
209383
+ case SQLITE_SESSION_OBJCONFIG_SIZE: {
209384
+ int iArg = *(int*)pArg;
209385
+ if( iArg>=0 ){
209386
+ if( pSession->pTable ){
209387
+ rc = SQLITE_MISUSE;
209388
+ }else{
209389
+ pSession->bEnableSize = (iArg!=0);
209390
+ }
209391
+ }
209392
+ *(int*)pArg = pSession->bEnableSize;
209393
+ break;
209394
+ }
209395
+
209396
+ default:
209397
+ rc = SQLITE_MISUSE;
209398
+ }
209399
+
209400
+ return rc;
209401
+}
209402
+
209403
+/*
209404
+** Return the maximum size of sqlite3session_changeset() output.
209405
+*/
209406
+SQLITE_API sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession){
209407
+ return pSession->nMaxChangesetSize;
209408
+}
208619209409
208620209410
/*
208621209411
** Do the work for either sqlite3changeset_start() or start_strm().
208622209412
*/
208623209413
static int sessionChangesetStart(
@@ -215435,10 +216225,11 @@
215435216225
return 1;
215436216226
}else{
215437216227
i64 iOff = *piOff;
215438216228
int iVal;
215439216229
fts5FastGetVarint32(a, i, iVal);
216230
+ assert( iVal>=0 );
215440216231
if( iVal<=1 ){
215441216232
if( iVal==0 ){
215442216233
*pi = i;
215443216234
return 0;
215444216235
}
@@ -215448,13 +216239,16 @@
215448216239
if( iVal<2 ){
215449216240
/* This is a corrupt record. So stop parsing it here. */
215450216241
*piOff = -1;
215451216242
return 1;
215452216243
}
216244
+ *piOff = iOff + ((iVal-2) & 0x7FFFFFFF);
216245
+ }else{
216246
+ *piOff = (iOff & (i64)0x7FFFFFFF<<32)+((iOff + (iVal-2)) & 0x7FFFFFFF);
215453216247
}
215454
- *piOff = iOff + ((iVal-2) & 0x7FFFFFFF);
215455216248
*pi = i;
216249
+ assert( *piOff>=iOff );
215456216250
return 0;
215457216251
}
215458216252
}
215459216253
215460216254
@@ -215489,18 +216283,20 @@
215489216283
static void sqlite3Fts5PoslistSafeAppend(
215490216284
Fts5Buffer *pBuf,
215491216285
i64 *piPrev,
215492216286
i64 iPos
215493216287
){
215494
- static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32;
215495
- if( (iPos & colmask) != (*piPrev & colmask) ){
215496
- pBuf->p[pBuf->n++] = 1;
215497
- pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32));
215498
- *piPrev = (iPos & colmask);
215499
- }
215500
- pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2);
215501
- *piPrev = iPos;
216288
+ if( iPos>=*piPrev ){
216289
+ static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32;
216290
+ if( (iPos & colmask) != (*piPrev & colmask) ){
216291
+ pBuf->p[pBuf->n++] = 1;
216292
+ pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32));
216293
+ *piPrev = (iPos & colmask);
216294
+ }
216295
+ pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2);
216296
+ *piPrev = iPos;
216297
+ }
215502216298
}
215503216299
215504216300
static int sqlite3Fts5PoslistWriterAppend(
215505216301
Fts5Buffer *pBuf,
215506216302
Fts5PoslistWriter *pWriter,
@@ -216198,11 +216994,11 @@
216198216994
pRet->db = db;
216199216995
pRet->iCookie = -1;
216200216996
216201216997
nByte = nArg * (sizeof(char*) + sizeof(u8));
216202216998
pRet->azCol = (char**)sqlite3Fts5MallocZero(&rc, nByte);
216203
- pRet->abUnindexed = (u8*)&pRet->azCol[nArg];
216999
+ pRet->abUnindexed = pRet->azCol ? (u8*)&pRet->azCol[nArg] : 0;
216204217000
pRet->zDb = sqlite3Fts5Strndup(&rc, azArg[1], -1);
216205217001
pRet->zName = sqlite3Fts5Strndup(&rc, azArg[2], -1);
216206217002
pRet->bColumnsize = 1;
216207217003
pRet->eDetail = FTS5_DETAIL_FULL;
216208217004
#ifdef SQLITE_DEBUG
@@ -219034,10 +219830,11 @@
219034219830
}
219035219831
219036219832
return pRet;
219037219833
}
219038219834
219835
+#ifdef SQLITE_TEST
219039219836
static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){
219040219837
sqlite3_int64 nByte = 0;
219041219838
Fts5ExprTerm *p;
219042219839
char *zQuoted;
219043219840
@@ -219400,16 +220197,18 @@
219400220197
iCode = sqlite3_value_int(apVal[0]);
219401220198
if( nArg==2 ) bRemoveDiacritics = sqlite3_value_int(apVal[1]);
219402220199
sqlite3_result_int(pCtx, sqlite3Fts5UnicodeFold(iCode, bRemoveDiacritics));
219403220200
}
219404220201
}
220202
+#endif /* ifdef SQLITE_TEST */
219405220203
219406220204
/*
219407220205
** This is called during initialization to register the fts5_expr() scalar
219408220206
** UDF with the SQLite handle passed as the only argument.
219409220207
*/
219410220208
static int sqlite3Fts5ExprInit(Fts5Global *pGlobal, sqlite3 *db){
220209
+#ifdef SQLITE_TEST
219411220210
struct Fts5ExprFunc {
219412220211
const char *z;
219413220212
void (*x)(sqlite3_context*,int,sqlite3_value**);
219414220213
} aFunc[] = {
219415220214
{ "fts5_expr", fts5ExprFunctionHr },
@@ -219423,10 +220222,14 @@
219423220222
219424220223
for(i=0; rc==SQLITE_OK && i<ArraySize(aFunc); i++){
219425220224
struct Fts5ExprFunc *p = &aFunc[i];
219426220225
rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0);
219427220226
}
220227
+#else
220228
+ int rc = SQLITE_OK;
220229
+ UNUSED_PARAM2(pGlobal,db);
220230
+#endif
219428220231
219429220232
/* Avoid warnings indicating that sqlite3Fts5ParserTrace() and
219430220233
** sqlite3Fts5ParserFallback() are unused */
219431220234
#ifndef NDEBUG
219432220235
(void)sqlite3Fts5ParserTrace;
@@ -220669,11 +221472,11 @@
220669221472
Fts5StructureSegment *pSeg; /* Segment to iterate through */
220670221473
int flags; /* Mask of configuration flags */
220671221474
int iLeafPgno; /* Current leaf page number */
220672221475
Fts5Data *pLeaf; /* Current leaf data */
220673221476
Fts5Data *pNextLeaf; /* Leaf page (iLeafPgno+1) */
220674
- int iLeafOffset; /* Byte offset within current leaf */
221477
+ i64 iLeafOffset; /* Byte offset within current leaf */
220675221478
220676221479
/* Next method */
220677221480
void (*xNext)(Fts5Index*, Fts5SegIter*, int*);
220678221481
220679221482
/* The page and offset from which the current term was read. The offset
@@ -221849,11 +222652,11 @@
221849222652
}
221850222653
}
221851222654
221852222655
static void fts5SegIterLoadRowid(Fts5Index *p, Fts5SegIter *pIter){
221853222656
u8 *a = pIter->pLeaf->p; /* Buffer to read data from */
221854
- int iOff = pIter->iLeafOffset;
222657
+ i64 iOff = pIter->iLeafOffset;
221855222658
221856222659
ASSERT_SZLEAF_OK(pIter->pLeaf);
221857222660
if( iOff>=pIter->pLeaf->szLeaf ){
221858222661
fts5SegIterNextPage(p, pIter);
221859222662
if( pIter->pLeaf==0 ){
@@ -221882,11 +222685,11 @@
221882222685
** the first position list. The position list belonging to document
221883222686
** (Fts5SegIter.iRowid).
221884222687
*/
221885222688
static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){
221886222689
u8 *a = pIter->pLeaf->p; /* Buffer to read data from */
221887
- int iOff = pIter->iLeafOffset; /* Offset to read at */
222690
+ i64 iOff = pIter->iLeafOffset; /* Offset to read at */
221888222691
int nNew; /* Bytes of new data */
221889222692
221890222693
iOff += fts5GetVarint32(&a[iOff], nNew);
221891222694
if( iOff+nNew>pIter->pLeaf->szLeaf || nKeep>pIter->term.n || nNew==0 ){
221892222695
p->rc = FTS5_CORRUPT;
@@ -222310,11 +223113,10 @@
222310223113
}else{
222311223114
/* The following could be done by calling fts5SegIterLoadNPos(). But
222312223115
** this block is particularly performance critical, so equivalent
222313223116
** code is inlined. */
222314223117
int nSz;
222315
- assert( p->rc==SQLITE_OK );
222316223118
assert_nc( pIter->iLeafOffset<=pIter->pLeaf->nn );
222317223119
fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz);
222318223120
pIter->bDel = (nSz & 0x0001);
222319223121
pIter->nPos = nSz>>1;
222320223122
assert_nc( pIter->nPos>=0 );
@@ -223422,11 +224224,11 @@
223422224224
pIter->base.nData = p-aCopy;
223423224225
return;
223424224226
}
223425224227
fts5BufferSafeAppendBlob(&pIter->poslist, aCopy, p-aCopy);
223426224228
}
223427
- if( p==pEnd ){
224229
+ if( p>=pEnd ){
223428224230
pIter->base.pData = pIter->poslist.p;
223429224231
pIter->base.nData = pIter->poslist.n;
223430224232
return;
223431224233
}
223432224234
aCopy = p++;
@@ -224779,18 +225581,18 @@
224779225581
if( pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){
224780225582
/* The entire doclist will fit on the current leaf. */
224781225583
fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist);
224782225584
}else{
224783225585
i64 iRowid = 0;
224784
- i64 iDelta = 0;
225586
+ u64 iDelta = 0;
224785225587
int iOff = 0;
224786225588
224787225589
/* The entire doclist will not fit on this leaf. The following
224788225590
** loop iterates through the poslists that make up the current
224789225591
** doclist. */
224790225592
while( p->rc==SQLITE_OK && iOff<nDoclist ){
224791
- iOff += fts5GetVarint(&pDoclist[iOff], (u64*)&iDelta);
225593
+ iOff += fts5GetVarint(&pDoclist[iOff], &iDelta);
224792225594
iRowid += iDelta;
224793225595
224794225596
if( writer.bFirstRowidInPage ){
224795225597
fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */
224796225598
pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);
@@ -225218,11 +226020,11 @@
225218226020
Fts5Buffer *p1, /* First list to merge */
225219226021
int nBuf, /* Number of buffers in array aBuf[] */
225220226022
Fts5Buffer *aBuf /* Other lists to merge in */
225221226023
){
225222226024
#define fts5PrefixMergerNextPosition(p) \
225223
- sqlite3Fts5PoslistNext64((p)->aPos,(p)->iter.nPoslist,&(p)->iOff,&(p)->iPos);
226025
+ sqlite3Fts5PoslistNext64((p)->aPos,(p)->iter.nPoslist,&(p)->iOff,&(p)->iPos)
225224226026
#define FTS5_MERGE_NLIST 16
225225226027
PrefixMerger aMerger[FTS5_MERGE_NLIST];
225226226028
PrefixMerger *pHead = 0;
225227226029
int i;
225228226030
int nOut = 0;
@@ -225317,11 +226119,12 @@
225317226119
sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, pHead->iPos);
225318226120
}
225319226121
nTail = pHead->iter.nPoslist - pHead->iOff;
225320226122
225321226123
/* WRITEPOSLISTSIZE */
225322
- assert( tmp.n+nTail<=nTmp );
226124
+ assert_nc( tmp.n+nTail<=nTmp );
226125
+ assert( tmp.n+nTail<=nTmp+nMerge*10 );
225323226126
if( tmp.n+nTail>nTmp-FTS5_DATA_ZERO_PADDING ){
225324226127
if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT;
225325226128
break;
225326226129
}
225327226130
fts5BufferSafeAppendVarint(&out, (tmp.n+nTail) * 2);
@@ -226958,10 +227761,11 @@
226958227761
);
226959227762
}
226960227763
return rc;
226961227764
#else
226962227765
return SQLITE_OK;
227766
+ UNUSED_PARAM(db);
226963227767
#endif
226964227768
}
226965227769
226966227770
226967227771
static int sqlite3Fts5IndexReset(Fts5Index *p){
@@ -228921,17 +229725,19 @@
228921229725
}
228922229726
if( iBest<0 ) break;
228923229727
228924229728
nInst++;
228925229729
if( nInst>=pCsr->nInstAlloc ){
228926
- pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32;
229730
+ int nNewSize = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32;
228927229731
aInst = (int*)sqlite3_realloc64(
228928
- pCsr->aInst, pCsr->nInstAlloc*sizeof(int)*3
229732
+ pCsr->aInst, nNewSize*sizeof(int)*3
228929229733
);
228930229734
if( aInst ){
228931229735
pCsr->aInst = aInst;
229736
+ pCsr->nInstAlloc = nNewSize;
228932229737
}else{
229738
+ nInst--;
228933229739
rc = SQLITE_NOMEM;
228934229740
break;
228935229741
}
228936229742
}
228937229743
@@ -229762,11 +230568,11 @@
229762230568
int nArg, /* Number of args */
229763230569
sqlite3_value **apUnused /* Function arguments */
229764230570
){
229765230571
assert( nArg==0 );
229766230572
UNUSED_PARAM2(nArg, apUnused);
229767
- sqlite3_result_text(pCtx, "fts5: 2021-04-07 13:20:34 c22e47c77a35ebcd1fdfc0caea9119dd5e24e76d5fdd0f2ffbb58205a7242297", -1, SQLITE_TRANSIENT);
230573
+ sqlite3_result_text(pCtx, "fts5: 2021-06-14 20:41:20 e5a5acd6006133c5da4a7dd79726dbaa41c0d60ebeda890f848a6aafe5f9ef70", -1, SQLITE_TRANSIENT);
229768230574
}
229769230575
229770230576
/*
229771230577
** Return true if zName is the extension on one of the shadow tables used
229772230578
** by this module.
@@ -234688,12 +235494,12 @@
234688235494
}
234689235495
#endif /* SQLITE_CORE */
234690235496
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
234691235497
234692235498
/************** End of stmt.c ************************************************/
234693
-#if __LINE__!=234693
235499
+#if __LINE__!=235499
234694235500
#undef SQLITE_SOURCE_ID
234695
-#define SQLITE_SOURCE_ID "2021-04-07 18:17:53 a2ddb89b206c13876d34c5f9e3db41cda72d6eb3fea31ffa8cc6daa1e158alt2"
235501
+#define SQLITE_SOURCE_ID "2021-06-14 20:41:20 e5a5acd6006133c5da4a7dd79726dbaa41c0d60ebeda890f848a6aafe5f9alt2"
234696235502
#endif
234697235503
/* Return the source-id for this library */
234698235504
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
234699235505
/************************** End of sqlite3.c ******************************/
234700235506
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -81,12 +81,14 @@
81 "4_BYTE_ALIGNED_MALLOC",
82 #endif
83 #if SQLITE_64BIT_STATS
84 "64BIT_STATS",
85 #endif
86 #if SQLITE_ALLOW_COVERING_INDEX_SCAN
87 "ALLOW_COVERING_INDEX_SCAN",
 
 
88 #endif
89 #if SQLITE_ALLOW_URI_AUTHORITY
90 "ALLOW_URI_AUTHORITY",
91 #endif
92 #ifdef SQLITE_BITMASK_TYPE
@@ -144,12 +146,14 @@
144 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
145 #endif
146 #ifdef SQLITE_DEFAULT_LOOKASIDE
147 "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE),
148 #endif
149 #if SQLITE_DEFAULT_MEMSTATUS
150 "DEFAULT_MEMSTATUS",
 
 
151 #endif
152 #ifdef SQLITE_DEFAULT_MMAP_SIZE
153 "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
154 #endif
155 #ifdef SQLITE_DEFAULT_PAGE_SIZE
@@ -219,11 +223,11 @@
219 "ENABLE_BATCH_ATOMIC_WRITE",
220 #endif
221 #if SQLITE_ENABLE_BYTECODE_VTAB
222 "ENABLE_BYTECODE_VTAB",
223 #endif
224 #if SQLITE_ENABLE_CEROD
225 "ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD),
226 #endif
227 #if SQLITE_ENABLE_COLUMN_METADATA
228 "ENABLE_COLUMN_METADATA",
229 #endif
@@ -233,22 +237,22 @@
233 #if SQLITE_ENABLE_COSTMULT
234 "ENABLE_COSTMULT",
235 #endif
236 #if SQLITE_ENABLE_CURSOR_HINTS
237 "ENABLE_CURSOR_HINTS",
 
 
 
238 #endif
239 #if SQLITE_ENABLE_DBSTAT_VTAB
240 "ENABLE_DBSTAT_VTAB",
241 #endif
242 #if SQLITE_ENABLE_EXPENSIVE_ASSERT
243 "ENABLE_EXPENSIVE_ASSERT",
244 #endif
245 #if SQLITE_ENABLE_FTS1
246 "ENABLE_FTS1",
247 #endif
248 #if SQLITE_ENABLE_FTS2
249 "ENABLE_FTS2",
250 #endif
251 #if SQLITE_ENABLE_FTS3
252 "ENABLE_FTS3",
253 #endif
254 #if SQLITE_ENABLE_FTS3_PARENTHESIS
@@ -302,10 +306,13 @@
302 #if SQLITE_ENABLE_NORMALIZE
303 "ENABLE_NORMALIZE",
304 #endif
305 #if SQLITE_ENABLE_NULL_TRIM
306 "ENABLE_NULL_TRIM",
 
 
 
307 #endif
308 #if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
309 "ENABLE_OVERSIZE_CELL_CHECK",
310 #endif
311 #if SQLITE_ENABLE_PREUPDATE_HOOK
@@ -333,11 +340,11 @@
333 "ENABLE_SORTER_REFERENCES",
334 #endif
335 #if SQLITE_ENABLE_SQLLOG
336 "ENABLE_SQLLOG",
337 #endif
338 #if defined(SQLITE_ENABLE_STAT4)
339 "ENABLE_STAT4",
340 #endif
341 #if SQLITE_ENABLE_STMTVTAB
342 "ENABLE_STMTVTAB",
343 #endif
@@ -387,12 +394,14 @@
387 "FTS5_NO_WITHOUT_ROWID",
388 #endif
389 #if HAVE_ISNAN || SQLITE_HAVE_ISNAN
390 "HAVE_ISNAN",
391 #endif
392 #if SQLITE_HOMEGROWN_RECURSIVE_MUTEX
393 "HOMEGROWN_RECURSIVE_MUTEX",
 
 
394 #endif
395 #if SQLITE_IGNORE_AFP_LOCK_ERRORS
396 "IGNORE_AFP_LOCK_ERRORS",
397 #endif
398 #if SQLITE_IGNORE_FLOCK_LOCK_ERRORS
@@ -486,13 +495,10 @@
486 "MMAP_READWRITE",
487 #endif
488 #if SQLITE_MUTEX_NOOP
489 "MUTEX_NOOP",
490 #endif
491 #if SQLITE_MUTEX_NREF
492 "MUTEX_NREF",
493 #endif
494 #if SQLITE_MUTEX_OMIT
495 "MUTEX_OMIT",
496 #endif
497 #if SQLITE_MUTEX_PTHREADS
498 "MUTEX_PTHREADS",
@@ -558,18 +564,21 @@
558 "OMIT_CONFLICT_CLAUSE",
559 #endif
560 #if SQLITE_OMIT_CTE
561 "OMIT_CTE",
562 #endif
563 #if SQLITE_OMIT_DATETIME_FUNCS
564 "OMIT_DATETIME_FUNCS",
565 #endif
566 #if SQLITE_OMIT_DECLTYPE
567 "OMIT_DECLTYPE",
568 #endif
569 #if SQLITE_OMIT_DEPRECATED
570 "OMIT_DEPRECATED",
 
 
 
571 #endif
572 #if SQLITE_OMIT_DISKIO
573 "OMIT_DISKIO",
574 #endif
575 #if SQLITE_OMIT_EXPLAIN
@@ -593,10 +602,13 @@
593 #if SQLITE_OMIT_INCRBLOB
594 "OMIT_INCRBLOB",
595 #endif
596 #if SQLITE_OMIT_INTEGRITY_CHECK
597 "OMIT_INTEGRITY_CHECK",
 
 
 
598 #endif
599 #if SQLITE_OMIT_LIKE_OPTIMIZATION
600 "OMIT_LIKE_OPTIMIZATION",
601 #endif
602 #if SQLITE_OMIT_LOAD_EXTENSION
@@ -657,12 +669,14 @@
657 "OMIT_TEMPDB",
658 #endif
659 #if SQLITE_OMIT_TEST_CONTROL
660 "OMIT_TEST_CONTROL",
661 #endif
662 #if SQLITE_OMIT_TRACE
663 "OMIT_TRACE",
 
 
664 #endif
665 #if SQLITE_OMIT_TRIGGER
666 "OMIT_TRIGGER",
667 #endif
668 #if SQLITE_OMIT_TRUNCATE_OPTIMIZATION
@@ -693,12 +707,14 @@
693 "PCACHE_SEPARATE_HEADER",
694 #endif
695 #if SQLITE_PERFORMANCE_TRACE
696 "PERFORMANCE_TRACE",
697 #endif
698 #if SQLITE_POWERSAFE_OVERWRITE
699 "POWERSAFE_OVERWRITE",
 
 
700 #endif
701 #if SQLITE_PREFER_PROXY_LOCKING
702 "PREFER_PROXY_LOCKING",
703 #endif
704 #if SQLITE_PROXY_DEBUG
@@ -729,11 +745,14 @@
729 "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),
730 #endif
731 #if SQLITE_SUBSTR_COMPATIBILITY
732 "SUBSTR_COMPATIBILITY",
733 #endif
734 #if SQLITE_SYSTEM_MALLOC
 
 
 
735 "SYSTEM_MALLOC",
736 #endif
737 #if SQLITE_TCL
738 "TCL",
739 #endif
@@ -1186,11 +1205,11 @@
1186 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1187 ** [sqlite_version()] and [sqlite_source_id()].
1188 */
1189 #define SQLITE_VERSION "3.36.0"
1190 #define SQLITE_VERSION_NUMBER 3036000
1191 #define SQLITE_SOURCE_ID "2021-04-07 18:17:53 a2ddb89b206c13876d34c5f9e3db41cda72d6eb3fea31ffa8cc6daa1e1580e16"
1192
1193 /*
1194 ** CAPI3REF: Run-Time Library Version Numbers
1195 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1196 **
@@ -2202,10 +2221,14 @@
2202 ** currently has an SQL transaction open on the database. It is set to 0 if
2203 ** the database is not a wal-mode db, or if there is no such connection in any
2204 ** other process. This opcode cannot be used to detect transactions opened
2205 ** by clients within the current process, only within other processes.
2206 ** </ul>
 
 
 
 
2207 */
2208 #define SQLITE_FCNTL_LOCKSTATE 1
2209 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
2210 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
2211 #define SQLITE_FCNTL_LAST_ERRNO 4
@@ -2241,12 +2264,12 @@
2241 #define SQLITE_FCNTL_DATA_VERSION 35
2242 #define SQLITE_FCNTL_SIZE_LIMIT 36
2243 #define SQLITE_FCNTL_CKPT_DONE 37
2244 #define SQLITE_FCNTL_RESERVE_BYTES 38
2245 #define SQLITE_FCNTL_CKPT_START 39
2246
2247 #define SQLITE_FCNTL_EXTERNAL_READER 40
 
2248
2249 /* deprecated names */
2250 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
2251 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
2252 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -5255,10 +5278,19 @@
5255 ** changes to the content of the database files on disk.
5256 ** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since
5257 ** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and
5258 ** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so
5259 ** sqlite3_stmt_readonly() returns false for those commands.
 
 
 
 
 
 
 
 
 
5260 */
5261 SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
5262
5263 /*
5264 ** CAPI3REF: Query The EXPLAIN Setting For A Prepared Statement
@@ -5424,22 +5456,26 @@
5424 ** terminated. If any NUL characters occurs at byte offsets less than
5425 ** the value of the fourth parameter then the resulting string value will
5426 ** contain embedded NULs. The result of expressions involving strings
5427 ** with embedded NULs is undefined.
5428 **
5429 ** ^The fifth argument to the BLOB and string binding interfaces
5430 ** is a destructor used to dispose of the BLOB or
5431 ** string after SQLite has finished with it. ^The destructor is called
5432 ** to dispose of the BLOB or string even if the call to the bind API fails,
5433 ** except the destructor is not called if the third parameter is a NULL
5434 ** pointer or the fourth parameter is negative.
5435 ** ^If the fifth argument is
5436 ** the special value [SQLITE_STATIC], then SQLite assumes that the
5437 ** information is in static, unmanaged space and does not need to be freed.
5438 ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
5439 ** SQLite makes its own private copy of the data immediately, before
5440 ** the sqlite3_bind_*() routine returns.
 
 
 
 
5441 **
5442 ** ^The sixth argument to sqlite3_bind_text64() must be one of
5443 ** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]
5444 ** to specify the encoding of the text in the third parameter. If
5445 ** the sixth argument to sqlite3_bind_text64() is not one of the
@@ -6177,21 +6213,19 @@
6177 ** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY]
6178 ** flag, which if present prevents the function from being invoked from
6179 ** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions,
6180 ** index expressions, or the WHERE clause of partial indexes.
6181 **
6182 ** <span style="background-color:#ffff90;">
6183 ** For best security, the [SQLITE_DIRECTONLY] flag is recommended for
6184 ** all application-defined SQL functions that do not need to be
6185 ** used inside of triggers, view, CHECK constraints, or other elements of
6186 ** the database schema. This flags is especially recommended for SQL
6187 ** functions that have side effects or reveal internal application state.
6188 ** Without this flag, an attacker might be able to modify the schema of
6189 ** a database file to include invocations of the function with parameters
6190 ** chosen by the attacker, which the application will then execute when
6191 ** the database file is opened and read.
6192 ** </span>
6193 **
6194 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
6195 ** function can gain access to this pointer using [sqlite3_user_data()].)^
6196 **
6197 ** ^The sixth, seventh and eighth parameters passed to the three
@@ -8855,11 +8889,12 @@
8855 #define SQLITE_TESTCTRL_RESULT_INTREAL 27
8856 #define SQLITE_TESTCTRL_PRNG_SEED 28
8857 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
8858 #define SQLITE_TESTCTRL_SEEK_COUNT 30
8859 #define SQLITE_TESTCTRL_TRACEFLAGS 31
8860 #define SQLITE_TESTCTRL_LAST 31 /* Largest TESTCTRL */
 
8861
8862 /*
8863 ** CAPI3REF: SQL Keyword Checking
8864 **
8865 ** These routines provide access to the set of SQL language keywords
@@ -10607,10 +10642,19 @@
10607 ** callback was invoked as a result of a direct insert, update, or delete
10608 ** operation; or 1 for inserts, updates, or deletes invoked by top-level
10609 ** triggers; or 2 for changes resulting from triggers called by top-level
10610 ** triggers; and so forth.
10611 **
 
 
 
 
 
 
 
 
 
10612 ** See also: [sqlite3_update_hook()]
10613 */
10614 #if defined(SQLITE_ENABLE_PREUPDATE_HOOK)
10615 SQLITE_API void *sqlite3_preupdate_hook(
10616 sqlite3 *db,
@@ -10627,10 +10671,11 @@
10627 );
10628 SQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);
10629 SQLITE_API int sqlite3_preupdate_count(sqlite3 *);
10630 SQLITE_API int sqlite3_preupdate_depth(sqlite3 *);
10631 SQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);
 
10632 #endif
10633
10634 /*
10635 ** CAPI3REF: Low-level system error code
10636 ** METHOD: sqlite3
@@ -10865,12 +10910,12 @@
10865 **
10866 ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
10867 ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory
10868 ** allocation error occurs.
10869 **
10870 ** This interface is only available if SQLite is compiled with the
10871 ** [SQLITE_ENABLE_DESERIALIZE] option.
10872 */
10873 SQLITE_API unsigned char *sqlite3_serialize(
10874 sqlite3 *db, /* The database connection */
10875 const char *zSchema, /* Which DB to serialize. ex: "main", "temp", ... */
10876 sqlite3_int64 *piSize, /* Write size of the DB here, if not NULL */
@@ -10917,12 +10962,12 @@
10917 **
10918 ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
10919 ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
10920 ** [sqlite3_free()] is invoked on argument P prior to returning.
10921 **
10922 ** This interface is only available if SQLite is compiled with the
10923 ** [SQLITE_ENABLE_DESERIALIZE] option.
10924 */
10925 SQLITE_API int sqlite3_deserialize(
10926 sqlite3 *db, /* The database connection */
10927 const char *zSchema, /* Which DB to reopen with the deserialization */
10928 unsigned char *pData, /* The serialized database content */
@@ -11167,10 +11212,42 @@
11167 ** are attached is closed. Refer to the documentation for
11168 ** [sqlite3session_create()] for details.
11169 */
11170 SQLITE_API void sqlite3session_delete(sqlite3_session *pSession);
11171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11172
11173 /*
11174 ** CAPI3REF: Enable Or Disable A Session Object
11175 ** METHOD: sqlite3_session
11176 **
@@ -11411,10 +11488,26 @@
11411 sqlite3_session *pSession, /* Session object */
11412 int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
11413 void **ppChangeset /* OUT: Buffer containing changeset */
11414 );
11415
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11416 /*
11417 ** CAPI3REF: Load The Difference Between Tables Into A Session
11418 ** METHOD: sqlite3_session
11419 **
11420 ** If it is not already attached to the session object passed as the first
@@ -14235,12 +14328,13 @@
14235 #define TK_VECTOR 176
14236 #define TK_SELECT_COLUMN 177
14237 #define TK_IF_NULL_ROW 178
14238 #define TK_ASTERISK 179
14239 #define TK_SPAN 180
14240 #define TK_SPACE 181
14241 #define TK_ILLEGAL 182
 
14242
14243 /************** End of parse.h ***********************************************/
14244 /************** Continuing where we left off in sqliteInt.h ******************/
14245 #include <stdio.h>
14246 #include <stdlib.h>
@@ -15931,11 +16025,11 @@
15931 /* 152 */ 0x10, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00,\
15932 /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15933 /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
15934 /* 176 */ 0x00, 0x00, 0x00, 0x00,}
15935
15936 /* The sqlite3P2Values() routine is able to run faster if it knows
15937 ** the value of the largest JUMP opcode. The smaller the maximum
15938 ** JUMP opcode the better, so the mkopcodeh.tcl script that
15939 ** generated this include file strives to group all JUMP opcodes
15940 ** together near the beginning of the list.
15941 */
@@ -16463,10 +16557,16 @@
16463 ** a no-op
16464 */
16465 #ifndef SET_FULLSYNC
16466 # define SET_FULLSYNC(x,y)
16467 #endif
 
 
 
 
 
 
16468
16469 /*
16470 ** The default size of a disk sector
16471 */
16472 #ifndef SQLITE_DEFAULT_SECTOR_SIZE
@@ -17219,11 +17319,11 @@
17219 #define SQLITE_PushDown 0x00001000 /* The push-down optimization */
17220 #define SQLITE_SimplifyJoin 0x00002000 /* Convert LEFT JOIN to JOIN */
17221 #define SQLITE_SkipScan 0x00004000 /* Skip-scans */
17222 #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */
17223 #define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */
17224 #define SQLITE_ExistsToIN 0x00020000 /* The EXISTS-to-IN optimization */
17225 #define SQLITE_AllOpts 0xffffffff /* All optimizations */
17226
17227 /*
17228 ** Macros for testing whether or not optimizations are enabled or disabled.
17229 */
@@ -17724,10 +17824,11 @@
17724 #define TF_OOOHidden 0x0400 /* Out-of-Order hidden columns */
17725 #define TF_HasNotNull 0x0800 /* Contains NOT NULL constraints */
17726 #define TF_Shadow 0x1000 /* True for a shadow table */
17727 #define TF_HasStat4 0x2000 /* STAT4 info available for this table */
17728 #define TF_Ephemeral 0x4000 /* An ephemeral table */
 
17729
17730 /*
17731 ** Test to see whether or not a table is a virtual table. This is
17732 ** done as a macro so that it will be optimized out when virtual
17733 ** table support is omitted from the build.
@@ -18436,10 +18537,11 @@
18436 unsigned isCorrelated :1; /* True if sub-query is correlated */
18437 unsigned viaCoroutine :1; /* Implemented as a co-routine */
18438 unsigned isRecursive :1; /* True for recursive reference in WITH */
18439 unsigned fromDDL :1; /* Comes from sqlite_schema */
18440 unsigned isCte :1; /* This is a CTE */
 
18441 } fg;
18442 int iCursor; /* The VDBE cursor number used to access this table */
18443 Expr *pOn; /* The ON clause of a join */
18444 IdList *pUsing; /* The USING clause of a join */
18445 Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */
@@ -18553,11 +18655,11 @@
18553 Upsert *pUpsert; /* ON CONFLICT clause information from an upsert */
18554 int iBaseReg; /* For TK_REGISTER when parsing RETURNING */
18555 } uNC;
18556 NameContext *pNext; /* Next outer name context. NULL for outermost */
18557 int nRef; /* Number of names resolved by this context */
18558 int nErr; /* Number of errors encountered while resolving names */
18559 int ncFlags; /* Zero or more NC_* flags defined below */
18560 Select *pWinSelect; /* SELECT statement for any window functions */
18561 };
18562
18563 /*
@@ -18586,10 +18688,11 @@
18586 #define NC_AllowWin 0x04000 /* Window functions are allowed here */
18587 #define NC_HasWin 0x08000 /* One or more window functions seen */
18588 #define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */
18589 #define NC_InAggFunc 0x20000 /* True if analyzing arguments to an agg func */
18590 #define NC_FromDDL 0x40000 /* SQL text comes from sqlite_schema */
 
18591
18592 /*
18593 ** An instance of the following object describes a single ON CONFLICT
18594 ** clause in an upsert.
18595 **
@@ -18698,10 +18801,11 @@
18698 #define SF_View 0x0200000 /* SELECT statement is a view */
18699 #define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */
18700 #define SF_UpdateFrom 0x0800000 /* Statement is an UPDATE...FROM */
18701 #define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */
18702 #define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */
 
18703
18704 /*
18705 ** The results of a SELECT can be distributed in several ways, as defined
18706 ** by one of the following macros. The "SRT" prefix means "SELECT Result
18707 ** Type".
@@ -19226,10 +19330,26 @@
19226 ** Allowed values for mInitFlags
19227 */
19228 #define INITFLAG_AlterRename 0x0001 /* Reparse after a RENAME */
19229 #define INITFLAG_AlterDrop 0x0002 /* Reparse after a DROP COLUMN */
19230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19231 /*
19232 ** Structure containing global configuration data for the SQLite library.
19233 **
19234 ** This structure also contains some state information.
19235 */
@@ -19280,20 +19400,24 @@
19280 ** operation. Set the callback using SQLITE_TESTCTRL_VDBE_COVERAGE.
19281 */
19282 void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx); /* Callback */
19283 void *pVdbeBranchArg; /* 1st argument */
19284 #endif
19285 #ifdef SQLITE_ENABLE_DESERIALIZE
19286 sqlite3_int64 mxMemdbSize; /* Default max memdb size */
19287 #endif
19288 #ifndef SQLITE_UNTESTABLE
19289 int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
19290 #endif
19291 int bLocaltimeFault; /* True to fail localtime() calls */
19292 int iOnceResetThreshold; /* When to reset OP_Once counters */
19293 u32 szSorterRef; /* Min size in bytes to use sorter-refs */
19294 unsigned int iPrngSeed; /* Alternative fixed seed for the PRNG */
 
 
 
 
19295 };
19296
19297 /*
19298 ** This macro is used inside of assert() statements to indicate that
19299 ** the assert is only valid on a well-formed database. Instead of:
@@ -19367,14 +19491,21 @@
19367 SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker*, Expr*);
19368 SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker*, Select*);
19369 SQLITE_PRIVATE int sqlite3SelectWalkFail(Walker*, Select*);
19370 SQLITE_PRIVATE int sqlite3WalkerDepthIncrease(Walker*,Select*);
19371 SQLITE_PRIVATE void sqlite3WalkerDepthDecrease(Walker*,Select*);
 
19372
19373 #ifdef SQLITE_DEBUG
19374 SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*);
19375 #endif
 
 
 
 
 
 
19376
19377 /*
19378 ** Return code from the parse-tree walking primitives and their
19379 ** callbacks.
19380 */
@@ -19405,10 +19536,11 @@
19405 ** An instance of the With object represents a WITH clause containing
19406 ** one or more CTEs (common table expressions).
19407 */
19408 struct With {
19409 int nCte; /* Number of CTEs in the WITH clause */
 
19410 With *pOuter; /* Containing WITH clause, or NULL */
19411 Cte a[1]; /* For each CTE in the WITH clause.... */
19412 };
19413
19414 /*
@@ -19797,10 +19929,11 @@
19797 SQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*);
19798 SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int);
19799 SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*);
19800 SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*);
19801 SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*);
 
19802 SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
19803 SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*,char);
19804 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*,char);
19805 SQLITE_PRIVATE void sqlite3OpenSchemaTable(Parse *, int);
19806 SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
@@ -20032,10 +20165,11 @@
20032 SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
20033 SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
20034 SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*);
20035 SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*);
20036 SQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int);
 
20037
20038 #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
20039 SQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int);
20040 #endif
20041
@@ -20175,11 +20309,11 @@
20175
20176 #if defined(SQLITE_NEED_ERR_NAME)
20177 SQLITE_PRIVATE const char *sqlite3ErrName(int);
20178 #endif
20179
20180 #ifdef SQLITE_ENABLE_DESERIALIZE
20181 SQLITE_PRIVATE int sqlite3MemdbInit(void);
20182 #endif
20183
20184 SQLITE_PRIVATE const char *sqlite3ErrStr(int);
20185 SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);
@@ -20442,11 +20576,11 @@
20442 #ifndef SQLITE_OMIT_CTE
20443 SQLITE_PRIVATE Cte *sqlite3CteNew(Parse*,Token*,ExprList*,Select*,u8);
20444 SQLITE_PRIVATE void sqlite3CteDelete(sqlite3*,Cte*);
20445 SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Cte*);
20446 SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*);
20447 SQLITE_PRIVATE void sqlite3WithPush(Parse*, With*, u8);
20448 #else
20449 # define sqlite3CteNew(P,T,E,S) ((void*)0)
20450 # define sqlite3CteDelete(D,C)
20451 # define sqlite3CteWithAdd(P,W,C) ((void*)0)
20452 # define sqlite3WithDelete(x,y)
@@ -20937,11 +21071,11 @@
20937 #endif
20938 #ifdef SQLITE_VDBE_COVERAGE
20939 0, /* xVdbeBranch */
20940 0, /* pVbeBranchArg */
20941 #endif
20942 #ifdef SQLITE_ENABLE_DESERIALIZE
20943 SQLITE_MEMDB_DEFAULT_MAXSIZE, /* mxMemdbSize */
20944 #endif
20945 #ifndef SQLITE_UNTESTABLE
20946 0, /* xTestCallback */
20947 #endif
@@ -21500,10 +21634,11 @@
21500 u8 *aRecord; /* old.* database record */
21501 KeyInfo keyinfo;
21502 UnpackedRecord *pUnpacked; /* Unpacked version of aRecord[] */
21503 UnpackedRecord *pNewUnpacked; /* Unpacked version of new.* record */
21504 int iNewReg; /* Register for new.* values */
 
21505 i64 iKey1; /* First key value passed to hook */
21506 i64 iKey2; /* Second key value passed to hook */
21507 Mem *aNew; /* Array of new.* values */
21508 Table *pTab; /* Schema object being upated */
21509 Index *pPk; /* PK index if pTab is WITHOUT ROWID */
@@ -21543,11 +21678,11 @@
21543 SQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem*);
21544 SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem*, const Mem*);
21545 SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);
21546 SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*);
21547 SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*);
21548 SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*));
21549 SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64);
21550 #ifdef SQLITE_OMIT_FLOATING_POINT
21551 # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
21552 #else
21553 SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double);
@@ -21588,11 +21723,12 @@
21588 #endif
21589 SQLITE_PRIVATE void sqlite3VdbeFrameMemDel(void*); /* Destructor on Mem */
21590 SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*); /* Actually deletes the Frame */
21591 SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
21592 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
21593 SQLITE_PRIVATE void sqlite3VdbePreUpdateHook(Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int);
 
21594 #endif
21595 SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p);
21596
21597 SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *);
21598 SQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *);
@@ -23539,10 +23675,12 @@
23539 zPathOut[0] = 0;
23540 return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);
23541 }
23542 #ifndef SQLITE_OMIT_LOAD_EXTENSION
23543 SQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){
 
 
23544 return pVfs->xDlOpen(pVfs, zPath);
23545 }
23546 SQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
23547 pVfs->xDlError(pVfs, nByte, zBufOut);
23548 }
@@ -27806,11 +27944,10 @@
27806 SQLITE_PRIVATE int sqlite3MallocInit(void){
27807 int rc;
27808 if( sqlite3GlobalConfig.m.xMalloc==0 ){
27809 sqlite3MemSetDefault();
27810 }
27811 memset(&mem0, 0, sizeof(mem0));
27812 mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
27813 if( sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.szPage<512
27814 || sqlite3GlobalConfig.nPage<=0 ){
27815 sqlite3GlobalConfig.pPage = 0;
27816 sqlite3GlobalConfig.szPage = 0;
@@ -29932,10 +30069,11 @@
29932 for(i=0; i<pSrc->nSrc; i++){
29933 const SrcItem *pItem = &pSrc->a[i];
29934 StrAccum x;
29935 char zLine[100];
29936 sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
 
29937 sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem);
29938 if( pItem->pTab ){
29939 sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx",
29940 pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed);
29941 }
@@ -30502,10 +30640,18 @@
30502 }
30503 case TK_IF_NULL_ROW: {
30504 sqlite3TreeViewLine(pView, "IF-NULL-ROW %d", pExpr->iTable);
30505 sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
30506 break;
 
 
 
 
 
 
 
 
30507 }
30508 default: {
30509 sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
30510 break;
30511 }
@@ -41972,10 +42118,26 @@
41972 /* Register all VFSes defined in the aVfs[] array */
41973 for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){
41974 sqlite3_vfs_register(&aVfs[i], i==0);
41975 }
41976 unixBigLock = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41977 return SQLITE_OK;
41978 }
41979
41980 /*
41981 ** Shutdown the operating system interface.
@@ -48365,35 +48527,92 @@
48365 **
48366 ** This file also implements interface sqlite3_serialize() and
48367 ** sqlite3_deserialize().
48368 */
48369 /* #include "sqliteInt.h" */
48370 #ifdef SQLITE_ENABLE_DESERIALIZE
48371
48372 /*
48373 ** Forward declaration of objects used by this utility
48374 */
48375 typedef struct sqlite3_vfs MemVfs;
48376 typedef struct MemFile MemFile;
 
48377
48378 /* Access to a lower-level VFS that (might) implement dynamic loading,
48379 ** access to randomness, etc.
48380 */
48381 #define ORIGVFS(p) ((sqlite3_vfs*)((p)->pAppData))
48382
48383 /* An open file */
48384 struct MemFile {
48385 sqlite3_file base; /* IO methods */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48386 sqlite3_int64 sz; /* Size of the file */
48387 sqlite3_int64 szAlloc; /* Space allocated to aData */
48388 sqlite3_int64 szMax; /* Maximum allowed size of the file */
48389 unsigned char *aData; /* content of the file */
 
48390 int nMmap; /* Number of memory mapped pages */
48391 unsigned mFlags; /* Flags */
 
 
 
 
 
 
 
 
 
 
48392 int eLock; /* Most recent lock against this file */
48393 };
48394
 
 
 
 
 
 
 
 
 
 
 
48395 /*
48396 ** Methods for MemFile
48397 */
48398 static int memdbClose(sqlite3_file*);
48399 static int memdbRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
@@ -48443,11 +48662,14 @@
48443 memdbDlClose, /* xDlClose */
48444 memdbRandomness, /* xRandomness */
48445 memdbSleep, /* xSleep */
48446 0, /* memdbCurrentTime, */ /* xCurrentTime */
48447 memdbGetLastError, /* xGetLastError */
48448 memdbCurrentTimeInt64 /* xCurrentTimeInt64 */
 
 
 
48449 };
48450
48451 static const sqlite3_io_methods memdb_io_methods = {
48452 3, /* iVersion */
48453 memdbClose, /* xClose */
@@ -48468,23 +48690,71 @@
48468 0, /* xShmUnmap */
48469 memdbFetch, /* xFetch */
48470 memdbUnfetch /* xUnfetch */
48471 };
48472
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48473
48474
48475 /*
48476 ** Close an memdb-file.
48477 **
48478 ** The pData pointer is owned by the application, so there is nothing
48479 ** to free. Unless the SQLITE_DESERIALIZE_FREEONCLOSE flag is set,
48480 ** in which case we own the pData pointer and need to free it.
48481 */
48482 static int memdbClose(sqlite3_file *pFile){
48483 MemFile *p = (MemFile *)pFile;
48484 if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ){
48485 sqlite3_free(p->aData);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48486 }
48487 return SQLITE_OK;
48488 }
48489
48490 /*
@@ -48494,24 +48764,27 @@
48494 sqlite3_file *pFile,
48495 void *zBuf,
48496 int iAmt,
48497 sqlite_int64 iOfst
48498 ){
48499 MemFile *p = (MemFile *)pFile;
 
48500 if( iOfst+iAmt>p->sz ){
48501 memset(zBuf, 0, iAmt);
48502 if( iOfst<p->sz ) memcpy(zBuf, p->aData+iOfst, p->sz - iOfst);
 
48503 return SQLITE_IOERR_SHORT_READ;
48504 }
48505 memcpy(zBuf, p->aData+iOfst, iAmt);
 
48506 return SQLITE_OK;
48507 }
48508
48509 /*
48510 ** Try to enlarge the memory allocation to hold at least sz bytes
48511 */
48512 static int memdbEnlarge(MemFile *p, sqlite3_int64 newSz){
48513 unsigned char *pNew;
48514 if( (p->mFlags & SQLITE_DESERIALIZE_RESIZEABLE)==0 || p->nMmap>0 ){
48515 return SQLITE_FULL;
48516 }
48517 if( newSz>p->szMax ){
@@ -48518,11 +48791,11 @@
48518 return SQLITE_FULL;
48519 }
48520 newSz *= 2;
48521 if( newSz>p->szMax ) newSz = p->szMax;
48522 pNew = sqlite3Realloc(p->aData, newSz);
48523 if( pNew==0 ) return SQLITE_NOMEM;
48524 p->aData = pNew;
48525 p->szAlloc = newSz;
48526 return SQLITE_OK;
48527 }
48528
@@ -48533,23 +48806,31 @@
48533 sqlite3_file *pFile,
48534 const void *z,
48535 int iAmt,
48536 sqlite_int64 iOfst
48537 ){
48538 MemFile *p = (MemFile *)pFile;
48539 if( NEVER(p->mFlags & SQLITE_DESERIALIZE_READONLY) ) return SQLITE_READONLY;
 
 
 
 
 
 
48540 if( iOfst+iAmt>p->sz ){
48541 int rc;
48542 if( iOfst+iAmt>p->szAlloc
48543 && (rc = memdbEnlarge(p, iOfst+iAmt))!=SQLITE_OK
48544 ){
 
48545 return rc;
48546 }
48547 if( iOfst>p->sz ) memset(p->aData+p->sz, 0, iOfst-p->sz);
48548 p->sz = iOfst+iAmt;
48549 }
48550 memcpy(p->aData+iOfst, z, iAmt);
 
48551 return SQLITE_OK;
48552 }
48553
48554 /*
48555 ** Truncate an memdb-file.
@@ -48557,62 +48838,103 @@
48557 ** In rollback mode (which is always the case for memdb, as it does not
48558 ** support WAL mode) the truncate() method is only used to reduce
48559 ** the size of a file, never to increase the size.
48560 */
48561 static int memdbTruncate(sqlite3_file *pFile, sqlite_int64 size){
48562 MemFile *p = (MemFile *)pFile;
48563 if( NEVER(size>p->sz) ) return SQLITE_FULL;
48564 p->sz = size;
48565 return SQLITE_OK;
 
 
 
 
 
 
48566 }
48567
48568 /*
48569 ** Sync an memdb-file.
48570 */
48571 static int memdbSync(sqlite3_file *pFile, int flags){
 
 
48572 return SQLITE_OK;
48573 }
48574
48575 /*
48576 ** Return the current file-size of an memdb-file.
48577 */
48578 static int memdbFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){
48579 MemFile *p = (MemFile *)pFile;
 
48580 *pSize = p->sz;
 
48581 return SQLITE_OK;
48582 }
48583
48584 /*
48585 ** Lock an memdb-file.
48586 */
48587 static int memdbLock(sqlite3_file *pFile, int eLock){
48588 MemFile *p = (MemFile *)pFile;
48589 if( eLock>SQLITE_LOCK_SHARED
48590 && (p->mFlags & SQLITE_DESERIALIZE_READONLY)!=0
48591 ){
48592 return SQLITE_READONLY;
48593 }
48594 p->eLock = eLock;
48595 return SQLITE_OK;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48596 }
48597
48598 #if 0 /* Never used because memdbAccess() always returns false */
48599 /*
48600 ** Check if another file-handle holds a RESERVED lock on an memdb-file.
 
48601 */
48602 static int memdbCheckReservedLock(sqlite3_file *pFile, int *pResOut){
48603 *pResOut = 0;
48604 return SQLITE_OK;
48605 }
48606 #endif
 
48607
48608 /*
48609 ** File control method. For custom operations on an memdb-file.
48610 */
48611 static int memdbFileControl(sqlite3_file *pFile, int op, void *pArg){
48612 MemFile *p = (MemFile *)pFile;
48613 int rc = SQLITE_NOTFOUND;
 
48614 if( op==SQLITE_FCNTL_VFSNAME ){
48615 *(char**)pArg = sqlite3_mprintf("memdb(%p,%lld)", p->aData, p->sz);
48616 rc = SQLITE_OK;
48617 }
48618 if( op==SQLITE_FCNTL_SIZE_LIMIT ){
@@ -48626,10 +48948,11 @@
48626 }
48627 p->szMax = iLimit;
48628 *(sqlite3_int64*)pArg = iLimit;
48629 rc = SQLITE_OK;
48630 }
 
48631 return rc;
48632 }
48633
48634 #if 0 /* Not used because of SQLITE_IOCAP_POWERSAFE_OVERWRITE */
48635 /*
@@ -48642,10 +48965,11 @@
48642
48643 /*
48644 ** Return the device characteristic flags supported by an memdb-file.
48645 */
48646 static int memdbDeviceCharacteristics(sqlite3_file *pFile){
 
48647 return SQLITE_IOCAP_ATOMIC |
48648 SQLITE_IOCAP_POWERSAFE_OVERWRITE |
48649 SQLITE_IOCAP_SAFE_APPEND |
48650 SQLITE_IOCAP_SEQUENTIAL;
48651 }
@@ -48655,47 +48979,112 @@
48655 sqlite3_file *pFile,
48656 sqlite3_int64 iOfst,
48657 int iAmt,
48658 void **pp
48659 ){
48660 MemFile *p = (MemFile *)pFile;
 
48661 if( iOfst+iAmt>p->sz ){
48662 *pp = 0;
48663 }else{
48664 p->nMmap++;
48665 *pp = (void*)(p->aData + iOfst);
48666 }
 
48667 return SQLITE_OK;
48668 }
48669
48670 /* Release a memory-mapped page */
48671 static int memdbUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){
48672 MemFile *p = (MemFile *)pFile;
 
 
 
48673 p->nMmap--;
 
48674 return SQLITE_OK;
48675 }
48676
48677 /*
48678 ** Open an mem file handle.
48679 */
48680 static int memdbOpen(
48681 sqlite3_vfs *pVfs,
48682 const char *zName,
48683 sqlite3_file *pFile,
48684 int flags,
48685 int *pOutFlags
48686 ){
48687 MemFile *p = (MemFile*)pFile;
 
 
48688 if( (flags & SQLITE_OPEN_MAIN_DB)==0 ){
48689 return ORIGVFS(pVfs)->xOpen(ORIGVFS(pVfs), zName, pFile, flags, pOutFlags);
48690 }
48691 memset(p, 0, sizeof(*p));
48692 p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48693 assert( pOutFlags!=0 ); /* True because flags==SQLITE_OPEN_MAIN_DB */
48694 *pOutFlags = flags | SQLITE_OPEN_MEMORY;
48695 pFile->pMethods = &memdb_io_methods;
48696 p->szMax = sqlite3GlobalConfig.mxMemdbSize;
48697 return SQLITE_OK;
48698 }
48699
48700 #if 0 /* Only used to delete rollback journals, super-journals, and WAL
48701 ** files, none of which exist in memdb. So this routine is never used */
@@ -48719,10 +49108,13 @@
48719 sqlite3_vfs *pVfs,
48720 const char *zPath,
48721 int flags,
48722 int *pResOut
48723 ){
 
 
 
48724 *pResOut = 0;
48725 return SQLITE_OK;
48726 }
48727
48728 /*
@@ -48734,10 +49126,11 @@
48734 sqlite3_vfs *pVfs,
48735 const char *zPath,
48736 int nOut,
48737 char *zOut
48738 ){
 
48739 sqlite3_snprintf(nOut, zOut, "%s", zPath);
48740 return SQLITE_OK;
48741 }
48742
48743 /*
@@ -48806,13 +49199,18 @@
48806 ** Translate a database connection pointer and schema name into a
48807 ** MemFile pointer.
48808 */
48809 static MemFile *memdbFromDbSchema(sqlite3 *db, const char *zSchema){
48810 MemFile *p = 0;
 
48811 int rc = sqlite3_file_control(db, zSchema, SQLITE_FCNTL_FILE_POINTER, &p);
48812 if( rc ) return 0;
48813 if( p->base.pMethods!=&memdb_io_methods ) return 0;
 
 
 
 
48814 return p;
48815 }
48816
48817 /*
48818 ** Return the serialization of a database
@@ -48844,16 +49242,18 @@
48844 p = memdbFromDbSchema(db, zSchema);
48845 iDb = sqlite3FindDbName(db, zSchema);
48846 if( piSize ) *piSize = -1;
48847 if( iDb<0 ) return 0;
48848 if( p ){
48849 if( piSize ) *piSize = p->sz;
 
 
48850 if( mFlags & SQLITE_SERIALIZE_NOCOPY ){
48851 pOut = p->aData;
48852 }else{
48853 pOut = sqlite3_malloc64( p->sz );
48854 if( pOut ) memcpy(pOut, p->aData, p->sz);
48855 }
48856 return pOut;
48857 }
48858 pBt = db->aDb[iDb].pBt;
48859 if( pBt==0 ) return 0;
@@ -48943,19 +49343,20 @@
48943 }
48944 p = memdbFromDbSchema(db, zSchema);
48945 if( p==0 ){
48946 rc = SQLITE_ERROR;
48947 }else{
48948 p->aData = pData;
 
48949 pData = 0;
48950 p->sz = szDb;
48951 p->szAlloc = szBuf;
48952 p->szMax = szBuf;
48953 if( p->szMax<sqlite3GlobalConfig.mxMemdbSize ){
48954 p->szMax = sqlite3GlobalConfig.mxMemdbSize;
48955 }
48956 p->mFlags = mFlags;
48957 rc = SQLITE_OK;
48958 }
48959
48960 end_deserialize:
48961 sqlite3_finalize(pStmt);
@@ -48970,21 +49371,21 @@
48970 ** This routine is called when the extension is loaded.
48971 ** Register the new VFS.
48972 */
48973 SQLITE_PRIVATE int sqlite3MemdbInit(void){
48974 sqlite3_vfs *pLower = sqlite3_vfs_find(0);
48975 int sz = pLower->szOsFile;
48976 memdb_vfs.pAppData = pLower;
48977 /* The following conditional can only be true when compiled for
48978 ** Windows x86 and SQLITE_MAX_MMAP_SIZE=0. We always leave
48979 ** it in, to be safe, but it is marked as NO_TEST since there
48980 ** is no way to reach it under most builds. */
48981 if( sz<sizeof(MemFile) ) sz = sizeof(MemFile); /*NO_TEST*/
48982 memdb_vfs.szOsFile = sz;
48983 return sqlite3_vfs_register(&memdb_vfs, 0);
48984 }
48985 #endif /* SQLITE_ENABLE_DESERIALIZE */
48986
48987 /************** End of memdb.c ***********************************************/
48988 /************** Begin file bitvec.c ******************************************/
48989 /*
48990 ** 2008 February 16
@@ -56895,11 +57296,11 @@
56895 u8 *pPtr;
56896 Pager *pPager = 0; /* Pager object to allocate and return */
56897 int rc = SQLITE_OK; /* Return code */
56898 int tempFile = 0; /* True for temp files (incl. in-memory files) */
56899 int memDb = 0; /* True if this is an in-memory file */
56900 #ifdef SQLITE_ENABLE_DESERIALIZE
56901 int memJM = 0; /* Memory journal mode */
56902 #else
56903 # define memJM 0
56904 #endif
56905 int readOnly = 0; /* True if this is a read-only file */
@@ -57099,11 +57500,11 @@
57099 */
57100 if( zFilename && zFilename[0] ){
57101 int fout = 0; /* VFS flags returned by xOpen() */
57102 rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout);
57103 assert( !memDb );
57104 #ifdef SQLITE_ENABLE_DESERIALIZE
57105 memJM = (fout&SQLITE_OPEN_MEMORY)!=0;
57106 #endif
57107 readOnly = (fout&SQLITE_OPEN_READONLY)!=0;
57108
57109 /* If the file was successfully opened for read/write access,
@@ -58067,11 +58468,11 @@
58067
58068 if( pPager->errCode ) return pPager->errCode;
58069 assert( pPager->eState>=PAGER_READER && pPager->eState<PAGER_ERROR );
58070 pPager->subjInMemory = (u8)subjInMemory;
58071
58072 if( ALWAYS(pPager->eState==PAGER_READER) ){
58073 assert( pPager->pInJournal==0 );
58074
58075 if( pagerUseWal(pPager) ){
58076 /* If the pager is configured to use locking_mode=exclusive, and an
58077 ** exclusive lock on the database is not already held, obtain it now.
@@ -60941,11 +61342,10 @@
60941 static void walCleanupHash(Wal *pWal){
60942 WalHashLoc sLoc; /* Hash table location */
60943 int iLimit = 0; /* Zero values greater than this */
60944 int nByte; /* Number of bytes to zero in aPgno[] */
60945 int i; /* Used to iterate through aHash[] */
60946 int rc; /* Return code form walHashGet() */
60947
60948 assert( pWal->writeLock );
60949 testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 );
60950 testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE );
60951 testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 );
@@ -60956,12 +61356,12 @@
60956 ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed
60957 ** that the page said hash-table and array reside on is already mapped.(1)
60958 */
60959 assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );
60960 assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );
60961 rc = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
60962 if( NEVER(rc) ) return; /* Defense-in-depth, in case (1) above is wrong */
60963
60964 /* Zero all hash-table entries that correspond to frame numbers greater
60965 ** than pWal->hdr.mxFrame.
60966 */
60967 iLimit = pWal->hdr.mxFrame - sLoc.iZero;
@@ -65587,11 +65987,11 @@
65587 Pgno pgnoRoot, /* The table that might be changing */
65588 i64 iRow, /* The rowid that might be changing */
65589 int isClearTable /* True if all rows are being deleted */
65590 ){
65591 BtCursor *p;
65592 if( pBtree->hasIncrblobCur==0 ) return;
65593 assert( sqlite3BtreeHoldsMutex(pBtree) );
65594 pBtree->hasIncrblobCur = 0;
65595 for(p=pBtree->pBt->pCursor; p; p=p->pNext){
65596 if( (p->curFlags & BTCF_Incrblob)!=0 ){
65597 pBtree->hasIncrblobCur = 1;
@@ -66488,10 +66888,11 @@
66488 unsigned char *data; /* The page data */
66489 unsigned char *temp; /* Temp area for cell content */
66490 unsigned char *src; /* Source of content */
66491 int iCellFirst; /* First allowable cell index */
66492 int iCellLast; /* Last possible cell index */
 
66493
66494 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
66495 assert( pPage->pBt!=0 );
66496 assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE );
66497 assert( pPage->nOverflow==0 );
@@ -66529,11 +66930,11 @@
66529 if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage);
66530 sz2 = get2byte(&data[iFree2+2]);
66531 if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage);
66532 memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));
66533 sz += sz2;
66534 }else if( NEVER(iFree+sz>usableSize) ){
66535 return SQLITE_CORRUPT_PAGE(pPage);
66536 }
66537
66538 cbrk = top+sz;
66539 assert( cbrk+(iFree-top) <= usableSize );
@@ -66548,38 +66949,37 @@
66548 }
66549 }
66550
66551 cbrk = usableSize;
66552 iCellLast = usableSize - 4;
 
66553 for(i=0; i<nCell; i++){
66554 u8 *pAddr; /* The i-th cell pointer */
66555 pAddr = &data[cellOffset + i*2];
66556 pc = get2byte(pAddr);
66557 testcase( pc==iCellFirst );
66558 testcase( pc==iCellLast );
66559 /* These conditions have already been verified in btreeInitPage()
66560 ** if PRAGMA cell_size_check=ON.
66561 */
66562 if( pc<iCellFirst || pc>iCellLast ){
66563 return SQLITE_CORRUPT_PAGE(pPage);
66564 }
66565 assert( pc>=iCellFirst && pc<=iCellLast );
66566 size = pPage->xCellSize(pPage, &src[pc]);
66567 cbrk -= size;
66568 if( cbrk<iCellFirst || pc+size>usableSize ){
66569 return SQLITE_CORRUPT_PAGE(pPage);
66570 }
66571 assert( cbrk+size<=usableSize && cbrk>=iCellFirst );
66572 testcase( cbrk+size==usableSize );
66573 testcase( pc+size==usableSize );
66574 put2byte(pAddr, cbrk);
66575 if( temp==0 ){
66576 int x;
66577 if( cbrk==pc ) continue;
66578 temp = sqlite3PagerTempSpace(pPage->pBt->pPager);
66579 x = get2byte(&data[hdr+5]);
66580 memcpy(&temp[x], &data[x], (cbrk+size) - x);
66581 src = temp;
66582 }
66583 memcpy(&data[cbrk], &src[pc], size);
66584 }
66585 data[hdr+7] = 0;
@@ -71459,14 +71859,13 @@
71459 *pRC = freePage2(pPage->pBt, pPage, pPage->pgno);
71460 }
71461 }
71462
71463 /*
71464 ** Free any overflow pages associated with the given Cell. Store
71465 ** size information about the cell in pInfo.
71466 */
71467 static int clearCell(
71468 MemPage *pPage, /* The page that contains the Cell */
71469 unsigned char *pCell, /* First byte of the Cell */
71470 CellInfo *pInfo /* Size information about the cell */
71471 ){
71472 BtShared *pBt;
@@ -71474,14 +71873,11 @@
71474 int rc;
71475 int nOvfl;
71476 u32 ovflPageSize;
71477
71478 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
71479 pPage->xParseCell(pPage, pCell, pInfo);
71480 if( pInfo->nLocal==pInfo->nPayload ){
71481 return SQLITE_OK; /* No overflow pages. Return without doing anything */
71482 }
71483 testcase( pCell + pInfo->nSize == pPage->aDataEnd );
71484 testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd );
71485 if( pCell + pInfo->nSize > pPage->aDataEnd ){
71486 /* Cell extends past end of page */
71487 return SQLITE_CORRUPT_PAGE(pPage);
@@ -71532,10 +71928,25 @@
71532 if( rc ) return rc;
71533 ovflPgno = iNext;
71534 }
71535 return SQLITE_OK;
71536 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71537
71538 /*
71539 ** Create the byte sequence used to represent a cell on page pPage
71540 ** and write that byte sequence into pCell[]. Overflow pages are
71541 ** allocated and filled in as necessary. The calling procedure
@@ -72055,11 +72466,11 @@
72055 pData = pEnd;
72056 while( 1/*exit by break*/ ){
72057 u8 *pCell = pCArray->apCell[i];
72058 u16 sz = pCArray->szCell[i];
72059 assert( sz>0 );
72060 if( SQLITE_WITHIN(pCell,aData,pEnd) ){
72061 if( ((uptr)(pCell+sz))>(uptr)pEnd ) return SQLITE_CORRUPT_BKPT;
72062 pCell = &pTmp[pCell - aData];
72063 }else if( (uptr)(pCell+sz)>(uptr)pSrcEnd
72064 && (uptr)(pCell)<(uptr)pSrcEnd
72065 ){
@@ -72068,13 +72479,12 @@
72068
72069 pData -= sz;
72070 put2byte(pCellptr, (pData - aData));
72071 pCellptr += 2;
72072 if( pData < pCellptr ) return SQLITE_CORRUPT_BKPT;
72073 memcpy(pData, pCell, sz);
72074 assert( sz==pPg->xCellSize(pPg, pCell) || CORRUPT_DB );
72075 testcase( sz!=pPg->xCellSize(pPg,pCell) )
72076 i++;
72077 if( i>=iEnd ) break;
72078 if( pCArray->ixNx[k]<=i ){
72079 k++;
72080 pSrcEnd = pCArray->apEnd[k];
@@ -72209,11 +72619,13 @@
72209 assert( pFree>aData && (pFree - aData)<65536 );
72210 freeSpace(pPg, (u16)(pFree - aData), szFree);
72211 }
72212 pFree = pCell;
72213 szFree = sz;
72214 if( pFree+sz>pEnd ) return 0;
 
 
72215 }else{
72216 pFree = pCell;
72217 szFree += sz;
72218 }
72219 nRet++;
@@ -72862,11 +73274,11 @@
72862 b.apCell[b.nCell] = pTemp+leafCorrection;
72863 assert( leafCorrection==0 || leafCorrection==4 );
72864 b.szCell[b.nCell] = b.szCell[b.nCell] - leafCorrection;
72865 if( !pOld->leaf ){
72866 assert( leafCorrection==0 );
72867 assert( pOld->hdrOffset==0 );
72868 /* The right pointer of the child page pOld becomes the left
72869 ** pointer of the divider cell */
72870 memcpy(b.apCell[b.nCell], &pOld->aData[8], 4);
72871 }else{
72872 assert( leafCorrection==4 );
@@ -73185,10 +73597,11 @@
73185 /* Insert new divider cells into pParent. */
73186 for(i=0; i<nNew-1; i++){
73187 u8 *pCell;
73188 u8 *pTemp;
73189 int sz;
 
73190 MemPage *pNew = apNew[i];
73191 j = cntNew[i];
73192
73193 assert( j<nMaxCells );
73194 assert( b.apCell[j]!=0 );
@@ -73228,10 +73641,16 @@
73228 }
73229 }
73230 iOvflSpace += sz;
73231 assert( sz<=pBt->maxLocal+23 );
73232 assert( iOvflSpace <= (int)pBt->pageSize );
 
 
 
 
 
 
73233 insertCell(pParent, nxDiv+i, pCell, sz, pTemp, pNew->pgno, &rc);
73234 if( rc!=SQLITE_OK ) goto balance_cleanup;
73235 assert( sqlite3PagerIswriteable(pParent->pDbPage) );
73236 }
73237
@@ -73770,17 +74189,27 @@
73770 ** not to clear the cursor here.
73771 */
73772 if( pCur->curFlags & BTCF_Multiple ){
73773 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
73774 if( rc ) return rc;
 
 
 
 
 
 
 
 
73775 }
73776
73777 if( pCur->pKeyInfo==0 ){
73778 assert( pX->pKey==0 );
73779 /* If this is an insert into a table b-tree, invalidate any incrblob
73780 ** cursors open on the row being replaced */
73781 invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0);
 
 
73782
73783 /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing
73784 ** to a row with the same key as the new entry being inserted.
73785 */
73786 #ifdef SQLITE_DEBUG
@@ -73857,21 +74286,20 @@
73857 x2.nData = pX->nKey;
73858 x2.nZero = 0;
73859 return btreeOverwriteCell(pCur, &x2);
73860 }
73861 }
73862
73863 }
73864 assert( pCur->eState==CURSOR_VALID
73865 || (pCur->eState==CURSOR_INVALID && loc)
73866 || CORRUPT_DB );
73867
73868 pPage = pCur->pPage;
73869 assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) );
73870 assert( pPage->leaf || !pPage->intKey );
73871 if( pPage->nFree<0 ){
73872 if( pCur->eState>CURSOR_INVALID ){
73873 rc = SQLITE_CORRUPT_BKPT;
73874 }else{
73875 rc = btreeComputeFreeSpace(pPage);
73876 }
73877 if( rc ) return rc;
@@ -73911,11 +74339,11 @@
73911 }
73912 oldCell = findCell(pPage, idx);
73913 if( !pPage->leaf ){
73914 memcpy(newCell, oldCell, 4);
73915 }
73916 rc = clearCell(pPage, oldCell, &info);
73917 testcase( pCur->curFlags & BTCF_ValidOvfl );
73918 invalidateOverflowCache(pCur);
73919 if( info.nSize==szNew && info.nLocal==info.nPayload
73920 && (!ISAUTOVACUUM || szNew<pPage->minLocal)
73921 ){
@@ -74148,11 +74576,12 @@
74148 assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );
74149 assert( !hasReadConflicts(p, pCur->pgnoRoot) );
74150 assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 );
74151 if( pCur->eState==CURSOR_REQUIRESEEK ){
74152 rc = btreeRestoreCursorPosition(pCur);
74153 if( rc ) return rc;
 
74154 }
74155 assert( CORRUPT_DB || pCur->eState==CURSOR_VALID );
74156
74157 iCellDepth = pCur->iPage;
74158 iCellIdx = pCur->ix;
@@ -74203,20 +74632,20 @@
74203 if( rc ) return rc;
74204 }
74205
74206 /* If this is a delete operation to remove a row from a table b-tree,
74207 ** invalidate any incrblob cursors open on the row being deleted. */
74208 if( pCur->pKeyInfo==0 ){
74209 invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0);
74210 }
74211
74212 /* Make the page containing the entry to be deleted writable. Then free any
74213 ** overflow pages associated with the entry and finally remove the cell
74214 ** itself from within the page. */
74215 rc = sqlite3PagerWrite(pPage->pDbPage);
74216 if( rc ) return rc;
74217 rc = clearCell(pPage, pCell, &info);
74218 dropCell(pPage, iCellIdx, info.nSize, &rc);
74219 if( rc ) return rc;
74220
74221 /* If the cell deleted was not located on a leaf page, then the cursor
74222 ** is currently pointing to the largest entry in the sub-tree headed
@@ -74499,18 +74928,18 @@
74499 pCell = findCell(pPage, i);
74500 if( !pPage->leaf ){
74501 rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
74502 if( rc ) goto cleardatabasepage_out;
74503 }
74504 rc = clearCell(pPage, pCell, &info);
74505 if( rc ) goto cleardatabasepage_out;
74506 }
74507 if( !pPage->leaf ){
74508 rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
74509 if( rc ) goto cleardatabasepage_out;
74510 }else if( pnChange ){
74511 assert( pPage->intKey || CORRUPT_DB );
74512 testcase( !pPage->intKey );
74513 *pnChange += pPage->nCell;
74514 }
74515 if( freePageFlag ){
74516 freePage(pPage, &rc);
@@ -74531,13 +74960,12 @@
74531 **
74532 ** This routine will fail with SQLITE_LOCKED if there are any open
74533 ** read cursors on the table. Open write cursors are moved to the
74534 ** root of the table.
74535 **
74536 ** If pnChange is not NULL, then table iTable must be an intkey table. The
74537 ** integer value pointed to by pnChange is incremented by the number of
74538 ** entries in the table.
74539 */
74540 SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){
74541 int rc;
74542 BtShared *pBt = p->pBt;
74543 sqlite3BtreeEnter(p);
@@ -74547,11 +74975,13 @@
74547
74548 if( SQLITE_OK==rc ){
74549 /* Invalidate all incrblob cursors open on table iTable (assuming iTable
74550 ** is the root of a table b-tree - if it is not, the following call is
74551 ** a no-op). */
74552 invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1);
 
 
74553 rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
74554 }
74555 sqlite3BtreeLeave(p);
74556 return rc;
74557 }
@@ -76630,11 +77060,13 @@
76630 assert( (p->flags & MEM_Cleared)==0 );
76631 }
76632
76633 /* The szMalloc field holds the correct memory allocation size */
76634 assert( p->szMalloc==0
76635 || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) );
 
 
76636
76637 /* If p holds a string or blob, the Mem.z must point to exactly
76638 ** one of the following:
76639 **
76640 ** (1) Memory in Mem.zMalloc and managed by the Mem object
@@ -76794,11 +77226,13 @@
76794 ** contain a valid string or blob value. */
76795 assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
76796 testcase( bPreserve && pMem->z==0 );
76797
76798 assert( pMem->szMalloc==0
76799 || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );
 
 
76800 if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){
76801 if( pMem->db ){
76802 pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
76803 }else{
76804 pMem->zMalloc = sqlite3Realloc(pMem->z, n);
@@ -77623,15 +78057,15 @@
77623 ** either case, SQLITE_TOOBIG is returned.
77624 */
77625 SQLITE_PRIVATE int sqlite3VdbeMemSetStr(
77626 Mem *pMem, /* Memory cell to set to string value */
77627 const char *z, /* String pointer */
77628 int n, /* Bytes in string, or negative */
77629 u8 enc, /* Encoding of z. 0 for BLOBs */
77630 void (*xDel)(void*) /* Destructor function */
77631 ){
77632 int nByte = n; /* New value for pMem->n */
77633 int iLimit; /* Maximum allowed string or blob size */
77634 u16 flags = 0; /* New value for pMem->flags */
77635
77636 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77637 assert( !sqlite3VdbeMemIsRowSet(pMem) );
@@ -77649,11 +78083,11 @@
77649 }
77650 flags = (enc==0?MEM_Blob:MEM_Str);
77651 if( nByte<0 ){
77652 assert( enc!=0 );
77653 if( enc==SQLITE_UTF8 ){
77654 nByte = 0x7fffffff & (int)strlen(z);
77655 }else{
77656 for(nByte=0; nByte<=iLimit && (z[nByte] | z[nByte+1]); nByte+=2){}
77657 }
77658 flags |= MEM_Term;
77659 }
@@ -77661,11 +78095,11 @@
77661 /* The following block sets the new values of Mem.z and Mem.xDel. It
77662 ** also sets a flag in local variable "flags" to indicate the memory
77663 ** management (one of MEM_Dyn or MEM_Static).
77664 */
77665 if( xDel==SQLITE_TRANSIENT ){
77666 u32 nAlloc = nByte;
77667 if( flags&MEM_Term ){
77668 nAlloc += (enc==SQLITE_UTF8?1:2);
77669 }
77670 if( nByte>iLimit ){
77671 return sqlite3ErrorToParser(pMem->db, SQLITE_TOOBIG);
@@ -77687,11 +78121,11 @@
77687 pMem->xDel = xDel;
77688 flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn);
77689 }
77690 }
77691
77692 pMem->n = nByte;
77693 pMem->flags = flags;
77694 if( enc ){
77695 pMem->enc = enc;
77696 #ifdef SQLITE_ENABLE_SESSION
77697 }else if( pMem->db==0 ){
@@ -77707,11 +78141,11 @@
77707 return SQLITE_NOMEM_BKPT;
77708 }
77709 #endif
77710
77711 if( nByte>iLimit ){
77712 return SQLITE_TOOBIG;
77713 }
77714
77715 return SQLITE_OK;
77716 }
77717
@@ -83652,11 +84086,12 @@
83652 VdbeCursor *pCsr, /* Cursor to grab old.* values from */
83653 int op, /* SQLITE_INSERT, UPDATE or DELETE */
83654 const char *zDb, /* Database name */
83655 Table *pTab, /* Modified table */
83656 i64 iKey1, /* Initial key value */
83657 int iReg /* Register for new.* record */
 
83658 ){
83659 sqlite3 *db = v->db;
83660 i64 iKey2;
83661 PreUpdate preupdate;
83662 const char *zTbl = pTab->zName;
@@ -83688,10 +84123,11 @@
83688 preupdate.keyinfo.nKeyField = pTab->nCol;
83689 preupdate.keyinfo.aSortFlags = (u8*)&fakeSortOrder;
83690 preupdate.iKey1 = iKey1;
83691 preupdate.iKey2 = iKey2;
83692 preupdate.pTab = pTab;
 
83693
83694 db->pPreUpdate = &preupdate;
83695 db->xPreUpdateCallback(db->pPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2);
83696 db->pPreUpdate = 0;
83697 sqlite3DbFree(db, preupdate.aRecord);
@@ -84101,11 +84537,11 @@
84101 }else if( xDel==SQLITE_TRANSIENT ){
84102 /* noop */
84103 }else{
84104 xDel((void*)p);
84105 }
84106 if( pCtx ) sqlite3_result_error_toobig(pCtx);
84107 return SQLITE_TOOBIG;
84108 }
84109 SQLITE_API void sqlite3_result_blob(
84110 sqlite3_context *pCtx,
84111 const void *z,
@@ -85083,11 +85519,11 @@
85083 */
85084 static int bindText(
85085 sqlite3_stmt *pStmt, /* The statement to bind against */
85086 int i, /* Index of the parameter to bind */
85087 const void *zData, /* Pointer to the data to be bound */
85088 int nData, /* Number of bytes of data to be bound */
85089 void (*xDel)(void*), /* Destructor for the data */
85090 u8 encoding /* Encoding for the data */
85091 ){
85092 Vdbe *p = (Vdbe *)pStmt;
85093 Mem *pVar;
@@ -85135,15 +85571,11 @@
85135 const void *zData,
85136 sqlite3_uint64 nData,
85137 void (*xDel)(void*)
85138 ){
85139 assert( xDel!=SQLITE_DYNAMIC );
85140 if( nData>0x7fffffff ){
85141 return invokeValueDestructor(zData, xDel, 0);
85142 }else{
85143 return bindText(pStmt, i, zData, (int)nData, xDel, 0);
85144 }
85145 }
85146 SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
85147 int rc;
85148 Vdbe *p = (Vdbe *)pStmt;
85149 rc = vdbeUnbind(p, i);
@@ -85209,16 +85641,12 @@
85209 sqlite3_uint64 nData,
85210 void (*xDel)(void*),
85211 unsigned char enc
85212 ){
85213 assert( xDel!=SQLITE_DYNAMIC );
85214 if( nData>0x7fffffff ){
85215 return invokeValueDestructor(zData, xDel, 0);
85216 }else{
85217 if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
85218 return bindText(pStmt, i, zData, (int)nData, xDel, enc);
85219 }
85220 }
85221 #ifndef SQLITE_OMIT_UTF16
85222 SQLITE_API int sqlite3_bind_text16(
85223 sqlite3_stmt *pStmt,
85224 int i,
@@ -85613,10 +86041,21 @@
85613 SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){
85614 PreUpdate *p = db->pPreUpdate;
85615 return (p ? p->v->nFrame : 0);
85616 }
85617 #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
 
 
 
 
 
 
 
 
 
 
 
85618
85619 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
85620 /*
85621 ** This function is called from within a pre-update callback to retrieve
85622 ** a field of the row currently being updated or inserted.
@@ -86235,22 +86674,40 @@
86235 assert( iCur>=0 && iCur<p->nCursor );
86236 if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/
86237 sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);
86238 p->apCsr[iCur] = 0;
86239 }
86240 if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){
86241 p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;
86242 memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));
86243 pCx->eCurType = eCurType;
86244 pCx->iDb = iDb;
86245 pCx->nField = nField;
86246 pCx->aOffset = &pCx->aType[nField];
86247 if( eCurType==CURTYPE_BTREE ){
86248 pCx->uc.pCursor = (BtCursor*)
86249 &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];
86250 sqlite3BtreeCursorZero(pCx->uc.pCursor);
86251 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86252 }
86253 return pCx;
86254 }
86255
86256 /*
@@ -86393,11 +86850,14 @@
86393 static u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){
86394 int rc;
86395 sqlite3_int64 ix;
86396 assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal))==0 );
86397 assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 );
86398 ExpandBlob(pMem);
 
 
 
86399 rc = sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc);
86400 if( rc<=0 ){
86401 if( rc==0 && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1 ){
86402 pMem->u.i = ix;
86403 return MEM_Int;
@@ -86530,10 +86990,15 @@
86530 if( p->pScopyFrom ){
86531 printf(" <== R[%d]", (int)(p->pScopyFrom - &p[-iReg]));
86532 }
86533 printf("\n");
86534 sqlite3VdbeCheckMemInvariants(p);
 
 
 
 
 
86535 }
86536 #endif
86537
86538 #ifdef SQLITE_DEBUG
86539 /*
@@ -88067,10 +88532,35 @@
88067
88068 pIn1 = &aMem[pOp->p1];
88069 pIn3 = &aMem[pOp->p3];
88070 flags1 = pIn1->flags;
88071 flags3 = pIn3->flags;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88072 if( (flags1 | flags3)&MEM_Null ){
88073 /* One or both operands are NULL */
88074 if( pOp->p5 & SQLITE_NULLEQ ){
88075 /* If SQLITE_NULLEQ is set (which will only happen if the operator is
88076 ** OP_Eq or OP_Ne) then take the jump or not depending on whether
@@ -88097,11 +88587,12 @@
88097 goto jump_to_p2;
88098 }
88099 break;
88100 }
88101 }else{
88102 /* Neither operand is NULL. Do a comparison. */
 
88103 affinity = pOp->p5 & SQLITE_AFF_MASK;
88104 if( affinity>=SQLITE_AFF_NUMERIC ){
88105 if( (flags1 | flags3)&MEM_Str ){
88106 if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
88107 applyNumericAffinity(pIn1,0);
@@ -88110,18 +88601,10 @@
88110 }
88111 if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
88112 applyNumericAffinity(pIn3,0);
88113 }
88114 }
88115 /* Handle the common case of integer comparison here, as an
88116 ** optimization, to avoid a call to sqlite3MemCompare() */
88117 if( (pIn1->flags & pIn3->flags & MEM_Int)!=0 ){
88118 if( pIn3->u.i > pIn1->u.i ){ res = +1; goto compare_op; }
88119 if( pIn3->u.i < pIn1->u.i ){ res = -1; goto compare_op; }
88120 res = 0;
88121 goto compare_op;
88122 }
88123 }else if( affinity==SQLITE_AFF_TEXT ){
88124 if( (flags1 & MEM_Str)==0 && (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
88125 testcase( pIn1->flags & MEM_Int );
88126 testcase( pIn1->flags & MEM_Real );
88127 testcase( pIn1->flags & MEM_IntReal );
@@ -88140,11 +88623,11 @@
88140 }
88141 }
88142 assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
88143 res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
88144 }
88145 compare_op:
88146 /* At this point, res is negative, zero, or positive if reg[P1] is
88147 ** less than, equal to, or greater than reg[P3], respectively. Compute
88148 ** the answer to this operator in res2, depending on what the comparison
88149 ** operator actually is. The next block of code depends on the fact
88150 ** that the 6 comparison operators are consecutive integers in this
@@ -90581,12 +91064,22 @@
90581 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
90582 pC = p->apCsr[pOp->p1];
90583 assert( pC!=0 );
90584 assert( pOp->p3>=pOp->p2 );
90585 if( pC->seekHit<pOp->p2 ){
 
 
 
 
 
90586 pC->seekHit = pOp->p2;
90587 }else if( pC->seekHit>pOp->p3 ){
 
 
 
 
 
90588 pC->seekHit = pOp->p3;
90589 }
90590 break;
90591 }
90592
@@ -90697,10 +91190,15 @@
90697 case OP_IfNoHope: { /* jump, in3 */
90698 VdbeCursor *pC;
90699 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
90700 pC = p->apCsr[pOp->p1];
90701 assert( pC!=0 );
 
 
 
 
 
90702 if( pC->seekHit>=pOp->p4.i ) break;
90703 /* Fall through into OP_NotFound */
90704 /* no break */ deliberate_fall_through
90705 }
90706 case OP_NoConflict: /* jump, in3 */
@@ -91126,11 +91624,11 @@
91126
91127 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
91128 /* Invoke the pre-update hook, if any */
91129 if( pTab ){
91130 if( db->xPreUpdateCallback && !(pOp->p5 & OPFLAG_ISUPDATE) ){
91131 sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey,pOp->p2);
91132 }
91133 if( db->xUpdateCallback==0 || pTab->aCol==0 ){
91134 /* Prevent post-update hook from running in cases when it should not */
91135 pTab = 0;
91136 }
@@ -91286,11 +91784,11 @@
91286 || (aMem[pOp->p3].flags & MEM_Int)
91287 );
91288 sqlite3VdbePreUpdateHook(p, pC,
91289 (opflags & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_DELETE,
91290 zDb, pTab, pC->movetoTarget,
91291 pOp->p3
91292 );
91293 }
91294 if( opflags & OPFLAG_ISNOOP ) break;
91295 #endif
91296
@@ -92232,15 +92730,14 @@
92232 **
92233 ** The table being clear is in the main database file if P2==0. If
92234 ** P2==1 then the table to be clear is in the auxiliary database file
92235 ** that is used to store tables create using CREATE TEMPORARY TABLE.
92236 **
92237 ** If the P3 value is non-zero, then the table referred to must be an
92238 ** intkey table (an SQL table, not an index). In this case the row change
92239 ** count is incremented by the number of rows in the table being cleared.
92240 ** If P3 is greater than zero, then the value stored in register P3 is
92241 ** also incremented by the number of rows in the table being cleared.
92242 **
92243 ** See also: Destroy
92244 */
92245 case OP_Clear: {
92246 int nChange;
@@ -92247,13 +92744,11 @@
92247
92248 sqlite3VdbeIncrWriteCounter(p, 0);
92249 nChange = 0;
92250 assert( p->readOnly==0 );
92251 assert( DbMaskTest(p->btreeMask, pOp->p2) );
92252 rc = sqlite3BtreeClearTable(
92253 db->aDb[pOp->p2].pBt, (u32)pOp->p1, (pOp->p3 ? &nChange : 0)
92254 );
92255 if( pOp->p3 ){
92256 p->nChange += nChange;
92257 if( pOp->p3>0 ){
92258 assert( memIsValid(&aMem[pOp->p3]) );
92259 memAboutToChange(p, &aMem[pOp->p3]);
@@ -92355,11 +92850,13 @@
92355 }
92356 #endif
92357
92358 iDb = pOp->p1;
92359 assert( iDb>=0 && iDb<db->nDb );
92360 assert( DbHasProperty(db, iDb, DB_SchemaLoaded) );
 
 
92361
92362 #ifndef SQLITE_OMIT_ALTERTABLE
92363 if( pOp->p4.z==0 ){
92364 sqlite3SchemaClear(db->aDb[iDb].pSchema);
92365 db->mDbFlags &= ~DBFLAG_SchemaKnownOk;
@@ -93237,10 +93734,11 @@
93237
93238 pBt = db->aDb[pOp->p1].pBt;
93239 pPager = sqlite3BtreePager(pBt);
93240 eOld = sqlite3PagerGetJournalMode(pPager);
93241 if( eNew==PAGER_JOURNALMODE_QUERY ) eNew = eOld;
 
93242 if( !sqlite3PagerOkToChangeJournalMode(pPager) ) eNew = eOld;
93243
93244 #ifndef SQLITE_OMIT_WAL
93245 zFilename = sqlite3PagerFilename(pPager, 1);
93246
@@ -94715,11 +95213,11 @@
94715 ** anyhow.
94716 */
94717 sqlite3_int64 iKey;
94718 iKey = sqlite3BtreeIntegerKey(p->pCsr);
94719 sqlite3VdbePreUpdateHook(
94720 v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1
94721 );
94722 }
94723 #endif
94724
94725 rc = xCall(p->pCsr, iOffset+p->iOffset, n, z);
@@ -94786,10 +95284,11 @@
94786 ** already been invalidated. Return SQLITE_ABORT in this case.
94787 */
94788 rc = SQLITE_ABORT;
94789 }else{
94790 char *zErr;
 
94791 rc = blobSeekToRow(p, iRow, &zErr);
94792 if( rc!=SQLITE_OK ){
94793 sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr);
94794 sqlite3DbFree(db, zErr);
94795 }
@@ -98256,30 +98755,32 @@
98256 /*
98257 ** Truncate the in-memory file.
98258 */
98259 static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){
98260 MemJournal *p = (MemJournal *)pJfd;
98261 FileChunk *pIter = 0;
98262
98263 if( size==0 ){
98264 memjrnlFreeChunks(p->pFirst);
98265 p->pFirst = 0;
98266 }else{
98267 i64 iOff = p->nChunkSize;
98268 for(pIter=p->pFirst; ALWAYS(pIter) && iOff<=size; pIter=pIter->pNext){
98269 iOff += p->nChunkSize;
98270 }
98271 if( ALWAYS(pIter) ){
98272 memjrnlFreeChunks(pIter->pNext);
98273 pIter->pNext = 0;
98274 }
98275 }
98276
98277 p->endpoint.pChunk = pIter;
98278 p->endpoint.iOffset = size;
98279 p->readpoint.pChunk = 0;
98280 p->readpoint.iOffset = 0;
 
 
98281 return SQLITE_OK;
98282 }
98283
98284 /*
98285 ** Close the file.
@@ -98468,19 +98969,14 @@
98468 if( rc ) return WRC_Abort;
98469 rc = sqlite3WalkExprList(pWalker, pWin->pPartition);
98470 if( rc ) return WRC_Abort;
98471 rc = sqlite3WalkExpr(pWalker, pWin->pFilter);
98472 if( rc ) return WRC_Abort;
98473
98474 /* The next two are purely for calls to sqlite3RenameExprUnmap()
98475 ** within sqlite3WindowOffsetExpr(). Because of constraints imposed
98476 ** by sqlite3WindowOffsetExpr(), they can never fail. The results do
98477 ** not matter anyhow. */
98478 rc = sqlite3WalkExpr(pWalker, pWin->pStart);
98479 if( NEVER(rc) ) return WRC_Abort;
98480 rc = sqlite3WalkExpr(pWalker, pWin->pEnd);
98481 if( NEVER(rc) ) return WRC_Abort;
98482 if( bOneOnly ) break;
98483 }
98484 return WRC_Continue;
98485 }
98486 #endif
@@ -98552,10 +99048,20 @@
98552 if( sqlite3WalkExpr(pWalker, pItem->pExpr) ) return WRC_Abort;
98553 }
98554 }
98555 return WRC_Continue;
98556 }
 
 
 
 
 
 
 
 
 
 
98557
98558 /*
98559 ** Walk all expressions associated with SELECT statement p. Do
98560 ** not invoke the SELECT callback on p, but do (of course) invoke
98561 ** any expr callbacks and SELECT callbacks that come from subqueries.
@@ -98566,14 +99072,19 @@
98566 if( sqlite3WalkExpr(pWalker, p->pWhere) ) return WRC_Abort;
98567 if( sqlite3WalkExprList(pWalker, p->pGroupBy) ) return WRC_Abort;
98568 if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort;
98569 if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort;
98570 if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort;
98571 #if !defined(SQLITE_OMIT_WINDOWFUNC) && !defined(SQLITE_OMIT_ALTERTABLE)
98572 {
98573 Parse *pParse = pWalker->pParse;
98574 if( pParse && IN_RENAME_OBJECT ){
 
 
 
 
 
98575 /* The following may return WRC_Abort if there are unresolvable
98576 ** symbols (e.g. a table that does not exist) in a window definition. */
98577 int rc = walkWindowList(pWalker, p->pWinDefn, 0);
98578 return rc;
98579 }
@@ -98593,11 +99104,11 @@
98593 SrcList *pSrc;
98594 int i;
98595 SrcItem *pItem;
98596
98597 pSrc = p->pSrc;
98598 if( pSrc ){
98599 for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){
98600 if( pItem->pSelect && sqlite3WalkSelect(pWalker, pItem->pSelect) ){
98601 return WRC_Abort;
98602 }
98603 if( pItem->fg.isTabFunc
@@ -98767,11 +99278,14 @@
98767 assert( iCol>=0 && iCol<pEList->nExpr );
98768 pOrig = pEList->a[iCol].pExpr;
98769 assert( pOrig!=0 );
98770 db = pParse->db;
98771 pDup = sqlite3ExprDup(db, pOrig, 0);
98772 if( pDup!=0 ){
 
 
 
98773 incrAggFunctionDepth(pDup, nSubquery);
98774 if( pExpr->op==TK_COLLATE ){
98775 pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken);
98776 }
98777
@@ -98789,14 +99303,12 @@
98789 assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );
98790 pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);
98791 pExpr->flags |= EP_MemToken;
98792 }
98793 if( ExprHasProperty(pExpr, EP_WinFunc) ){
98794 if( pExpr->y.pWin!=0 ){
98795 pExpr->y.pWin->pOwner = pExpr;
98796 }else{
98797 assert( db->mallocFailed );
98798 }
98799 }
98800 sqlite3DbFree(db, pDup);
98801 }
98802 }
@@ -99184,12 +99696,12 @@
99184 ** or HAVING clauses, or as part of a larger expression in the ORDER BY
99185 ** clause is not standard SQL. This is a (goofy) SQLite extension, that
99186 ** is supported for backwards compatibility only. Hence, we issue a warning
99187 ** on sqlite3_log() whenever the capability is used.
99188 */
99189 if( (pNC->ncFlags & NC_UEList)!=0
99190 && cnt==0
99191 && zTab==0
99192 ){
99193 pEList = pNC->uNC.pEList;
99194 assert( pEList!=0 );
99195 for(j=0; j<pEList->nExpr; j++){
@@ -99293,11 +99805,11 @@
99293 sqlite3ErrorMsg(pParse, "%s: %s.%s", zErr, zTab, zCol);
99294 }else{
99295 sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol);
99296 }
99297 pParse->checkSchema = 1;
99298 pTopNC->nErr++;
99299 }
99300
99301 /* If a column from a table in pSrcList is referenced, then record
99302 ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes
99303 ** bit 0 to be set. Column 1 sets bit 1. And so forth. Bit 63 is
@@ -99600,11 +100112,11 @@
99600 pExpr->iTable = exprProbability(pList->a[1].pExpr);
99601 if( pExpr->iTable<0 ){
99602 sqlite3ErrorMsg(pParse,
99603 "second argument to likelihood() must be a "
99604 "constant between 0.0 and 1.0");
99605 pNC->nErr++;
99606 }
99607 }else{
99608 /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is
99609 ** equivalent to likelihood(X, 0.0625).
99610 ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is
@@ -99622,11 +100134,11 @@
99622 int auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0,pDef->zName,0);
99623 if( auth!=SQLITE_OK ){
99624 if( auth==SQLITE_DENY ){
99625 sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
99626 pDef->zName);
99627 pNC->nErr++;
99628 }
99629 pExpr->op = TK_NULL;
99630 return WRC_Prune;
99631 }
99632 }
@@ -99678,11 +100190,11 @@
99678 );
99679 if( pDef && pDef->xValue==0 && pWin ){
99680 sqlite3ErrorMsg(pParse,
99681 "%.*s() may not be used as a window function", nId, zId
99682 );
99683 pNC->nErr++;
99684 }else if(
99685 (is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
99686 || (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !pWin)
99687 || (is_agg && pWin && (pNC->ncFlags & NC_AllowWin)==0)
99688 ){
@@ -99691,39 +100203,39 @@
99691 zType = "window";
99692 }else{
99693 zType = "aggregate";
99694 }
99695 sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
99696 pNC->nErr++;
99697 is_agg = 0;
99698 }
99699 #else
99700 if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){
99701 sqlite3ErrorMsg(pParse,"misuse of aggregate function %.*s()",nId,zId);
99702 pNC->nErr++;
99703 is_agg = 0;
99704 }
99705 #endif
99706 else if( no_such_func && pParse->db->init.busy==0
99707 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
99708 && pParse->explain==0
99709 #endif
99710 ){
99711 sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
99712 pNC->nErr++;
99713 }else if( wrong_num_args ){
99714 sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
99715 nId, zId);
99716 pNC->nErr++;
99717 }
99718 #ifndef SQLITE_OMIT_WINDOWFUNC
99719 else if( is_agg==0 && ExprHasProperty(pExpr, EP_WinFunc) ){
99720 sqlite3ErrorMsg(pParse,
99721 "FILTER may not be used with non-aggregate %.*s()",
99722 nId, zId
99723 );
99724 pNC->nErr++;
99725 }
99726 #endif
99727 if( is_agg ){
99728 /* Window functions may not be arguments of aggregate functions.
99729 ** Or arguments of other window functions. But aggregate functions
@@ -99943,15 +100455,15 @@
99943 */
99944 memset(&nc, 0, sizeof(nc));
99945 nc.pParse = pParse;
99946 nc.pSrcList = pSelect->pSrc;
99947 nc.uNC.pEList = pEList;
99948 nc.ncFlags = NC_AllowAgg|NC_UEList;
99949 nc.nErr = 0;
99950 db = pParse->db;
99951 savedSuppErr = db->suppressErr;
99952 if( IN_RENAME_OBJECT==0 ) db->suppressErr = 1;
99953 rc = sqlite3ResolveExprNames(&nc, pE);
99954 db->suppressErr = savedSuppErr;
99955 if( rc ) return 0;
99956
99957 /* Try to match the ORDER BY expression against an expression
@@ -100046,33 +100558,28 @@
100046 ** expression, resolving any symbols in it, and then comparing
100047 ** it against each expression returned by the SELECT statement.
100048 ** Once the comparisons are finished, the duplicate expression
100049 ** is deleted.
100050 **
100051 ** Or, if this is running as part of an ALTER TABLE operation,
100052 ** resolve the symbols in the actual expression, not a duplicate.
100053 ** And, if one of the comparisons is successful, leave the expression
100054 ** as is instead of transforming it to an integer as in the usual
100055 ** case. This allows the code in alter.c to modify column
100056 ** refererences within the ORDER BY expression as required. */
100057 if( IN_RENAME_OBJECT ){
100058 pDup = pE;
100059 }else{
100060 pDup = sqlite3ExprDup(db, pE, 0);
100061 }
100062 if( !db->mallocFailed ){
100063 assert(pDup);
100064 iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup);
 
 
 
100065 }
100066 if( !IN_RENAME_OBJECT ){
100067 sqlite3ExprDelete(db, pDup);
100068 }
100069 }
100070 }
100071 if( iCol>0 ){
100072 /* Convert the ORDER BY term into an integer column number iCol,
100073 ** taking care to preserve the COLLATE clause if it exists */
100074 if( !IN_RENAME_OBJECT ){
100075 Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);
100076 if( pNew==0 ) return 1;
100077 pNew->flags |= EP_IntValue;
100078 pNew->u.iValue = iCol;
@@ -100203,11 +100710,11 @@
100203 int iCol; /* Column number */
100204 struct ExprList_item *pItem; /* A term of the ORDER BY clause */
100205 Parse *pParse; /* Parsing context */
100206 int nResult; /* Number of terms in the result set */
100207
100208 if( pOrderBy==0 ) return 0;
100209 nResult = pSelect->pEList->nExpr;
100210 pParse = pNC->pParse;
100211 for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){
100212 Expr *pE = pItem->pExpr;
100213 Expr *pE2 = sqlite3ExprSkipCollateAndLikely(pE);
@@ -100293,11 +100800,13 @@
100293 nCompound = 0;
100294 pLeftmost = p;
100295 while( p ){
100296 assert( (p->selFlags & SF_Expanded)!=0 );
100297 assert( (p->selFlags & SF_Resolved)==0 );
 
100298 p->selFlags |= SF_Resolved;
 
100299
100300 /* Resolve the expressions in the LIMIT and OFFSET clauses. These
100301 ** are not allowed to refer to any names, so pass an empty NameContext.
100302 */
100303 memset(&sNC, 0, sizeof(sNC));
@@ -100368,17 +100877,10 @@
100368 p->selFlags |= SF_Aggregate | (sNC.ncFlags&NC_MinMaxAgg);
100369 }else{
100370 sNC.ncFlags &= ~NC_AllowAgg;
100371 }
100372
100373 /* If a HAVING clause is present, then there must be a GROUP BY clause.
100374 */
100375 if( p->pHaving && !pGroupBy ){
100376 sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING");
100377 return WRC_Abort;
100378 }
100379
100380 /* Add the output column list to the name-context before parsing the
100381 ** other expressions in the SELECT statement. This is so that
100382 ** expressions in the WHERE clause (etc.) can refer to expressions by
100383 ** aliases in the result set.
100384 **
@@ -100386,11 +100888,17 @@
100386 ** re-evaluated for each reference to it.
100387 */
100388 assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert|NC_UBaseReg))==0 );
100389 sNC.uNC.pEList = p->pEList;
100390 sNC.ncFlags |= NC_UEList;
100391 if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
 
 
 
 
 
 
100392 if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;
100393
100394 /* Resolve names in table-valued-function arguments */
100395 for(i=0; i<p->pSrc->nSrc; i++){
100396 SrcItem *pItem = &p->pSrc->a[i];
@@ -100398,10 +100906,23 @@
100398 && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg)
100399 ){
100400 return WRC_Abort;
100401 }
100402 }
 
 
 
 
 
 
 
 
 
 
 
 
 
100403
100404 /* The ORDER BY and GROUP BY clauses may not refer to terms in
100405 ** outer queries
100406 */
100407 sNC.pNext = 0;
@@ -100426,11 +100947,12 @@
100426 ** If there is an ORDER BY clause on a term of a compound-select other
100427 ** than the right-most term, then that is a syntax error. But the error
100428 ** is not detected until much later, and so we need to go ahead and
100429 ** resolve those symbols on the incorrect ORDER BY for consistency.
100430 */
100431 if( isCompound<=nCompound /* Defer right-most ORDER BY of a compound */
 
100432 && resolveOrderGroupBy(&sNC, p, p->pOrderBy, "ORDER")
100433 ){
100434 return WRC_Abort;
100435 }
100436 if( db->mallocFailed ){
@@ -100454,23 +100976,10 @@
100454 return WRC_Abort;
100455 }
100456 }
100457 }
100458
100459 #ifndef SQLITE_OMIT_WINDOWFUNC
100460 if( IN_RENAME_OBJECT ){
100461 Window *pWin;
100462 for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){
100463 if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy)
100464 || sqlite3ResolveExprListNames(&sNC, pWin->pPartition)
100465 ){
100466 return WRC_Abort;
100467 }
100468 }
100469 }
100470 #endif
100471
100472 /* If this is part of a compound SELECT, check that it has the right
100473 ** number of expressions in the select list. */
100474 if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){
100475 sqlite3SelectWrongNumTermsError(pParse, p->pNext);
100476 return WRC_Abort;
@@ -100550,11 +101059,11 @@
100550 if( pExpr==0 ) return SQLITE_OK;
100551 savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
100552 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
100553 w.pParse = pNC->pParse;
100554 w.xExprCallback = resolveExprStep;
100555 w.xSelectCallback = resolveSelectStep;
100556 w.xSelectCallback2 = 0;
100557 w.u.pNC = pNC;
100558 #if SQLITE_MAX_EXPR_DEPTH>0
100559 w.pParse->nHeight += pExpr->nHeight;
100560 if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){
@@ -100569,11 +101078,11 @@
100569 assert( EP_Win==NC_HasWin );
100570 testcase( pNC->ncFlags & NC_HasAgg );
100571 testcase( pNC->ncFlags & NC_HasWin );
100572 ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) );
100573 pNC->ncFlags |= savedHasAgg;
100574 return pNC->nErr>0 || w.pParse->nErr>0;
100575 }
100576
100577 /*
100578 ** Resolve all names for all expression in an expression list. This is
100579 ** just like sqlite3ResolveExprNames() except that it works for an expression
@@ -100614,11 +101123,11 @@
100614 if( pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin) ){
100615 ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) );
100616 savedHasAgg |= pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
100617 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
100618 }
100619 if( pNC->nErr>0 || w.pParse->nErr>0 ) return WRC_Abort;
100620 }
100621 pNC->ncFlags |= savedHasAgg;
100622 return WRC_Continue;
100623 }
100624
@@ -100757,27 +101266,27 @@
100757 || (pExpr->op==TK_REGISTER && pExpr->op2==TK_IF_NULL_ROW) );
100758 pExpr = pExpr->pLeft;
100759 assert( pExpr!=0 );
100760 }
100761 op = pExpr->op;
 
 
 
 
100762 if( op==TK_SELECT ){
100763 assert( pExpr->flags&EP_xIsSelect );
100764 assert( pExpr->x.pSelect!=0 );
100765 assert( pExpr->x.pSelect->pEList!=0 );
100766 assert( pExpr->x.pSelect->pEList->a[0].pExpr!=0 );
100767 return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);
100768 }
100769 if( op==TK_REGISTER ) op = pExpr->op2;
100770 #ifndef SQLITE_OMIT_CAST
100771 if( op==TK_CAST ){
100772 assert( !ExprHasProperty(pExpr, EP_IntValue) );
100773 return sqlite3AffinityType(pExpr->u.zToken, 0);
100774 }
100775 #endif
100776 if( (op==TK_AGG_COLUMN || op==TK_COLUMN) && pExpr->y.pTab ){
100777 return sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
100778 }
100779 if( op==TK_SELECT_COLUMN ){
100780 assert( pExpr->pLeft->flags&EP_xIsSelect );
100781 return sqlite3ExprAffinity(
100782 pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
100783 );
@@ -100800,22 +101309,11 @@
100800 Parse *pParse, /* Parsing context */
100801 Expr *pExpr, /* Add the "COLLATE" clause to this expression */
100802 const Token *pCollName, /* Name of collating sequence */
100803 int dequote /* True to dequote pCollName */
100804 ){
100805 assert( pExpr!=0 || pParse->db->mallocFailed );
100806 if( pExpr==0 ) return 0;
100807 if( pExpr->op==TK_VECTOR ){
100808 ExprList *pList = pExpr->x.pList;
100809 if( ALWAYS(pList!=0) ){
100810 int i;
100811 for(i=0; i<pList->nExpr; i++){
100812 pList->a[i].pExpr = sqlite3ExprAddCollateToken(pParse,pList->a[i].pExpr,
100813 pCollName, dequote);
100814 }
100815 }
100816 }else if( pCollName->n>0 ){
100817 Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote);
100818 if( pNew ){
100819 pNew->pLeft = pExpr;
100820 pNew->flags |= EP_Collate|EP_Skip;
100821 pExpr = pNew;
@@ -101161,11 +101659,11 @@
101161 ** just the expression for the i-th term of the result set, and may
101162 ** not be ready for evaluation because the table cursor has not yet
101163 ** been positioned.
101164 */
101165 SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr *pVector, int i){
101166 assert( i<sqlite3ExprVectorSize(pVector) );
101167 if( sqlite3ExprIsVector(pVector) ){
101168 assert( pVector->op2==0 || pVector->op==TK_REGISTER );
101169 if( pVector->op==TK_SELECT || pVector->op2==TK_SELECT ){
101170 return pVector->x.pSelect->pEList->a[i].pExpr;
101171 }else{
@@ -101277,21 +101775,24 @@
101277 int regSelect, /* First in array of registers */
101278 Expr **ppExpr, /* OUT: Expression element */
101279 int *pRegFree /* OUT: Temp register to free */
101280 ){
101281 u8 op = pVector->op;
101282 assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT );
101283 if( op==TK_REGISTER ){
101284 *ppExpr = sqlite3VectorFieldSubexpr(pVector, iField);
101285 return pVector->iTable+iField;
101286 }
101287 if( op==TK_SELECT ){
101288 *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr;
101289 return regSelect+iField;
101290 }
101291 *ppExpr = pVector->x.pList->a[iField].pExpr;
101292 return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree);
 
 
 
101293 }
101294
101295 /*
101296 ** Expression pExpr is a comparison between two vector values. Compute
101297 ** the result of the comparison (1, 0, or NULL) and write that
@@ -101346,11 +101847,11 @@
101346 regRight = exprCodeSubselect(pParse, pRight);
101347
101348 sqlite3VdbeAddOp2(v, OP_Integer, 1, dest);
101349 for(i=0; 1 /*Loop exits by "break"*/; i++){
101350 int regFree1 = 0, regFree2 = 0;
101351 Expr *pL, *pR;
101352 int r1, r2;
101353 assert( i>=0 && i<nLeft );
101354 if( addrCmp ) sqlite3VdbeJumpHere(v, addrCmp);
101355 r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, &regFree1);
101356 r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, &regFree2);
@@ -102029,10 +102530,11 @@
102029
102030 /* Figure out where to write the new Expr structure. */
102031 if( pzBuffer ){
102032 zAlloc = *pzBuffer;
102033 staticFlag = EP_Static;
 
102034 }else{
102035 zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags));
102036 staticFlag = 0;
102037 }
102038 pNew = (Expr *)zAlloc;
@@ -102107,11 +102609,12 @@
102107 }else{
102108 if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
102109 if( pNew->op==TK_SELECT_COLUMN ){
102110 pNew->pLeft = p->pLeft;
102111 assert( p->iColumn==0 || p->pRight==0 );
102112 assert( p->pRight==0 || p->pRight==p->pLeft );
 
102113 }else{
102114 pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
102115 }
102116 pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
102117 }
@@ -102124,11 +102627,11 @@
102124 ** Create and return a deep copy of the object passed as the second
102125 ** argument. If an OOM condition is encountered, NULL is returned
102126 ** and the db->mallocFailed flag set.
102127 */
102128 #ifndef SQLITE_OMIT_CTE
102129 static With *withDup(sqlite3 *db, With *p){
102130 With *pRet = 0;
102131 if( p ){
102132 sqlite3_int64 nByte = sizeof(*p) + sizeof(p->a[0]) * (p->nCte-1);
102133 pRet = sqlite3DbMallocZero(db, nByte);
102134 if( pRet ){
@@ -102142,11 +102645,11 @@
102142 }
102143 }
102144 return pRet;
102145 }
102146 #else
102147 # define withDup(x,y) 0
102148 #endif
102149
102150 #ifndef SQLITE_OMIT_WINDOWFUNC
102151 /*
102152 ** The gatherSelectWindows() procedure and its helper routine
@@ -102222,11 +102725,12 @@
102222 && pOldExpr->op==TK_SELECT_COLUMN
102223 && (pNewExpr = pItem->pExpr)!=0
102224 ){
102225 assert( pNewExpr->iColumn==0 || i>0 );
102226 if( pNewExpr->iColumn==0 ){
102227 assert( pOldExpr->pLeft==pOldExpr->pRight );
 
102228 pPriorSelectCol = pNewExpr->pLeft = pNewExpr->pRight;
102229 }else{
102230 assert( i>0 );
102231 assert( pItem[-1].pExpr!=0 );
102232 assert( pNewExpr->iColumn==pItem[-1].pExpr->iColumn+1 );
@@ -102345,17 +102849,25 @@
102345 pNew->iOffset = 0;
102346 pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;
102347 pNew->addrOpenEphm[0] = -1;
102348 pNew->addrOpenEphm[1] = -1;
102349 pNew->nSelectRow = p->nSelectRow;
102350 pNew->pWith = withDup(db, p->pWith);
102351 #ifndef SQLITE_OMIT_WINDOWFUNC
102352 pNew->pWin = 0;
102353 pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
102354 if( p->pWin && db->mallocFailed==0 ) gatherSelectWindows(pNew);
102355 #endif
102356 pNew->selId = p->selId;
 
 
 
 
 
 
 
 
102357 *pp = pNew;
102358 pp = &pNew->pPrior;
102359 pNext = pNew;
102360 }
102361
@@ -103052,12 +103564,14 @@
103052 ** will likely result in an incorrect answer. So when in doubt, return
103053 ** TRUE.
103054 */
103055 SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){
103056 u8 op;
 
103057 while( p->op==TK_UPLUS || p->op==TK_UMINUS ){
103058 p = p->pLeft;
 
103059 }
103060 op = p->op;
103061 if( op==TK_REGISTER ) op = p->op2;
103062 switch( op ){
103063 case TK_INTEGER:
@@ -103685,23 +104199,27 @@
103685 addrOnce?"":"CORRELATED ", pSelect->selId
103686 ));
103687 /* If the LHS and RHS of the IN operator do not match, that
103688 ** error will have been caught long before we reach this point. */
103689 if( ALWAYS(pEList->nExpr==nVal) ){
 
103690 SelectDest dest;
103691 int i;
 
103692 sqlite3SelectDestInit(&dest, SRT_Set, iTab);
103693 dest.zAffSdst = exprINAffinity(pParse, pExpr);
103694 pSelect->iLimit = 0;
103695 testcase( pSelect->selFlags & SF_Distinct );
103696 testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
103697 if( sqlite3Select(pParse, pSelect, &dest) ){
103698 sqlite3DbFree(pParse->db, dest.zAffSdst);
 
 
 
103699 sqlite3KeyInfoUnref(pKeyInfo);
103700 return;
103701 }
103702 sqlite3DbFree(pParse->db, dest.zAffSdst);
103703 assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */
103704 assert( pEList!=0 );
103705 assert( pEList->nExpr>0 );
103706 assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
103707 for(i=0; i<nVal; i++){
@@ -103796,15 +104314,33 @@
103796 int nReg; /* Registers to allocate */
103797 Expr *pLimit; /* New limit expression */
103798
103799 Vdbe *v = pParse->pVdbe;
103800 assert( v!=0 );
 
103801 testcase( pExpr->op==TK_EXISTS );
103802 testcase( pExpr->op==TK_SELECT );
103803 assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
103804 assert( ExprHasProperty(pExpr, EP_xIsSelect) );
103805 pSel = pExpr->x.pSelect;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103806
103807 /* The evaluation of the EXISTS/SELECT must be repeated every time it
103808 ** is encountered if any of the following is true:
103809 **
103810 ** * The right-hand side is a correlated subquery
@@ -103813,26 +104349,10 @@
103813 **
103814 ** If all of the above are false, then we can run this code just once
103815 ** save the results, and reuse the same result on subsequent invocations.
103816 */
103817 if( !ExprHasProperty(pExpr, EP_VarSelect) ){
103818 /* If this routine has already been coded, then invoke it as a
103819 ** subroutine. */
103820 if( ExprHasProperty(pExpr, EP_Subrtn) ){
103821 ExplainQueryPlan((pParse, 0, "REUSE SUBQUERY %d", pSel->selId));
103822 sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn,
103823 pExpr->y.sub.iAddr);
103824 return pExpr->iTable;
103825 }
103826
103827 /* Begin coding the subroutine */
103828 ExprSetProperty(pExpr, EP_Subrtn);
103829 pExpr->y.sub.regReturn = ++pParse->nMem;
103830 pExpr->y.sub.iAddr =
103831 sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
103832 VdbeComment((v, "return address"));
103833
103834 addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
103835 }
103836
103837 /* For a SELECT, generate code to put the values for all columns of
103838 ** the first row into an array of registers and return the index of
@@ -103877,23 +104397,26 @@
103877 pLimit = sqlite3Expr(pParse->db, TK_INTEGER, "1");
103878 pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0);
103879 }
103880 pSel->iLimit = 0;
103881 if( sqlite3Select(pParse, pSel, &dest) ){
 
 
 
 
103882 return 0;
103883 }
103884 pExpr->iTable = rReg = dest.iSDParm;
103885 ExprSetVVAProperty(pExpr, EP_NoReduce);
103886 if( addrOnce ){
103887 sqlite3VdbeJumpHere(v, addrOnce);
103888
103889 /* Subroutine return */
103890 sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
103891 sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
103892 sqlite3ClearTempRegCache(pParse);
103893 }
103894
 
 
 
 
103895 return rReg;
103896 }
103897 #endif /* SQLITE_OMIT_SUBQUERY */
103898
103899 #ifndef SQLITE_OMIT_SUBQUERY
@@ -103903,11 +104426,11 @@
103903 ** columns as the vector on the LHS. Or, if the RHS of the IN() is not
103904 ** a sub-query, that the LHS is a vector of size 1.
103905 */
103906 SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse *pParse, Expr *pIn){
103907 int nVector = sqlite3ExprVectorSize(pIn->pLeft);
103908 if( (pIn->flags & EP_xIsSelect) ){
103909 if( nVector!=pIn->x.pSelect->pEList->nExpr ){
103910 sqlite3SubselectError(pParse, pIn->x.pSelect->pEList->nExpr, nVector);
103911 return 1;
103912 }
103913 }else if( nVector!=1 ){
@@ -104720,11 +105243,11 @@
104720 default: {
104721 /* Make NULL the default case so that if a bug causes an illegal
104722 ** Expr node to be passed into this function, it will be handled
104723 ** sanely and not crash. But keep the assert() to bring the problem
104724 ** to the attention of the developers. */
104725 assert( op==TK_NULL );
104726 sqlite3VdbeAddOp2(v, OP_Null, 0, target);
104727 return target;
104728 }
104729 #ifndef SQLITE_OMIT_BLOB_LITERAL
104730 case TK_BLOB: {
@@ -105063,11 +105586,12 @@
105063 case TK_SELECT_COLUMN: {
105064 int n;
105065 if( pExpr->pLeft->iTable==0 ){
105066 pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft);
105067 }
105068 assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT );
 
105069 if( pExpr->iTable!=0
105070 && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft))
105071 ){
105072 sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
105073 pExpr->iTable, n);
@@ -106695,10 +107219,11 @@
106695 /* Check to see if pExpr is a duplicate of another aggregate
106696 ** function that is already in the pAggInfo structure
106697 */
106698 struct AggInfo_func *pItem = pAggInfo->aFunc;
106699 for(i=0; i<pAggInfo->nFunc; i++, pItem++){
 
106700 if( sqlite3ExprCompare(0, pItem->pFExpr, pExpr, -1)==0 ){
106701 break;
106702 }
106703 }
106704 if( i>=pAggInfo->nFunc ){
@@ -106895,10 +107420,11 @@
106895 ** Or, if zName is not a system table, zero is returned.
106896 */
106897 static int isAlterableTable(Parse *pParse, Table *pTab){
106898 if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7)
106899 #ifndef SQLITE_OMIT_VIRTUALTABLE
 
106900 || ( (pTab->tabFlags & TF_Shadow)!=0
106901 && sqlite3ReadOnlyShadowTables(pParse->db)
106902 )
106903 #endif
106904 ){
@@ -107663,19 +108189,34 @@
107663 ** to select statement pSelect.
107664 */
107665 static void renameWalkWith(Walker *pWalker, Select *pSelect){
107666 With *pWith = pSelect->pWith;
107667 if( pWith ){
 
107668 int i;
 
 
 
 
 
 
 
 
 
 
 
107669 for(i=0; i<pWith->nCte; i++){
107670 Select *p = pWith->a[i].pSelect;
107671 NameContext sNC;
107672 memset(&sNC, 0, sizeof(sNC));
107673 sNC.pParse = pWalker->pParse;
107674 sqlite3SelectPrep(sNC.pParse, p, &sNC);
107675 sqlite3WalkSelect(pWalker, p);
107676 sqlite3RenameExprlistUnmap(pWalker->pParse, pWith->a[i].pCols);
 
 
 
107677 }
107678 }
107679 }
107680
107681 /*
@@ -107698,11 +108239,15 @@
107698 */
107699 static int renameUnmapSelectCb(Walker *pWalker, Select *p){
107700 Parse *pParse = pWalker->pParse;
107701 int i;
107702 if( pParse->nErr ) return WRC_Abort;
107703 if( NEVER(p->selFlags & SF_View) ) return WRC_Prune;
 
 
 
 
107704 if( ALWAYS(p->pEList) ){
107705 ExprList *pList = p->pEList;
107706 for(i=0; i<pList->nExpr; i++){
107707 if( pList->a[i].zEName && pList->a[i].eEName==ENAME_NAME ){
107708 sqlite3RenameTokenRemap(pParse, 0, (void*)pList->a[i].zEName);
@@ -107782,11 +108327,13 @@
107782 Parse *pParse,
107783 struct RenameCtx *pCtx,
107784 void *pPtr
107785 ){
107786 RenameToken **pp;
107787 assert( pPtr!=0 );
 
 
107788 for(pp=&pParse->pRename; (*pp); pp=&(*pp)->pNext){
107789 if( (*pp)->p==pPtr ){
107790 RenameToken *pToken = *pp;
107791 if( pCtx ){
107792 *pp = pToken->pNext;
@@ -107804,11 +108351,15 @@
107804 ** This is a Walker select callback. It does nothing. It is only required
107805 ** because without a dummy callback, sqlite3WalkExpr() and similar do not
107806 ** descend into sub-select statements.
107807 */
107808 static int renameColumnSelectCb(Walker *pWalker, Select *p){
107809 if( p->selFlags & SF_View ) return WRC_Prune;
 
 
 
 
107810 renameWalkWith(pWalker, p);
107811 return WRC_Continue;
107812 }
107813
107814 /*
@@ -108334,13 +108885,15 @@
108334 int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName);
108335 FKey *pFKey;
108336 assert( sParse.pNewTable->pSelect==0 );
108337 sCtx.pTab = sParse.pNewTable;
108338 if( bFKOnly==0 ){
108339 renameTokenFind(
108340 &sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zName
108341 );
 
 
108342 if( sCtx.iCol<0 ){
108343 renameTokenFind(&sParse, &sCtx, (void*)&sParse.pNewTable->iPKey);
108344 }
108345 sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck);
108346 for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){
@@ -108438,12 +108991,16 @@
108438 */
108439 static int renameTableSelectCb(Walker *pWalker, Select *pSelect){
108440 int i;
108441 RenameCtx *p = pWalker->u.pRename;
108442 SrcList *pSrc = pSelect->pSrc;
108443 if( pSelect->selFlags & SF_View ) return WRC_Prune;
108444 if( pSrc==0 ){
 
 
 
 
108445 assert( pWalker->pParse->db->mallocFailed );
108446 return WRC_Abort;
108447 }
108448 for(i=0; i<pSrc->nSrc; i++){
108449 SrcItem *pItem = &pSrc->a[i];
@@ -108983,20 +109540,25 @@
108983 if( iPos<pPk->nKeyCol ) continue;
108984 regOut = reg+1+iPos-(iPos>iColPos);
108985 }else{
108986 regOut = reg+1+nField;
108987 }
108988 sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOut);
 
 
 
 
108989 nField++;
108990 }
108991 }
108992 sqlite3VdbeAddOp3(v, OP_MakeRecord, reg+1, nField, regRec);
108993 if( pPk ){
108994 sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iCur, regRec, reg+1, pPk->nKeyCol);
108995 }else{
108996 sqlite3VdbeAddOp3(v, OP_Insert, iCur, regRec, reg);
108997 }
 
108998
108999 sqlite3VdbeAddOp2(v, OP_Next, iCur, addr+1); VdbeCoverage(v);
109000 sqlite3VdbeJumpHere(v, addr);
109001 }
109002
@@ -111063,11 +111625,11 @@
111063 zFile = (const char *)sqlite3_value_text(argv[0]);
111064 zName = (const char *)sqlite3_value_text(argv[1]);
111065 if( zFile==0 ) zFile = "";
111066 if( zName==0 ) zName = "";
111067
111068 #ifdef SQLITE_ENABLE_DESERIALIZE
111069 # define REOPEN_AS_MEMDB(db) (db->init.reopenMemdb)
111070 #else
111071 # define REOPEN_AS_MEMDB(db) (0)
111072 #endif
111073
@@ -111432,18 +111994,21 @@
111432 SrcList *pList = pSelect->pSrc;
111433
111434 if( NEVER(pList==0) ) return WRC_Continue;
111435 for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
111436 if( pFix->bTemp==0 ){
111437 if( pItem->zDatabase && iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){
111438 sqlite3ErrorMsg(pFix->pParse,
111439 "%s %T cannot reference objects in database %s",
111440 pFix->zType, pFix->pName, pItem->zDatabase);
111441 return WRC_Abort;
111442 }
111443 sqlite3DbFree(db, pItem->zDatabase);
111444 pItem->zDatabase = 0;
 
 
 
111445 pItem->pSchema = pFix->pSchema;
111446 pItem->fg.fromDDL = 1;
111447 }
111448 #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
111449 if( sqlite3WalkExpr(&pFix->w, pList->a[i].pOn) ) return WRC_Abort;
@@ -111479,11 +112044,11 @@
111479 pFix->pName = pName;
111480 pFix->bTemp = (iDb==1);
111481 pFix->w.pParse = pParse;
111482 pFix->w.xExprCallback = fixExprCb;
111483 pFix->w.xSelectCallback = fixSelectCb;
111484 pFix->w.xSelectCallback2 = 0;
111485 pFix->w.walkerDepth = 0;
111486 pFix->w.eCode = 0;
111487 pFix->w.u.pFix = pFix;
111488 }
111489
@@ -111541,18 +112106,20 @@
111541 || sqlite3FixSrcList(pFix, pStep->pFrom)
111542 ){
111543 return 1;
111544 }
111545 #ifndef SQLITE_OMIT_UPSERT
111546 if( pStep->pUpsert ){
111547 Upsert *pUp = pStep->pUpsert;
111548 if( sqlite3WalkExprList(&pFix->w, pUp->pUpsertTarget)
111549 || sqlite3WalkExpr(&pFix->w, pUp->pUpsertTargetWhere)
111550 || sqlite3WalkExprList(&pFix->w, pUp->pUpsertSet)
111551 || sqlite3WalkExpr(&pFix->w, pUp->pUpsertWhere)
111552 ){
111553 return 1;
 
 
111554 }
111555 }
111556 #endif
111557 pStep = pStep->pNext;
111558 }
@@ -111880,11 +112447,11 @@
111880 **
111881 ** This routine just records the fact that the lock is desired. The
111882 ** code to make the lock occur is generated by a later call to
111883 ** codeTableLocks() which occurs during sqlite3FinishCoding().
111884 */
111885 SQLITE_PRIVATE void sqlite3TableLock(
111886 Parse *pParse, /* Parsing context */
111887 int iDb, /* Index of the database containing the table to lock */
111888 Pgno iTab, /* Root page number of the table to be locked */
111889 u8 isWriteLock, /* True for a write lock */
111890 const char *zName /* Name of the table to be locked */
@@ -111893,12 +112460,10 @@
111893 int i;
111894 int nBytes;
111895 TableLock *p;
111896 assert( iDb>=0 );
111897
111898 if( iDb==1 ) return;
111899 if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return;
111900 pToplevel = sqlite3ParseToplevel(pParse);
111901 for(i=0; i<pToplevel->nTableLock; i++){
111902 p = &pToplevel->aTableLock[i];
111903 if( p->iDb==iDb && p->iTab==iTab ){
111904 p->isWriteLock = (p->isWriteLock || isWriteLock);
@@ -111918,10 +112483,21 @@
111918 }else{
111919 pToplevel->nTableLock = 0;
111920 sqlite3OomFault(pToplevel->db);
111921 }
111922 }
 
 
 
 
 
 
 
 
 
 
 
111923
111924 /*
111925 ** Code an OP_TableLock instruction for each table locked by the
111926 ** statement (configured by calls to sqlite3TableLock()).
111927 */
@@ -112272,11 +112848,11 @@
112272 if( p==0 ){
112273 #ifndef SQLITE_OMIT_VIRTUALTABLE
112274 /* If zName is the not the name of a table in the schema created using
112275 ** CREATE, then check to see if it is the name of an virtual table that
112276 ** can be an eponymous virtual table. */
112277 if( pParse->disableVtab==0 ){
112278 Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
112279 if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
112280 pMod = sqlite3PragmaVtabRegister(db, zName);
112281 }
112282 if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
@@ -112295,10 +112871,12 @@
112295 if( zDbase ){
112296 sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
112297 }else{
112298 sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
112299 }
 
 
112300 }
112301
112302 return p;
112303 }
112304
@@ -112711,11 +113289,11 @@
112711 if( iDb<0 ){
112712 sqlite3ErrorMsg(pParse, "unknown database %T", pName1);
112713 return -1;
112714 }
112715 }else{
112716 assert( db->init.iDb==0 || db->init.busy || IN_RENAME_OBJECT
112717 || (db->mDbFlags & DBFLAG_Vacuum)!=0);
112718 iDb = db->init.iDb;
112719 *pUnqual = pName1;
112720 }
112721 return iDb;
@@ -112879,10 +113457,27 @@
112879 /* iCol is a normal or stored column */
112880 return n;
112881 }
112882 }
112883 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112884
112885 /*
112886 ** Begin constructing a new table representation in memory. This is
112887 ** the first of several action routines that get called in response
112888 ** to a CREATE TABLE statement. In particular, this routine is called
@@ -112979,10 +113574,11 @@
112979 if( !noErr ){
112980 sqlite3ErrorMsg(pParse, "table %T already exists", pName);
112981 }else{
112982 assert( !db->init.busy || CORRUPT_DB );
112983 sqlite3CodeVerifySchema(pParse, iDb);
 
112984 }
112985 goto begin_table_error;
112986 }
112987 if( sqlite3FindIndex(db, zName, zDb)!=0 ){
112988 sqlite3ErrorMsg(pParse, "there is already an index named %s", zName);
@@ -113155,10 +113751,11 @@
113155 pRet->retTrig.zName = RETURNING_TRIGGER_NAME;
113156 pRet->retTrig.op = TK_RETURNING;
113157 pRet->retTrig.tr_tm = TRIGGER_AFTER;
113158 pRet->retTrig.bReturning = 1;
113159 pRet->retTrig.pSchema = db->aDb[1].pSchema;
 
113160 pRet->retTrig.step_list = &pRet->retTStep;
113161 pRet->retTStep.op = TK_RETURNING;
113162 pRet->retTStep.pTrig = &pRet->retTrig;
113163 pRet->retTStep.pExprList = pList;
113164 pHash = &(db->aDb[1].pSchema->trigHash);
@@ -114013,20 +114610,26 @@
114013 ExprList *pList;
114014 Token ipkToken;
114015 sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName);
114016 pList = sqlite3ExprListAppend(pParse, 0,
114017 sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
114018 if( pList==0 ) return;
 
 
 
114019 if( IN_RENAME_OBJECT ){
114020 sqlite3RenameTokenRemap(pParse, pList->a[0].pExpr, &pTab->iPKey);
114021 }
114022 pList->a[0].sortFlags = pParse->iPkSortOrder;
114023 assert( pParse->pNewTable==pTab );
114024 pTab->iPKey = -1;
114025 sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
114026 SQLITE_IDXTYPE_PRIMARYKEY);
114027 if( db->mallocFailed || pParse->nErr ) return;
 
 
 
114028 pPk = sqlite3PrimaryKeyIndex(pTab);
114029 assert( pPk->nKeyCol==1 );
114030 }else{
114031 pPk = sqlite3PrimaryKeyIndex(pTab);
114032 assert( pPk!=0 );
@@ -114226,11 +114829,10 @@
114226 Index *pIdx; /* An implied index of the table */
114227
114228 if( pEnd==0 && pSelect==0 ){
114229 return;
114230 }
114231 assert( !db->mallocFailed );
114232 p = pParse->pNewTable;
114233 if( p==0 ) return;
114234
114235 if( pSelect==0 && sqlite3ShadowTableName(db, p->zName) ){
114236 p->tabFlags |= TF_Shadow;
@@ -114474,10 +115076,11 @@
114474 */
114475 if( db->init.busy ){
114476 Table *pOld;
114477 Schema *pSchema = p->pSchema;
114478 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
 
114479 pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName, p);
114480 if( pOld ){
114481 assert( p==pOld ); /* Malloc must have failed inside HashInsert() */
114482 sqlite3OomFault(db);
114483 return;
@@ -115022,11 +115625,14 @@
115022 assert( isView==0 || isView==LOCATE_VIEW );
115023 pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);
115024 if( noErr ) db->suppressErr--;
115025
115026 if( pTab==0 ){
115027 if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
 
 
 
115028 goto exit_drop_table;
115029 }
115030 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
115031 assert( iDb>=0 && iDb<db->nDb );
115032
@@ -115592,10 +116198,11 @@
115592 if( !ifNotExist ){
115593 sqlite3ErrorMsg(pParse, "index %s already exists", zName);
115594 }else{
115595 assert( !db->init.busy );
115596 sqlite3CodeVerifySchema(pParse, iDb);
 
115597 }
115598 goto exit_create_index;
115599 }
115600 }
115601 }else{
@@ -116072,11 +116679,11 @@
116072 x = pIdx->pTable->nRowLogEst;
116073 assert( 99==sqlite3LogEst(1000) );
116074 if( x<99 ){
116075 pIdx->pTable->nRowLogEst = x = 99;
116076 }
116077 if( pIdx->pPartIdxWhere!=0 ) x -= 10; assert( 10==sqlite3LogEst(2) );
116078 a[0] = x;
116079
116080 /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is
116081 ** 6 and each subsequent value (if any) is 5. */
116082 memcpy(&a[1], aVal, nCopy*sizeof(LogEst));
@@ -116110,10 +116717,11 @@
116110 if( pIndex==0 ){
116111 if( !ifExists ){
116112 sqlite3ErrorMsg(pParse, "no such index: %S", pName->a);
116113 }else{
116114 sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
 
116115 }
116116 pParse->checkSchema = 1;
116117 goto exit_drop_index;
116118 }
116119 if( pIndex->idxType!=SQLITE_IDXTYPE_APPDEF ){
@@ -116129,11 +116737,11 @@
116129 const char *zDb = db->aDb[iDb].zDbSName;
116130 const char *zTab = SCHEMA_TABLE(iDb);
116131 if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){
116132 goto exit_drop_index;
116133 }
116134 if( !OMIT_TEMPDB && iDb ) code = SQLITE_DROP_TEMP_INDEX;
116135 if( sqlite3AuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){
116136 goto exit_drop_index;
116137 }
116138 }
116139 #endif
@@ -116421,12 +117029,12 @@
116421 ** Assign VdbeCursor index numbers to all tables in a SrcList
116422 */
116423 SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){
116424 int i;
116425 SrcItem *pItem;
116426 assert(pList || pParse->db->mallocFailed );
116427 if( pList ){
116428 for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
116429 if( pItem->iCursor>=0 ) continue;
116430 pItem->iCursor = pParse->nTab++;
116431 if( pItem->pSelect ){
116432 sqlite3SrcListAssignCursors(pParse, pItem->pSelect->pSrc);
@@ -118147,10 +118755,13 @@
118147 pTab->zName, P4_STATIC);
118148 }
118149 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
118150 assert( pIdx->pSchema==pTab->pSchema );
118151 sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);
 
 
 
118152 }
118153 }else
118154 #endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */
118155 {
118156 u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK;
@@ -118658,17 +119269,19 @@
118658 ){
118659 /* This column was already computed by the previous index */
118660 continue;
118661 }
118662 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j);
118663 /* If the column affinity is REAL but the number is an integer, then it
118664 ** might be stored in the table as an integer (using a compact
118665 ** representation) then converted to REAL by an OP_RealAffinity opcode.
118666 ** But we are getting ready to store this value back into an index, where
118667 ** it should be converted by to INTEGER again. So omit the OP_RealAffinity
118668 ** opcode if it is present */
118669 sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);
 
 
118670 }
118671 if( regOut ){
118672 sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut);
118673 }
118674 sqlite3ReleaseTempRange(pParse, regBase, nCol);
@@ -120759,13 +121372,11 @@
120759 ans = x(v0, v1);
120760 sqlite3_result_double(context, ans);
120761 }
120762
120763 /*
120764 ** Implementation of 2-argument SQL math functions:
120765 **
120766 ** power(X,Y) - Compute X to the Y-th power
120767 */
120768 static void piFunc(
120769 sqlite3_context *context,
120770 int argc,
120771 sqlite3_value **argv
@@ -122791,11 +123402,11 @@
122791 /* Verify that the sqlite_sequence table exists and is an ordinary
122792 ** rowid table with exactly two columns.
122793 ** Ticket d8dc2b3a58cd5dc2918a1d4acb 2018-05-23 */
122794 if( pSeqTab==0
122795 || !HasRowid(pSeqTab)
122796 || IsVirtual(pSeqTab)
122797 || pSeqTab->nCol!=2
122798 ){
122799 pParse->nErr++;
122800 pParse->rc = SQLITE_CORRUPT_SEQUENCE;
122801 return 0;
@@ -126824,11 +127435,11 @@
126824 sqlite3_loadext_entry xInit;
126825 char *zErrmsg = 0;
126826 const char *zEntry;
126827 char *zAltEntry = 0;
126828 void **aHandle;
126829 u64 nMsg = 300 + sqlite3Strlen30(zFile);
126830 int ii;
126831 int rc;
126832
126833 /* Shared library endings to try if zFile cannot be loaded as written */
126834 static const char *azEndings[] = {
@@ -126858,30 +127469,26 @@
126858 return SQLITE_ERROR;
126859 }
126860
126861 zEntry = zProc ? zProc : "sqlite3_extension_init";
126862
 
 
 
 
 
 
126863 handle = sqlite3OsDlOpen(pVfs, zFile);
126864 #if SQLITE_OS_UNIX || SQLITE_OS_WIN
126865 for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){
126866 char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEndings[ii]);
126867 if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;
126868 handle = sqlite3OsDlOpen(pVfs, zAltFile);
126869 sqlite3_free(zAltFile);
126870 }
126871 #endif
126872 if( handle==0 ){
126873 if( pzErrMsg ){
126874 *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
126875 if( zErrmsg ){
126876 sqlite3_snprintf(nMsg, zErrmsg,
126877 "unable to open shared library [%s]", zFile);
126878 sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
126879 }
126880 }
126881 return SQLITE_ERROR;
126882 }
126883 xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
126884
126885 /* If no entry point was specified and the default legacy
126886 ** entry point name "sqlite3_extension_init" was not found, then
126887 ** construct an entry point name "sqlite3_X_init" where the X is
@@ -126914,14 +127521,15 @@
126914 zEntry = zAltEntry;
126915 xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
126916 }
126917 if( xInit==0 ){
126918 if( pzErrMsg ){
126919 nMsg += sqlite3Strlen30(zEntry);
126920 *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
126921 if( zErrmsg ){
126922 sqlite3_snprintf(nMsg, zErrmsg,
 
126923 "no entry point [%s] in shared library [%s]", zEntry, zFile);
126924 sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
126925 }
126926 }
126927 sqlite3OsDlClose(pVfs, handle);
@@ -126951,10 +127559,23 @@
126951 sqlite3DbFree(db, db->aExtension);
126952 db->aExtension = aHandle;
126953
126954 db->aExtension[db->nExtension++] = handle;
126955 return SQLITE_OK;
 
 
 
 
 
 
 
 
 
 
 
 
 
126956 }
126957 SQLITE_API int sqlite3_load_extension(
126958 sqlite3 *db, /* Load the extension into this database connection */
126959 const char *zFile, /* Name of the shared library containing extension */
126960 const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
@@ -130510,18 +131131,18 @@
130510
130511 assert( argc==5 );
130512 UNUSED_PARAMETER2(NotUsed, argc);
130513 assert( sqlite3_mutex_held(db->mutex) );
130514 db->mDbFlags |= DBFLAG_EncodingFixed;
 
130515 pData->nInitRow++;
130516 if( db->mallocFailed ){
130517 corruptSchema(pData, argv, 0);
130518 return 1;
130519 }
130520
130521 assert( iDb>=0 && iDb<db->nDb );
130522 if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */
130523 if( argv[3]==0 ){
130524 corruptSchema(pData, argv, 0);
130525 }else if( argv[4]
130526 && 'c'==sqlite3UpperToLower[(unsigned char)argv[4][0]]
130527 && 'r'==sqlite3UpperToLower[(unsigned char)argv[4][1]] ){
@@ -130791,22 +131412,26 @@
130791 if( rc==SQLITE_OK ){
130792 sqlite3AnalysisLoad(db, iDb);
130793 }
130794 #endif
130795 }
 
130796 if( db->mallocFailed ){
130797 rc = SQLITE_NOMEM_BKPT;
130798 sqlite3ResetAllSchemasOfConnection(db);
130799 }
 
130800 if( rc==SQLITE_OK || (db->flags&SQLITE_NoSchemaError)){
130801 /* Black magic: If the SQLITE_NoSchemaError flag is set, then consider
130802 ** the schema loaded, even if errors occurred. In this situation the
130803 ** current sqlite3_prepare() operation will fail, but the following one
130804 ** will attempt to compile the supplied statement against whatever subset
130805 ** of the schema was loaded before the error occurred. The primary
130806 ** purpose of this is to allow access to the sqlite_schema table
130807 ** even when its contents have been corrupted.
 
 
130808 */
130809 DbSetProperty(db, iDb, DB_SchemaLoaded);
130810 rc = SQLITE_OK;
130811 }
130812
@@ -133387,11 +134012,11 @@
133387 **
133388 ** full=ON, short=ANY: If the result refers directly to a table column,
133389 ** then the result column name with the table name
133390 ** prefix, ex: TABLE.COLUMN. Otherwise use zSpan.
133391 */
133392 static void generateColumnNames(
133393 Parse *pParse, /* Parser context */
133394 Select *pSelect /* Generate column names for this SELECT statement */
133395 ){
133396 Vdbe *v = pParse->pVdbe;
133397 int i;
@@ -133477,11 +134102,11 @@
133477 ** That is the only documented guarantee. However, countless applications
133478 ** developed over the years have made baseless assumptions about column names
133479 ** and will break if those assumptions changes. Hence, use extreme caution
133480 ** when modifying this routine to avoid breaking legacy.
133481 **
133482 ** See Also: generateColumnNames()
133483 */
133484 SQLITE_PRIVATE int sqlite3ColumnsFromExprList(
133485 Parse *pParse, /* Parsing context */
133486 ExprList *pEList, /* Expr list from which to derive column names */
133487 i16 *pnCol, /* Write the number of columns here */
@@ -134180,10 +134805,11 @@
134180 int nLimit = 0; /* Initialize to suppress harmless compiler warning */
134181 assert( !pPrior->pLimit );
134182 pPrior->iLimit = p->iLimit;
134183 pPrior->iOffset = p->iOffset;
134184 pPrior->pLimit = p->pLimit;
 
134185 rc = sqlite3Select(pParse, pPrior, &dest);
134186 pPrior->pLimit = 0;
134187 if( rc ){
134188 goto multi_select_end;
134189 }
@@ -134197,10 +134823,11 @@
134197 sqlite3VdbeAddOp3(v, OP_OffsetLimit,
134198 p->iLimit, p->iOffset+1, p->iOffset);
134199 }
134200 }
134201 ExplainQueryPlan((pParse, 1, "UNION ALL"));
 
134202 rc = sqlite3Select(pParse, p, &dest);
134203 testcase( rc!=SQLITE_OK );
134204 pDelete = p->pPrior;
134205 p->pPrior = pPrior;
134206 p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
@@ -134249,10 +134876,11 @@
134249
134250 /* Code the SELECT statements to our left
134251 */
134252 assert( !pPrior->pOrderBy );
134253 sqlite3SelectDestInit(&uniondest, priorOp, unionTab);
 
134254 rc = sqlite3Select(pParse, pPrior, &uniondest);
134255 if( rc ){
134256 goto multi_select_end;
134257 }
134258
@@ -134268,10 +134896,11 @@
134268 pLimit = p->pLimit;
134269 p->pLimit = 0;
134270 uniondest.eDest = op;
134271 ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
134272 sqlite3SelectOpName(p->op)));
 
134273 rc = sqlite3Select(pParse, p, &uniondest);
134274 testcase( rc!=SQLITE_OK );
134275 assert( p->pOrderBy==0 );
134276 pDelete = p->pPrior;
134277 p->pPrior = pPrior;
@@ -134328,10 +134957,11 @@
134328 assert( p->pEList );
134329
134330 /* Code the SELECTs to our left into temporary table "tab1".
134331 */
134332 sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1);
 
134333 rc = sqlite3Select(pParse, pPrior, &intersectdest);
134334 if( rc ){
134335 goto multi_select_end;
134336 }
134337
@@ -134344,10 +134974,11 @@
134344 pLimit = p->pLimit;
134345 p->pLimit = 0;
134346 intersectdest.iSDParm = tab2;
134347 ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
134348 sqlite3SelectOpName(p->op)));
 
134349 rc = sqlite3Select(pParse, p, &intersectdest);
134350 testcase( rc!=SQLITE_OK );
134351 pDelete = p->pPrior;
134352 p->pPrior = pPrior;
134353 if( p->nSelectRow>pPrior->nSelectRow ){
@@ -134976,10 +135607,13 @@
134976 if( p->pPrior ){
134977 sqlite3SelectDelete(db, p->pPrior);
134978 }
134979 p->pPrior = pPrior;
134980 pPrior->pNext = p;
 
 
 
134981
134982 /*** TBD: Insert subroutine calls to close cursors on incomplete
134983 **** subqueries ****/
134984 ExplainQueryPlanPop(pParse);
134985 return pParse->nErr!=0;
@@ -135056,30 +135690,32 @@
135056 ifNullRow.flags = EP_IfNullRow;
135057 pCopy = &ifNullRow;
135058 }
135059 testcase( ExprHasProperty(pCopy, EP_Subquery) );
135060 pNew = sqlite3ExprDup(db, pCopy, 0);
135061 if( pNew && pSubst->isLeftJoin ){
 
 
 
 
135062 ExprSetProperty(pNew, EP_CanBeNull);
135063 }
135064 if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){
135065 sqlite3SetJoinExpr(pNew, pExpr->iRightJoinTable);
135066 }
135067 sqlite3ExprDelete(db, pExpr);
135068 pExpr = pNew;
135069
135070 /* Ensure that the expression now has an implicit collation sequence,
135071 ** just as it did when it was a column of a view or sub-query. */
135072 if( pExpr ){
135073 if( pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE ){
135074 CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, pExpr);
135075 pExpr = sqlite3ExprAddCollateString(pSubst->pParse, pExpr,
135076 (pColl ? pColl->zName : "BINARY")
135077 );
135078 }
135079 ExprClearProperty(pExpr, EP_Collate);
135080 }
135081 }
135082 }
135083 }else{
135084 if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){
135085 pExpr->iTable = pSubst->iNewTable;
@@ -135194,11 +135830,14 @@
135194 int i;
135195 SrcItem *pItem;
135196 for(i=0, pItem=pSrc->a; i<pSrc->nSrc; i++, pItem++){
135197 if( i!=iExcept ){
135198 Select *p;
135199 pItem->iCursor = aCsrMap[pItem->iCursor] = pParse->nTab++;
 
 
 
135200 for(p=pItem->pSelect; p; p=p->pPrior){
135201 srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1);
135202 }
135203 }
135204 }
@@ -135634,11 +136273,11 @@
135634 pSubitem->pTab = pItemTab;
135635 if( pNew==0 ){
135636 p->pPrior = pPrior;
135637 }else{
135638 pNew->selId = ++pParse->nSelect;
135639 if( aCsrMap && db->mallocFailed==0 ){
135640 renumberCursors(pParse, pNew, iFrom, aCsrMap);
135641 }
135642 pNew->pPrior = pPrior;
135643 if( pPrior ) pPrior->pNext = pNew;
135644 pNew->pNext = p;
@@ -135833,12 +136472,14 @@
135833 ** a known value due to WHERE clause constraints of the form COLUMN=VALUE.
135834 */
135835 typedef struct WhereConst WhereConst;
135836 struct WhereConst {
135837 Parse *pParse; /* Parsing context */
 
135838 int nConst; /* Number for COLUMN=CONSTANT terms */
135839 int nChng; /* Number of times a constant is propagated */
 
135840 Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */
135841 };
135842
135843 /*
135844 ** Add a new entry to the pConst object. Except, do not add duplicate
@@ -135873,10 +136514,13 @@
135873 && pE2->iColumn==pColumn->iColumn
135874 ){
135875 return; /* Already present. Return without doing anything. */
135876 }
135877 }
 
 
 
135878
135879 pConst->nConst++;
135880 pConst->apExpr = sqlite3DbReallocOrFree(pConst->pParse->db, pConst->apExpr,
135881 pConst->nConst*2*sizeof(Expr*));
135882 if( pConst->apExpr==0 ){
@@ -135893,11 +136537,11 @@
135893 ** is part of the AND-connected terms of the expression. For each term
135894 ** found, add it to the pConst structure.
135895 */
135896 static void findConstInWhere(WhereConst *pConst, Expr *pExpr){
135897 Expr *pRight, *pLeft;
135898 if( pExpr==0 ) return;
135899 if( ExprHasProperty(pExpr, EP_FromJoin) ) return;
135900 if( pExpr->op==TK_AND ){
135901 findConstInWhere(pConst, pExpr->pRight);
135902 findConstInWhere(pConst, pExpr->pLeft);
135903 return;
@@ -135914,40 +136558,86 @@
135914 constInsert(pConst,pLeft,pRight,pExpr);
135915 }
135916 }
135917
135918 /*
135919 ** This is a Walker expression callback. pExpr is a candidate expression
135920 ** to be replaced by a value. If pExpr is equivalent to one of the
135921 ** columns named in pWalker->u.pConst, then overwrite it with its
135922 ** corresponding value.
 
 
 
135923 */
135924 static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){
 
 
 
 
135925 int i;
135926 WhereConst *pConst;
135927 if( pExpr->op!=TK_COLUMN ) return WRC_Continue;
135928 if( ExprHasProperty(pExpr, EP_FixedCol|EP_FromJoin) ){
135929 testcase( ExprHasProperty(pExpr, EP_FixedCol) );
135930 testcase( ExprHasProperty(pExpr, EP_FromJoin) );
135931 return WRC_Continue;
135932 }
135933 pConst = pWalker->u.pConst;
135934 for(i=0; i<pConst->nConst; i++){
135935 Expr *pColumn = pConst->apExpr[i*2];
135936 if( pColumn==pExpr ) continue;
135937 if( pColumn->iTable!=pExpr->iTable ) continue;
135938 if( pColumn->iColumn!=pExpr->iColumn ) continue;
 
 
 
135939 /* A match is found. Add the EP_FixedCol property */
135940 pConst->nChng++;
135941 ExprClearProperty(pExpr, EP_Leaf);
135942 ExprSetProperty(pExpr, EP_FixedCol);
135943 assert( pExpr->pLeft==0 );
135944 pExpr->pLeft = sqlite3ExprDup(pConst->pParse->db, pConst->apExpr[i*2+1], 0);
 
135945 break;
135946 }
135947 return WRC_Prune;
135948 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135949
135950 /*
135951 ** The WHERE-clause constant propagation optimization.
135952 **
135953 ** If the WHERE clause contains terms of the form COLUMN=CONSTANT or
@@ -135980,23 +136670,40 @@
135980 ** "b=a" to "b=123" but rather the "a" in "b=a" is tagged with EP_FixedCol
135981 ** and the "123" value is hung off of the pLeft pointer. Code generator
135982 ** routines know to generate the constant "123" instead of looking up the
135983 ** column value. Also, to avoid collation problems, this optimization is
135984 ** only attempted if the "a=123" term uses the default BINARY collation.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135985 */
135986 static int propagateConstants(
135987 Parse *pParse, /* The parsing context */
135988 Select *p /* The query in which to propagate constants */
135989 ){
135990 WhereConst x;
135991 Walker w;
135992 int nChng = 0;
135993 x.pParse = pParse;
 
135994 do{
135995 x.nConst = 0;
135996 x.nChng = 0;
135997 x.apExpr = 0;
 
135998 findConstInWhere(&x, p->pWhere);
135999 if( x.nConst ){
136000 memset(&w, 0, sizeof(w));
136001 w.pParse = pParse;
136002 w.xExprCallback = propagateConstantExprRewrite;
@@ -136429,36 +137136,47 @@
136429 if( sqlite3StrICmp(zName, p->a[i].zName)==0 ){
136430 *ppContext = p;
136431 return &p->a[i];
136432 }
136433 }
 
136434 }
136435 return 0;
136436 }
136437
136438 /* The code generator maintains a stack of active WITH clauses
136439 ** with the inner-most WITH clause being at the top of the stack.
136440 **
136441 ** This routine pushes the WITH clause passed as the second argument
136442 ** onto the top of the stack. If argument bFree is true, then this
136443 ** WITH clause will never be popped from the stack. In this case it
136444 ** should be freed along with the Parse object. In other cases, when
136445 ** bFree==0, the With object will be freed along with the SELECT
136446 ** statement with which it is associated.
 
 
 
 
 
 
 
136447 */
136448 SQLITE_PRIVATE void sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){
136449 if( pWith ){
136450 assert( pParse->pWith!=pWith );
136451 pWith->pOuter = pParse->pWith;
136452 pParse->pWith = pWith;
136453 if( bFree ){
136454 sqlite3ParserAddCleanup(pParse,
136455 (void(*)(sqlite3*,void*))sqlite3WithDelete,
136456 pWith);
136457 testcase( pParse->earlyCleanup );
 
 
 
 
 
136458 }
136459 }
 
136460 }
136461
136462 /*
136463 ** This function checks if argument pFrom refers to a CTE declared by
136464 ** a WITH clause on the stack currently maintained by the parser (on the
@@ -136483,15 +137201,28 @@
136483
136484 assert( pFrom->pTab==0 );
136485 if( pParse->pWith==0 ){
136486 /* There are no WITH clauses in the stack. No match is possible */
136487 return 0;
 
 
 
 
 
136488 }
136489 if( pFrom->zDatabase!=0 ){
136490 /* The FROM term contains a schema qualifier (ex: main.t1) and so
136491 ** it cannot possibly be a CTE reference. */
136492 return 0;
 
 
 
 
 
 
 
 
136493 }
136494 pCte = searchWith(pParse->pWith, pFrom, &pWith);
136495 if( pCte ){
136496 sqlite3 *db = pParse->db;
136497 Table *pTab;
@@ -136534,10 +137265,11 @@
136534 pTab->iPKey = -1;
136535 pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
136536 pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid;
136537 pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0);
136538 if( db->mallocFailed ) return 2;
 
136539 assert( pFrom->pSelect );
136540 pFrom->fg.isCte = 1;
136541 pFrom->u2.pCteUse = pCteUse;
136542 pCteUse->nUse++;
136543 if( pCteUse->nUse>=2 && pCteUse->eM10d==M10d_Any ){
@@ -136637,22 +137369,20 @@
136637 **
136638 ** This function is used as the xSelectCallback2() callback by
136639 ** sqlite3SelectExpand() when walking a SELECT tree to resolve table
136640 ** names and other FROM clause elements.
136641 */
136642 static void selectPopWith(Walker *pWalker, Select *p){
136643 Parse *pParse = pWalker->pParse;
136644 if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){
136645 With *pWith = findRightmost(p)->pWith;
136646 if( pWith!=0 ){
136647 assert( pParse->pWith==pWith || pParse->nErr );
136648 pParse->pWith = pWith->pOuter;
136649 }
136650 }
136651 }
136652 #else
136653 #define selectPopWith 0
136654 #endif
136655
136656 /*
136657 ** The SrcList_item structure passed as the second argument represents a
136658 ** sub-query in the FROM clause of a SELECT statement. This function
@@ -136735,10 +137465,19 @@
136735 /* Renumber selId because it has been copied from a view */
136736 p->selId = ++pParse->nSelect;
136737 }
136738 pTabList = p->pSrc;
136739 pEList = p->pEList;
 
 
 
 
 
 
 
 
 
136740 sqlite3WithPush(pParse, p->pWith, 0);
136741
136742 /* Make sure cursor numbers have been assigned to all entries in
136743 ** the FROM clause of the SELECT statement.
136744 */
@@ -136795,10 +137534,11 @@
136795 ){
136796 sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited",
136797 pTab->zName);
136798 }
136799 #ifndef SQLITE_OMIT_VIRTUALTABLE
 
136800 if( IsVirtual(pTab)
136801 && pFrom->fg.fromDDL
136802 && ALWAYS(pTab->pVTable!=0)
136803 && pTab->pVTable->eVtabRisk > ((db->flags & SQLITE_TrustedSchema)!=0)
136804 ){
@@ -137035,11 +137775,11 @@
137035 w.xSelectCallback = convertCompoundSelectToSubquery;
137036 w.xSelectCallback2 = 0;
137037 sqlite3WalkSelect(&w, pSelect);
137038 }
137039 w.xSelectCallback = selectExpander;
137040 w.xSelectCallback2 = selectPopWith;
137041 w.eCode = 0;
137042 sqlite3WalkSelect(&w, pSelect);
137043 }
137044
137045
@@ -137622,16 +138362,15 @@
137622 }
137623 }
137624 }
137625
137626 if( pDest->eDest==SRT_Output ){
137627 generateColumnNames(pParse, p);
137628 }
137629
137630 #ifndef SQLITE_OMIT_WINDOWFUNC
137631 rc = sqlite3WindowRewrite(pParse, p);
137632 if( rc ){
137633 assert( db->mallocFailed || pParse->nErr>0 );
137634 goto select_end;
137635 }
137636 #if SELECTTRACE_ENABLED
137637 if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){
@@ -137753,11 +138492,12 @@
137753 /* Do the WHERE-clause constant propagation optimization if this is
137754 ** a join. No need to speed time on this operation for non-join queries
137755 ** as the equivalent optimization will be handled by query planner in
137756 ** sqlite3WhereBegin().
137757 */
137758 if( pTabList->nSrc>1
 
137759 && OptimizationEnabled(db, SQLITE_PropagateConst)
137760 && propagateConstants(pParse, p)
137761 ){
137762 #if SELECTTRACE_ENABLED
137763 if( sqlite3SelectTrace & 0x100 ){
@@ -137816,23 +138556,12 @@
137816 /* Generate code for all sub-queries in the FROM clause
137817 */
137818 pSub = pItem->pSelect;
137819 if( pSub==0 ) continue;
137820
137821 /* The code for a subquery should only be generated once, though it is
137822 ** technically harmless for it to be generated multiple times. The
137823 ** following assert() will detect if something changes to cause
137824 ** the same subquery to be coded multiple times, as a signal to the
137825 ** developers to try to optimize the situation.
137826 **
137827 ** Update 2019-07-24:
137828 ** See ticket https://sqlite.org/src/tktview/c52b09c7f38903b1311cec40.
137829 ** The dbsqlfuzz fuzzer found a case where the same subquery gets
137830 ** coded twice. So this assert() now becomes a testcase(). It should
137831 ** be very rare, though.
137832 */
137833 testcase( pItem->addrFillSub!=0 );
137834
137835 /* Increment Parse.nHeight by the height of the largest expression
137836 ** tree referred to by this, the parent select. The child select
137837 ** may contain expression trees of at most
137838 ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit
@@ -137915,18 +138644,17 @@
137915 sqlite3VdbeAddOp2(v, OP_Gosub, pPrior->regReturn, pPrior->addrFillSub);
137916 }
137917 sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);
137918 pSub->nSelectRow = pPrior->pSelect->nSelectRow;
137919 }else{
137920 /* Materalize the view. If the view is not correlated, generate a
137921 ** subroutine to do the materialization so that subsequent uses of
137922 ** the same view can reuse the materialization. */
137923 int topAddr;
137924 int onceAddr = 0;
137925 int retAddr;
137926
137927 testcase( pItem->addrFillSub==0 ); /* Ticket c52b09c7f38903b1311 */
137928 pItem->regReturn = ++pParse->nMem;
137929 topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn);
137930 pItem->addrFillSub = topAddr+1;
137931 if( pItem->fg.isCorrelated==0 ){
137932 /* If the subquery is not correlated and if we are not inside of
@@ -138344,12 +139072,14 @@
138344 sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);
138345 SELECTTRACE(1,pParse,p,("WhereBegin\n"));
138346 pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pGroupBy, pDistinct,
138347 WHERE_GROUPBY | (orderByGrp ? WHERE_SORTBYGROUP : 0) | distFlag, 0
138348 );
138349 sqlite3ExprListDelete(db, pDistinct);
138350 if( pWInfo==0 ) goto select_end;
 
 
138351 eDist = sqlite3WhereIsDistinct(pWInfo);
138352 SELECTTRACE(1,pParse,p,("WhereBegin returns\n"));
138353 if( sqlite3WhereIsOrdered(pWInfo)==pGroupBy->nExpr ){
138354 /* The optimizer is able to deliver rows in group by order so
138355 ** we do not have to sort. The OP_OpenEphemeral table will be
@@ -138478,10 +139208,11 @@
138478 }else{
138479 SELECTTRACE(1,pParse,p,("WhereEnd\n"));
138480 sqlite3WhereEnd(pWInfo);
138481 sqlite3VdbeChangeToNoop(v, addrSortingIdx);
138482 }
 
138483
138484 /* Output the final row of result
138485 */
138486 sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);
138487 VdbeComment((v, "output final row"));
@@ -138692,10 +139423,12 @@
138692
138693 /* Control jumps to here if an error is encountered above, or upon
138694 ** successful coding of the SELECT.
138695 */
138696 select_end:
 
 
138697 sqlite3ExprListDelete(db, pMinMaxOrderBy);
138698 #ifdef SQLITE_DEBUG
138699 if( pAggInfo && !db->mallocFailed ){
138700 for(i=0; i<pAggInfo->nColumn; i++){
138701 Expr *pExpr = pAggInfo->aCol[i].pCExpr;
@@ -138982,37 +139715,45 @@
138982 if( pParse->disableTriggers ){
138983 return 0;
138984 }
138985 pTmpSchema = pParse->db->aDb[1].pSchema;
138986 p = sqliteHashFirst(&pTmpSchema->trigHash);
138987 if( p==0 ){
138988 return pTab->pTrigger;
138989 }
138990 pList = pTab->pTrigger;
138991 if( pTmpSchema!=pTab->pSchema ){
138992 while( p ){
138993 Trigger *pTrig = (Trigger *)sqliteHashData(p);
138994 if( pTrig->pTabSchema==pTab->pSchema
138995 && 0==sqlite3StrICmp(pTrig->table, pTab->zName)
138996 ){
138997 pTrig->pNext = pList;
138998 pList = pTrig;
138999 }else if( pTrig->op==TK_RETURNING
 
139000 #ifndef SQLITE_OMIT_VIRTUALTABLE
139001 && pParse->db->pVtabCtx==0
139002 #endif
139003 ){
139004 assert( pParse->bReturning );
139005 assert( &(pParse->u1.pReturning->retTrig) == pTrig );
139006 pTrig->table = pTab->zName;
139007 pTrig->pTabSchema = pTab->pSchema;
139008 pTrig->pNext = pList;
139009 pList = pTrig;
139010 }
139011 p = sqliteHashNext(p);
139012 }
139013 }
 
 
 
 
 
 
 
 
 
 
139014 return pList;
139015 }
139016
139017 /*
139018 ** This is called by the parser when it sees a CREATE TRIGGER statement
@@ -139812,19 +140553,10 @@
139812 pItem->zEName = sqlite3DbStrDup(db, pList->a[i].zEName);
139813 pItem->eEName = pList->a[i].eEName;
139814 }
139815 }
139816 }
139817 if( !db->mallocFailed ){
139818 Vdbe *v = pParse->pVdbe;
139819 assert( v!=0 );
139820 sqlite3VdbeSetNumCols(v, pNew->nExpr);
139821 for(i=0; i<pNew->nExpr; i++){
139822 sqlite3VdbeSetColName(v, i, COLNAME_NAME, pNew->a[i].zEName,
139823 SQLITE_TRANSIENT);
139824 }
139825 }
139826 return pNew;
139827 }
139828
139829 /*
139830 ** Generate code for the RETURNING trigger. Unlike other triggers
@@ -139836,17 +140568,31 @@
139836 Trigger *pTrigger, /* The trigger step that defines the RETURNING */
139837 Table *pTab, /* The table to code triggers from */
139838 int regIn /* The first in an array of registers */
139839 ){
139840 Vdbe *v = pParse->pVdbe;
 
139841 ExprList *pNew;
139842 Returning *pReturning;
 
 
139843
139844 assert( v!=0 );
139845 assert( pParse->bReturning );
139846 pReturning = pParse->u1.pReturning;
139847 assert( pTrigger == &(pReturning->retTrig) );
 
 
 
 
 
 
 
 
 
 
 
139848 pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab);
139849 if( pNew ){
139850 NameContext sNC;
139851 memset(&sNC, 0, sizeof(sNC));
139852 if( pReturning->nRetCol==0 ){
@@ -139863,17 +140609,18 @@
139863 int nCol = pNew->nExpr;
139864 int reg = pParse->nMem+1;
139865 pParse->nMem += nCol+2;
139866 pReturning->iRetReg = reg;
139867 for(i=0; i<nCol; i++){
139868 sqlite3ExprCodeFactorable(pParse, pNew->a[i].pExpr, reg+i);
 
139869 }
139870 sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, i, reg+i);
139871 sqlite3VdbeAddOp2(v, OP_NewRowid, pReturning->iRetCur, reg+i+1);
139872 sqlite3VdbeAddOp3(v, OP_Insert, pReturning->iRetCur, reg+i, reg+i+1);
139873 }
139874 sqlite3ExprListDelete(pParse->db, pNew);
139875 pParse->eTriggerOp = 0;
139876 pParse->pTriggerTab = 0;
139877 }
139878 }
139879
@@ -140552,10 +141299,11 @@
140552 pSrc = sqlite3SrcListDup(db, pTabList, 0);
140553 pWhere2 = sqlite3ExprDup(db, pWhere, 0);
140554
140555 assert( pTabList->nSrc>1 );
140556 if( pSrc ){
 
140557 pSrc->a[0].iCursor = -1;
140558 pSrc->a[0].pTab->nTabRef--;
140559 pSrc->a[0].pTab = 0;
140560 }
140561 if( pPk ){
@@ -140581,11 +141329,12 @@
140581 if( pLimit ){
140582 pGrp = sqlite3ExprListAppend(pParse, 0, sqlite3PExpr(pParse,TK_ROW,0,0));
140583 }
140584 #endif
140585 }
140586 if( ALWAYS(pChanges) ){
 
140587 for(i=0; i<pChanges->nExpr; i++){
140588 pList = sqlite3ExprListAppend(pParse, pList,
140589 sqlite3ExprDup(db, pChanges->a[i].pExpr, 0)
140590 );
140591 }
@@ -143607,10 +144356,11 @@
143607 pMod->pEpoTab = pTab;
143608 pTab->nTabRef = 1;
143609 pTab->pSchema = db->aDb[0].pSchema;
143610 assert( pTab->nModuleArg==0 );
143611 pTab->iPKey = -1;
 
143612 addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName));
143613 addModuleArgument(pParse, pTab, 0);
143614 addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName));
143615 rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr);
143616 if( rc ){
@@ -144023,12 +144773,12 @@
144023 WhereClause *pOrigWC; /* Original, innermost WhereClause */
144024 WhereClause *pWC; /* WhereClause currently being scanned */
144025 const char *zCollName; /* Required collating sequence, if not NULL */
144026 Expr *pIdxExpr; /* Search for this index expression */
144027 char idxaff; /* Must match this affinity, if zCollName!=NULL */
144028 unsigned char nEquiv; /* Number of entries in aEquiv[] */
144029 unsigned char iEquiv; /* Next unused slot in aEquiv[] */
144030 u32 opMask; /* Acceptable operators */
144031 int k; /* Resume scanning at this->pWC->a[this->k] */
144032 int aiCur[11]; /* Cursors in the equivalence class */
144033 i16 aiColumn[11]; /* Corresponding column number in the eq-class */
144034 };
@@ -144333,10 +145083,11 @@
144333 #define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
144334 #define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
144335 #define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */
144336 #define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */
144337 #define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */
 
144338
144339 #endif /* !defined(SQLITE_WHEREINT_H) */
144340
144341 /************** End of whereInt.h ********************************************/
144342 /************** Continuing where we left off in wherecode.c ******************/
@@ -144616,10 +145367,16 @@
144616 if( nLoop && (pTerm->wtFlags & TERM_LIKE)!=0 ){
144617 pTerm->wtFlags |= TERM_LIKECOND;
144618 }else{
144619 pTerm->wtFlags |= TERM_CODED;
144620 }
 
 
 
 
 
 
144621 if( pTerm->iParent<0 ) break;
144622 pTerm = &pTerm->pWC->a[pTerm->iParent];
144623 assert( pTerm!=0 );
144624 pTerm->nChild--;
144625 if( pTerm->nChild!=0 ) break;
@@ -144933,11 +145690,26 @@
144933 pLevel->u.in.nIn = 0;
144934 }
144935 sqlite3DbFree(pParse->db, aiMap);
144936 #endif
144937 }
144938 disableTerm(pLevel, pTerm);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144939 return iReg;
144940 }
144941
144942 /*
144943 ** Generate code that will evaluate all == and IN constraints for an
@@ -145019,10 +145791,11 @@
145019 zAff = sqlite3DbStrDup(pParse->db,sqlite3IndexAffinityStr(pParse->db,pIdx));
145020 assert( zAff!=0 || pParse->db->mallocFailed );
145021
145022 if( nSkip ){
145023 int iIdxCur = pLevel->iIdxCur;
 
145024 sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur);
145025 VdbeCoverageIf(v, bRev==0);
145026 VdbeCoverageIf(v, bRev!=0);
145027 VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
145028 j = sqlite3VdbeAddOp0(v, OP_Goto);
@@ -145053,11 +145826,11 @@
145053 if( r1!=regBase+j ){
145054 if( nReg==1 ){
145055 sqlite3ReleaseTempReg(pParse, regBase);
145056 regBase = r1;
145057 }else{
145058 sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j);
145059 }
145060 }
145061 if( pTerm->eOperator & WO_IN ){
145062 if( pTerm->pExpr->flags & EP_xIsSelect ){
145063 /* No affinity ever needs to be (or should be) applied to a value
@@ -145070,11 +145843,11 @@
145070 Expr *pRight = pTerm->pExpr->pRight;
145071 if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){
145072 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
145073 VdbeCoverage(v);
145074 }
145075 if( zAff ){
145076 if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){
145077 zAff[j] = SQLITE_AFF_BLOB;
145078 }
145079 if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){
145080 zAff[j] = SQLITE_AFF_BLOB;
@@ -145419,11 +146192,11 @@
145419 for(i=0; i<nReg; i++){
145420 sqlite3ExprCode(pParse, pList->a[i].pExpr, iReg+i);
145421 }
145422 }
145423 }else{
145424 assert( nReg==1 );
145425 sqlite3ExprCode(pParse, p, iReg);
145426 }
145427 }
145428
145429 /* An instance of the IdxExprTrans object carries information about a
@@ -146046,13 +146819,11 @@
146046
146047 /* If we are doing a reverse order scan on an ascending index, or
146048 ** a forward order scan on a descending index, interchange the
146049 ** start and end terms (pRangeStart and pRangeEnd).
146050 */
146051 if( (nEq<pIdx->nKeyCol && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC))
146052 || (bRev && pIdx->nKeyCol==nEq)
146053 ){
146054 SWAP(WhereTerm *, pRangeEnd, pRangeStart);
146055 SWAP(u8, bSeekPastNull, bStopAtNull);
146056 SWAP(u8, nBtm, nTop);
146057 }
146058
@@ -146469,11 +147240,11 @@
146469 }
146470 if( pAndExpr ){
146471 /* The extra 0x10000 bit on the opcode is masked off and does not
146472 ** become part of the new Expr.op. However, it does make the
146473 ** op==TK_AND comparison inside of sqlite3PExpr() false, and this
146474 ** prevents sqlite3PExpr() from implementing AND short-circuit
146475 ** optimization, which we do not want here. */
146476 pAndExpr = sqlite3PExpr(pParse, TK_AND|0x10000, 0, pAndExpr);
146477 }
146478 }
146479
@@ -146485,14 +147256,20 @@
146485 for(ii=0; ii<pOrWc->nTerm; ii++){
146486 WhereTerm *pOrTerm = &pOrWc->a[ii];
146487 if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
146488 WhereInfo *pSubWInfo; /* Info for single OR-term scan */
146489 Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
 
146490 int jmp1 = 0; /* Address of jump operation */
146491 testcase( (pTabItem[0].fg.jointype & JT_LEFT)!=0
146492 && !ExprHasProperty(pOrExpr, EP_FromJoin)
146493 ); /* See TH3 vtab25.400 and ticket 614b25314c766238 */
 
 
 
 
 
146494 if( pAndExpr ){
146495 pAndExpr->pLeft = pOrExpr;
146496 pOrExpr = pAndExpr;
146497 }
146498 /* Loop through table entries that match term pOrTerm. */
@@ -146603,10 +147380,11 @@
146603
146604 /* Finish the loop through table entries that match term pOrTerm. */
146605 sqlite3WhereEnd(pSubWInfo);
146606 ExplainQueryPlanPop(pParse);
146607 }
 
146608 }
146609 }
146610 ExplainQueryPlanPop(pParse);
146611 pLevel->u.pCovidx = pCov;
146612 if( pCov ) pLevel->iIdxCur = iCovCur;
@@ -147320,10 +148098,11 @@
147320 sqlite3 *db; /* Database connection (for malloc) */
147321 Expr *pNew; /* New virtual expression */
147322 int op; /* Operator for the combined expression */
147323 int idxNew; /* Index in pWC of the next virtual term */
147324
 
147325 if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
147326 if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
147327 if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
147328 && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;
147329 assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );
@@ -147680,11 +148459,11 @@
147680 assert( !ExprHasProperty(pNew, EP_xIsSelect) );
147681 pNew->x.pList = pList;
147682 idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);
147683 testcase( idxNew==0 );
147684 exprAnalyze(pSrc, pWC, idxNew);
147685 /* pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where used again */
147686 markTermAsChild(pWC, idxNew, idxTerm);
147687 }else{
147688 sqlite3ExprListDelete(db, pList);
147689 }
147690 }
@@ -147804,10 +148583,11 @@
147804 assert( TK_GT+1==TK_LE && TK_GT+2==TK_LT && TK_GT+3==TK_GE );
147805 assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE );
147806 assert( op<=TK_GE );
147807 if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){
147808 pExpr = pExpr->x.pList->a[0].pExpr;
 
147809 }
147810
147811 if( pExpr->op==TK_COLUMN ){
147812 aiCurCol[0] = pExpr->iTable;
147813 aiCurCol[1] = pExpr->iColumn;
@@ -147816,280 +148596,10 @@
147816 if( mPrereq==0 ) return 0; /* No table references */
147817 if( (mPrereq&(mPrereq-1))!=0 ) return 0; /* Refs more than one table */
147818 return exprMightBeIndexed2(pFrom,mPrereq,aiCurCol,pExpr);
147819 }
147820
147821 /*
147822 ** Expression callback for exprUsesSrclist().
147823 */
147824 static int exprUsesSrclistCb(Walker *p, Expr *pExpr){
147825 if( pExpr->op==TK_COLUMN ){
147826 SrcList *pSrc = p->u.pSrcList;
147827 int iCsr = pExpr->iTable;
147828 int ii;
147829 for(ii=0; ii<pSrc->nSrc; ii++){
147830 if( pSrc->a[ii].iCursor==iCsr ){
147831 return p->eCode ? WRC_Abort : WRC_Continue;
147832 }
147833 }
147834 return p->eCode ? WRC_Continue : WRC_Abort;
147835 }
147836 return WRC_Continue;
147837 }
147838
147839 /*
147840 ** Select callback for exprUsesSrclist().
147841 */
147842 static int exprUsesSrclistSelectCb(Walker *NotUsed1, Select *NotUsed2){
147843 UNUSED_PARAMETER(NotUsed1);
147844 UNUSED_PARAMETER(NotUsed2);
147845 return WRC_Abort;
147846 }
147847
147848 /*
147849 ** This function always returns true if expression pExpr contains
147850 ** a sub-select.
147851 **
147852 ** If there is no sub-select in pExpr, then return true if pExpr
147853 ** contains a TK_COLUMN node for a table that is (bUses==1)
147854 ** or is not (bUses==0) in pSrc.
147855 **
147856 ** Said another way:
147857 **
147858 ** bUses Return Meaning
147859 ** -------- ------ ------------------------------------------------
147860 **
147861 ** bUses==1 true pExpr contains either a sub-select or a
147862 ** TK_COLUMN referencing pSrc.
147863 **
147864 ** bUses==1 false pExpr contains no sub-selects and all TK_COLUMN
147865 ** nodes reference tables not found in pSrc
147866 **
147867 ** bUses==0 true pExpr contains either a sub-select or a TK_COLUMN
147868 ** that references a table not in pSrc.
147869 **
147870 ** bUses==0 false pExpr contains no sub-selects and all TK_COLUMN
147871 ** nodes reference pSrc
147872 */
147873 static int exprUsesSrclist(SrcList *pSrc, Expr *pExpr, int bUses){
147874 Walker sWalker;
147875 memset(&sWalker, 0, sizeof(Walker));
147876 sWalker.eCode = bUses;
147877 sWalker.u.pSrcList = pSrc;
147878 sWalker.xExprCallback = exprUsesSrclistCb;
147879 sWalker.xSelectCallback = exprUsesSrclistSelectCb;
147880 return (sqlite3WalkExpr(&sWalker, pExpr)==WRC_Abort);
147881 }
147882
147883 /*
147884 ** Context object used by exprExistsToInIter() as it iterates through an
147885 ** expression tree.
147886 */
147887 struct ExistsToInCtx {
147888 SrcList *pSrc; /* The tables in an EXISTS(SELECT ... FROM <here> ...) */
147889 Expr *pInLhs; /* OUT: Use this as the LHS of the IN operator */
147890 Expr *pEq; /* OUT: The == term that include pInLhs */
147891 Expr **ppAnd; /* OUT: The AND operator that includes pEq as a child */
147892 Expr **ppParent; /* The AND operator currently being examined */
147893 };
147894
147895 /*
147896 ** Iterate through all AND connected nodes in the expression tree
147897 ** headed by (*ppExpr), populating the structure passed as the first
147898 ** argument with the values required by exprAnalyzeExistsFindEq().
147899 **
147900 ** This function returns non-zero if the expression tree does not meet
147901 ** the two conditions described by the header comment for
147902 ** exprAnalyzeExistsFindEq(), or zero if it does.
147903 */
147904 static int exprExistsToInIter(struct ExistsToInCtx *p, Expr **ppExpr){
147905 Expr *pExpr = *ppExpr;
147906 switch( pExpr->op ){
147907 case TK_AND:
147908 p->ppParent = ppExpr;
147909 if( exprExistsToInIter(p, &pExpr->pLeft) ) return 1;
147910 p->ppParent = ppExpr;
147911 if( exprExistsToInIter(p, &pExpr->pRight) ) return 1;
147912 break;
147913 case TK_EQ: {
147914 int bLeft = exprUsesSrclist(p->pSrc, pExpr->pLeft, 0);
147915 int bRight = exprUsesSrclist(p->pSrc, pExpr->pRight, 0);
147916 if( bLeft || bRight ){
147917 if( (bLeft && bRight) || p->pInLhs ) return 1;
147918 p->pInLhs = bLeft ? pExpr->pLeft : pExpr->pRight;
147919 if( exprUsesSrclist(p->pSrc, p->pInLhs, 1) ) return 1;
147920 p->pEq = pExpr;
147921 p->ppAnd = p->ppParent;
147922 }
147923 break;
147924 }
147925 default:
147926 if( exprUsesSrclist(p->pSrc, pExpr, 0) ){
147927 return 1;
147928 }
147929 break;
147930 }
147931
147932 return 0;
147933 }
147934
147935 /*
147936 ** This function is used by exprAnalyzeExists() when creating virtual IN(...)
147937 ** terms equivalent to user-supplied EXIST(...) clauses. It splits the WHERE
147938 ** clause of the Select object passed as the first argument into one or more
147939 ** expressions joined by AND operators, and then tests if the following are
147940 ** true:
147941 **
147942 ** 1. Exactly one of the AND separated terms refers to the outer
147943 ** query, and it is an == (TK_EQ) expression.
147944 **
147945 ** 2. Only one side of the == expression refers to the outer query, and
147946 ** it does not refer to any columns from the inner query.
147947 **
147948 ** If both these conditions are true, then a pointer to the side of the ==
147949 ** expression that refers to the outer query is returned. The caller will
147950 ** use this expression as the LHS of the IN(...) virtual term. Or, if one
147951 ** or both of the above conditions are not true, NULL is returned.
147952 **
147953 ** If non-NULL is returned and ppEq is non-NULL, *ppEq is set to point
147954 ** to the == expression node before returning. If pppAnd is non-NULL and
147955 ** the == node is not the root of the WHERE clause, then *pppAnd is set
147956 ** to point to the pointer to the AND node that is the parent of the ==
147957 ** node within the WHERE expression tree.
147958 */
147959 static Expr *exprAnalyzeExistsFindEq(
147960 Select *pSel, /* The SELECT of the EXISTS */
147961 Expr **ppEq, /* OUT: == node from WHERE clause */
147962 Expr ***pppAnd /* OUT: Pointer to parent of ==, if any */
147963 ){
147964 struct ExistsToInCtx ctx;
147965 memset(&ctx, 0, sizeof(ctx));
147966 ctx.pSrc = pSel->pSrc;
147967 if( exprExistsToInIter(&ctx, &pSel->pWhere) ){
147968 return 0;
147969 }
147970 if( ppEq ) *ppEq = ctx.pEq;
147971 if( pppAnd ) *pppAnd = ctx.ppAnd;
147972 return ctx.pInLhs;
147973 }
147974
147975 /*
147976 ** Term idxTerm of the WHERE clause passed as the second argument is an
147977 ** EXISTS expression with a correlated SELECT statement on the RHS.
147978 ** This function analyzes the SELECT statement, and if possible adds an
147979 ** equivalent "? IN(SELECT...)" virtual term to the WHERE clause.
147980 **
147981 ** For an EXISTS term such as the following:
147982 **
147983 ** EXISTS (SELECT ... FROM <srclist> WHERE <e1> = <e2> AND <e3>)
147984 **
147985 ** The virtual IN() term added is:
147986 **
147987 ** <e1> IN (SELECT <e2> FROM <srclist> WHERE <e3>)
147988 **
147989 ** The virtual term is only added if the following conditions are met:
147990 **
147991 ** 1. The sub-select must not be an aggregate or use window functions,
147992 **
147993 ** 2. The sub-select must not be a compound SELECT,
147994 **
147995 ** 3. Expression <e1> must refer to at least one column from the outer
147996 ** query, and must not refer to any column from the inner query
147997 ** (i.e. from <srclist>).
147998 **
147999 ** 4. <e2> and <e3> must not refer to any values from the outer query.
148000 ** In other words, once <e1> has been removed, the inner query
148001 ** must not be correlated.
148002 **
148003 */
148004 static void exprAnalyzeExists(
148005 SrcList *pSrc, /* the FROM clause */
148006 WhereClause *pWC, /* the WHERE clause */
148007 int idxTerm /* Index of the term to be analyzed */
148008 ){
148009 Parse *pParse = pWC->pWInfo->pParse;
148010 WhereTerm *pTerm = &pWC->a[idxTerm];
148011 Expr *pExpr = pTerm->pExpr;
148012 Select *pSel = pExpr->x.pSelect;
148013 Expr *pDup = 0;
148014 Expr *pEq = 0;
148015 Expr *pRet = 0;
148016 Expr *pInLhs = 0;
148017 Expr **ppAnd = 0;
148018 int idxNew;
148019 sqlite3 *db = pParse->db;
148020
148021 assert( pExpr->op==TK_EXISTS );
148022 assert( (pExpr->flags & EP_VarSelect) && (pExpr->flags & EP_xIsSelect) );
148023
148024 if( pSel->selFlags & SF_Aggregate ) return;
148025 #ifndef SQLITE_OMIT_WINDOWFUNC
148026 if( pSel->pWin ) return;
148027 #endif
148028 if( pSel->pPrior ) return;
148029 if( pSel->pWhere==0 ) return;
148030 if( pSel->pLimit ) return;
148031 if( 0==exprAnalyzeExistsFindEq(pSel, 0, 0) ) return;
148032
148033 pDup = sqlite3ExprDup(db, pExpr, 0);
148034 if( db->mallocFailed ){
148035 sqlite3ExprDelete(db, pDup);
148036 return;
148037 }
148038 pSel = pDup->x.pSelect;
148039 sqlite3ExprListDelete(db, pSel->pEList);
148040 pSel->pEList = 0;
148041
148042 pInLhs = exprAnalyzeExistsFindEq(pSel, &pEq, &ppAnd);
148043 assert( pInLhs && pEq );
148044 assert( pEq==pSel->pWhere || ppAnd );
148045 if( pInLhs==pEq->pLeft ){
148046 pRet = pEq->pRight;
148047 }else{
148048 CollSeq *p = sqlite3ExprCompareCollSeq(pParse, pEq);
148049 pInLhs = sqlite3ExprAddCollateString(pParse, pInLhs, p?p->zName:"BINARY");
148050 pRet = pEq->pLeft;
148051 }
148052
148053 assert( pDup->pLeft==0 );
148054 pDup->op = TK_IN;
148055 pDup->pLeft = pInLhs;
148056 pDup->flags &= ~EP_VarSelect;
148057 if( pRet->op==TK_VECTOR ){
148058 pSel->pEList = pRet->x.pList;
148059 pRet->x.pList = 0;
148060 sqlite3ExprDelete(db, pRet);
148061 }else{
148062 pSel->pEList = sqlite3ExprListAppend(pParse, 0, pRet);
148063 }
148064 pEq->pLeft = 0;
148065 pEq->pRight = 0;
148066 if( ppAnd ){
148067 Expr *pAnd = *ppAnd;
148068 Expr *pOther = (pAnd->pLeft==pEq) ? pAnd->pRight : pAnd->pLeft;
148069 pAnd->pLeft = pAnd->pRight = 0;
148070 sqlite3ExprDelete(db, pAnd);
148071 *ppAnd = pOther;
148072 }else{
148073 assert( pSel->pWhere==pEq );
148074 pSel->pWhere = 0;
148075 }
148076 sqlite3ExprDelete(db, pEq);
148077
148078 #ifdef WHERETRACE_ENABLED /* 0x20 */
148079 if( sqlite3WhereTrace & 0x20 ){
148080 sqlite3DebugPrintf("Convert EXISTS:\n");
148081 sqlite3TreeViewExpr(0, pExpr, 0);
148082 sqlite3DebugPrintf("into IN:\n");
148083 sqlite3TreeViewExpr(0, pDup, 0);
148084 }
148085 #endif
148086 idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC);
148087 exprAnalyze(pSrc, pWC, idxNew);
148088 markTermAsChild(pWC, idxNew, idxTerm);
148089 pWC->a[idxTerm].wtFlags |= TERM_COPIED;
148090 }
148091
148092 /*
148093 ** The input to this routine is an WhereTerm structure with only the
148094 ** "pExpr" field filled in. The job of this routine is to analyze the
148095 ** subexpression and populate all the other fields of the WhereTerm
@@ -148185,10 +148695,11 @@
148185 pTerm->eOperator = operatorMask(op) & opMask;
148186 }
148187 if( op==TK_IS ) pTerm->wtFlags |= TERM_IS;
148188 if( pRight
148189 && exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op)
 
148190 ){
148191 WhereTerm *pNew;
148192 Expr *pDup;
148193 u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */
148194 assert( pTerm->u.x.iField==0 );
@@ -148277,20 +148788,10 @@
148277 assert( pWC->op==TK_AND );
148278 exprAnalyzeOrTerm(pSrc, pWC, idxTerm);
148279 pTerm = &pWC->a[idxTerm];
148280 }
148281 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
148282
148283 else if( pExpr->op==TK_EXISTS ){
148284 /* Perhaps treat an EXISTS operator as an IN operator */
148285 if( (pExpr->flags & EP_VarSelect)!=0
148286 && OptimizationEnabled(db, SQLITE_ExistsToIN)
148287 ){
148288 exprAnalyzeExists(pSrc, pWC, idxTerm);
148289 }
148290 }
148291
148292 /* The form "x IS NOT NULL" can sometimes be evaluated more efficiently
148293 ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
148294 ** virtual term of that form.
148295 **
148296 ** The virtual term must be tagged with TERM_VNULL.
@@ -148973,11 +149474,13 @@
148973 ** If the right-hand branch of the expression is a TK_COLUMN, then return
148974 ** a pointer to the right-hand branch. Otherwise, return NULL.
148975 */
148976 static Expr *whereRightSubexprIsColumn(Expr *p){
148977 p = sqlite3ExprSkipCollateAndLikely(p->pRight);
148978 if( ALWAYS(p!=0) && p->op==TK_COLUMN ) return p;
 
 
148979 return 0;
148980 }
148981
148982 /*
148983 ** Advance to the next WhereTerm that matches according to the criteria
@@ -149048,10 +149551,22 @@
149048 testcase( pTerm->eOperator & WO_IS );
149049 continue;
149050 }
149051 pScan->pWC = pWC;
149052 pScan->k = k+1;
 
 
 
 
 
 
 
 
 
 
 
 
149053 return pTerm;
149054 }
149055 }
149056 }
149057 pWC = pWC->pOuter;
@@ -150652,11 +151167,11 @@
150652 ** Transfer content from the second pLoop into the first.
150653 */
150654 static int whereLoopXfer(sqlite3 *db, WhereLoop *pTo, WhereLoop *pFrom){
150655 whereLoopClearUnion(db, pTo);
150656 if( whereLoopResize(db, pTo, pFrom->nLTerm) ){
150657 memset(&pTo->u, 0, sizeof(pTo->u));
150658 return SQLITE_NOMEM_BKPT;
150659 }
150660 memcpy(pTo, pFrom, WHERE_LOOP_XFER_SZ);
150661 memcpy(pTo->aLTerm, pFrom->aLTerm, pTo->nLTerm*sizeof(pTo->aLTerm[0]));
150662 if( pFrom->wsFlags & WHERE_VIRTUALTABLE ){
@@ -150694,10 +151209,21 @@
150694 whereLoopDelete(db, p);
150695 }
150696 assert( pWInfo->pExprMods==0 );
150697 sqlite3DbFreeNN(db, pWInfo);
150698 }
 
 
 
 
 
 
 
 
 
 
 
150699
150700 /*
150701 ** Return TRUE if all of the following are true:
150702 **
150703 ** (1) X has the same or lower cost that Y
@@ -151200,10 +151726,12 @@
151200 opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
151201 }
151202 if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
151203
151204 assert( pNew->u.btree.nEq<pProbe->nColumn );
 
 
151205
151206 saved_nEq = pNew->u.btree.nEq;
151207 saved_nBtm = pNew->u.btree.nBtm;
151208 saved_nTop = pNew->u.btree.nTop;
151209 saved_nSkip = pNew->nSkip;
@@ -151282,11 +151810,11 @@
151282 }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
151283 /* "x IN (value, value, ...)" */
151284 nIn = sqlite3LogEst(pExpr->x.pList->nExpr);
151285 }
151286 if( pProbe->hasStat1 && rLogSize>=10 ){
151287 LogEst M, logK, safetyMargin;
151288 /* Let:
151289 ** N = the total number of rows in the table
151290 ** K = the number of entries on the RHS of the IN operator
151291 ** M = the number of rows in the table that match terms to the
151292 ** to the left in the same index. If the IN operator is on
@@ -151305,20 +151833,29 @@
151305 ** the index. Do not bother with this optimization on very small
151306 ** tables (less than 2 rows) as it is pointless in that case.
151307 */
151308 M = pProbe->aiRowLogEst[saved_nEq];
151309 logK = estLog(nIn);
151310 safetyMargin = 10; /* TUNING: extra weight for indexed IN */
151311 if( M + logK + safetyMargin < nIn + rLogSize ){
 
 
 
 
 
 
151312 WHERETRACE(0x40,
151313 ("Scan preferred over IN operator on column %d of \"%s\" (%d<%d)\n",
151314 saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
 
151315 pNew->wsFlags |= WHERE_IN_SEEKSCAN;
151316 }else{
151317 WHERETRACE(0x40,
151318 ("IN operator preferred on column %d of \"%s\" (%d>=%d)\n",
151319 saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
 
 
151320 }
151321 }
151322 pNew->wsFlags |= WHERE_COLUMN_IN;
151323 }else if( eOp & (WO_EQ|WO_IS) ){
151324 int iCol = pProbe->aiColumn[saved_nEq];
@@ -151333,10 +151870,11 @@
151333 pNew->wsFlags |= WHERE_ONEROW;
151334 }else{
151335 pNew->wsFlags |= WHERE_UNQ_WANTED;
151336 }
151337 }
 
151338 }else if( eOp & WO_ISNULL ){
151339 pNew->wsFlags |= WHERE_COLUMN_NULL;
151340 }else if( eOp & (WO_GT|WO_GE) ){
151341 testcase( eOp & WO_GT );
151342 testcase( eOp & WO_GE );
@@ -151476,10 +152014,12 @@
151476 pNew->nOut = nOutUnadjusted;
151477 }
151478
151479 if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
151480 && pNew->u.btree.nEq<pProbe->nColumn
 
 
151481 ){
151482 whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
151483 }
151484 pNew->nOut = saved_nOut;
151485 #ifdef SQLITE_ENABLE_STAT4
@@ -151597,10 +152137,11 @@
151597 Expr *pExpr;
151598 pExpr = pTerm->pExpr;
151599 if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
151600 && (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin))
151601 && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
 
151602 ){
151603 return 1;
151604 }
151605 }
151606 return 0;
@@ -152307,11 +152848,13 @@
152307 rc = whereLoopAddBtree(&sSubBuild, mPrereq);
152308 }
152309 if( rc==SQLITE_OK ){
152310 rc = whereLoopAddOr(&sSubBuild, mPrereq, mUnusable);
152311 }
152312 assert( rc==SQLITE_OK || rc==SQLITE_DONE || sCur.n==0 );
 
 
152313 testcase( rc==SQLITE_DONE );
152314 if( sCur.n==0 ){
152315 sSum.n = 0;
152316 break;
152317 }else if( once ){
@@ -152576,10 +153119,14 @@
152576 nKeyCol = pIndex->nKeyCol;
152577 nColumn = pIndex->nColumn;
152578 assert( nColumn==nKeyCol+1 || !HasRowid(pIndex->pTable) );
152579 assert( pIndex->aiColumn[nColumn-1]==XN_ROWID
152580 || !HasRowid(pIndex->pTable));
 
 
 
 
152581 isOrderDistinct = IsUniqueIndex(pIndex)
152582 && (pLoop->wsFlags & WHERE_SKIPSCAN)==0;
152583 }
152584
152585 /* Loop through all columns of the index and deal with the ones
@@ -152643,18 +153190,22 @@
152643 iColumn = XN_ROWID;
152644 revIdx = 0;
152645 }
152646
152647 /* An unconstrained column that might be NULL means that this
152648 ** WhereLoop is not well-ordered
152649 */
152650 if( isOrderDistinct
152651 && iColumn>=0
152652 && j>=pLoop->u.btree.nEq
152653 && pIndex->pTable->aCol[iColumn].notNull==0
152654 ){
152655 isOrderDistinct = 0;
 
 
 
 
152656 }
152657
152658 /* Find the ORDER BY term that corresponds to the j-th column
152659 ** of the index and mark that ORDER BY term off
152660 */
@@ -152834,11 +153385,11 @@
152834 if( (pWInfo->wctrlFlags & WHERE_USE_LIMIT)!=0 && pWInfo->iLimit<nRow ){
152835 nRow = pWInfo->iLimit;
152836 }else if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT) ){
152837 /* TUNING: In the sort for a DISTINCT operator, assume that the DISTINCT
152838 ** reduces the number of output rows by a factor of 2 */
152839 if( nRow>10 ) nRow -= 10; assert( 10==sqlite3LogEst(2) );
152840 }
152841 rSortCost += estLog(nRow);
152842 return rSortCost;
152843 }
152844
@@ -154026,10 +154577,12 @@
154026 return pWInfo;
154027
154028 /* Jump here if malloc fails */
154029 whereBeginError:
154030 if( pWInfo ){
 
 
154031 pParse->nQueryLoop = pWInfo->savedNQueryLoop;
154032 whereInfoFree(db, pWInfo);
154033 }
154034 return 0;
154035 }
@@ -154122,10 +154675,12 @@
154122 if( pLoop->wsFlags & WHERE_IN_ABLE && pLevel->u.in.nIn>0 ){
154123 struct InLoop *pIn;
154124 int j;
154125 sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
154126 for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
 
 
154127 sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
154128 if( pIn->eEndLoopOp!=OP_Noop ){
154129 if( pIn->nPrefix ){
154130 int bEarlyOut =
154131 (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0
@@ -154146,10 +154701,15 @@
154146 if( bEarlyOut ){
154147 sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur,
154148 sqlite3VdbeCurrentAddr(v)+2,
154149 pIn->iBase, pIn->nPrefix);
154150 VdbeCoverage(v);
 
 
 
 
 
154151 }
154152 }
154153 sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
154154 VdbeCoverage(v);
154155 VdbeCoverageIf(v, pIn->eEndLoopOp==OP_Prev);
@@ -154325,20 +154885,13 @@
154325 if( db->flags & SQLITE_VdbeAddopTrace ) printf("TRANSLATE complete\n");
154326 #endif
154327 }
154328 }
154329
154330 /* Undo all Expr node modifications */
154331 while( pWInfo->pExprMods ){
154332 WhereExprMod *p = pWInfo->pExprMods;
154333 pWInfo->pExprMods = p->pNext;
154334 memcpy(p->pExpr, &p->orig, sizeof(p->orig));
154335 sqlite3DbFree(db, p);
154336 }
154337
154338 /* Final cleanup
154339 */
 
154340 pParse->nQueryLoop = pWInfo->savedNQueryLoop;
154341 whereInfoFree(db, pWInfo);
154342 return;
154343 }
154344
@@ -155284,10 +155837,18 @@
155284 ){
155285 pExpr->op2++;
155286 }
155287 return WRC_Continue;
155288 }
 
 
 
 
 
 
 
 
155289
155290 /*
155291 ** If the SELECT statement passed as the second argument does not invoke
155292 ** any SQL window functions, this function is a no-op. Otherwise, it
155293 ** rewrites the SELECT statement so that window function xStep functions
@@ -155294,11 +155855,11 @@
155294 ** are invoked in the correct order as described under "SELECT REWRITING"
155295 ** at the top of this file.
155296 */
155297 SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
155298 int rc = SQLITE_OK;
155299 if( p->pWin && p->pPrior==0 && (p->selFlags & SF_WinRewrite)==0 ){
155300 Vdbe *v = sqlite3GetVdbe(pParse);
155301 sqlite3 *db = pParse->db;
155302 Select *pSub = 0; /* The subquery */
155303 SrcList *pSrc = p->pSrc;
155304 Expr *pWhere = p->pWhere;
@@ -155318,10 +155879,15 @@
155318 if( pTab==0 ){
155319 return sqlite3ErrorToParser(db, SQLITE_NOMEM);
155320 }
155321 sqlite3AggInfoPersistWalkerInit(&w, pParse);
155322 sqlite3WalkSelect(&w, p);
 
 
 
 
 
155323
155324 p->pSrc = 0;
155325 p->pWhere = 0;
155326 p->pGroupBy = 0;
155327 p->pHaving = 0;
@@ -155914,10 +156480,11 @@
155914 Vdbe *pVdbe; /* VDBE object */
155915 int addrGosub; /* OP_Gosub to this address to return one row */
155916 int regGosub; /* Register used with OP_Gosub(addrGosub) */
155917 int regArg; /* First in array of accumulator registers */
155918 int eDelete; /* See above */
 
155919
155920 WindowCsrAndReg start;
155921 WindowCsrAndReg current;
155922 WindowCsrAndReg end;
155923 };
@@ -156590,20 +157157,28 @@
156590 addrContinue = sqlite3VdbeCurrentAddr(v);
156591
156592 /* If this is a (RANGE BETWEEN a FOLLOWING AND b FOLLOWING) or
156593 ** (RANGE BETWEEN b PRECEDING AND a PRECEDING) frame, ensure the
156594 ** start cursor does not advance past the end cursor within the
156595 ** temporary table. It otherwise might, if (a>b). */
 
 
156596 if( pMWin->eStart==pMWin->eEnd && regCountdown
156597 && pMWin->eFrmType==TK_RANGE && op==WINDOW_AGGINVERSE
156598 ){
156599 int regRowid1 = sqlite3GetTempReg(pParse);
156600 int regRowid2 = sqlite3GetTempReg(pParse);
156601 sqlite3VdbeAddOp2(v, OP_Rowid, p->start.csr, regRowid1);
156602 sqlite3VdbeAddOp2(v, OP_Rowid, p->end.csr, regRowid2);
156603 sqlite3VdbeAddOp3(v, OP_Ge, regRowid2, lblDone, regRowid1);
156604 VdbeCoverage(v);
 
 
 
 
 
 
156605 sqlite3ReleaseTempReg(pParse, regRowid1);
156606 sqlite3ReleaseTempReg(pParse, regRowid2);
156607 assert( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_FOLLOWING );
156608 }
156609
@@ -157096,11 +157671,10 @@
157096 int addrGosubFlush = 0; /* Address of OP_Gosub to flush: */
157097 int addrInteger = 0; /* Address of OP_Integer */
157098 int addrEmpty; /* Address of OP_Rewind in flush: */
157099 int regNew; /* Array of registers holding new input row */
157100 int regRecord; /* regNew array in record form */
157101 int regRowid; /* Rowid for regRecord in eph table */
157102 int regNewPeer = 0; /* Peer values for new row (part of regNew) */
157103 int regPeer = 0; /* Peer values for current row */
157104 int regFlushPart = 0; /* Register for "Gosub flush_partition" */
157105 WindowCodeArg s; /* Context object for sub-routines */
157106 int lblWhereEnd; /* Label just before sqlite3WhereEnd() code */
@@ -157168,11 +157742,11 @@
157168 ** samve values in record form, and the rowid used to insert said record
157169 ** into the ephemeral table. */
157170 regNew = pParse->nMem+1;
157171 pParse->nMem += nInput;
157172 regRecord = ++pParse->nMem;
157173 regRowid = ++pParse->nMem;
157174
157175 /* If the window frame contains an "<expr> PRECEDING" or "<expr> FOLLOWING"
157176 ** clause, allocate registers to store the results of evaluating each
157177 ** <expr>. */
157178 if( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_FOLLOWING ){
@@ -157224,13 +157798,13 @@
157224 VdbeComment((v, "call flush_partition"));
157225 sqlite3VdbeAddOp3(v, OP_Copy, regNewPart, pMWin->regPart, nPart-1);
157226 }
157227
157228 /* Insert the new row into the ephemeral table */
157229 sqlite3VdbeAddOp2(v, OP_NewRowid, csrWrite, regRowid);
157230 sqlite3VdbeAddOp3(v, OP_Insert, csrWrite, regRecord, regRowid);
157231 addrNe = sqlite3VdbeAddOp3(v, OP_Ne, pMWin->regOne, 0, regRowid);
157232 VdbeCoverageNeverNull(v);
157233
157234 /* This block is run for the first row of each partition */
157235 s.regArg = windowInitAccum(pParse, pMWin);
157236
@@ -157344,10 +157918,11 @@
157344 if( pMWin->pPartition ){
157345 addrInteger = sqlite3VdbeAddOp2(v, OP_Integer, 0, regFlushPart);
157346 sqlite3VdbeJumpHere(v, addrGosubFlush);
157347 }
157348
 
157349 addrEmpty = sqlite3VdbeAddOp1(v, OP_Rewind, csrWrite);
157350 VdbeCoverage(v);
157351 if( pMWin->eEnd==TK_PRECEDING ){
157352 int bRPS = (pMWin->eStart==TK_PRECEDING && pMWin->eFrmType==TK_RANGE);
157353 windowCodeOp(&s, WINDOW_AGGSTEP, regEnd, 0);
@@ -157817,12 +158392,13 @@
157817 #define TK_VECTOR 176
157818 #define TK_SELECT_COLUMN 177
157819 #define TK_IF_NULL_ROW 178
157820 #define TK_ASTERISK 179
157821 #define TK_SPAN 180
157822 #define TK_SPACE 181
157823 #define TK_ILLEGAL 182
 
157824 #endif
157825 /**************** End token definitions ***************************************/
157826
157827 /* The next sections is a series of control #defines.
157828 ** various aspects of the generated parser.
@@ -157878,33 +158454,33 @@
157878 #ifndef INTERFACE
157879 # define INTERFACE 1
157880 #endif
157881 /************* Begin control #defines *****************************************/
157882 #define YYCODETYPE unsigned short int
157883 #define YYNOCODE 316
157884 #define YYACTIONTYPE unsigned short int
157885 #define YYWILDCARD 101
157886 #define sqlite3ParserTOKENTYPE Token
157887 typedef union {
157888 int yyinit;
157889 sqlite3ParserTOKENTYPE yy0;
157890 Window* yy19;
157891 struct TrigEvent yy50;
157892 int yy60;
157893 struct FrameBound yy113;
157894 Upsert* yy178;
157895 With* yy195;
157896 IdList* yy288;
157897 SrcList* yy291;
157898 Select* yy307;
157899 ExprList* yy338;
157900 TriggerStep* yy483;
157901 const char* yy528;
157902 u8 yy570;
157903 Expr* yy602;
157904 Cte* yy607;
157905 struct {int value; int mask;} yy615;
157906 } YYMINORTYPE;
157907 #ifndef YYSTACKDEPTH
157908 #define YYSTACKDEPTH 100
157909 #endif
157910 #define sqlite3ParserARG_SDECL
@@ -157919,11 +158495,11 @@
157919 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
157920 #define YYFALLBACK 1
157921 #define YYNSTATE 570
157922 #define YYNRULE 398
157923 #define YYNRULE_WITH_ACTION 337
157924 #define YYNTOKEN 183
157925 #define YY_MAX_SHIFT 569
157926 #define YY_MIN_SHIFTREDUCE 825
157927 #define YY_MAX_SHIFTREDUCE 1222
157928 #define YY_ERROR_ACTION 1223
157929 #define YY_ACCEPT_ACTION 1224
@@ -157994,545 +158570,546 @@
157994 ** yy_reduce_ofst[] For each state, the offset into yy_action for
157995 ** shifting non-terminals after a reduce.
157996 ** yy_default[] Default action for each state.
157997 **
157998 *********** Begin parsing tables **********************************************/
157999 #define YY_ACTTAB_COUNT (2020)
158000 static const YYACTIONTYPE yy_action[] = {
158001 /* 0 */ 563, 1295, 563, 1274, 168, 361, 115, 112, 218, 373,
158002 /* 10 */ 563, 1295, 374, 563, 488, 563, 115, 112, 218, 406,
158003 /* 20 */ 1300, 1300, 41, 41, 41, 41, 514, 1504, 520, 1298,
158004 /* 30 */ 1298, 959, 41, 41, 1257, 71, 71, 51, 51, 960,
158005 /* 40 */ 557, 557, 557, 122, 123, 113, 1200, 1200, 1035, 1038,
158006 /* 50 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 414, 406,
158007 /* 60 */ 273, 273, 273, 273, 115, 112, 218, 115, 112, 218,
158008 /* 70 */ 197, 268, 545, 560, 515, 560, 1260, 563, 385, 248,
158009 /* 80 */ 215, 521, 399, 122, 123, 113, 1200, 1200, 1035, 1038,
158010 /* 90 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 540, 13,
158011 /* 100 */ 13, 1259, 119, 119, 119, 119, 118, 118, 117, 117,
158012 /* 110 */ 117, 116, 441, 1176, 419, 1531, 446, 137, 512, 1539,
158013 /* 120 */ 1545, 372, 1547, 6, 371, 1176, 1148, 1584, 1148, 406,
158014 /* 130 */ 1545, 534, 115, 112, 218, 1267, 99, 441, 121, 121,
158015 /* 140 */ 121, 121, 119, 119, 119, 119, 118, 118, 117, 117,
158016 /* 150 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038,
158017 /* 160 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 197, 1176,
158018 /* 170 */ 1177, 1178, 241, 304, 554, 501, 498, 497, 473, 124,
158019 /* 180 */ 394, 1176, 1177, 1178, 1176, 496, 119, 119, 119, 119,
158020 /* 190 */ 118, 118, 117, 117, 117, 116, 441, 139, 540, 406,
158021 /* 200 */ 121, 121, 121, 121, 114, 117, 117, 117, 116, 441,
158022 /* 210 */ 541, 1532, 119, 119, 119, 119, 118, 118, 117, 117,
158023 /* 220 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038,
158024 /* 230 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 406, 320,
158025 /* 240 */ 1176, 1177, 1178, 81, 342, 1590, 396, 80, 119, 119,
158026 /* 250 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 1176,
158027 /* 260 */ 211, 450, 122, 123, 113, 1200, 1200, 1035, 1038, 1028,
158028 /* 270 */ 1028, 120, 120, 121, 121, 121, 121, 251, 450, 449,
158029 /* 280 */ 273, 273, 119, 119, 119, 119, 118, 118, 117, 117,
158030 /* 290 */ 117, 116, 441, 560, 1224, 1, 1, 569, 2, 1228,
158031 /* 300 */ 317, 1176, 319, 1561, 305, 337, 140, 340, 406, 430,
158032 /* 310 */ 469, 1533, 1197, 1308, 348, 1176, 1177, 1178, 168, 462,
158033 /* 320 */ 330, 119, 119, 119, 119, 118, 118, 117, 117, 117,
158034 /* 330 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028,
158035 /* 340 */ 1028, 120, 120, 121, 121, 121, 121, 273, 273, 563,
158036 /* 350 */ 83, 450, 416, 1564, 569, 2, 1228, 1176, 1177, 1178,
158037 /* 360 */ 560, 305, 471, 140, 944, 995, 860, 563, 467, 1197,
158038 /* 370 */ 1308, 13, 13, 137, 229, 118, 118, 117, 117, 117,
158039 /* 380 */ 116, 441, 96, 318, 946, 504, 424, 361, 562, 71,
158040 /* 390 */ 71, 119, 119, 119, 119, 118, 118, 117, 117, 117,
158041 /* 400 */ 116, 441, 427, 205, 273, 273, 445, 1015, 259, 276,
158042 /* 410 */ 356, 507, 351, 506, 246, 406, 959, 560, 328, 344,
158043 /* 420 */ 347, 315, 860, 1006, 960, 126, 545, 1005, 313, 304,
158044 /* 430 */ 554, 229, 538, 1539, 148, 544, 281, 6, 203, 122,
158045 /* 440 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120,
158046 /* 450 */ 121, 121, 121, 121, 563, 217, 563, 12, 406, 1005,
158047 /* 460 */ 1005, 1007, 502, 445, 119, 119, 119, 119, 118, 118,
158048 /* 470 */ 117, 117, 117, 116, 441, 452, 71, 71, 70, 70,
158049 /* 480 */ 944, 137, 122, 123, 113, 1200, 1200, 1035, 1038, 1028,
158050 /* 490 */ 1028, 120, 120, 121, 121, 121, 121, 1530, 119, 119,
158051 /* 500 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 403,
158052 /* 510 */ 402, 241, 1176, 545, 501, 498, 497, 1468, 1143, 451,
158053 /* 520 */ 267, 267, 513, 1540, 496, 142, 1176, 6, 406, 530,
158054 /* 530 */ 194, 1143, 864, 560, 1143, 461, 182, 304, 554, 32,
158055 /* 540 */ 379, 119, 119, 119, 119, 118, 118, 117, 117, 117,
158056 /* 550 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028,
158057 /* 560 */ 1028, 120, 120, 121, 121, 121, 121, 406, 1176, 1177,
158058 /* 570 */ 1178, 857, 568, 1176, 1228, 925, 1176, 454, 361, 305,
158059 /* 580 */ 189, 140, 1176, 1177, 1178, 519, 529, 404, 1308, 183,
158060 /* 590 */ 1015, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028,
158061 /* 600 */ 120, 120, 121, 121, 121, 121, 1006, 16, 16, 370,
158062 /* 610 */ 1005, 119, 119, 119, 119, 118, 118, 117, 117, 117,
158063 /* 620 */ 116, 441, 273, 273, 1537, 150, 1176, 98, 6, 1176,
158064 /* 630 */ 1177, 1178, 1176, 1177, 1178, 560, 380, 406, 376, 438,
158065 /* 640 */ 437, 1161, 1005, 1005, 1007, 1025, 1025, 1036, 1039, 229,
158066 /* 650 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
158067 /* 660 */ 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028,
158068 /* 670 */ 120, 120, 121, 121, 121, 121, 406, 1143, 1619, 392,
158069 /* 680 */ 1016, 445, 1176, 1177, 1178, 1207, 525, 1207, 1530, 995,
158070 /* 690 */ 1143, 304, 554, 1143, 5, 563, 543, 3, 361, 216,
158071 /* 700 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120,
158072 /* 710 */ 120, 121, 121, 121, 121, 143, 563, 13, 13, 1029,
158073 /* 720 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
158074 /* 730 */ 441, 1176, 426, 563, 1176, 563, 274, 274, 13, 13,
158075 /* 740 */ 1078, 1176, 328, 457, 316, 147, 406, 211, 361, 560,
158076 /* 750 */ 1000, 213, 511, 293, 477, 55, 55, 71, 71, 119,
158077 /* 760 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441,
158078 /* 770 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120,
158079 /* 780 */ 120, 121, 121, 121, 121, 406, 455, 1176, 1177, 1178,
158080 /* 790 */ 1176, 1177, 1178, 471, 526, 149, 404, 1176, 1177, 1178,
158081 /* 800 */ 105, 270, 103, 563, 944, 563, 116, 441, 1530, 122,
158082 /* 810 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120,
158083 /* 820 */ 121, 121, 121, 121, 945, 13, 13, 13, 13, 119,
158084 /* 830 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441,
158085 /* 840 */ 191, 563, 192, 563, 416, 439, 439, 439, 1083, 1083,
158086 /* 850 */ 485, 561, 285, 914, 914, 406, 462, 330, 1530, 830,
158087 /* 860 */ 831, 832, 206, 71, 71, 71, 71, 286, 119, 119,
158088 /* 870 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 122,
158089 /* 880 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120,
158090 /* 890 */ 121, 121, 121, 121, 563, 217, 563, 1122, 1617, 406,
158091 /* 900 */ 300, 1617, 301, 416, 1278, 1473, 244, 243, 242, 1249,
158092 /* 910 */ 412, 556, 412, 282, 842, 279, 71, 71, 71, 71,
158093 /* 920 */ 944, 1415, 1473, 1475, 101, 113, 1200, 1200, 1035, 1038,
158094 /* 930 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 119, 119,
158095 /* 940 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 273,
158096 /* 950 */ 273, 1099, 563, 436, 1143, 440, 563, 1122, 1618, 357,
158097 /* 960 */ 1558, 1618, 560, 546, 488, 197, 1100, 1143, 378, 290,
158098 /* 970 */ 1143, 1306, 284, 460, 71, 71, 1120, 405, 13, 13,
158099 /* 980 */ 145, 1101, 119, 119, 119, 119, 118, 118, 117, 117,
158100 /* 990 */ 117, 116, 441, 542, 104, 1473, 509, 273, 273, 294,
158101 /* 1000 */ 1514, 294, 900, 273, 273, 273, 273, 563, 1503, 563,
158102 /* 1010 */ 560, 545, 901, 464, 406, 1058, 560, 852, 560, 198,
158103 /* 1020 */ 547, 1080, 920, 404, 1400, 1080, 146, 919, 38, 56,
158104 /* 1030 */ 56, 15, 15, 563, 406, 12, 1120, 471, 122, 123,
158105 /* 1040 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121,
158106 /* 1050 */ 121, 121, 121, 1460, 406, 43, 43, 483, 122, 123,
158107 /* 1060 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121,
158108 /* 1070 */ 121, 121, 121, 563, 852, 9, 471, 251, 122, 111,
158109 /* 1080 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121,
158110 /* 1090 */ 121, 121, 121, 563, 421, 57, 57, 119, 119, 119,
158111 /* 1100 */ 119, 118, 118, 117, 117, 117, 116, 441, 1176, 493,
158112 /* 1110 */ 563, 289, 1197, 478, 1516, 44, 44, 119, 119, 119,
158113 /* 1120 */ 119, 118, 118, 117, 117, 117, 116, 441, 880, 563,
158114 /* 1130 */ 536, 563, 58, 58, 488, 1414, 245, 119, 119, 119,
158115 /* 1140 */ 119, 118, 118, 117, 117, 117, 116, 441, 563, 535,
158116 /* 1150 */ 291, 59, 59, 60, 60, 438, 437, 406, 1154, 505,
158117 /* 1160 */ 304, 554, 477, 1204, 1176, 1177, 1178, 881, 1206, 1197,
158118 /* 1170 */ 61, 61, 1246, 357, 1558, 1538, 1205, 563, 1467, 6,
158119 /* 1180 */ 1176, 488, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028,
158120 /* 1190 */ 120, 120, 121, 121, 121, 121, 1400, 1143, 410, 62,
158121 /* 1200 */ 62, 1207, 1099, 1207, 411, 447, 273, 273, 537, 1154,
158122 /* 1210 */ 1143, 108, 555, 1143, 4, 391, 1220, 1100, 1512, 560,
158123 /* 1220 */ 347, 516, 428, 548, 308, 1307, 1536, 1077, 558, 1077,
158124 /* 1230 */ 6, 488, 1101, 1400, 488, 309, 1176, 1177, 1178, 563,
158125 /* 1240 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
158126 /* 1250 */ 441, 442, 278, 551, 563, 273, 273, 273, 273, 563,
158127 /* 1260 */ 327, 45, 45, 552, 563, 528, 422, 563, 560, 1400,
158128 /* 1270 */ 560, 108, 555, 137, 4, 1303, 46, 46, 335, 563,
158129 /* 1280 */ 482, 47, 47, 477, 479, 307, 49, 49, 558, 50,
158130 /* 1290 */ 50, 563, 1015, 563, 1221, 563, 1400, 563, 106, 106,
158131 /* 1300 */ 8, 63, 63, 423, 563, 107, 312, 442, 565, 564,
158132 /* 1310 */ 563, 442, 1005, 64, 64, 65, 65, 14, 14, 66,
158133 /* 1320 */ 66, 391, 1121, 552, 1312, 1180, 128, 128, 563, 304,
158134 /* 1330 */ 554, 563, 67, 67, 563, 359, 560, 532, 563, 484,
158135 /* 1340 */ 563, 1196, 531, 222, 1005, 1005, 1007, 1008, 27, 522,
158136 /* 1350 */ 52, 52, 1015, 68, 68, 563, 69, 69, 106, 106,
158137 /* 1360 */ 53, 53, 156, 156, 563, 107, 434, 442, 565, 564,
158138 /* 1370 */ 272, 215, 1005, 425, 563, 359, 563, 157, 157, 563,
158139 /* 1380 */ 1535, 292, 1180, 98, 6, 1344, 76, 76, 1215, 475,
158140 /* 1390 */ 413, 169, 226, 563, 245, 563, 54, 54, 72, 72,
158141 /* 1400 */ 1221, 129, 129, 1343, 1005, 1005, 1007, 1008, 27, 1563,
158142 /* 1410 */ 1165, 444, 456, 433, 277, 73, 73, 130, 130, 389,
158143 /* 1420 */ 389, 388, 262, 386, 1165, 444, 839, 1519, 277, 108,
158144 /* 1430 */ 555, 321, 4, 389, 389, 388, 262, 386, 563, 223,
158145 /* 1440 */ 839, 311, 468, 84, 202, 523, 558, 1492, 303, 310,
158146 /* 1450 */ 563, 110, 404, 223, 563, 311, 206, 30, 404, 277,
158147 /* 1460 */ 131, 131, 411, 310, 389, 389, 388, 262, 386, 442,
158148 /* 1470 */ 920, 839, 127, 127, 563, 919, 155, 155, 1491, 225,
158149 /* 1480 */ 563, 552, 871, 563, 223, 476, 311, 161, 31, 563,
158150 /* 1490 */ 135, 563, 480, 225, 310, 532, 154, 154, 332, 17,
158151 /* 1500 */ 533, 161, 136, 136, 135, 134, 134, 224, 228, 355,
158152 /* 1510 */ 1015, 132, 132, 133, 133, 1589, 106, 106, 889, 354,
158153 /* 1520 */ 563, 224, 563, 107, 225, 442, 565, 564, 1117, 275,
158154 /* 1530 */ 1005, 393, 161, 518, 563, 135, 108, 555, 417, 4,
158155 /* 1540 */ 1340, 407, 75, 75, 77, 77, 304, 554, 867, 563,
158156 /* 1550 */ 336, 563, 224, 558, 463, 407, 74, 74, 465, 1065,
158157 /* 1560 */ 304, 554, 1005, 1005, 1007, 1008, 27, 962, 963, 543,
158158 /* 1570 */ 448, 42, 42, 48, 48, 326, 442, 325, 98, 997,
158159 /* 1580 */ 470, 287, 250, 250, 448, 1009, 407, 472, 552, 339,
158160 /* 1590 */ 250, 304, 554, 879, 878, 331, 108, 555, 98, 4,
158161 /* 1600 */ 1277, 494, 532, 345, 247, 867, 98, 531, 341, 886,
158162 /* 1610 */ 887, 1126, 1076, 558, 1076, 448, 1065, 1015, 1061, 953,
158163 /* 1620 */ 343, 247, 250, 106, 106, 1291, 917, 1276, 850, 110,
158164 /* 1630 */ 107, 144, 442, 565, 564, 918, 442, 1005, 110, 1275,
158165 /* 1640 */ 350, 360, 1009, 1331, 1352, 299, 1399, 1577, 552, 1327,
158166 /* 1650 */ 1552, 550, 1338, 549, 1405, 1256, 1248, 1237, 1236, 1238,
158167 /* 1660 */ 1571, 489, 265, 200, 1324, 363, 365, 367, 11, 1005,
158168 /* 1670 */ 1005, 1007, 1008, 27, 390, 221, 1386, 1015, 280, 1391,
158169 /* 1680 */ 1381, 208, 323, 106, 106, 924, 1374, 453, 283, 324,
158170 /* 1690 */ 107, 474, 442, 565, 564, 1390, 499, 1005, 212, 288,
158171 /* 1700 */ 1274, 397, 353, 108, 555, 195, 4, 1464, 369, 1463,
158172 /* 1710 */ 1574, 1215, 1212, 329, 553, 171, 207, 383, 1511, 196,
158173 /* 1720 */ 558, 254, 1509, 415, 100, 555, 83, 4, 204, 1005,
158174 /* 1730 */ 1005, 1007, 1008, 27, 219, 79, 82, 1469, 180, 166,
158175 /* 1740 */ 173, 558, 458, 442, 175, 176, 177, 178, 35, 1387,
158176 /* 1750 */ 492, 459, 231, 1395, 96, 552, 1393, 1392, 395, 184,
158177 /* 1760 */ 481, 466, 36, 235, 442, 89, 398, 266, 487, 1480,
158178 /* 1770 */ 1458, 237, 188, 338, 508, 429, 552, 490, 400, 238,
158179 /* 1780 */ 334, 1239, 239, 1294, 1015, 1293, 1292, 1285, 91, 871,
158180 /* 1790 */ 106, 106, 213, 431, 1588, 432, 524, 107, 517, 442,
158181 /* 1800 */ 565, 564, 401, 1264, 1005, 1015, 1263, 1587, 352, 1262,
158182 /* 1810 */ 1557, 106, 106, 1586, 1284, 297, 298, 358, 107, 1335,
158183 /* 1820 */ 442, 565, 564, 95, 362, 1005, 253, 252, 435, 125,
158184 /* 1830 */ 543, 10, 1444, 1543, 377, 1542, 1005, 1005, 1007, 1008,
158185 /* 1840 */ 27, 302, 102, 97, 527, 1336, 260, 1317, 364, 1245,
158186 /* 1850 */ 1334, 34, 566, 1171, 366, 381, 375, 1005, 1005, 1007,
158187 /* 1860 */ 1008, 27, 1333, 1359, 368, 1316, 199, 382, 261, 263,
158188 /* 1870 */ 264, 1358, 158, 1496, 141, 1497, 1495, 567, 1234, 1229,
158189 /* 1880 */ 1494, 295, 159, 209, 210, 78, 826, 443, 201, 306,
158190 /* 1890 */ 220, 1075, 138, 1073, 160, 314, 162, 172, 1196, 174,
158191 /* 1900 */ 903, 227, 230, 322, 1089, 179, 163, 164, 418, 85,
158192 /* 1910 */ 420, 181, 170, 408, 409, 86, 87, 165, 88, 1092,
158193 /* 1920 */ 232, 233, 1088, 151, 18, 234, 1081, 250, 333, 185,
158194 /* 1930 */ 1209, 486, 236, 186, 37, 841, 491, 354, 240, 346,
158195 /* 1940 */ 503, 187, 90, 167, 19, 495, 20, 869, 500, 349,
158196 /* 1950 */ 92, 882, 296, 152, 93, 510, 1127, 1159, 153, 1041,
158197 /* 1960 */ 214, 1128, 39, 94, 269, 271, 952, 190, 947, 110,
158198 /* 1970 */ 1149, 1145, 1153, 249, 1133, 1147, 7, 33, 21, 193,
158199 /* 1980 */ 22, 23, 24, 25, 1152, 539, 98, 1056, 26, 1042,
158200 /* 1990 */ 1040, 1044, 1098, 1045, 1097, 256, 255, 28, 40, 387,
158201 /* 2000 */ 1010, 851, 109, 29, 1167, 559, 384, 257, 913, 258,
158202 /* 2010 */ 1166, 1579, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1578,
 
158203 };
158204 static const YYCODETYPE yy_lookahead[] = {
158205 /* 0 */ 191, 220, 191, 222, 191, 191, 271, 272, 273, 216,
158206 /* 10 */ 191, 230, 216, 191, 191, 191, 271, 272, 273, 19,
158207 /* 20 */ 232, 233, 213, 214, 213, 214, 202, 292, 202, 232,
158208 /* 30 */ 233, 31, 213, 214, 213, 213, 214, 213, 214, 39,
158209 /* 40 */ 207, 208, 209, 43, 44, 45, 46, 47, 48, 49,
158210 /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 235, 19,
158211 /* 60 */ 236, 237, 236, 237, 271, 272, 273, 271, 272, 273,
158212 /* 70 */ 191, 210, 250, 249, 250, 249, 213, 191, 199, 253,
158213 /* 80 */ 254, 259, 203, 43, 44, 45, 46, 47, 48, 49,
158214 /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 191, 213,
158215 /* 100 */ 214, 213, 102, 103, 104, 105, 106, 107, 108, 109,
158216 /* 110 */ 110, 111, 112, 59, 228, 301, 293, 81, 305, 306,
158217 /* 120 */ 311, 312, 311, 310, 313, 59, 86, 212, 88, 19,
158218 /* 130 */ 311, 312, 271, 272, 273, 220, 26, 112, 54, 55,
158219 /* 140 */ 56, 57, 102, 103, 104, 105, 106, 107, 108, 109,
158220 /* 150 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49,
158221 /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 191, 115,
158222 /* 170 */ 116, 117, 118, 137, 138, 121, 122, 123, 191, 69,
158223 /* 180 */ 203, 115, 116, 117, 59, 131, 102, 103, 104, 105,
158224 /* 190 */ 106, 107, 108, 109, 110, 111, 112, 72, 191, 19,
158225 /* 200 */ 54, 55, 56, 57, 58, 108, 109, 110, 111, 112,
158226 /* 210 */ 303, 304, 102, 103, 104, 105, 106, 107, 108, 109,
158227 /* 220 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49,
158228 /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 16,
158229 /* 240 */ 115, 116, 117, 24, 16, 227, 202, 67, 102, 103,
158230 /* 250 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 59,
158231 /* 260 */ 26, 191, 43, 44, 45, 46, 47, 48, 49, 50,
158232 /* 270 */ 51, 52, 53, 54, 55, 56, 57, 24, 208, 209,
158233 /* 280 */ 236, 237, 102, 103, 104, 105, 106, 107, 108, 109,
158234 /* 290 */ 110, 111, 112, 249, 183, 184, 185, 186, 187, 188,
158235 /* 300 */ 77, 59, 79, 191, 193, 77, 195, 79, 19, 19,
158236 /* 310 */ 266, 304, 59, 202, 24, 115, 116, 117, 191, 127,
158237 /* 320 */ 128, 102, 103, 104, 105, 106, 107, 108, 109, 110,
158238 /* 330 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50,
158239 /* 340 */ 51, 52, 53, 54, 55, 56, 57, 236, 237, 191,
158240 /* 350 */ 150, 281, 191, 185, 186, 187, 188, 115, 116, 117,
158241 /* 360 */ 249, 193, 191, 195, 26, 73, 59, 191, 114, 116,
158242 /* 370 */ 202, 213, 214, 81, 263, 106, 107, 108, 109, 110,
158243 /* 380 */ 111, 112, 148, 160, 142, 95, 228, 191, 191, 213,
158244 /* 390 */ 214, 102, 103, 104, 105, 106, 107, 108, 109, 110,
158245 /* 400 */ 111, 112, 112, 149, 236, 237, 295, 100, 118, 119,
158246 /* 410 */ 120, 121, 122, 123, 124, 19, 31, 249, 126, 23,
158247 /* 420 */ 130, 260, 115, 116, 39, 22, 250, 120, 191, 137,
158248 /* 430 */ 138, 263, 305, 306, 238, 259, 265, 310, 149, 43,
158249 /* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
158250 /* 450 */ 54, 55, 56, 57, 191, 117, 191, 210, 19, 152,
158251 /* 460 */ 153, 154, 23, 295, 102, 103, 104, 105, 106, 107,
158252 /* 470 */ 108, 109, 110, 111, 112, 266, 213, 214, 213, 214,
158253 /* 480 */ 142, 81, 43, 44, 45, 46, 47, 48, 49, 50,
158254 /* 490 */ 51, 52, 53, 54, 55, 56, 57, 301, 102, 103,
158255 /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 106,
158256 /* 510 */ 107, 118, 59, 250, 121, 122, 123, 280, 76, 119,
158257 /* 520 */ 236, 237, 259, 306, 131, 72, 59, 310, 19, 87,
158258 /* 530 */ 283, 89, 23, 249, 92, 288, 22, 137, 138, 22,
158259 /* 540 */ 275, 102, 103, 104, 105, 106, 107, 108, 109, 110,
158260 /* 550 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50,
158261 /* 560 */ 51, 52, 53, 54, 55, 56, 57, 19, 115, 116,
158262 /* 570 */ 117, 23, 186, 59, 188, 108, 59, 241, 191, 193,
158263 /* 580 */ 26, 195, 115, 116, 117, 191, 144, 251, 202, 22,
158264 /* 590 */ 100, 43, 44, 45, 46, 47, 48, 49, 50, 51,
158265 /* 600 */ 52, 53, 54, 55, 56, 57, 116, 213, 214, 191,
158266 /* 610 */ 120, 102, 103, 104, 105, 106, 107, 108, 109, 110,
158267 /* 620 */ 111, 112, 236, 237, 306, 238, 59, 26, 310, 115,
158268 /* 630 */ 116, 117, 115, 116, 117, 249, 246, 19, 248, 106,
158269 /* 640 */ 107, 23, 152, 153, 154, 46, 47, 48, 49, 263,
158270 /* 650 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
158271 /* 660 */ 112, 43, 44, 45, 46, 47, 48, 49, 50, 51,
158272 /* 670 */ 52, 53, 54, 55, 56, 57, 19, 76, 298, 299,
158273 /* 680 */ 23, 295, 115, 116, 117, 152, 191, 154, 301, 73,
158274 /* 690 */ 89, 137, 138, 92, 22, 191, 144, 22, 191, 191,
158275 /* 700 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
158276 /* 710 */ 53, 54, 55, 56, 57, 163, 191, 213, 214, 120,
158277 /* 720 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
158278 /* 730 */ 112, 59, 228, 191, 59, 191, 236, 237, 213, 214,
158279 /* 740 */ 11, 59, 126, 127, 128, 238, 19, 26, 191, 249,
158280 /* 750 */ 23, 164, 165, 228, 191, 213, 214, 213, 214, 102,
158281 /* 760 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
158282 /* 770 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
158283 /* 780 */ 53, 54, 55, 56, 57, 19, 241, 115, 116, 117,
158284 /* 790 */ 115, 116, 117, 191, 250, 238, 251, 115, 116, 117,
158285 /* 800 */ 157, 23, 159, 191, 26, 191, 111, 112, 301, 43,
158286 /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
158287 /* 820 */ 54, 55, 56, 57, 142, 213, 214, 213, 214, 102,
158288 /* 830 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
158289 /* 840 */ 228, 191, 228, 191, 191, 207, 208, 209, 126, 127,
158290 /* 850 */ 128, 133, 289, 135, 136, 19, 127, 128, 301, 7,
158291 /* 860 */ 8, 9, 141, 213, 214, 213, 214, 265, 102, 103,
158292 /* 870 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 43,
158293 /* 880 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
158294 /* 890 */ 54, 55, 56, 57, 191, 117, 191, 22, 23, 19,
158295 /* 900 */ 250, 26, 250, 191, 223, 191, 126, 127, 128, 205,
158296 /* 910 */ 206, 205, 206, 260, 21, 202, 213, 214, 213, 214,
158297 /* 920 */ 142, 270, 208, 209, 158, 45, 46, 47, 48, 49,
158298 /* 930 */ 50, 51, 52, 53, 54, 55, 56, 57, 102, 103,
158299 /* 940 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 236,
158300 /* 950 */ 237, 12, 191, 250, 76, 250, 191, 22, 23, 308,
158301 /* 960 */ 309, 26, 249, 202, 191, 191, 27, 89, 191, 202,
158302 /* 970 */ 92, 202, 260, 80, 213, 214, 101, 203, 213, 214,
158303 /* 980 */ 22, 42, 102, 103, 104, 105, 106, 107, 108, 109,
158304 /* 990 */ 110, 111, 112, 228, 158, 281, 108, 236, 237, 225,
158305 /* 1000 */ 191, 227, 63, 236, 237, 236, 237, 191, 235, 191,
158306 /* 1010 */ 249, 250, 73, 241, 19, 122, 249, 59, 249, 24,
158307 /* 1020 */ 259, 29, 134, 251, 191, 33, 22, 139, 24, 213,
158308 /* 1030 */ 214, 213, 214, 191, 19, 210, 101, 191, 43, 44,
158309 /* 1040 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
158310 /* 1050 */ 55, 56, 57, 160, 19, 213, 214, 65, 43, 44,
158311 /* 1060 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
158312 /* 1070 */ 55, 56, 57, 191, 116, 22, 191, 24, 43, 44,
158313 /* 1080 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
158314 /* 1090 */ 55, 56, 57, 191, 261, 213, 214, 102, 103, 104,
158315 /* 1100 */ 105, 106, 107, 108, 109, 110, 111, 112, 59, 19,
158316 /* 1110 */ 191, 265, 59, 288, 191, 213, 214, 102, 103, 104,
158317 /* 1120 */ 105, 106, 107, 108, 109, 110, 111, 112, 35, 191,
158318 /* 1130 */ 66, 191, 213, 214, 191, 270, 46, 102, 103, 104,
158319 /* 1140 */ 105, 106, 107, 108, 109, 110, 111, 112, 191, 85,
158320 /* 1150 */ 265, 213, 214, 213, 214, 106, 107, 19, 94, 66,
158321 /* 1160 */ 137, 138, 191, 114, 115, 116, 117, 74, 119, 116,
158322 /* 1170 */ 213, 214, 202, 308, 309, 306, 127, 191, 235, 310,
158323 /* 1180 */ 59, 191, 44, 45, 46, 47, 48, 49, 50, 51,
158324 /* 1190 */ 52, 53, 54, 55, 56, 57, 191, 76, 196, 213,
158325 /* 1200 */ 214, 152, 12, 154, 114, 191, 236, 237, 87, 145,
158326 /* 1210 */ 89, 19, 20, 92, 22, 22, 23, 27, 191, 249,
158327 /* 1220 */ 130, 202, 129, 202, 191, 235, 306, 152, 36, 154,
158328 /* 1230 */ 310, 191, 42, 191, 191, 191, 115, 116, 117, 191,
158329 /* 1240 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
158330 /* 1250 */ 112, 59, 99, 63, 191, 236, 237, 236, 237, 191,
158331 /* 1260 */ 289, 213, 214, 71, 191, 144, 261, 191, 249, 191,
158332 /* 1270 */ 249, 19, 20, 81, 22, 235, 213, 214, 235, 191,
158333 /* 1280 */ 278, 213, 214, 191, 282, 132, 213, 214, 36, 213,
158334 /* 1290 */ 214, 191, 100, 191, 101, 191, 191, 191, 106, 107,
158335 /* 1300 */ 48, 213, 214, 261, 191, 113, 191, 115, 116, 117,
158336 /* 1310 */ 191, 59, 120, 213, 214, 213, 214, 213, 214, 213,
158337 /* 1320 */ 214, 22, 23, 71, 237, 59, 213, 214, 191, 137,
158338 /* 1330 */ 138, 191, 213, 214, 191, 191, 249, 85, 191, 261,
158339 /* 1340 */ 191, 26, 90, 15, 152, 153, 154, 155, 156, 19,
158340 /* 1350 */ 213, 214, 100, 213, 214, 191, 213, 214, 106, 107,
158341 /* 1360 */ 213, 214, 213, 214, 191, 113, 261, 115, 116, 117,
158342 /* 1370 */ 253, 254, 120, 229, 191, 191, 191, 213, 214, 191,
158343 /* 1380 */ 306, 289, 116, 26, 310, 191, 213, 214, 60, 19,
158344 /* 1390 */ 296, 297, 24, 191, 46, 191, 213, 214, 213, 214,
158345 /* 1400 */ 101, 213, 214, 191, 152, 153, 154, 155, 156, 0,
158346 /* 1410 */ 1, 2, 191, 229, 5, 213, 214, 213, 214, 10,
158347 /* 1420 */ 11, 12, 13, 14, 1, 2, 17, 191, 5, 19,
158348 /* 1430 */ 20, 191, 22, 10, 11, 12, 13, 14, 191, 30,
158349 /* 1440 */ 17, 32, 241, 148, 149, 115, 36, 191, 241, 40,
158350 /* 1450 */ 191, 26, 251, 30, 191, 32, 141, 22, 251, 5,
158351 /* 1460 */ 213, 214, 114, 40, 10, 11, 12, 13, 14, 59,
158352 /* 1470 */ 134, 17, 213, 214, 191, 139, 213, 214, 191, 70,
158353 /* 1480 */ 191, 71, 125, 191, 30, 115, 32, 78, 53, 191,
158354 /* 1490 */ 81, 191, 191, 70, 40, 85, 213, 214, 191, 22,
158355 /* 1500 */ 90, 78, 213, 214, 81, 213, 214, 98, 140, 120,
158356 /* 1510 */ 100, 213, 214, 213, 214, 23, 106, 107, 26, 130,
158357 /* 1520 */ 191, 98, 191, 113, 70, 115, 116, 117, 23, 22,
158358 /* 1530 */ 120, 26, 78, 19, 191, 81, 19, 20, 61, 22,
158359 /* 1540 */ 191, 132, 213, 214, 213, 214, 137, 138, 59, 191,
158360 /* 1550 */ 191, 191, 98, 36, 128, 132, 213, 214, 128, 59,
158361 /* 1560 */ 137, 138, 152, 153, 154, 155, 156, 83, 84, 144,
158362 /* 1570 */ 161, 213, 214, 213, 214, 23, 59, 151, 26, 23,
158363 /* 1580 */ 23, 151, 26, 26, 161, 59, 132, 23, 71, 191,
158364 /* 1590 */ 26, 137, 138, 119, 120, 23, 19, 20, 26, 22,
158365 /* 1600 */ 223, 23, 85, 23, 26, 116, 26, 90, 191, 7,
158366 /* 1610 */ 8, 97, 152, 36, 154, 161, 116, 100, 23, 23,
158367 /* 1620 */ 191, 26, 26, 106, 107, 191, 23, 223, 23, 26,
158368 /* 1630 */ 113, 26, 115, 116, 117, 23, 59, 120, 26, 191,
158369 /* 1640 */ 191, 191, 116, 255, 191, 252, 191, 140, 71, 191,
158370 /* 1650 */ 315, 233, 191, 191, 191, 191, 191, 191, 191, 191,
158371 /* 1660 */ 191, 285, 284, 239, 252, 252, 252, 252, 240, 152,
158372 /* 1670 */ 153, 154, 155, 156, 189, 294, 268, 100, 242, 268,
158373 /* 1680 */ 264, 211, 290, 106, 107, 108, 264, 256, 256, 243,
158374 /* 1690 */ 113, 290, 115, 116, 117, 268, 217, 120, 226, 243,
158375 /* 1700 */ 222, 268, 216, 19, 20, 246, 22, 216, 256, 216,
158376 /* 1710 */ 194, 60, 38, 242, 277, 294, 240, 242, 198, 246,
158377 /* 1720 */ 36, 140, 198, 198, 19, 20, 150, 22, 149, 152,
158378 /* 1730 */ 153, 154, 155, 156, 294, 291, 291, 280, 22, 43,
158379 /* 1740 */ 231, 36, 18, 59, 234, 234, 234, 234, 267, 269,
158380 /* 1750 */ 18, 198, 197, 231, 148, 71, 269, 269, 243, 231,
158381 /* 1760 */ 198, 243, 267, 197, 59, 157, 243, 198, 62, 287,
158382 /* 1770 */ 243, 197, 22, 198, 114, 64, 71, 218, 218, 197,
158383 /* 1780 */ 286, 198, 197, 215, 100, 215, 215, 224, 22, 125,
158384 /* 1790 */ 106, 107, 164, 24, 221, 112, 143, 113, 302, 115,
158385 /* 1800 */ 116, 117, 218, 215, 120, 100, 217, 221, 215, 215,
158386 /* 1810 */ 309, 106, 107, 215, 224, 279, 279, 218, 113, 258,
158387 /* 1820 */ 115, 116, 117, 114, 257, 120, 91, 198, 82, 147,
158388 /* 1830 */ 144, 22, 274, 314, 198, 314, 152, 153, 154, 155,
158389 /* 1840 */ 156, 276, 157, 146, 145, 258, 25, 247, 257, 201,
158390 /* 1850 */ 258, 26, 200, 13, 257, 244, 246, 152, 153, 154,
158391 /* 1860 */ 155, 156, 258, 262, 257, 247, 245, 243, 192, 192,
158392 /* 1870 */ 6, 262, 204, 210, 219, 210, 210, 190, 190, 190,
158393 /* 1880 */ 210, 219, 204, 211, 211, 210, 4, 3, 22, 162,
158394 /* 1890 */ 15, 23, 16, 23, 204, 138, 129, 150, 26, 141,
158395 /* 1900 */ 20, 24, 143, 16, 1, 141, 129, 129, 61, 53,
158396 /* 1910 */ 37, 150, 297, 300, 300, 53, 53, 129, 53, 115,
158397 /* 1920 */ 34, 140, 1, 5, 22, 114, 68, 26, 160, 68,
158398 /* 1930 */ 75, 41, 140, 114, 24, 20, 19, 130, 124, 23,
158399 /* 1940 */ 96, 22, 22, 37, 22, 67, 22, 59, 67, 24,
158400 /* 1950 */ 22, 28, 67, 23, 148, 22, 97, 23, 23, 23,
158401 /* 1960 */ 140, 23, 22, 26, 23, 23, 115, 22, 142, 26,
158402 /* 1970 */ 75, 88, 75, 34, 23, 86, 44, 22, 34, 26,
158403 /* 1980 */ 34, 34, 34, 34, 93, 24, 26, 23, 34, 23,
158404 /* 1990 */ 23, 23, 23, 11, 23, 22, 26, 22, 22, 15,
158405 /* 2000 */ 23, 23, 22, 22, 1, 26, 23, 140, 134, 140,
158406 /* 2010 */ 1, 140, 316, 316, 316, 316, 316, 316, 316, 140,
158407 /* 2020 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158408 /* 2030 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158409 /* 2040 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158410 /* 2050 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158411 /* 2060 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158412 /* 2070 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158413 /* 2080 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158414 /* 2090 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158415 /* 2100 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158416 /* 2110 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158417 /* 2120 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158418 /* 2130 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158419 /* 2140 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158420 /* 2150 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158421 /* 2160 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158422 /* 2170 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158423 /* 2180 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158424 /* 2190 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316,
158425 /* 2200 */ 316, 316, 316,
158426 };
158427 #define YY_SHIFT_COUNT (569)
158428 #define YY_SHIFT_MIN (0)
158429 #define YY_SHIFT_MAX (2009)
158430 static const unsigned short int yy_shift_ofst[] = {
158431 /* 0 */ 1423, 1409, 1454, 1192, 1192, 36, 1252, 1410, 1517, 1684,
158432 /* 10 */ 1684, 1684, 292, 0, 0, 180, 1015, 1684, 1684, 1684,
158433 /* 20 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
158434 /* 30 */ 1049, 1049, 1121, 1121, 54, 400, 36, 36, 36, 36,
158435 /* 40 */ 36, 40, 110, 219, 289, 396, 439, 509, 548, 618,
158436 /* 50 */ 657, 727, 766, 836, 995, 1015, 1015, 1015, 1015, 1015,
158437 /* 60 */ 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015,
158438 /* 70 */ 1015, 1015, 1015, 1035, 1015, 1138, 880, 880, 1577, 1684,
158439 /* 80 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
158440 /* 90 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
158441 /* 100 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
158442 /* 110 */ 1684, 1684, 1684, 1705, 1684, 1684, 1684, 1684, 1684, 1684,
158443 /* 120 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 146, 84, 84,
158444 /* 130 */ 84, 84, 84, 362, 269, 125, 97, 453, 66, 66,
158445 /* 140 */ 893, 1090, 66, 66, 533, 533, 66, 554, 554, 554,
158446 /* 150 */ 554, 192, 587, 587, 695, 25, 2020, 2020, 290, 290,
158447 /* 160 */ 290, 200, 514, 514, 514, 514, 939, 939, 442, 875,
158448 /* 170 */ 935, 66, 66, 66, 66, 66, 66, 66, 66, 66,
158449 /* 180 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
158450 /* 190 */ 66, 601, 601, 66, 729, 878, 878, 1266, 1266, 552,
158451 /* 200 */ 1023, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 307, 490,
158452 /* 210 */ 490, 567, 393, 517, 467, 672, 242, 682, 675, 66,
158453 /* 220 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 616,
158454 /* 230 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
158455 /* 240 */ 66, 66, 1093, 1093, 1093, 66, 66, 66, 778, 66,
158456 /* 250 */ 66, 66, 1053, 1064, 66, 66, 1190, 66, 66, 66,
158457 /* 260 */ 66, 66, 66, 66, 66, 722, 992, 718, 253, 253,
158458 /* 270 */ 253, 253, 338, 718, 718, 888, 403, 852, 1328, 254,
158459 /* 280 */ 1295, 721, 1330, 1295, 1330, 1370, 234, 254, 254, 234,
158460 /* 290 */ 254, 721, 1370, 1357, 1492, 1348, 385, 385, 385, 1330,
158461 /* 300 */ 1425, 1425, 643, 1315, 1336, 1004, 1651, 1651, 1581, 1581,
158462 /* 310 */ 1674, 1674, 1581, 1576, 1579, 1716, 1696, 1724, 1724, 1724,
158463 /* 320 */ 1724, 1581, 1732, 1606, 1579, 1579, 1606, 1716, 1696, 1606,
158464 /* 330 */ 1696, 1606, 1581, 1732, 1608, 1706, 1581, 1732, 1750, 1581,
158465 /* 340 */ 1732, 1581, 1732, 1750, 1660, 1660, 1660, 1711, 1766, 1766,
158466 /* 350 */ 1750, 1660, 1664, 1660, 1711, 1660, 1660, 1628, 1769, 1683,
158467 /* 360 */ 1683, 1750, 1653, 1709, 1653, 1709, 1653, 1709, 1653, 1709,
158468 /* 370 */ 1581, 1735, 1735, 1746, 1746, 1682, 1686, 1809, 1581, 1685,
158469 /* 380 */ 1682, 1697, 1699, 1606, 1821, 1825, 1840, 1840, 1864, 1864,
158470 /* 390 */ 1864, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020,
158471 /* 400 */ 2020, 2020, 2020, 2020, 2020, 2020, 599, 223, 1193, 1299,
158472 /* 410 */ 228, 780, 958, 1505, 1153, 1435, 1368, 1426, 1430, 1552,
158473 /* 420 */ 1477, 1556, 1557, 1564, 1572, 1578, 1580, 1489, 1474, 1602,
158474 /* 430 */ 1389, 1514, 1500, 1595, 1596, 1484, 1603, 1075, 1460, 1605,
158475 /* 440 */ 1612, 1526, 1507, 1882, 1884, 1866, 1727, 1875, 1876, 1868,
158476 /* 450 */ 1870, 1757, 1747, 1767, 1872, 1872, 1877, 1758, 1880, 1759,
158477 /* 460 */ 1887, 1903, 1764, 1777, 1872, 1778, 1847, 1873, 1872, 1761,
158478 /* 470 */ 1856, 1862, 1863, 1865, 1788, 1804, 1886, 1781, 1921, 1918,
158479 /* 480 */ 1902, 1811, 1768, 1858, 1901, 1861, 1855, 1890, 1792, 1819,
158480 /* 490 */ 1910, 1915, 1917, 1807, 1814, 1919, 1878, 1920, 1922, 1916,
158481 /* 500 */ 1924, 1881, 1888, 1925, 1844, 1923, 1928, 1885, 1906, 1930,
158482 /* 510 */ 1806, 1933, 1934, 1935, 1936, 1937, 1938, 1940, 1859, 1820,
158483 /* 520 */ 1941, 1942, 1851, 1939, 1945, 1826, 1943, 1944, 1946, 1947,
158484 /* 530 */ 1948, 1883, 1895, 1889, 1932, 1897, 1891, 1949, 1951, 1955,
158485 /* 540 */ 1961, 1953, 1960, 1954, 1964, 1943, 1966, 1967, 1968, 1969,
158486 /* 550 */ 1970, 1971, 1973, 1982, 1975, 1976, 1977, 1978, 1980, 1981,
158487 /* 560 */ 1979, 1874, 1867, 1869, 1871, 1879, 1983, 1984, 2003, 2009,
158488 };
158489 #define YY_REDUCE_COUNT (405)
158490 #define YY_REDUCE_MIN (-265)
158491 #define YY_REDUCE_MAX (1690)
158492 static const short yy_reduce_ofst[] = {
158493 /* 0 */ 111, 168, 386, 761, -176, -174, -191, -189, -181, -178,
158494 /* 10 */ 176, 263, 44, -207, -204, -265, -139, -114, 158, 504,
158495 /* 20 */ 525, 544, 612, 614, 650, 652, 765, 265, 703, 705,
158496 /* 30 */ 70, 714, -187, 127, 774, 713, 767, 769, 970, 1019,
158497 /* 40 */ 1021, -255, -255, -255, -255, -255, -255, -255, -255, -255,
158498 /* 50 */ -255, -255, -255, -255, -255, -255, -255, -255, -255, -255,
158499 /* 60 */ -255, -255, -255, -255, -255, -255, -255, -255, -255, -255,
158500 /* 70 */ -255, -255, -255, -255, -255, -255, -255, -255, 394, 542,
158501 /* 80 */ 816, 818, 842, 882, 902, 919, 938, 940, 957, 986,
158502 /* 90 */ 1048, 1063, 1068, 1073, 1076, 1088, 1100, 1102, 1104, 1106,
158503 /* 100 */ 1113, 1119, 1137, 1140, 1143, 1147, 1149, 1164, 1173, 1183,
158504 /* 110 */ 1185, 1188, 1202, 1204, 1247, 1259, 1263, 1283, 1289, 1292,
158505 /* 120 */ 1298, 1300, 1329, 1331, 1343, 1358, 1360, -255, -255, -255,
158506 /* 130 */ -255, -255, -255, -255, -255, 196, -255, 387, -177, 507,
158507 /* 140 */ 1002, -219, 557, -93, -167, 638, -121, 284, 500, 284,
158508 /* 150 */ 500, 247, 651, 865, -255, -255, -255, -255, -85, -85,
158509 /* 160 */ -85, 237, 171, 602, 846, 885, -212, -203, 217, 380,
158510 /* 170 */ 380, -23, 161, 653, 712, 773, 943, 990, 1040, 563,
158511 /* 180 */ 833, 971, 1005, 1042, 1092, 1078, 1043, 1144, 1184, -186,
158512 /* 190 */ 1105, 318, 869, 7, 825, 920, 1074, 704, 706, 390,
158513 /* 200 */ 1087, 1094, 336, 545, 772, 1201, 1117, 1207, -179, -137,
158514 /* 210 */ -112, -13, 18, 112, 197, 418, 495, 508, 777, 809,
158515 /* 220 */ 923, 1014, 1027, 1033, 1044, 1115, 1194, 1212, 1221, 209,
158516 /* 230 */ 1236, 1240, 1256, 1287, 1301, 1307, 1349, 1359, 1398, 1417,
158517 /* 240 */ 1429, 1434, 681, 1377, 1404, 1448, 1449, 1450, 1388, 1453,
158518 /* 250 */ 1455, 1458, 1393, 1335, 1461, 1462, 1418, 1463, 197, 1464,
158519 /* 260 */ 1465, 1466, 1467, 1468, 1469, 1376, 1378, 1424, 1412, 1413,
158520 /* 270 */ 1414, 1415, 1388, 1424, 1424, 1428, 1470, 1485, 1381, 1408,
158521 /* 280 */ 1416, 1436, 1431, 1422, 1432, 1392, 1446, 1411, 1427, 1456,
158522 /* 290 */ 1433, 1471, 1401, 1479, 1472, 1478, 1486, 1491, 1493, 1452,
158523 /* 300 */ 1459, 1473, 1437, 1475, 1476, 1516, 1421, 1440, 1520, 1524,
158524 /* 310 */ 1444, 1445, 1525, 1457, 1480, 1481, 1509, 1510, 1511, 1512,
158525 /* 320 */ 1513, 1553, 1555, 1515, 1487, 1488, 1518, 1495, 1522, 1523,
158526 /* 330 */ 1528, 1527, 1562, 1566, 1482, 1494, 1569, 1574, 1559, 1575,
158527 /* 340 */ 1582, 1583, 1585, 1560, 1568, 1570, 1571, 1563, 1573, 1586,
158528 /* 350 */ 1584, 1588, 1589, 1593, 1590, 1594, 1598, 1501, 1496, 1536,
158529 /* 360 */ 1537, 1599, 1561, 1567, 1587, 1591, 1592, 1597, 1604, 1607,
158530 /* 370 */ 1629, 1519, 1521, 1601, 1609, 1600, 1610, 1558, 1636, 1565,
158531 /* 380 */ 1618, 1621, 1611, 1624, 1648, 1652, 1676, 1677, 1687, 1688,
158532 /* 390 */ 1689, 1613, 1614, 1615, 1668, 1663, 1665, 1666, 1670, 1678,
158533 /* 400 */ 1655, 1662, 1672, 1673, 1675, 1690,
158534 };
158535 static const YYACTIONTYPE yy_default[] = {
158536 /* 0 */ 1623, 1623, 1623, 1453, 1223, 1332, 1223, 1223, 1223, 1453,
158537 /* 10 */ 1453, 1453, 1223, 1362, 1362, 1506, 1254, 1223, 1223, 1223,
158538 /* 20 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1452, 1223, 1223,
@@ -158788,10 +159365,11 @@
158788 0, /* VECTOR => nothing */
158789 0, /* SELECT_COLUMN => nothing */
158790 0, /* IF_NULL_ROW => nothing */
158791 0, /* ASTERISK => nothing */
158792 0, /* SPAN => nothing */
 
158793 0, /* SPACE => nothing */
158794 0, /* ILLEGAL => nothing */
158795 };
158796 #endif /* YYFALLBACK */
158797
@@ -159059,145 +159637,146 @@
159059 /* 176 */ "VECTOR",
159060 /* 177 */ "SELECT_COLUMN",
159061 /* 178 */ "IF_NULL_ROW",
159062 /* 179 */ "ASTERISK",
159063 /* 180 */ "SPAN",
159064 /* 181 */ "SPACE",
159065 /* 182 */ "ILLEGAL",
159066 /* 183 */ "input",
159067 /* 184 */ "cmdlist",
159068 /* 185 */ "ecmd",
159069 /* 186 */ "cmdx",
159070 /* 187 */ "explain",
159071 /* 188 */ "cmd",
159072 /* 189 */ "transtype",
159073 /* 190 */ "trans_opt",
159074 /* 191 */ "nm",
159075 /* 192 */ "savepoint_opt",
159076 /* 193 */ "create_table",
159077 /* 194 */ "create_table_args",
159078 /* 195 */ "createkw",
159079 /* 196 */ "temp",
159080 /* 197 */ "ifnotexists",
159081 /* 198 */ "dbnm",
159082 /* 199 */ "columnlist",
159083 /* 200 */ "conslist_opt",
159084 /* 201 */ "table_options",
159085 /* 202 */ "select",
159086 /* 203 */ "columnname",
159087 /* 204 */ "carglist",
159088 /* 205 */ "typetoken",
159089 /* 206 */ "typename",
159090 /* 207 */ "signed",
159091 /* 208 */ "plus_num",
159092 /* 209 */ "minus_num",
159093 /* 210 */ "scanpt",
159094 /* 211 */ "scantok",
159095 /* 212 */ "ccons",
159096 /* 213 */ "term",
159097 /* 214 */ "expr",
159098 /* 215 */ "onconf",
159099 /* 216 */ "sortorder",
159100 /* 217 */ "autoinc",
159101 /* 218 */ "eidlist_opt",
159102 /* 219 */ "refargs",
159103 /* 220 */ "defer_subclause",
159104 /* 221 */ "generated",
159105 /* 222 */ "refarg",
159106 /* 223 */ "refact",
159107 /* 224 */ "init_deferred_pred_opt",
159108 /* 225 */ "conslist",
159109 /* 226 */ "tconscomma",
159110 /* 227 */ "tcons",
159111 /* 228 */ "sortlist",
159112 /* 229 */ "eidlist",
159113 /* 230 */ "defer_subclause_opt",
159114 /* 231 */ "orconf",
159115 /* 232 */ "resolvetype",
159116 /* 233 */ "raisetype",
159117 /* 234 */ "ifexists",
159118 /* 235 */ "fullname",
159119 /* 236 */ "selectnowith",
159120 /* 237 */ "oneselect",
159121 /* 238 */ "wqlist",
159122 /* 239 */ "multiselect_op",
159123 /* 240 */ "distinct",
159124 /* 241 */ "selcollist",
159125 /* 242 */ "from",
159126 /* 243 */ "where_opt",
159127 /* 244 */ "groupby_opt",
159128 /* 245 */ "having_opt",
159129 /* 246 */ "orderby_opt",
159130 /* 247 */ "limit_opt",
159131 /* 248 */ "window_clause",
159132 /* 249 */ "values",
159133 /* 250 */ "nexprlist",
159134 /* 251 */ "sclp",
159135 /* 252 */ "as",
159136 /* 253 */ "seltablist",
159137 /* 254 */ "stl_prefix",
159138 /* 255 */ "joinop",
159139 /* 256 */ "indexed_opt",
159140 /* 257 */ "on_opt",
159141 /* 258 */ "using_opt",
159142 /* 259 */ "exprlist",
159143 /* 260 */ "xfullname",
159144 /* 261 */ "idlist",
159145 /* 262 */ "nulls",
159146 /* 263 */ "with",
159147 /* 264 */ "where_opt_ret",
159148 /* 265 */ "setlist",
159149 /* 266 */ "insert_cmd",
159150 /* 267 */ "idlist_opt",
159151 /* 268 */ "upsert",
159152 /* 269 */ "returning",
159153 /* 270 */ "filter_over",
159154 /* 271 */ "likeop",
159155 /* 272 */ "between_op",
159156 /* 273 */ "in_op",
159157 /* 274 */ "paren_exprlist",
159158 /* 275 */ "case_operand",
159159 /* 276 */ "case_exprlist",
159160 /* 277 */ "case_else",
159161 /* 278 */ "uniqueflag",
159162 /* 279 */ "collate",
159163 /* 280 */ "vinto",
159164 /* 281 */ "nmnum",
159165 /* 282 */ "trigger_decl",
159166 /* 283 */ "trigger_cmd_list",
159167 /* 284 */ "trigger_time",
159168 /* 285 */ "trigger_event",
159169 /* 286 */ "foreach_clause",
159170 /* 287 */ "when_clause",
159171 /* 288 */ "trigger_cmd",
159172 /* 289 */ "trnm",
159173 /* 290 */ "tridxby",
159174 /* 291 */ "database_kw_opt",
159175 /* 292 */ "key_opt",
159176 /* 293 */ "add_column_fullname",
159177 /* 294 */ "kwcolumn_opt",
159178 /* 295 */ "create_vtab",
159179 /* 296 */ "vtabarglist",
159180 /* 297 */ "vtabarg",
159181 /* 298 */ "vtabargtoken",
159182 /* 299 */ "lp",
159183 /* 300 */ "anylist",
159184 /* 301 */ "wqitem",
159185 /* 302 */ "wqas",
159186 /* 303 */ "windowdefn_list",
159187 /* 304 */ "windowdefn",
159188 /* 305 */ "window",
159189 /* 306 */ "frame_opt",
159190 /* 307 */ "part_opt",
159191 /* 308 */ "filter_clause",
159192 /* 309 */ "over_clause",
159193 /* 310 */ "range_or_rows",
159194 /* 311 */ "frame_bound",
159195 /* 312 */ "frame_bound_s",
159196 /* 313 */ "frame_bound_e",
159197 /* 314 */ "frame_exclude_opt",
159198 /* 315 */ "frame_exclude",
 
159199 };
159200 #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
159201
159202 #ifndef NDEBUG
159203 /* For tracing reduce actions, the names of all rules are required.
@@ -159724,103 +160303,103 @@
159724 ** Note: during a reduce, the only symbols destroyed are those
159725 ** which appear on the RHS of the rule, but which are *not* used
159726 ** inside the C code.
159727 */
159728 /********* Begin destructor definitions ***************************************/
159729 case 202: /* select */
159730 case 236: /* selectnowith */
159731 case 237: /* oneselect */
159732 case 249: /* values */
159733 {
159734 sqlite3SelectDelete(pParse->db, (yypminor->yy307));
159735 }
159736 break;
159737 case 213: /* term */
159738 case 214: /* expr */
159739 case 243: /* where_opt */
159740 case 245: /* having_opt */
159741 case 257: /* on_opt */
159742 case 264: /* where_opt_ret */
159743 case 275: /* case_operand */
159744 case 277: /* case_else */
159745 case 280: /* vinto */
159746 case 287: /* when_clause */
159747 case 292: /* key_opt */
159748 case 308: /* filter_clause */
159749 {
159750 sqlite3ExprDelete(pParse->db, (yypminor->yy602));
159751 }
159752 break;
159753 case 218: /* eidlist_opt */
159754 case 228: /* sortlist */
159755 case 229: /* eidlist */
159756 case 241: /* selcollist */
159757 case 244: /* groupby_opt */
159758 case 246: /* orderby_opt */
159759 case 250: /* nexprlist */
159760 case 251: /* sclp */
159761 case 259: /* exprlist */
159762 case 265: /* setlist */
159763 case 274: /* paren_exprlist */
159764 case 276: /* case_exprlist */
159765 case 307: /* part_opt */
159766 {
159767 sqlite3ExprListDelete(pParse->db, (yypminor->yy338));
159768 }
159769 break;
159770 case 235: /* fullname */
159771 case 242: /* from */
159772 case 253: /* seltablist */
159773 case 254: /* stl_prefix */
159774 case 260: /* xfullname */
159775 {
159776 sqlite3SrcListDelete(pParse->db, (yypminor->yy291));
159777 }
159778 break;
159779 case 238: /* wqlist */
159780 {
159781 sqlite3WithDelete(pParse->db, (yypminor->yy195));
159782 }
159783 break;
159784 case 248: /* window_clause */
159785 case 303: /* windowdefn_list */
159786 {
159787 sqlite3WindowListDelete(pParse->db, (yypminor->yy19));
159788 }
159789 break;
159790 case 258: /* using_opt */
159791 case 261: /* idlist */
159792 case 267: /* idlist_opt */
159793 {
159794 sqlite3IdListDelete(pParse->db, (yypminor->yy288));
159795 }
159796 break;
159797 case 270: /* filter_over */
159798 case 304: /* windowdefn */
159799 case 305: /* window */
159800 case 306: /* frame_opt */
159801 case 309: /* over_clause */
159802 {
159803 sqlite3WindowDelete(pParse->db, (yypminor->yy19));
159804 }
159805 break;
159806 case 283: /* trigger_cmd_list */
159807 case 288: /* trigger_cmd */
159808 {
159809 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy483));
159810 }
159811 break;
159812 case 285: /* trigger_event */
159813 {
159814 sqlite3IdListDelete(pParse->db, (yypminor->yy50).b);
159815 }
159816 break;
159817 case 311: /* frame_bound */
159818 case 312: /* frame_bound_s */
159819 case 313: /* frame_bound_e */
159820 {
159821 sqlite3ExprDelete(pParse->db, (yypminor->yy113).pExpr);
159822 }
159823 break;
159824 /********* End destructor definitions *****************************************/
159825 default: break; /* If no destructor action specified: do nothing */
159826 }
@@ -160107,408 +160686,408 @@
160107 }
160108
160109 /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
160110 ** of that rule */
160111 static const YYCODETYPE yyRuleInfoLhs[] = {
160112 187, /* (0) explain ::= EXPLAIN */
160113 187, /* (1) explain ::= EXPLAIN QUERY PLAN */
160114 186, /* (2) cmdx ::= cmd */
160115 188, /* (3) cmd ::= BEGIN transtype trans_opt */
160116 189, /* (4) transtype ::= */
160117 189, /* (5) transtype ::= DEFERRED */
160118 189, /* (6) transtype ::= IMMEDIATE */
160119 189, /* (7) transtype ::= EXCLUSIVE */
160120 188, /* (8) cmd ::= COMMIT|END trans_opt */
160121 188, /* (9) cmd ::= ROLLBACK trans_opt */
160122 188, /* (10) cmd ::= SAVEPOINT nm */
160123 188, /* (11) cmd ::= RELEASE savepoint_opt nm */
160124 188, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
160125 193, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
160126 195, /* (14) createkw ::= CREATE */
160127 197, /* (15) ifnotexists ::= */
160128 197, /* (16) ifnotexists ::= IF NOT EXISTS */
160129 196, /* (17) temp ::= TEMP */
160130 196, /* (18) temp ::= */
160131 194, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
160132 194, /* (20) create_table_args ::= AS select */
160133 201, /* (21) table_options ::= */
160134 201, /* (22) table_options ::= WITHOUT nm */
160135 203, /* (23) columnname ::= nm typetoken */
160136 205, /* (24) typetoken ::= */
160137 205, /* (25) typetoken ::= typename LP signed RP */
160138 205, /* (26) typetoken ::= typename LP signed COMMA signed RP */
160139 206, /* (27) typename ::= typename ID|STRING */
160140 210, /* (28) scanpt ::= */
160141 211, /* (29) scantok ::= */
160142 212, /* (30) ccons ::= CONSTRAINT nm */
160143 212, /* (31) ccons ::= DEFAULT scantok term */
160144 212, /* (32) ccons ::= DEFAULT LP expr RP */
160145 212, /* (33) ccons ::= DEFAULT PLUS scantok term */
160146 212, /* (34) ccons ::= DEFAULT MINUS scantok term */
160147 212, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */
160148 212, /* (36) ccons ::= NOT NULL onconf */
160149 212, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */
160150 212, /* (38) ccons ::= UNIQUE onconf */
160151 212, /* (39) ccons ::= CHECK LP expr RP */
160152 212, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
160153 212, /* (41) ccons ::= defer_subclause */
160154 212, /* (42) ccons ::= COLLATE ID|STRING */
160155 221, /* (43) generated ::= LP expr RP */
160156 221, /* (44) generated ::= LP expr RP ID */
160157 217, /* (45) autoinc ::= */
160158 217, /* (46) autoinc ::= AUTOINCR */
160159 219, /* (47) refargs ::= */
160160 219, /* (48) refargs ::= refargs refarg */
160161 222, /* (49) refarg ::= MATCH nm */
160162 222, /* (50) refarg ::= ON INSERT refact */
160163 222, /* (51) refarg ::= ON DELETE refact */
160164 222, /* (52) refarg ::= ON UPDATE refact */
160165 223, /* (53) refact ::= SET NULL */
160166 223, /* (54) refact ::= SET DEFAULT */
160167 223, /* (55) refact ::= CASCADE */
160168 223, /* (56) refact ::= RESTRICT */
160169 223, /* (57) refact ::= NO ACTION */
160170 220, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
160171 220, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
160172 224, /* (60) init_deferred_pred_opt ::= */
160173 224, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */
160174 224, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
160175 200, /* (63) conslist_opt ::= */
160176 226, /* (64) tconscomma ::= COMMA */
160177 227, /* (65) tcons ::= CONSTRAINT nm */
160178 227, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
160179 227, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */
160180 227, /* (68) tcons ::= CHECK LP expr RP onconf */
160181 227, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
160182 230, /* (70) defer_subclause_opt ::= */
160183 215, /* (71) onconf ::= */
160184 215, /* (72) onconf ::= ON CONFLICT resolvetype */
160185 231, /* (73) orconf ::= */
160186 231, /* (74) orconf ::= OR resolvetype */
160187 232, /* (75) resolvetype ::= IGNORE */
160188 232, /* (76) resolvetype ::= REPLACE */
160189 188, /* (77) cmd ::= DROP TABLE ifexists fullname */
160190 234, /* (78) ifexists ::= IF EXISTS */
160191 234, /* (79) ifexists ::= */
160192 188, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
160193 188, /* (81) cmd ::= DROP VIEW ifexists fullname */
160194 188, /* (82) cmd ::= select */
160195 202, /* (83) select ::= WITH wqlist selectnowith */
160196 202, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */
160197 202, /* (85) select ::= selectnowith */
160198 236, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */
160199 239, /* (87) multiselect_op ::= UNION */
160200 239, /* (88) multiselect_op ::= UNION ALL */
160201 239, /* (89) multiselect_op ::= EXCEPT|INTERSECT */
160202 237, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
160203 237, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
160204 249, /* (92) values ::= VALUES LP nexprlist RP */
160205 249, /* (93) values ::= values COMMA LP nexprlist RP */
160206 240, /* (94) distinct ::= DISTINCT */
160207 240, /* (95) distinct ::= ALL */
160208 240, /* (96) distinct ::= */
160209 251, /* (97) sclp ::= */
160210 241, /* (98) selcollist ::= sclp scanpt expr scanpt as */
160211 241, /* (99) selcollist ::= sclp scanpt STAR */
160212 241, /* (100) selcollist ::= sclp scanpt nm DOT STAR */
160213 252, /* (101) as ::= AS nm */
160214 252, /* (102) as ::= */
160215 242, /* (103) from ::= */
160216 242, /* (104) from ::= FROM seltablist */
160217 254, /* (105) stl_prefix ::= seltablist joinop */
160218 254, /* (106) stl_prefix ::= */
160219 253, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
160220 253, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
160221 253, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
160222 253, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
160223 198, /* (111) dbnm ::= */
160224 198, /* (112) dbnm ::= DOT nm */
160225 235, /* (113) fullname ::= nm */
160226 235, /* (114) fullname ::= nm DOT nm */
160227 260, /* (115) xfullname ::= nm */
160228 260, /* (116) xfullname ::= nm DOT nm */
160229 260, /* (117) xfullname ::= nm DOT nm AS nm */
160230 260, /* (118) xfullname ::= nm AS nm */
160231 255, /* (119) joinop ::= COMMA|JOIN */
160232 255, /* (120) joinop ::= JOIN_KW JOIN */
160233 255, /* (121) joinop ::= JOIN_KW nm JOIN */
160234 255, /* (122) joinop ::= JOIN_KW nm nm JOIN */
160235 257, /* (123) on_opt ::= ON expr */
160236 257, /* (124) on_opt ::= */
160237 256, /* (125) indexed_opt ::= */
160238 256, /* (126) indexed_opt ::= INDEXED BY nm */
160239 256, /* (127) indexed_opt ::= NOT INDEXED */
160240 258, /* (128) using_opt ::= USING LP idlist RP */
160241 258, /* (129) using_opt ::= */
160242 246, /* (130) orderby_opt ::= */
160243 246, /* (131) orderby_opt ::= ORDER BY sortlist */
160244 228, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */
160245 228, /* (133) sortlist ::= expr sortorder nulls */
160246 216, /* (134) sortorder ::= ASC */
160247 216, /* (135) sortorder ::= DESC */
160248 216, /* (136) sortorder ::= */
160249 262, /* (137) nulls ::= NULLS FIRST */
160250 262, /* (138) nulls ::= NULLS LAST */
160251 262, /* (139) nulls ::= */
160252 244, /* (140) groupby_opt ::= */
160253 244, /* (141) groupby_opt ::= GROUP BY nexprlist */
160254 245, /* (142) having_opt ::= */
160255 245, /* (143) having_opt ::= HAVING expr */
160256 247, /* (144) limit_opt ::= */
160257 247, /* (145) limit_opt ::= LIMIT expr */
160258 247, /* (146) limit_opt ::= LIMIT expr OFFSET expr */
160259 247, /* (147) limit_opt ::= LIMIT expr COMMA expr */
160260 188, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
160261 243, /* (149) where_opt ::= */
160262 243, /* (150) where_opt ::= WHERE expr */
160263 264, /* (151) where_opt_ret ::= */
160264 264, /* (152) where_opt_ret ::= WHERE expr */
160265 264, /* (153) where_opt_ret ::= RETURNING selcollist */
160266 264, /* (154) where_opt_ret ::= WHERE expr RETURNING selcollist */
160267 188, /* (155) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
160268 265, /* (156) setlist ::= setlist COMMA nm EQ expr */
160269 265, /* (157) setlist ::= setlist COMMA LP idlist RP EQ expr */
160270 265, /* (158) setlist ::= nm EQ expr */
160271 265, /* (159) setlist ::= LP idlist RP EQ expr */
160272 188, /* (160) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
160273 188, /* (161) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
160274 268, /* (162) upsert ::= */
160275 268, /* (163) upsert ::= RETURNING selcollist */
160276 268, /* (164) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
160277 268, /* (165) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
160278 268, /* (166) upsert ::= ON CONFLICT DO NOTHING returning */
160279 268, /* (167) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
160280 269, /* (168) returning ::= RETURNING selcollist */
160281 266, /* (169) insert_cmd ::= INSERT orconf */
160282 266, /* (170) insert_cmd ::= REPLACE */
160283 267, /* (171) idlist_opt ::= */
160284 267, /* (172) idlist_opt ::= LP idlist RP */
160285 261, /* (173) idlist ::= idlist COMMA nm */
160286 261, /* (174) idlist ::= nm */
160287 214, /* (175) expr ::= LP expr RP */
160288 214, /* (176) expr ::= ID|INDEXED */
160289 214, /* (177) expr ::= JOIN_KW */
160290 214, /* (178) expr ::= nm DOT nm */
160291 214, /* (179) expr ::= nm DOT nm DOT nm */
160292 213, /* (180) term ::= NULL|FLOAT|BLOB */
160293 213, /* (181) term ::= STRING */
160294 213, /* (182) term ::= INTEGER */
160295 214, /* (183) expr ::= VARIABLE */
160296 214, /* (184) expr ::= expr COLLATE ID|STRING */
160297 214, /* (185) expr ::= CAST LP expr AS typetoken RP */
160298 214, /* (186) expr ::= ID|INDEXED LP distinct exprlist RP */
160299 214, /* (187) expr ::= ID|INDEXED LP STAR RP */
160300 214, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
160301 214, /* (189) expr ::= ID|INDEXED LP STAR RP filter_over */
160302 213, /* (190) term ::= CTIME_KW */
160303 214, /* (191) expr ::= LP nexprlist COMMA expr RP */
160304 214, /* (192) expr ::= expr AND expr */
160305 214, /* (193) expr ::= expr OR expr */
160306 214, /* (194) expr ::= expr LT|GT|GE|LE expr */
160307 214, /* (195) expr ::= expr EQ|NE expr */
160308 214, /* (196) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
160309 214, /* (197) expr ::= expr PLUS|MINUS expr */
160310 214, /* (198) expr ::= expr STAR|SLASH|REM expr */
160311 214, /* (199) expr ::= expr CONCAT expr */
160312 271, /* (200) likeop ::= NOT LIKE_KW|MATCH */
160313 214, /* (201) expr ::= expr likeop expr */
160314 214, /* (202) expr ::= expr likeop expr ESCAPE expr */
160315 214, /* (203) expr ::= expr ISNULL|NOTNULL */
160316 214, /* (204) expr ::= expr NOT NULL */
160317 214, /* (205) expr ::= expr IS expr */
160318 214, /* (206) expr ::= expr IS NOT expr */
160319 214, /* (207) expr ::= NOT expr */
160320 214, /* (208) expr ::= BITNOT expr */
160321 214, /* (209) expr ::= PLUS|MINUS expr */
160322 272, /* (210) between_op ::= BETWEEN */
160323 272, /* (211) between_op ::= NOT BETWEEN */
160324 214, /* (212) expr ::= expr between_op expr AND expr */
160325 273, /* (213) in_op ::= IN */
160326 273, /* (214) in_op ::= NOT IN */
160327 214, /* (215) expr ::= expr in_op LP exprlist RP */
160328 214, /* (216) expr ::= LP select RP */
160329 214, /* (217) expr ::= expr in_op LP select RP */
160330 214, /* (218) expr ::= expr in_op nm dbnm paren_exprlist */
160331 214, /* (219) expr ::= EXISTS LP select RP */
160332 214, /* (220) expr ::= CASE case_operand case_exprlist case_else END */
160333 276, /* (221) case_exprlist ::= case_exprlist WHEN expr THEN expr */
160334 276, /* (222) case_exprlist ::= WHEN expr THEN expr */
160335 277, /* (223) case_else ::= ELSE expr */
160336 277, /* (224) case_else ::= */
160337 275, /* (225) case_operand ::= expr */
160338 275, /* (226) case_operand ::= */
160339 259, /* (227) exprlist ::= */
160340 250, /* (228) nexprlist ::= nexprlist COMMA expr */
160341 250, /* (229) nexprlist ::= expr */
160342 274, /* (230) paren_exprlist ::= */
160343 274, /* (231) paren_exprlist ::= LP exprlist RP */
160344 188, /* (232) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
160345 278, /* (233) uniqueflag ::= UNIQUE */
160346 278, /* (234) uniqueflag ::= */
160347 218, /* (235) eidlist_opt ::= */
160348 218, /* (236) eidlist_opt ::= LP eidlist RP */
160349 229, /* (237) eidlist ::= eidlist COMMA nm collate sortorder */
160350 229, /* (238) eidlist ::= nm collate sortorder */
160351 279, /* (239) collate ::= */
160352 279, /* (240) collate ::= COLLATE ID|STRING */
160353 188, /* (241) cmd ::= DROP INDEX ifexists fullname */
160354 188, /* (242) cmd ::= VACUUM vinto */
160355 188, /* (243) cmd ::= VACUUM nm vinto */
160356 280, /* (244) vinto ::= INTO expr */
160357 280, /* (245) vinto ::= */
160358 188, /* (246) cmd ::= PRAGMA nm dbnm */
160359 188, /* (247) cmd ::= PRAGMA nm dbnm EQ nmnum */
160360 188, /* (248) cmd ::= PRAGMA nm dbnm LP nmnum RP */
160361 188, /* (249) cmd ::= PRAGMA nm dbnm EQ minus_num */
160362 188, /* (250) cmd ::= PRAGMA nm dbnm LP minus_num RP */
160363 208, /* (251) plus_num ::= PLUS INTEGER|FLOAT */
160364 209, /* (252) minus_num ::= MINUS INTEGER|FLOAT */
160365 188, /* (253) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
160366 282, /* (254) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
160367 284, /* (255) trigger_time ::= BEFORE|AFTER */
160368 284, /* (256) trigger_time ::= INSTEAD OF */
160369 284, /* (257) trigger_time ::= */
160370 285, /* (258) trigger_event ::= DELETE|INSERT */
160371 285, /* (259) trigger_event ::= UPDATE */
160372 285, /* (260) trigger_event ::= UPDATE OF idlist */
160373 287, /* (261) when_clause ::= */
160374 287, /* (262) when_clause ::= WHEN expr */
160375 283, /* (263) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
160376 283, /* (264) trigger_cmd_list ::= trigger_cmd SEMI */
160377 289, /* (265) trnm ::= nm DOT nm */
160378 290, /* (266) tridxby ::= INDEXED BY nm */
160379 290, /* (267) tridxby ::= NOT INDEXED */
160380 288, /* (268) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
160381 288, /* (269) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
160382 288, /* (270) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
160383 288, /* (271) trigger_cmd ::= scanpt select scanpt */
160384 214, /* (272) expr ::= RAISE LP IGNORE RP */
160385 214, /* (273) expr ::= RAISE LP raisetype COMMA nm RP */
160386 233, /* (274) raisetype ::= ROLLBACK */
160387 233, /* (275) raisetype ::= ABORT */
160388 233, /* (276) raisetype ::= FAIL */
160389 188, /* (277) cmd ::= DROP TRIGGER ifexists fullname */
160390 188, /* (278) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
160391 188, /* (279) cmd ::= DETACH database_kw_opt expr */
160392 292, /* (280) key_opt ::= */
160393 292, /* (281) key_opt ::= KEY expr */
160394 188, /* (282) cmd ::= REINDEX */
160395 188, /* (283) cmd ::= REINDEX nm dbnm */
160396 188, /* (284) cmd ::= ANALYZE */
160397 188, /* (285) cmd ::= ANALYZE nm dbnm */
160398 188, /* (286) cmd ::= ALTER TABLE fullname RENAME TO nm */
160399 188, /* (287) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
160400 188, /* (288) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
160401 293, /* (289) add_column_fullname ::= fullname */
160402 188, /* (290) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
160403 188, /* (291) cmd ::= create_vtab */
160404 188, /* (292) cmd ::= create_vtab LP vtabarglist RP */
160405 295, /* (293) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
160406 297, /* (294) vtabarg ::= */
160407 298, /* (295) vtabargtoken ::= ANY */
160408 298, /* (296) vtabargtoken ::= lp anylist RP */
160409 299, /* (297) lp ::= LP */
160410 263, /* (298) with ::= WITH wqlist */
160411 263, /* (299) with ::= WITH RECURSIVE wqlist */
160412 302, /* (300) wqas ::= AS */
160413 302, /* (301) wqas ::= AS MATERIALIZED */
160414 302, /* (302) wqas ::= AS NOT MATERIALIZED */
160415 301, /* (303) wqitem ::= nm eidlist_opt wqas LP select RP */
160416 238, /* (304) wqlist ::= wqitem */
160417 238, /* (305) wqlist ::= wqlist COMMA wqitem */
160418 303, /* (306) windowdefn_list ::= windowdefn */
160419 303, /* (307) windowdefn_list ::= windowdefn_list COMMA windowdefn */
160420 304, /* (308) windowdefn ::= nm AS LP window RP */
160421 305, /* (309) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
160422 305, /* (310) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
160423 305, /* (311) window ::= ORDER BY sortlist frame_opt */
160424 305, /* (312) window ::= nm ORDER BY sortlist frame_opt */
160425 305, /* (313) window ::= frame_opt */
160426 305, /* (314) window ::= nm frame_opt */
160427 306, /* (315) frame_opt ::= */
160428 306, /* (316) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
160429 306, /* (317) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
160430 310, /* (318) range_or_rows ::= RANGE|ROWS|GROUPS */
160431 312, /* (319) frame_bound_s ::= frame_bound */
160432 312, /* (320) frame_bound_s ::= UNBOUNDED PRECEDING */
160433 313, /* (321) frame_bound_e ::= frame_bound */
160434 313, /* (322) frame_bound_e ::= UNBOUNDED FOLLOWING */
160435 311, /* (323) frame_bound ::= expr PRECEDING|FOLLOWING */
160436 311, /* (324) frame_bound ::= CURRENT ROW */
160437 314, /* (325) frame_exclude_opt ::= */
160438 314, /* (326) frame_exclude_opt ::= EXCLUDE frame_exclude */
160439 315, /* (327) frame_exclude ::= NO OTHERS */
160440 315, /* (328) frame_exclude ::= CURRENT ROW */
160441 315, /* (329) frame_exclude ::= GROUP|TIES */
160442 248, /* (330) window_clause ::= WINDOW windowdefn_list */
160443 270, /* (331) filter_over ::= filter_clause over_clause */
160444 270, /* (332) filter_over ::= over_clause */
160445 270, /* (333) filter_over ::= filter_clause */
160446 309, /* (334) over_clause ::= OVER LP window RP */
160447 309, /* (335) over_clause ::= OVER nm */
160448 308, /* (336) filter_clause ::= FILTER LP WHERE expr RP */
160449 183, /* (337) input ::= cmdlist */
160450 184, /* (338) cmdlist ::= cmdlist ecmd */
160451 184, /* (339) cmdlist ::= ecmd */
160452 185, /* (340) ecmd ::= SEMI */
160453 185, /* (341) ecmd ::= cmdx SEMI */
160454 185, /* (342) ecmd ::= explain cmdx SEMI */
160455 190, /* (343) trans_opt ::= */
160456 190, /* (344) trans_opt ::= TRANSACTION */
160457 190, /* (345) trans_opt ::= TRANSACTION nm */
160458 192, /* (346) savepoint_opt ::= SAVEPOINT */
160459 192, /* (347) savepoint_opt ::= */
160460 188, /* (348) cmd ::= create_table create_table_args */
160461 199, /* (349) columnlist ::= columnlist COMMA columnname carglist */
160462 199, /* (350) columnlist ::= columnname carglist */
160463 191, /* (351) nm ::= ID|INDEXED */
160464 191, /* (352) nm ::= STRING */
160465 191, /* (353) nm ::= JOIN_KW */
160466 205, /* (354) typetoken ::= typename */
160467 206, /* (355) typename ::= ID|STRING */
160468 207, /* (356) signed ::= plus_num */
160469 207, /* (357) signed ::= minus_num */
160470 204, /* (358) carglist ::= carglist ccons */
160471 204, /* (359) carglist ::= */
160472 212, /* (360) ccons ::= NULL onconf */
160473 212, /* (361) ccons ::= GENERATED ALWAYS AS generated */
160474 212, /* (362) ccons ::= AS generated */
160475 200, /* (363) conslist_opt ::= COMMA conslist */
160476 225, /* (364) conslist ::= conslist tconscomma tcons */
160477 225, /* (365) conslist ::= tcons */
160478 226, /* (366) tconscomma ::= */
160479 230, /* (367) defer_subclause_opt ::= defer_subclause */
160480 232, /* (368) resolvetype ::= raisetype */
160481 236, /* (369) selectnowith ::= oneselect */
160482 237, /* (370) oneselect ::= values */
160483 251, /* (371) sclp ::= selcollist COMMA */
160484 252, /* (372) as ::= ID|STRING */
160485 269, /* (373) returning ::= */
160486 214, /* (374) expr ::= term */
160487 271, /* (375) likeop ::= LIKE_KW|MATCH */
160488 259, /* (376) exprlist ::= nexprlist */
160489 281, /* (377) nmnum ::= plus_num */
160490 281, /* (378) nmnum ::= nm */
160491 281, /* (379) nmnum ::= ON */
160492 281, /* (380) nmnum ::= DELETE */
160493 281, /* (381) nmnum ::= DEFAULT */
160494 208, /* (382) plus_num ::= INTEGER|FLOAT */
160495 286, /* (383) foreach_clause ::= */
160496 286, /* (384) foreach_clause ::= FOR EACH ROW */
160497 289, /* (385) trnm ::= nm */
160498 290, /* (386) tridxby ::= */
160499 291, /* (387) database_kw_opt ::= DATABASE */
160500 291, /* (388) database_kw_opt ::= */
160501 294, /* (389) kwcolumn_opt ::= */
160502 294, /* (390) kwcolumn_opt ::= COLUMNKW */
160503 296, /* (391) vtabarglist ::= vtabarg */
160504 296, /* (392) vtabarglist ::= vtabarglist COMMA vtabarg */
160505 297, /* (393) vtabarg ::= vtabarg vtabargtoken */
160506 300, /* (394) anylist ::= */
160507 300, /* (395) anylist ::= anylist LP anylist RP */
160508 300, /* (396) anylist ::= anylist ANY */
160509 263, /* (397) with ::= */
160510 };
160511
160512 /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
160513 ** of symbols on the right-hand side of that rule. */
160514 static const signed char yyRuleInfoNRhs[] = {
@@ -160959,20 +161538,20 @@
160959 break;
160960 case 2: /* cmdx ::= cmd */
160961 { sqlite3FinishCoding(pParse); }
160962 break;
160963 case 3: /* cmd ::= BEGIN transtype trans_opt */
160964 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy60);}
160965 break;
160966 case 4: /* transtype ::= */
160967 {yymsp[1].minor.yy60 = TK_DEFERRED;}
160968 break;
160969 case 5: /* transtype ::= DEFERRED */
160970 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
160971 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
160972 case 318: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==318);
160973 {yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-X*/}
160974 break;
160975 case 8: /* cmd ::= COMMIT|END trans_opt */
160976 case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
160977 {sqlite3EndTransaction(pParse,yymsp[-1].major);}
160978 break;
@@ -160991,11 +161570,11 @@
160991 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
160992 }
160993 break;
160994 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
160995 {
160996 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy60,0,0,yymsp[-2].minor.yy60);
160997 }
160998 break;
160999 case 14: /* createkw ::= CREATE */
161000 {disableLookaside(pParse);}
161001 break;
@@ -161006,36 +161585,35 @@
161006 case 60: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==60);
161007 case 70: /* defer_subclause_opt ::= */ yytestcase(yyruleno==70);
161008 case 79: /* ifexists ::= */ yytestcase(yyruleno==79);
161009 case 96: /* distinct ::= */ yytestcase(yyruleno==96);
161010 case 239: /* collate ::= */ yytestcase(yyruleno==239);
161011 {yymsp[1].minor.yy60 = 0;}
161012 break;
161013 case 16: /* ifnotexists ::= IF NOT EXISTS */
161014 {yymsp[-2].minor.yy60 = 1;}
161015 break;
161016 case 17: /* temp ::= TEMP */
161017 case 46: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==46);
161018 {yymsp[0].minor.yy60 = 1;}
161019 break;
161020 case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
161021 {
161022 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy60,0);
161023 }
161024 break;
161025 case 20: /* create_table_args ::= AS select */
161026 {
161027 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy307);
161028 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy307);
161029 }
161030 break;
161031 case 22: /* table_options ::= WITHOUT nm */
161032 {
161033 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
161034 yymsp[-1].minor.yy60 = TF_WithoutRowid | TF_NoVisibleRowid;
161035 }else{
161036 yymsp[-1].minor.yy60 = 0;
161037 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
161038 }
161039 }
161040 break;
161041 case 23: /* columnname ::= nm typetoken */
@@ -161060,11 +161638,11 @@
161060 {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
161061 break;
161062 case 28: /* scanpt ::= */
161063 {
161064 assert( yyLookahead!=YYNOCODE );
161065 yymsp[1].minor.yy528 = yyLookaheadToken.z;
161066 }
161067 break;
161068 case 29: /* scantok ::= */
161069 {
161070 assert( yyLookahead!=YYNOCODE );
@@ -161074,21 +161652,21 @@
161074 case 30: /* ccons ::= CONSTRAINT nm */
161075 case 65: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==65);
161076 {pParse->constraintName = yymsp[0].minor.yy0;}
161077 break;
161078 case 31: /* ccons ::= DEFAULT scantok term */
161079 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy602,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
161080 break;
161081 case 32: /* ccons ::= DEFAULT LP expr RP */
161082 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy602,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
161083 break;
161084 case 33: /* ccons ::= DEFAULT PLUS scantok term */
161085 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy602,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
161086 break;
161087 case 34: /* ccons ::= DEFAULT MINUS scantok term */
161088 {
161089 Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy602, 0);
161090 sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
161091 }
161092 break;
161093 case 35: /* ccons ::= DEFAULT scantok ID|INDEXED */
161094 {
@@ -161099,256 +161677,259 @@
161099 }
161100 sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
161101 }
161102 break;
161103 case 36: /* ccons ::= NOT NULL onconf */
161104 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy60);}
161105 break;
161106 case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
161107 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy60,yymsp[0].minor.yy60,yymsp[-2].minor.yy60);}
161108 break;
161109 case 38: /* ccons ::= UNIQUE onconf */
161110 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy60,0,0,0,0,
161111 SQLITE_IDXTYPE_UNIQUE);}
161112 break;
161113 case 39: /* ccons ::= CHECK LP expr RP */
161114 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy602,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
161115 break;
161116 case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */
161117 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy338,yymsp[0].minor.yy60);}
161118 break;
161119 case 41: /* ccons ::= defer_subclause */
161120 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy60);}
161121 break;
161122 case 42: /* ccons ::= COLLATE ID|STRING */
161123 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
161124 break;
161125 case 43: /* generated ::= LP expr RP */
161126 {sqlite3AddGenerated(pParse,yymsp[-1].minor.yy602,0);}
161127 break;
161128 case 44: /* generated ::= LP expr RP ID */
161129 {sqlite3AddGenerated(pParse,yymsp[-2].minor.yy602,&yymsp[0].minor.yy0);}
 
 
 
161130 break;
161131 case 47: /* refargs ::= */
161132 { yymsp[1].minor.yy60 = OE_None*0x0101; /* EV: R-19803-45884 */}
161133 break;
161134 case 48: /* refargs ::= refargs refarg */
161135 { yymsp[-1].minor.yy60 = (yymsp[-1].minor.yy60 & ~yymsp[0].minor.yy615.mask) | yymsp[0].minor.yy615.value; }
161136 break;
161137 case 49: /* refarg ::= MATCH nm */
161138 { yymsp[-1].minor.yy615.value = 0; yymsp[-1].minor.yy615.mask = 0x000000; }
161139 break;
161140 case 50: /* refarg ::= ON INSERT refact */
161141 { yymsp[-2].minor.yy615.value = 0; yymsp[-2].minor.yy615.mask = 0x000000; }
161142 break;
161143 case 51: /* refarg ::= ON DELETE refact */
161144 { yymsp[-2].minor.yy615.value = yymsp[0].minor.yy60; yymsp[-2].minor.yy615.mask = 0x0000ff; }
161145 break;
161146 case 52: /* refarg ::= ON UPDATE refact */
161147 { yymsp[-2].minor.yy615.value = yymsp[0].minor.yy60<<8; yymsp[-2].minor.yy615.mask = 0x00ff00; }
161148 break;
161149 case 53: /* refact ::= SET NULL */
161150 { yymsp[-1].minor.yy60 = OE_SetNull; /* EV: R-33326-45252 */}
161151 break;
161152 case 54: /* refact ::= SET DEFAULT */
161153 { yymsp[-1].minor.yy60 = OE_SetDflt; /* EV: R-33326-45252 */}
161154 break;
161155 case 55: /* refact ::= CASCADE */
161156 { yymsp[0].minor.yy60 = OE_Cascade; /* EV: R-33326-45252 */}
161157 break;
161158 case 56: /* refact ::= RESTRICT */
161159 { yymsp[0].minor.yy60 = OE_Restrict; /* EV: R-33326-45252 */}
161160 break;
161161 case 57: /* refact ::= NO ACTION */
161162 { yymsp[-1].minor.yy60 = OE_None; /* EV: R-33326-45252 */}
161163 break;
161164 case 58: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
161165 {yymsp[-2].minor.yy60 = 0;}
161166 break;
161167 case 59: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
161168 case 74: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==74);
161169 case 169: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==169);
161170 {yymsp[-1].minor.yy60 = yymsp[0].minor.yy60;}
161171 break;
161172 case 61: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
161173 case 78: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==78);
161174 case 211: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==211);
161175 case 214: /* in_op ::= NOT IN */ yytestcase(yyruleno==214);
161176 case 240: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==240);
161177 {yymsp[-1].minor.yy60 = 1;}
161178 break;
161179 case 62: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
161180 {yymsp[-1].minor.yy60 = 0;}
161181 break;
161182 case 64: /* tconscomma ::= COMMA */
161183 {pParse->constraintName.n = 0;}
161184 break;
161185 case 66: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
161186 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy338,yymsp[0].minor.yy60,yymsp[-2].minor.yy60,0);}
161187 break;
161188 case 67: /* tcons ::= UNIQUE LP sortlist RP onconf */
161189 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy338,yymsp[0].minor.yy60,0,0,0,0,
161190 SQLITE_IDXTYPE_UNIQUE);}
161191 break;
161192 case 68: /* tcons ::= CHECK LP expr RP onconf */
161193 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy602,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
161194 break;
161195 case 69: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
161196 {
161197 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy338, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy338, yymsp[-1].minor.yy60);
161198 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy60);
161199 }
161200 break;
161201 case 71: /* onconf ::= */
161202 case 73: /* orconf ::= */ yytestcase(yyruleno==73);
161203 {yymsp[1].minor.yy60 = OE_Default;}
161204 break;
161205 case 72: /* onconf ::= ON CONFLICT resolvetype */
161206 {yymsp[-2].minor.yy60 = yymsp[0].minor.yy60;}
161207 break;
161208 case 75: /* resolvetype ::= IGNORE */
161209 {yymsp[0].minor.yy60 = OE_Ignore;}
161210 break;
161211 case 76: /* resolvetype ::= REPLACE */
161212 case 170: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==170);
161213 {yymsp[0].minor.yy60 = OE_Replace;}
161214 break;
161215 case 77: /* cmd ::= DROP TABLE ifexists fullname */
161216 {
161217 sqlite3DropTable(pParse, yymsp[0].minor.yy291, 0, yymsp[-1].minor.yy60);
161218 }
161219 break;
161220 case 80: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
161221 {
161222 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy338, yymsp[0].minor.yy307, yymsp[-7].minor.yy60, yymsp[-5].minor.yy60);
161223 }
161224 break;
161225 case 81: /* cmd ::= DROP VIEW ifexists fullname */
161226 {
161227 sqlite3DropTable(pParse, yymsp[0].minor.yy291, 1, yymsp[-1].minor.yy60);
161228 }
161229 break;
161230 case 82: /* cmd ::= select */
161231 {
161232 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0};
161233 sqlite3Select(pParse, yymsp[0].minor.yy307, &dest);
161234 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy307);
161235 }
161236 break;
161237 case 83: /* select ::= WITH wqlist selectnowith */
161238 {yymsp[-2].minor.yy307 = attachWithToSelect(pParse,yymsp[0].minor.yy307,yymsp[-1].minor.yy195);}
161239 break;
161240 case 84: /* select ::= WITH RECURSIVE wqlist selectnowith */
161241 {yymsp[-3].minor.yy307 = attachWithToSelect(pParse,yymsp[0].minor.yy307,yymsp[-1].minor.yy195);}
161242 break;
161243 case 85: /* select ::= selectnowith */
161244 {
161245 Select *p = yymsp[0].minor.yy307;
161246 if( p ){
161247 parserDoubleLinkSelect(pParse, p);
161248 }
161249 yymsp[0].minor.yy307 = p; /*A-overwrites-X*/
161250 }
161251 break;
161252 case 86: /* selectnowith ::= selectnowith multiselect_op oneselect */
161253 {
161254 Select *pRhs = yymsp[0].minor.yy307;
161255 Select *pLhs = yymsp[-2].minor.yy307;
161256 if( pRhs && pRhs->pPrior ){
161257 SrcList *pFrom;
161258 Token x;
161259 x.n = 0;
161260 parserDoubleLinkSelect(pParse, pRhs);
161261 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
161262 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
161263 }
161264 if( pRhs ){
161265 pRhs->op = (u8)yymsp[-1].minor.yy60;
161266 pRhs->pPrior = pLhs;
161267 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
161268 pRhs->selFlags &= ~SF_MultiValue;
161269 if( yymsp[-1].minor.yy60!=TK_ALL ) pParse->hasCompound = 1;
161270 }else{
161271 sqlite3SelectDelete(pParse->db, pLhs);
161272 }
161273 yymsp[-2].minor.yy307 = pRhs;
161274 }
161275 break;
161276 case 87: /* multiselect_op ::= UNION */
161277 case 89: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==89);
161278 {yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-OP*/}
161279 break;
161280 case 88: /* multiselect_op ::= UNION ALL */
161281 {yymsp[-1].minor.yy60 = TK_ALL;}
161282 break;
161283 case 90: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
161284 {
161285 yymsp[-8].minor.yy307 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy338,yymsp[-5].minor.yy291,yymsp[-4].minor.yy602,yymsp[-3].minor.yy338,yymsp[-2].minor.yy602,yymsp[-1].minor.yy338,yymsp[-7].minor.yy60,yymsp[0].minor.yy602);
161286 }
161287 break;
161288 case 91: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
161289 {
161290 yymsp[-9].minor.yy307 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy338,yymsp[-6].minor.yy291,yymsp[-5].minor.yy602,yymsp[-4].minor.yy338,yymsp[-3].minor.yy602,yymsp[-1].minor.yy338,yymsp[-8].minor.yy60,yymsp[0].minor.yy602);
161291 if( yymsp[-9].minor.yy307 ){
161292 yymsp[-9].minor.yy307->pWinDefn = yymsp[-2].minor.yy19;
161293 }else{
161294 sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy19);
161295 }
161296 }
161297 break;
161298 case 92: /* values ::= VALUES LP nexprlist RP */
161299 {
161300 yymsp[-3].minor.yy307 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy338,0,0,0,0,0,SF_Values,0);
161301 }
161302 break;
161303 case 93: /* values ::= values COMMA LP nexprlist RP */
161304 {
161305 Select *pRight, *pLeft = yymsp[-4].minor.yy307;
161306 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy338,0,0,0,0,0,SF_Values|SF_MultiValue,0);
161307 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
161308 if( pRight ){
161309 pRight->op = TK_ALL;
161310 pRight->pPrior = pLeft;
161311 yymsp[-4].minor.yy307 = pRight;
161312 }else{
161313 yymsp[-4].minor.yy307 = pLeft;
161314 }
161315 }
161316 break;
161317 case 94: /* distinct ::= DISTINCT */
161318 {yymsp[0].minor.yy60 = SF_Distinct;}
161319 break;
161320 case 95: /* distinct ::= ALL */
161321 {yymsp[0].minor.yy60 = SF_All;}
161322 break;
161323 case 97: /* sclp ::= */
161324 case 130: /* orderby_opt ::= */ yytestcase(yyruleno==130);
161325 case 140: /* groupby_opt ::= */ yytestcase(yyruleno==140);
161326 case 227: /* exprlist ::= */ yytestcase(yyruleno==227);
161327 case 230: /* paren_exprlist ::= */ yytestcase(yyruleno==230);
161328 case 235: /* eidlist_opt ::= */ yytestcase(yyruleno==235);
161329 {yymsp[1].minor.yy338 = 0;}
161330 break;
161331 case 98: /* selcollist ::= sclp scanpt expr scanpt as */
161332 {
161333 yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy338, yymsp[-2].minor.yy602);
161334 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy338, &yymsp[0].minor.yy0, 1);
161335 sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy338,yymsp[-3].minor.yy528,yymsp[-1].minor.yy528);
161336 }
161337 break;
161338 case 99: /* selcollist ::= sclp scanpt STAR */
161339 {
161340 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
161341 yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy338, p);
161342 }
161343 break;
161344 case 100: /* selcollist ::= sclp scanpt nm DOT STAR */
161345 {
161346 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
161347 Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
161348 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
161349 yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, pDot);
161350 }
161351 break;
161352 case 101: /* as ::= AS nm */
161353 case 112: /* dbnm ::= DOT nm */ yytestcase(yyruleno==112);
161354 case 251: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==251);
@@ -161355,49 +161936,49 @@
161355 case 252: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==252);
161356 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
161357 break;
161358 case 103: /* from ::= */
161359 case 106: /* stl_prefix ::= */ yytestcase(yyruleno==106);
161360 {yymsp[1].minor.yy291 = 0;}
161361 break;
161362 case 104: /* from ::= FROM seltablist */
161363 {
161364 yymsp[-1].minor.yy291 = yymsp[0].minor.yy291;
161365 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy291);
161366 }
161367 break;
161368 case 105: /* stl_prefix ::= seltablist joinop */
161369 {
161370 if( ALWAYS(yymsp[-1].minor.yy291 && yymsp[-1].minor.yy291->nSrc>0) ) yymsp[-1].minor.yy291->a[yymsp[-1].minor.yy291->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy60;
161371 }
161372 break;
161373 case 107: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
161374 {
161375 yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy602,yymsp[0].minor.yy288);
161376 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy291, &yymsp[-2].minor.yy0);
161377 }
161378 break;
161379 case 108: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
161380 {
161381 yymsp[-8].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy291,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy602,yymsp[0].minor.yy288);
161382 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy291, yymsp[-4].minor.yy338);
161383 }
161384 break;
161385 case 109: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
161386 {
161387 yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy307,yymsp[-1].minor.yy602,yymsp[0].minor.yy288);
161388 }
161389 break;
161390 case 110: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
161391 {
161392 if( yymsp[-6].minor.yy291==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy602==0 && yymsp[0].minor.yy288==0 ){
161393 yymsp[-6].minor.yy291 = yymsp[-4].minor.yy291;
161394 }else if( yymsp[-4].minor.yy291->nSrc==1 ){
161395 yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy602,yymsp[0].minor.yy288);
161396 if( yymsp[-6].minor.yy291 ){
161397 SrcItem *pNew = &yymsp[-6].minor.yy291->a[yymsp[-6].minor.yy291->nSrc-1];
161398 SrcItem *pOld = yymsp[-4].minor.yy291->a;
161399 pNew->zName = pOld->zName;
161400 pNew->zDatabase = pOld->zDatabase;
161401 pNew->pSelect = pOld->pSelect;
161402 if( pOld->fg.isTabFunc ){
161403 pNew->u1.pFuncArg = pOld->u1.pFuncArg;
@@ -161406,240 +161987,240 @@
161406 pNew->fg.isTabFunc = 1;
161407 }
161408 pOld->zName = pOld->zDatabase = 0;
161409 pOld->pSelect = 0;
161410 }
161411 sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy291);
161412 }else{
161413 Select *pSubquery;
161414 sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy291);
161415 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy291,0,0,0,0,SF_NestedFrom,0);
161416 yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy602,yymsp[0].minor.yy288);
161417 }
161418 }
161419 break;
161420 case 111: /* dbnm ::= */
161421 case 125: /* indexed_opt ::= */ yytestcase(yyruleno==125);
161422 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
161423 break;
161424 case 113: /* fullname ::= nm */
161425 {
161426 yylhsminor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
161427 if( IN_RENAME_OBJECT && yylhsminor.yy291 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy291->a[0].zName, &yymsp[0].minor.yy0);
161428 }
161429 yymsp[0].minor.yy291 = yylhsminor.yy291;
161430 break;
161431 case 114: /* fullname ::= nm DOT nm */
161432 {
161433 yylhsminor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
161434 if( IN_RENAME_OBJECT && yylhsminor.yy291 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy291->a[0].zName, &yymsp[0].minor.yy0);
161435 }
161436 yymsp[-2].minor.yy291 = yylhsminor.yy291;
161437 break;
161438 case 115: /* xfullname ::= nm */
161439 {yymsp[0].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
161440 break;
161441 case 116: /* xfullname ::= nm DOT nm */
161442 {yymsp[-2].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
161443 break;
161444 case 117: /* xfullname ::= nm DOT nm AS nm */
161445 {
161446 yymsp[-4].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
161447 if( yymsp[-4].minor.yy291 ) yymsp[-4].minor.yy291->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
161448 }
161449 break;
161450 case 118: /* xfullname ::= nm AS nm */
161451 {
161452 yymsp[-2].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
161453 if( yymsp[-2].minor.yy291 ) yymsp[-2].minor.yy291->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
161454 }
161455 break;
161456 case 119: /* joinop ::= COMMA|JOIN */
161457 { yymsp[0].minor.yy60 = JT_INNER; }
161458 break;
161459 case 120: /* joinop ::= JOIN_KW JOIN */
161460 {yymsp[-1].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
161461 break;
161462 case 121: /* joinop ::= JOIN_KW nm JOIN */
161463 {yymsp[-2].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
161464 break;
161465 case 122: /* joinop ::= JOIN_KW nm nm JOIN */
161466 {yymsp[-3].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
161467 break;
161468 case 123: /* on_opt ::= ON expr */
161469 case 143: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==143);
161470 case 150: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==150);
161471 case 152: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==152);
161472 case 223: /* case_else ::= ELSE expr */ yytestcase(yyruleno==223);
161473 case 244: /* vinto ::= INTO expr */ yytestcase(yyruleno==244);
161474 {yymsp[-1].minor.yy602 = yymsp[0].minor.yy602;}
161475 break;
161476 case 124: /* on_opt ::= */
161477 case 142: /* having_opt ::= */ yytestcase(yyruleno==142);
161478 case 144: /* limit_opt ::= */ yytestcase(yyruleno==144);
161479 case 149: /* where_opt ::= */ yytestcase(yyruleno==149);
161480 case 151: /* where_opt_ret ::= */ yytestcase(yyruleno==151);
161481 case 224: /* case_else ::= */ yytestcase(yyruleno==224);
161482 case 226: /* case_operand ::= */ yytestcase(yyruleno==226);
161483 case 245: /* vinto ::= */ yytestcase(yyruleno==245);
161484 {yymsp[1].minor.yy602 = 0;}
161485 break;
161486 case 126: /* indexed_opt ::= INDEXED BY nm */
161487 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
161488 break;
161489 case 127: /* indexed_opt ::= NOT INDEXED */
161490 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
161491 break;
161492 case 128: /* using_opt ::= USING LP idlist RP */
161493 {yymsp[-3].minor.yy288 = yymsp[-1].minor.yy288;}
161494 break;
161495 case 129: /* using_opt ::= */
161496 case 171: /* idlist_opt ::= */ yytestcase(yyruleno==171);
161497 {yymsp[1].minor.yy288 = 0;}
161498 break;
161499 case 131: /* orderby_opt ::= ORDER BY sortlist */
161500 case 141: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==141);
161501 {yymsp[-2].minor.yy338 = yymsp[0].minor.yy338;}
161502 break;
161503 case 132: /* sortlist ::= sortlist COMMA expr sortorder nulls */
161504 {
161505 yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338,yymsp[-2].minor.yy602);
161506 sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy338,yymsp[-1].minor.yy60,yymsp[0].minor.yy60);
161507 }
161508 break;
161509 case 133: /* sortlist ::= expr sortorder nulls */
161510 {
161511 yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy602); /*A-overwrites-Y*/
161512 sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy338,yymsp[-1].minor.yy60,yymsp[0].minor.yy60);
161513 }
161514 break;
161515 case 134: /* sortorder ::= ASC */
161516 {yymsp[0].minor.yy60 = SQLITE_SO_ASC;}
161517 break;
161518 case 135: /* sortorder ::= DESC */
161519 {yymsp[0].minor.yy60 = SQLITE_SO_DESC;}
161520 break;
161521 case 136: /* sortorder ::= */
161522 case 139: /* nulls ::= */ yytestcase(yyruleno==139);
161523 {yymsp[1].minor.yy60 = SQLITE_SO_UNDEFINED;}
161524 break;
161525 case 137: /* nulls ::= NULLS FIRST */
161526 {yymsp[-1].minor.yy60 = SQLITE_SO_ASC;}
161527 break;
161528 case 138: /* nulls ::= NULLS LAST */
161529 {yymsp[-1].minor.yy60 = SQLITE_SO_DESC;}
161530 break;
161531 case 145: /* limit_opt ::= LIMIT expr */
161532 {yymsp[-1].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy602,0);}
161533 break;
161534 case 146: /* limit_opt ::= LIMIT expr OFFSET expr */
161535 {yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);}
161536 break;
161537 case 147: /* limit_opt ::= LIMIT expr COMMA expr */
161538 {yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy602,yymsp[-2].minor.yy602);}
161539 break;
161540 case 148: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
161541 {
161542 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy291, &yymsp[-1].minor.yy0);
161543 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy291,yymsp[0].minor.yy602,0,0);
161544 }
161545 break;
161546 case 153: /* where_opt_ret ::= RETURNING selcollist */
161547 {sqlite3AddReturning(pParse,yymsp[0].minor.yy338); yymsp[-1].minor.yy602 = 0;}
161548 break;
161549 case 154: /* where_opt_ret ::= WHERE expr RETURNING selcollist */
161550 {sqlite3AddReturning(pParse,yymsp[0].minor.yy338); yymsp[-3].minor.yy602 = yymsp[-2].minor.yy602;}
161551 break;
161552 case 155: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
161553 {
161554 sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy291, &yymsp[-4].minor.yy0);
161555 sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy338,"set list");
161556 yymsp[-5].minor.yy291 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy291, yymsp[-1].minor.yy291);
161557 sqlite3Update(pParse,yymsp[-5].minor.yy291,yymsp[-2].minor.yy338,yymsp[0].minor.yy602,yymsp[-6].minor.yy60,0,0,0);
161558 }
161559 break;
161560 case 156: /* setlist ::= setlist COMMA nm EQ expr */
161561 {
161562 yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy338, yymsp[0].minor.yy602);
161563 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy338, &yymsp[-2].minor.yy0, 1);
161564 }
161565 break;
161566 case 157: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
161567 {
161568 yymsp[-6].minor.yy338 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy338, yymsp[-3].minor.yy288, yymsp[0].minor.yy602);
161569 }
161570 break;
161571 case 158: /* setlist ::= nm EQ expr */
161572 {
161573 yylhsminor.yy338 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy602);
161574 sqlite3ExprListSetName(pParse, yylhsminor.yy338, &yymsp[-2].minor.yy0, 1);
161575 }
161576 yymsp[-2].minor.yy338 = yylhsminor.yy338;
161577 break;
161578 case 159: /* setlist ::= LP idlist RP EQ expr */
161579 {
161580 yymsp[-4].minor.yy338 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy288, yymsp[0].minor.yy602);
161581 }
161582 break;
161583 case 160: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
161584 {
161585 sqlite3Insert(pParse, yymsp[-3].minor.yy291, yymsp[-1].minor.yy307, yymsp[-2].minor.yy288, yymsp[-5].minor.yy60, yymsp[0].minor.yy178);
161586 }
161587 break;
161588 case 161: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
161589 {
161590 sqlite3Insert(pParse, yymsp[-4].minor.yy291, 0, yymsp[-3].minor.yy288, yymsp[-6].minor.yy60, 0);
161591 }
161592 break;
161593 case 162: /* upsert ::= */
161594 { yymsp[1].minor.yy178 = 0; }
161595 break;
161596 case 163: /* upsert ::= RETURNING selcollist */
161597 { yymsp[-1].minor.yy178 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy338); }
161598 break;
161599 case 164: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
161600 { yymsp[-11].minor.yy178 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy338,yymsp[-6].minor.yy602,yymsp[-2].minor.yy338,yymsp[-1].minor.yy602,yymsp[0].minor.yy178);}
161601 break;
161602 case 165: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
161603 { yymsp[-8].minor.yy178 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy338,yymsp[-3].minor.yy602,0,0,yymsp[0].minor.yy178); }
161604 break;
161605 case 166: /* upsert ::= ON CONFLICT DO NOTHING returning */
161606 { yymsp[-4].minor.yy178 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
161607 break;
161608 case 167: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
161609 { yymsp[-7].minor.yy178 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy338,yymsp[-1].minor.yy602,0);}
161610 break;
161611 case 168: /* returning ::= RETURNING selcollist */
161612 {sqlite3AddReturning(pParse,yymsp[0].minor.yy338);}
161613 break;
161614 case 172: /* idlist_opt ::= LP idlist RP */
161615 {yymsp[-2].minor.yy288 = yymsp[-1].minor.yy288;}
161616 break;
161617 case 173: /* idlist ::= idlist COMMA nm */
161618 {yymsp[-2].minor.yy288 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy288,&yymsp[0].minor.yy0);}
161619 break;
161620 case 174: /* idlist ::= nm */
161621 {yymsp[0].minor.yy288 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
161622 break;
161623 case 175: /* expr ::= LP expr RP */
161624 {yymsp[-2].minor.yy602 = yymsp[-1].minor.yy602;}
161625 break;
161626 case 176: /* expr ::= ID|INDEXED */
161627 case 177: /* expr ::= JOIN_KW */ yytestcase(yyruleno==177);
161628 {yymsp[0].minor.yy602=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
161629 break;
161630 case 178: /* expr ::= nm DOT nm */
161631 {
161632 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
161633 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
161634 if( IN_RENAME_OBJECT ){
161635 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
161636 sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
161637 }
161638 yylhsminor.yy602 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
161639 }
161640 yymsp[-2].minor.yy602 = yylhsminor.yy602;
161641 break;
161642 case 179: /* expr ::= nm DOT nm DOT nm */
161643 {
161644 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
161645 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
@@ -161647,322 +162228,322 @@
161647 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
161648 if( IN_RENAME_OBJECT ){
161649 sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
161650 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
161651 }
161652 yylhsminor.yy602 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
161653 }
161654 yymsp[-4].minor.yy602 = yylhsminor.yy602;
161655 break;
161656 case 180: /* term ::= NULL|FLOAT|BLOB */
161657 case 181: /* term ::= STRING */ yytestcase(yyruleno==181);
161658 {yymsp[0].minor.yy602=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
161659 break;
161660 case 182: /* term ::= INTEGER */
161661 {
161662 yylhsminor.yy602 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
161663 }
161664 yymsp[0].minor.yy602 = yylhsminor.yy602;
161665 break;
161666 case 183: /* expr ::= VARIABLE */
161667 {
161668 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
161669 u32 n = yymsp[0].minor.yy0.n;
161670 yymsp[0].minor.yy602 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
161671 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy602, n);
161672 }else{
161673 /* When doing a nested parse, one can include terms in an expression
161674 ** that look like this: #1 #2 ... These terms refer to registers
161675 ** in the virtual machine. #N is the N-th register. */
161676 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
161677 assert( t.n>=2 );
161678 if( pParse->nested==0 ){
161679 sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
161680 yymsp[0].minor.yy602 = 0;
161681 }else{
161682 yymsp[0].minor.yy602 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
161683 if( yymsp[0].minor.yy602 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy602->iTable);
161684 }
161685 }
161686 }
161687 break;
161688 case 184: /* expr ::= expr COLLATE ID|STRING */
161689 {
161690 yymsp[-2].minor.yy602 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy602, &yymsp[0].minor.yy0, 1);
161691 }
161692 break;
161693 case 185: /* expr ::= CAST LP expr AS typetoken RP */
161694 {
161695 yymsp[-5].minor.yy602 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
161696 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy602, yymsp[-3].minor.yy602, 0);
161697 }
161698 break;
161699 case 186: /* expr ::= ID|INDEXED LP distinct exprlist RP */
161700 {
161701 yylhsminor.yy602 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy338, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy60);
161702 }
161703 yymsp[-4].minor.yy602 = yylhsminor.yy602;
161704 break;
161705 case 187: /* expr ::= ID|INDEXED LP STAR RP */
161706 {
161707 yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
161708 }
161709 yymsp[-3].minor.yy602 = yylhsminor.yy602;
161710 break;
161711 case 188: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
161712 {
161713 yylhsminor.yy602 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy338, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy60);
161714 sqlite3WindowAttach(pParse, yylhsminor.yy602, yymsp[0].minor.yy19);
161715 }
161716 yymsp[-5].minor.yy602 = yylhsminor.yy602;
161717 break;
161718 case 189: /* expr ::= ID|INDEXED LP STAR RP filter_over */
161719 {
161720 yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
161721 sqlite3WindowAttach(pParse, yylhsminor.yy602, yymsp[0].minor.yy19);
161722 }
161723 yymsp[-4].minor.yy602 = yylhsminor.yy602;
161724 break;
161725 case 190: /* term ::= CTIME_KW */
161726 {
161727 yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
161728 }
161729 yymsp[0].minor.yy602 = yylhsminor.yy602;
161730 break;
161731 case 191: /* expr ::= LP nexprlist COMMA expr RP */
161732 {
161733 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy338, yymsp[-1].minor.yy602);
161734 yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
161735 if( yymsp[-4].minor.yy602 ){
161736 yymsp[-4].minor.yy602->x.pList = pList;
161737 if( ALWAYS(pList->nExpr) ){
161738 yymsp[-4].minor.yy602->flags |= pList->a[0].pExpr->flags & EP_Propagate;
161739 }
161740 }else{
161741 sqlite3ExprListDelete(pParse->db, pList);
161742 }
161743 }
161744 break;
161745 case 192: /* expr ::= expr AND expr */
161746 {yymsp[-2].minor.yy602=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);}
161747 break;
161748 case 193: /* expr ::= expr OR expr */
161749 case 194: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==194);
161750 case 195: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==195);
161751 case 196: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==196);
161752 case 197: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==197);
161753 case 198: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==198);
161754 case 199: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==199);
161755 {yymsp[-2].minor.yy602=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);}
161756 break;
161757 case 200: /* likeop ::= NOT LIKE_KW|MATCH */
161758 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
161759 break;
161760 case 201: /* expr ::= expr likeop expr */
161761 {
161762 ExprList *pList;
161763 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
161764 yymsp[-1].minor.yy0.n &= 0x7fffffff;
161765 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy602);
161766 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy602);
161767 yymsp[-2].minor.yy602 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
161768 if( bNot ) yymsp[-2].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy602, 0);
161769 if( yymsp[-2].minor.yy602 ) yymsp[-2].minor.yy602->flags |= EP_InfixFunc;
161770 }
161771 break;
161772 case 202: /* expr ::= expr likeop expr ESCAPE expr */
161773 {
161774 ExprList *pList;
161775 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
161776 yymsp[-3].minor.yy0.n &= 0x7fffffff;
161777 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602);
161778 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy602);
161779 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy602);
161780 yymsp[-4].minor.yy602 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
161781 if( bNot ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0);
161782 if( yymsp[-4].minor.yy602 ) yymsp[-4].minor.yy602->flags |= EP_InfixFunc;
161783 }
161784 break;
161785 case 203: /* expr ::= expr ISNULL|NOTNULL */
161786 {yymsp[-1].minor.yy602 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy602,0);}
161787 break;
161788 case 204: /* expr ::= expr NOT NULL */
161789 {yymsp[-2].minor.yy602 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy602,0);}
161790 break;
161791 case 205: /* expr ::= expr IS expr */
161792 {
161793 yymsp[-2].minor.yy602 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);
161794 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy602, yymsp[-2].minor.yy602, TK_ISNULL);
161795 }
161796 break;
161797 case 206: /* expr ::= expr IS NOT expr */
161798 {
161799 yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy602,yymsp[0].minor.yy602);
161800 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy602, yymsp[-3].minor.yy602, TK_NOTNULL);
161801 }
161802 break;
161803 case 207: /* expr ::= NOT expr */
161804 case 208: /* expr ::= BITNOT expr */ yytestcase(yyruleno==208);
161805 {yymsp[-1].minor.yy602 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy602, 0);/*A-overwrites-B*/}
161806 break;
161807 case 209: /* expr ::= PLUS|MINUS expr */
161808 {
161809 yymsp[-1].minor.yy602 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy602, 0);
161810 /*A-overwrites-B*/
161811 }
161812 break;
161813 case 210: /* between_op ::= BETWEEN */
161814 case 213: /* in_op ::= IN */ yytestcase(yyruleno==213);
161815 {yymsp[0].minor.yy60 = 0;}
161816 break;
161817 case 212: /* expr ::= expr between_op expr AND expr */
161818 {
161819 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602);
161820 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy602);
161821 yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy602, 0);
161822 if( yymsp[-4].minor.yy602 ){
161823 yymsp[-4].minor.yy602->x.pList = pList;
161824 }else{
161825 sqlite3ExprListDelete(pParse->db, pList);
161826 }
161827 if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0);
161828 }
161829 break;
161830 case 215: /* expr ::= expr in_op LP exprlist RP */
161831 {
161832 if( yymsp[-1].minor.yy338==0 ){
161833 /* Expressions of the form
161834 **
161835 ** expr1 IN ()
161836 ** expr1 NOT IN ()
161837 **
161838 ** simplify to constants 0 (false) and 1 (true), respectively,
161839 ** regardless of the value of expr1.
161840 */
161841 sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy602);
161842 yymsp[-4].minor.yy602 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy60 ? "1" : "0");
161843 }else if( yymsp[-1].minor.yy338->nExpr==1 && sqlite3ExprIsConstant(yymsp[-1].minor.yy338->a[0].pExpr) ){
161844 Expr *pRHS = yymsp[-1].minor.yy338->a[0].pExpr;
161845 yymsp[-1].minor.yy338->a[0].pExpr = 0;
161846 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy338);
161847 pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
161848 yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy602, pRHS);
161849 if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0);
161850 }else{
161851 yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0);
161852 if( yymsp[-4].minor.yy602 ){
161853 yymsp[-4].minor.yy602->x.pList = yymsp[-1].minor.yy338;
161854 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy602);
161855 }else{
161856 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy338);
161857 }
161858 if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0);
161859 }
161860 }
161861 break;
161862 case 216: /* expr ::= LP select RP */
161863 {
161864 yymsp[-2].minor.yy602 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
161865 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy602, yymsp[-1].minor.yy307);
161866 }
161867 break;
161868 case 217: /* expr ::= expr in_op LP select RP */
161869 {
161870 yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0);
161871 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy602, yymsp[-1].minor.yy307);
161872 if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0);
161873 }
161874 break;
161875 case 218: /* expr ::= expr in_op nm dbnm paren_exprlist */
161876 {
161877 SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
161878 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
161879 if( yymsp[0].minor.yy338 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy338);
161880 yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0);
161881 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy602, pSelect);
161882 if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0);
161883 }
161884 break;
161885 case 219: /* expr ::= EXISTS LP select RP */
161886 {
161887 Expr *p;
161888 p = yymsp[-3].minor.yy602 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
161889 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy307);
161890 }
161891 break;
161892 case 220: /* expr ::= CASE case_operand case_exprlist case_else END */
161893 {
161894 yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy602, 0);
161895 if( yymsp[-4].minor.yy602 ){
161896 yymsp[-4].minor.yy602->x.pList = yymsp[-1].minor.yy602 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy338,yymsp[-1].minor.yy602) : yymsp[-2].minor.yy338;
161897 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy602);
161898 }else{
161899 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy338);
161900 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy602);
161901 }
161902 }
161903 break;
161904 case 221: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
161905 {
161906 yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, yymsp[-2].minor.yy602);
161907 yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, yymsp[0].minor.yy602);
161908 }
161909 break;
161910 case 222: /* case_exprlist ::= WHEN expr THEN expr */
161911 {
161912 yymsp[-3].minor.yy338 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602);
161913 yymsp[-3].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy338, yymsp[0].minor.yy602);
161914 }
161915 break;
161916 case 225: /* case_operand ::= expr */
161917 {yymsp[0].minor.yy602 = yymsp[0].minor.yy602; /*A-overwrites-X*/}
161918 break;
161919 case 228: /* nexprlist ::= nexprlist COMMA expr */
161920 {yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy338,yymsp[0].minor.yy602);}
161921 break;
161922 case 229: /* nexprlist ::= expr */
161923 {yymsp[0].minor.yy338 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy602); /*A-overwrites-Y*/}
161924 break;
161925 case 231: /* paren_exprlist ::= LP exprlist RP */
161926 case 236: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==236);
161927 {yymsp[-2].minor.yy338 = yymsp[-1].minor.yy338;}
161928 break;
161929 case 232: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
161930 {
161931 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
161932 sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy338, yymsp[-10].minor.yy60,
161933 &yymsp[-11].minor.yy0, yymsp[0].minor.yy602, SQLITE_SO_ASC, yymsp[-8].minor.yy60, SQLITE_IDXTYPE_APPDEF);
161934 if( IN_RENAME_OBJECT && pParse->pNewIndex ){
161935 sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
161936 }
161937 }
161938 break;
161939 case 233: /* uniqueflag ::= UNIQUE */
161940 case 275: /* raisetype ::= ABORT */ yytestcase(yyruleno==275);
161941 {yymsp[0].minor.yy60 = OE_Abort;}
161942 break;
161943 case 234: /* uniqueflag ::= */
161944 {yymsp[1].minor.yy60 = OE_None;}
161945 break;
161946 case 237: /* eidlist ::= eidlist COMMA nm collate sortorder */
161947 {
161948 yymsp[-4].minor.yy338 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy338, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy60, yymsp[0].minor.yy60);
161949 }
161950 break;
161951 case 238: /* eidlist ::= nm collate sortorder */
161952 {
161953 yymsp[-2].minor.yy338 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy60, yymsp[0].minor.yy60); /*A-overwrites-Y*/
161954 }
161955 break;
161956 case 241: /* cmd ::= DROP INDEX ifexists fullname */
161957 {sqlite3DropIndex(pParse, yymsp[0].minor.yy291, yymsp[-1].minor.yy60);}
161958 break;
161959 case 242: /* cmd ::= VACUUM vinto */
161960 {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy602);}
161961 break;
161962 case 243: /* cmd ::= VACUUM nm vinto */
161963 {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy602);}
161964 break;
161965 case 246: /* cmd ::= PRAGMA nm dbnm */
161966 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
161967 break;
161968 case 247: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
@@ -161980,54 +162561,54 @@
161980 case 253: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
161981 {
161982 Token all;
161983 all.z = yymsp[-3].minor.yy0.z;
161984 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
161985 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy483, &all);
161986 }
161987 break;
161988 case 254: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
161989 {
161990 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy60, yymsp[-4].minor.yy50.a, yymsp[-4].minor.yy50.b, yymsp[-2].minor.yy291, yymsp[0].minor.yy602, yymsp[-10].minor.yy60, yymsp[-8].minor.yy60);
161991 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
161992 }
161993 break;
161994 case 255: /* trigger_time ::= BEFORE|AFTER */
161995 { yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-X*/ }
161996 break;
161997 case 256: /* trigger_time ::= INSTEAD OF */
161998 { yymsp[-1].minor.yy60 = TK_INSTEAD;}
161999 break;
162000 case 257: /* trigger_time ::= */
162001 { yymsp[1].minor.yy60 = TK_BEFORE; }
162002 break;
162003 case 258: /* trigger_event ::= DELETE|INSERT */
162004 case 259: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==259);
162005 {yymsp[0].minor.yy50.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy50.b = 0;}
162006 break;
162007 case 260: /* trigger_event ::= UPDATE OF idlist */
162008 {yymsp[-2].minor.yy50.a = TK_UPDATE; yymsp[-2].minor.yy50.b = yymsp[0].minor.yy288;}
162009 break;
162010 case 261: /* when_clause ::= */
162011 case 280: /* key_opt ::= */ yytestcase(yyruleno==280);
162012 { yymsp[1].minor.yy602 = 0; }
162013 break;
162014 case 262: /* when_clause ::= WHEN expr */
162015 case 281: /* key_opt ::= KEY expr */ yytestcase(yyruleno==281);
162016 { yymsp[-1].minor.yy602 = yymsp[0].minor.yy602; }
162017 break;
162018 case 263: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
162019 {
162020 assert( yymsp[-2].minor.yy483!=0 );
162021 yymsp[-2].minor.yy483->pLast->pNext = yymsp[-1].minor.yy483;
162022 yymsp[-2].minor.yy483->pLast = yymsp[-1].minor.yy483;
162023 }
162024 break;
162025 case 264: /* trigger_cmd_list ::= trigger_cmd SEMI */
162026 {
162027 assert( yymsp[-1].minor.yy483!=0 );
162028 yymsp[-1].minor.yy483->pLast = yymsp[-1].minor.yy483;
162029 }
162030 break;
162031 case 265: /* trnm ::= nm DOT nm */
162032 {
162033 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
@@ -162049,62 +162630,62 @@
162049 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
162050 "within triggers");
162051 }
162052 break;
162053 case 268: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
162054 {yylhsminor.yy483 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy291, yymsp[-3].minor.yy338, yymsp[-1].minor.yy602, yymsp[-7].minor.yy60, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy528);}
162055 yymsp[-8].minor.yy483 = yylhsminor.yy483;
162056 break;
162057 case 269: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
162058 {
162059 yylhsminor.yy483 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy288,yymsp[-2].minor.yy307,yymsp[-6].minor.yy60,yymsp[-1].minor.yy178,yymsp[-7].minor.yy528,yymsp[0].minor.yy528);/*yylhsminor.yy483-overwrites-yymsp[-6].minor.yy60*/
162060 }
162061 yymsp[-7].minor.yy483 = yylhsminor.yy483;
162062 break;
162063 case 270: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
162064 {yylhsminor.yy483 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy602, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy528);}
162065 yymsp[-5].minor.yy483 = yylhsminor.yy483;
162066 break;
162067 case 271: /* trigger_cmd ::= scanpt select scanpt */
162068 {yylhsminor.yy483 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy307, yymsp[-2].minor.yy528, yymsp[0].minor.yy528); /*yylhsminor.yy483-overwrites-yymsp[-1].minor.yy307*/}
162069 yymsp[-2].minor.yy483 = yylhsminor.yy483;
162070 break;
162071 case 272: /* expr ::= RAISE LP IGNORE RP */
162072 {
162073 yymsp[-3].minor.yy602 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
162074 if( yymsp[-3].minor.yy602 ){
162075 yymsp[-3].minor.yy602->affExpr = OE_Ignore;
162076 }
162077 }
162078 break;
162079 case 273: /* expr ::= RAISE LP raisetype COMMA nm RP */
162080 {
162081 yymsp[-5].minor.yy602 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
162082 if( yymsp[-5].minor.yy602 ) {
162083 yymsp[-5].minor.yy602->affExpr = (char)yymsp[-3].minor.yy60;
162084 }
162085 }
162086 break;
162087 case 274: /* raisetype ::= ROLLBACK */
162088 {yymsp[0].minor.yy60 = OE_Rollback;}
162089 break;
162090 case 276: /* raisetype ::= FAIL */
162091 {yymsp[0].minor.yy60 = OE_Fail;}
162092 break;
162093 case 277: /* cmd ::= DROP TRIGGER ifexists fullname */
162094 {
162095 sqlite3DropTrigger(pParse,yymsp[0].minor.yy291,yymsp[-1].minor.yy60);
162096 }
162097 break;
162098 case 278: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
162099 {
162100 sqlite3Attach(pParse, yymsp[-3].minor.yy602, yymsp[-1].minor.yy602, yymsp[0].minor.yy602);
162101 }
162102 break;
162103 case 279: /* cmd ::= DETACH database_kw_opt expr */
162104 {
162105 sqlite3Detach(pParse, yymsp[0].minor.yy602);
162106 }
162107 break;
162108 case 282: /* cmd ::= REINDEX */
162109 {sqlite3Reindex(pParse, 0, 0);}
162110 break;
@@ -162117,11 +162698,11 @@
162117 case 285: /* cmd ::= ANALYZE nm dbnm */
162118 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
162119 break;
162120 case 286: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
162121 {
162122 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy291,&yymsp[0].minor.yy0);
162123 }
162124 break;
162125 case 287: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
162126 {
162127 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
@@ -162128,22 +162709,22 @@
162128 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
162129 }
162130 break;
162131 case 288: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
162132 {
162133 sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy291, &yymsp[0].minor.yy0);
162134 }
162135 break;
162136 case 289: /* add_column_fullname ::= fullname */
162137 {
162138 disableLookaside(pParse);
162139 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy291);
162140 }
162141 break;
162142 case 290: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
162143 {
162144 sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy291, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
162145 }
162146 break;
162147 case 291: /* cmd ::= create_vtab */
162148 {sqlite3VtabFinishParse(pParse,0);}
162149 break;
@@ -162150,11 +162731,11 @@
162150 case 292: /* cmd ::= create_vtab LP vtabarglist RP */
162151 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
162152 break;
162153 case 293: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
162154 {
162155 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy60);
162156 }
162157 break;
162158 case 294: /* vtabarg ::= */
162159 {sqlite3VtabArgInit(pParse);}
162160 break;
@@ -162163,176 +162744,180 @@
162163 case 297: /* lp ::= LP */ yytestcase(yyruleno==297);
162164 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
162165 break;
162166 case 298: /* with ::= WITH wqlist */
162167 case 299: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==299);
162168 { sqlite3WithPush(pParse, yymsp[0].minor.yy195, 1); }
162169 break;
162170 case 300: /* wqas ::= AS */
162171 {yymsp[0].minor.yy570 = M10d_Any;}
162172 break;
162173 case 301: /* wqas ::= AS MATERIALIZED */
162174 {yymsp[-1].minor.yy570 = M10d_Yes;}
162175 break;
162176 case 302: /* wqas ::= AS NOT MATERIALIZED */
162177 {yymsp[-2].minor.yy570 = M10d_No;}
162178 break;
162179 case 303: /* wqitem ::= nm eidlist_opt wqas LP select RP */
162180 {
162181 yymsp[-5].minor.yy607 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy338, yymsp[-1].minor.yy307, yymsp[-3].minor.yy570); /*A-overwrites-X*/
162182 }
162183 break;
162184 case 304: /* wqlist ::= wqitem */
162185 {
162186 yymsp[0].minor.yy195 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy607); /*A-overwrites-X*/
162187 }
162188 break;
162189 case 305: /* wqlist ::= wqlist COMMA wqitem */
162190 {
162191 yymsp[-2].minor.yy195 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy195, yymsp[0].minor.yy607);
162192 }
162193 break;
162194 case 306: /* windowdefn_list ::= windowdefn */
162195 { yylhsminor.yy19 = yymsp[0].minor.yy19; }
162196 yymsp[0].minor.yy19 = yylhsminor.yy19;
162197 break;
162198 case 307: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
162199 {
162200 assert( yymsp[0].minor.yy19!=0 );
162201 sqlite3WindowChain(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy19);
162202 yymsp[0].minor.yy19->pNextWin = yymsp[-2].minor.yy19;
162203 yylhsminor.yy19 = yymsp[0].minor.yy19;
162204 }
162205 yymsp[-2].minor.yy19 = yylhsminor.yy19;
162206 break;
162207 case 308: /* windowdefn ::= nm AS LP window RP */
162208 {
162209 if( ALWAYS(yymsp[-1].minor.yy19) ){
162210 yymsp[-1].minor.yy19->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
162211 }
162212 yylhsminor.yy19 = yymsp[-1].minor.yy19;
162213 }
162214 yymsp[-4].minor.yy19 = yylhsminor.yy19;
162215 break;
162216 case 309: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
162217 {
162218 yymsp[-4].minor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy338, yymsp[-1].minor.yy338, 0);
162219 }
162220 break;
162221 case 310: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
162222 {
162223 yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy338, yymsp[-1].minor.yy338, &yymsp[-5].minor.yy0);
162224 }
162225 yymsp[-5].minor.yy19 = yylhsminor.yy19;
162226 break;
162227 case 311: /* window ::= ORDER BY sortlist frame_opt */
162228 {
162229 yymsp[-3].minor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, yymsp[-1].minor.yy338, 0);
162230 }
162231 break;
162232 case 312: /* window ::= nm ORDER BY sortlist frame_opt */
162233 {
162234 yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, yymsp[-1].minor.yy338, &yymsp[-4].minor.yy0);
162235 }
162236 yymsp[-4].minor.yy19 = yylhsminor.yy19;
162237 break;
162238 case 313: /* window ::= frame_opt */
162239 case 332: /* filter_over ::= over_clause */ yytestcase(yyruleno==332);
162240 {
162241 yylhsminor.yy19 = yymsp[0].minor.yy19;
162242 }
162243 yymsp[0].minor.yy19 = yylhsminor.yy19;
162244 break;
162245 case 314: /* window ::= nm frame_opt */
162246 {
162247 yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, 0, &yymsp[-1].minor.yy0);
162248 }
162249 yymsp[-1].minor.yy19 = yylhsminor.yy19;
162250 break;
162251 case 315: /* frame_opt ::= */
162252 {
162253 yymsp[1].minor.yy19 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
162254 }
162255 break;
162256 case 316: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
162257 {
162258 yylhsminor.yy19 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy60, yymsp[-1].minor.yy113.eType, yymsp[-1].minor.yy113.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy570);
162259 }
162260 yymsp[-2].minor.yy19 = yylhsminor.yy19;
162261 break;
162262 case 317: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
162263 {
162264 yylhsminor.yy19 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy60, yymsp[-3].minor.yy113.eType, yymsp[-3].minor.yy113.pExpr, yymsp[-1].minor.yy113.eType, yymsp[-1].minor.yy113.pExpr, yymsp[0].minor.yy570);
162265 }
162266 yymsp[-5].minor.yy19 = yylhsminor.yy19;
162267 break;
162268 case 319: /* frame_bound_s ::= frame_bound */
162269 case 321: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==321);
162270 {yylhsminor.yy113 = yymsp[0].minor.yy113;}
162271 yymsp[0].minor.yy113 = yylhsminor.yy113;
162272 break;
162273 case 320: /* frame_bound_s ::= UNBOUNDED PRECEDING */
162274 case 322: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==322);
162275 case 324: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==324);
162276 {yylhsminor.yy113.eType = yymsp[-1].major; yylhsminor.yy113.pExpr = 0;}
162277 yymsp[-1].minor.yy113 = yylhsminor.yy113;
162278 break;
162279 case 323: /* frame_bound ::= expr PRECEDING|FOLLOWING */
162280 {yylhsminor.yy113.eType = yymsp[0].major; yylhsminor.yy113.pExpr = yymsp[-1].minor.yy602;}
162281 yymsp[-1].minor.yy113 = yylhsminor.yy113;
162282 break;
162283 case 325: /* frame_exclude_opt ::= */
162284 {yymsp[1].minor.yy570 = 0;}
162285 break;
162286 case 326: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
162287 {yymsp[-1].minor.yy570 = yymsp[0].minor.yy570;}
162288 break;
162289 case 327: /* frame_exclude ::= NO OTHERS */
162290 case 328: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==328);
162291 {yymsp[-1].minor.yy570 = yymsp[-1].major; /*A-overwrites-X*/}
162292 break;
162293 case 329: /* frame_exclude ::= GROUP|TIES */
162294 {yymsp[0].minor.yy570 = yymsp[0].major; /*A-overwrites-X*/}
162295 break;
162296 case 330: /* window_clause ::= WINDOW windowdefn_list */
162297 { yymsp[-1].minor.yy19 = yymsp[0].minor.yy19; }
162298 break;
162299 case 331: /* filter_over ::= filter_clause over_clause */
162300 {
162301 yymsp[0].minor.yy19->pFilter = yymsp[-1].minor.yy602;
162302 yylhsminor.yy19 = yymsp[0].minor.yy19;
 
 
 
 
162303 }
162304 yymsp[-1].minor.yy19 = yylhsminor.yy19;
162305 break;
162306 case 333: /* filter_over ::= filter_clause */
162307 {
162308 yylhsminor.yy19 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
162309 if( yylhsminor.yy19 ){
162310 yylhsminor.yy19->eFrmType = TK_FILTER;
162311 yylhsminor.yy19->pFilter = yymsp[0].minor.yy602;
162312 }else{
162313 sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy602);
162314 }
162315 }
162316 yymsp[0].minor.yy19 = yylhsminor.yy19;
162317 break;
162318 case 334: /* over_clause ::= OVER LP window RP */
162319 {
162320 yymsp[-3].minor.yy19 = yymsp[-1].minor.yy19;
162321 assert( yymsp[-3].minor.yy19!=0 );
162322 }
162323 break;
162324 case 335: /* over_clause ::= OVER nm */
162325 {
162326 yymsp[-1].minor.yy19 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
162327 if( yymsp[-1].minor.yy19 ){
162328 yymsp[-1].minor.yy19->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
162329 }
162330 }
162331 break;
162332 case 336: /* filter_clause ::= FILTER LP WHERE expr RP */
162333 { yymsp[-4].minor.yy602 = yymsp[-1].minor.yy602; }
162334 break;
162335 default:
162336 /* (337) input ::= cmdlist */ yytestcase(yyruleno==337);
162337 /* (338) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==338);
162338 /* (339) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=339);
@@ -162795,10 +163380,11 @@
162795 #define CC_TILDA 25 /* '~' */
162796 #define CC_DOT 26 /* '.' */
162797 #define CC_ID 27 /* unicode characters usable in IDs */
162798 #define CC_ILLEGAL 28 /* Illegal character */
162799 #define CC_NUL 29 /* 0x00 */
 
162800
162801 static const unsigned char aiClass[] = {
162802 #ifdef SQLITE_ASCII
162803 /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
162804 /* 0x */ 29, 28, 28, 28, 28, 28, 28, 28, 28, 7, 7, 28, 7, 7, 28, 28,
@@ -162807,18 +163393,18 @@
162807 /* 3x */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 19, 12, 14, 13, 6,
162808 /* 4x */ 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
162809 /* 5x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 9, 28, 28, 28, 2,
162810 /* 6x */ 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
162811 /* 7x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 28, 10, 28, 25, 28,
162812 /* 8x */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162813 /* 9x */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162814 /* Ax */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162815 /* Bx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162816 /* Cx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162817 /* Dx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162818 /* Ex */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162819 /* Fx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
162820 #endif
162821 #ifdef SQLITE_EBCDIC
162822 /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
162823 /* 0x */ 29, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 7, 7, 28, 28,
162824 /* 1x */ 28, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
@@ -163757,10 +164343,18 @@
163757 ** SQL keywords start with the letter 'x'. Fall through */
163758 /* no break */ deliberate_fall_through
163759 }
163760 case CC_KYWD:
163761 case CC_ID: {
 
 
 
 
 
 
 
 
163762 i = 1;
163763 break;
163764 }
163765 case CC_NUL: {
163766 *tokenType = TK_ILLEGAL;
@@ -164776,11 +165370,11 @@
164776 }
164777 if( rc==SQLITE_OK ){
164778 sqlite3GlobalConfig.isPCacheInit = 1;
164779 rc = sqlite3OsInit();
164780 }
164781 #ifdef SQLITE_ENABLE_DESERIALIZE
164782 if( rc==SQLITE_OK ){
164783 rc = sqlite3MemdbInit();
164784 }
164785 #endif
164786 if( rc==SQLITE_OK ){
@@ -165191,16 +165785,16 @@
165191 sqlite3GlobalConfig.szSorterRef = (u32)iVal;
165192 break;
165193 }
165194 #endif /* SQLITE_ENABLE_SORTER_REFERENCES */
165195
165196 #ifdef SQLITE_ENABLE_DESERIALIZE
165197 case SQLITE_CONFIG_MEMDB_MAXSIZE: {
165198 sqlite3GlobalConfig.mxMemdbSize = va_arg(ap, sqlite3_int64);
165199 break;
165200 }
165201 #endif /* SQLITE_ENABLE_DESERIALIZE */
165202
165203 default: {
165204 rc = SQLITE_ERROR;
165205 break;
165206 }
@@ -165745,11 +166339,11 @@
165745 }
165746
165747 /*
165748 ** Two variations on the public interface for closing a database
165749 ** connection. The sqlite3_close() version returns SQLITE_BUSY and
165750 ** leaves the connection option if there are unfinalized prepared
165751 ** statements or unfinished sqlite3_backups. The sqlite3_close_v2()
165752 ** version forces the connection to become a zombie if there are
165753 ** unclosed resources, and arranges for deallocation when the last
165754 ** prepare statement or sqlite3_backup closes.
165755 */
@@ -166355,10 +166949,14 @@
166355 assert( !db->mallocFailed );
166356 return SQLITE_BUSY;
166357 }else{
166358 sqlite3ExpirePreparedStatements(db, 0);
166359 }
 
 
 
 
166360 }
166361
166362 p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1);
166363 assert(p || db->mallocFailed);
166364 if( !p ){
@@ -168750,10 +169348,40 @@
168750 case 2: *ptr = sqlite3WhereTrace; break;
168751 case 3: sqlite3WhereTrace = *ptr; break;
168752 }
168753 break;
168754 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168755 }
168756 va_end(ap);
168757 #endif /* SQLITE_UNTESTABLE */
168758 return rc;
168759 }
@@ -172321,11 +172949,11 @@
172321 const char *zCsr = zNode; /* Cursor to iterate through node */
172322 const char *zEnd = &zCsr[nNode];/* End of interior node buffer */
172323 char *zBuffer = 0; /* Buffer to load terms into */
172324 i64 nAlloc = 0; /* Size of allocated buffer */
172325 int isFirstTerm = 1; /* True when processing first term on page */
172326 sqlite3_int64 iChild; /* Block id of child node to descend to */
172327 int nBuffer = 0; /* Total term size */
172328
172329 /* Skip over the 'height' varint that occurs at the start of every
172330 ** interior node. Then load the blockid of the left-child of the b-tree
172331 ** node into variable iChild.
@@ -172337,12 +172965,12 @@
172337 ** either more than 20 bytes of allocated space following the nNode bytes of
172338 ** contents, or two zero bytes. Or, if the node is read from the %_segments
172339 ** table, then there are always 20 bytes of zeroed padding following the
172340 ** nNode bytes of content (see sqlite3Fts3ReadBlock() for details).
172341 */
172342 zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);
172343 zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);
172344 if( zCsr>zEnd ){
172345 return FTS_CORRUPT_VTAB;
172346 }
172347
172348 while( zCsr<zEnd && (piFirst || piLast) ){
@@ -172391,24 +173019,24 @@
172391 ** If the interior node term is larger than the specified term, then
172392 ** the tree headed by iChild may contain the specified term.
172393 */
172394 cmp = memcmp(zTerm, zBuffer, (nBuffer>nTerm ? nTerm : nBuffer));
172395 if( piFirst && (cmp<0 || (cmp==0 && nBuffer>nTerm)) ){
172396 *piFirst = iChild;
172397 piFirst = 0;
172398 }
172399
172400 if( piLast && cmp<0 ){
172401 *piLast = iChild;
172402 piLast = 0;
172403 }
172404
172405 iChild++;
172406 };
172407
172408 if( piFirst ) *piFirst = iChild;
172409 if( piLast ) *piLast = iChild;
172410
172411 finish_scan:
172412 sqlite3_free(zBuffer);
172413 return rc;
172414 }
@@ -175552,20 +176180,19 @@
175552
175553 /* Determine which, if any, tokens in the expression should be deferred. */
175554 #ifndef SQLITE_DISABLE_FTS4_DEFERRED
175555 if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){
175556 Fts3TokenAndCost *aTC;
175557 Fts3Expr **apOr;
175558 aTC = (Fts3TokenAndCost *)sqlite3_malloc64(
175559 sizeof(Fts3TokenAndCost) * nToken
175560 + sizeof(Fts3Expr *) * nOr * 2
175561 );
175562 apOr = (Fts3Expr **)&aTC[nToken];
175563
175564 if( !aTC ){
175565 rc = SQLITE_NOMEM;
175566 }else{
 
175567 int ii;
175568 Fts3TokenAndCost *pTC = aTC;
175569 Fts3Expr **ppOr = apOr;
175570
175571 fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);
@@ -176937,10 +177564,11 @@
176937 /* In case this cursor is being reused, close and zero it. */
176938 testcase(pCsr->filter.zTerm);
176939 sqlite3Fts3SegReaderFinish(&pCsr->csr);
176940 sqlite3_free((void *)pCsr->filter.zTerm);
176941 sqlite3_free(pCsr->aStat);
 
176942 memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr);
176943
176944 pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;
176945 if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN;
176946
@@ -182458,11 +183086,11 @@
182458 rc = (pLhs->aNode==0) - (pRhs->aNode==0);
182459 }
182460 if( rc==0 ){
182461 rc = pRhs->iIdx - pLhs->iIdx;
182462 }
182463 assert( rc!=0 );
182464 return rc;
182465 }
182466
182467 /*
182468 ** A different comparison function for SegReader structures. In this
@@ -182654,12 +183282,12 @@
182654 int nPrev, /* Size of buffer zPrev in bytes */
182655 const char *zNext, /* Buffer containing next term */
182656 int nNext /* Size of buffer zNext in bytes */
182657 ){
182658 int n;
182659 UNUSED_PARAMETER(nNext);
182660 for(n=0; n<nPrev && zPrev[n]==zNext[n]; n++);
182661 return n;
182662 }
182663
182664 /*
182665 ** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger
@@ -183654,11 +184282,11 @@
183654 iDelta = (i64)((u64)iDocid - (u64)iPrev);
183655 }
183656
183657 nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
183658
183659 rc = fts3GrowSegReaderBuffer(pCsr, nByte+nDoclist);
183660 if( rc ) return rc;
183661
183662 if( isFirst ){
183663 char *a = &pCsr->aBuffer[nDoclist];
183664 int nWrite;
@@ -186468,10 +187096,14 @@
186468 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
186469
186470 /* #include <string.h> */
186471 /* #include <assert.h> */
186472
 
 
 
 
186473 /*
186474 ** Characters that may appear in the second argument to matchinfo().
186475 */
186476 #define FTS3_MATCHINFO_NPHRASE 'p' /* 1 value */
186477 #define FTS3_MATCHINFO_NCOL 'c' /* 1 value */
@@ -186518,13 +187150,13 @@
186518 };
186519
186520 struct SnippetPhrase {
186521 int nToken; /* Number of tokens in phrase */
186522 char *pList; /* Pointer to start of phrase position list */
186523 int iHead; /* Next value in position list */
186524 char *pHead; /* Position list data following iHead */
186525 int iTail; /* Next value in trailing position list */
186526 char *pTail; /* Position list data following iTail */
186527 };
186528
186529 struct SnippetFragment {
186530 int iCol; /* Column snippet is extracted from */
@@ -186685,11 +187317,11 @@
186685 ** When this function is called, *pp points to the start of an element of
186686 ** the list. *piPos contains the value of the previous entry in the list.
186687 ** After it returns, *piPos contains the value of the next element of the
186688 ** list and *pp is advanced to the following varint.
186689 */
186690 static void fts3GetDeltaPosition(char **pp, int *piPos){
186691 int iVal;
186692 *pp += fts3GetVarint32(*pp, &iVal);
186693 *piPos += (iVal-2);
186694 }
186695
@@ -186794,14 +187426,14 @@
186794 /*
186795 ** Advance the position list iterator specified by the first two
186796 ** arguments so that it points to the first element with a value greater
186797 ** than or equal to parameter iNext.
186798 */
186799 static void fts3SnippetAdvance(char **ppIter, int *piIter, int iNext){
186800 char *pIter = *ppIter;
186801 if( pIter ){
186802 int iIter = *piIter;
186803
186804 while( iIter<iNext ){
186805 if( 0==(*pIter & 0xFE) ){
186806 iIter = -1;
186807 pIter = 0;
@@ -186880,11 +187512,11 @@
186880
186881 for(i=0; i<pIter->nPhrase; i++){
186882 SnippetPhrase *pPhrase = &pIter->aPhrase[i];
186883 if( pPhrase->pTail ){
186884 char *pCsr = pPhrase->pTail;
186885 int iCsr = pPhrase->iTail;
186886
186887 while( iCsr<(iStart+pIter->nSnippet) && iCsr>=iStart ){
186888 int j;
186889 u64 mPhrase = (u64)1 << (i%64);
186890 u64 mPos = (u64)1 << (iCsr - iStart);
@@ -186926,11 +187558,11 @@
186926
186927 pPhrase->nToken = pExpr->pPhrase->nToken;
186928 rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr);
186929 assert( rc==SQLITE_OK || pCsr==0 );
186930 if( pCsr ){
186931 int iFirst = 0;
186932 pPhrase->pList = pCsr;
186933 fts3GetDeltaPosition(&pCsr, &iFirst);
186934 if( iFirst<0 ){
186935 rc = FTS_CORRUPT_VTAB;
186936 }else{
@@ -187990,12 +188622,12 @@
187990 typedef struct TermOffset TermOffset;
187991 typedef struct TermOffsetCtx TermOffsetCtx;
187992
187993 struct TermOffset {
187994 char *pList; /* Position-list */
187995 int iPos; /* Position just read from pList */
187996 int iOff; /* Offset of this term from read positions */
187997 };
187998
187999 struct TermOffsetCtx {
188000 Fts3Cursor *pCsr;
188001 int iCol; /* Column of table to populate aTerm for */
@@ -188010,11 +188642,11 @@
188010 static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){
188011 TermOffsetCtx *p = (TermOffsetCtx *)ctx;
188012 int nTerm; /* Number of tokens in phrase */
188013 int iTerm; /* For looping through nTerm phrase terms */
188014 char *pList; /* Pointer to position list for phrase */
188015 int iPos = 0; /* First position in position-list */
188016 int rc;
188017
188018 UNUSED_PARAMETER(iPhrase);
188019 rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pList);
188020 nTerm = pExpr->pPhrase->nToken;
@@ -189287,11 +189919,11 @@
189287 ** any double-quotes or backslash characters contained within the
189288 ** string.
189289 */
189290 static void jsonAppendString(JsonString *p, const char *zIn, u32 N){
189291 u32 i;
189292 if( (N+p->nUsed+2 >= p->nAlloc) && jsonGrow(p,N+2)!=0 ) return;
189293 p->zBuf[p->nUsed++] = '"';
189294 for(i=0; i<N; i++){
189295 unsigned char c = ((unsigned const char*)zIn)[i];
189296 if( c=='"' || c=='\\' ){
189297 json_simple_escape:
@@ -190886,12 +191518,12 @@
190886 if( pStr->zBuf==0 ){
190887 jsonInit(pStr, ctx);
190888 jsonAppendChar(pStr, '[');
190889 }else if( pStr->nUsed>1 ){
190890 jsonAppendChar(pStr, ',');
190891 pStr->pCtx = ctx;
190892 }
 
190893 jsonAppendValue(pStr, argv[0]);
190894 }
190895 }
190896 static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){
190897 JsonString *pStr;
@@ -190947,26 +191579,27 @@
190947 /* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will
190948 ** always have been called to initalize it */
190949 if( NEVER(!pStr) ) return;
190950 #endif
190951 z = pStr->zBuf;
190952 for(i=1; (c = z[i])!=',' || inStr || nNest; i++){
190953 if( i>=pStr->nUsed ){
190954 pStr->nUsed = 1;
190955 return;
190956 }
190957 if( c=='"' ){
190958 inStr = !inStr;
190959 }else if( c=='\\' ){
190960 i++;
190961 }else if( !inStr ){
190962 if( c=='{' || c=='[' ) nNest++;
190963 if( c=='}' || c==']' ) nNest--;
190964 }
190965 }
190966 pStr->nUsed -= i;
190967 memmove(&z[1], &z[i+1], (size_t)pStr->nUsed-1);
 
 
 
 
 
190968 }
190969 #else
190970 # define jsonGroupInverse 0
190971 #endif
190972
@@ -190990,12 +191623,12 @@
190990 if( pStr->zBuf==0 ){
190991 jsonInit(pStr, ctx);
190992 jsonAppendChar(pStr, '{');
190993 }else if( pStr->nUsed>1 ){
190994 jsonAppendChar(pStr, ',');
190995 pStr->pCtx = ctx;
190996 }
 
190997 z = (const char*)sqlite3_value_text(argv[0]);
190998 n = (u32)sqlite3_value_bytes(argv[0]);
190999 jsonAppendString(pStr, z, n);
191000 jsonAppendChar(pStr, ':');
191001 jsonAppendValue(pStr, argv[1]);
@@ -195512,15 +196145,20 @@
195512 */
195513 static void rtreedepth(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){
195514 UNUSED_PARAMETER(nArg);
195515 if( sqlite3_value_type(apArg[0])!=SQLITE_BLOB
195516 || sqlite3_value_bytes(apArg[0])<2
 
195517 ){
195518 sqlite3_result_error(ctx, "Invalid argument to rtreedepth()", -1);
195519 }else{
195520 u8 *zBlob = (u8 *)sqlite3_value_blob(apArg[0]);
195521 sqlite3_result_int(ctx, readInt16(zBlob));
 
 
 
 
195522 }
195523 }
195524
195525 /*
195526 ** Context object passed between the various routines that make up the
@@ -201039,11 +201677,13 @@
201039 );
201040 if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSel) ){
201041 zSep = "";
201042 for(iCol=0; iCol<pIter->nCol; iCol++){
201043 const char *zQuoted = (const char*)sqlite3_column_text(pSel, iCol);
201044 if( zQuoted[0]=='N' ){
 
 
201045 bFailed = 1;
201046 break;
201047 }
201048 zVector = rbuMPrintf(p, "%z%s%s", zVector, zSep, zQuoted);
201049 zSep = ", ";
@@ -204411,32 +205051,18 @@
204411 }
204412 else if( flags & SQLITE_OPEN_WAL ){
204413 rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName, 0);
204414 if( pDb ){
204415 if( pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){
204416 /* This call is to open a *-wal file. Intead, open the *-oal. This
204417 ** code ensures that the string passed to xOpen() is terminated by a
204418 ** pair of '\0' bytes in case the VFS attempts to extract a URI
204419 ** parameter from it. */
204420 const char *zBase = zName;
204421 size_t nCopy;
204422 char *zCopy;
204423 if( rbuIsVacuum(pDb->pRbu) ){
204424 zBase = sqlite3_db_filename(pDb->pRbu->dbRbu, "main");
204425 zBase = sqlite3_filename_wal(zBase);
204426 }
204427 nCopy = strlen(zBase);
204428 zCopy = sqlite3_malloc64(nCopy+2);
204429 if( zCopy ){
204430 memcpy(zCopy, zBase, nCopy);
204431 zCopy[nCopy-3] = 'o';
204432 zCopy[nCopy] = '\0';
204433 zCopy[nCopy+1] = '\0';
204434 zOpen = (const char*)(pFd->zDel = zCopy);
204435 }else{
204436 rc = SQLITE_NOMEM;
204437 }
204438 pFd->pRbu = pDb->pRbu;
204439 }
204440 pDb->pWalFd = pFd;
204441 }
204442 }
@@ -206045,17 +206671,19 @@
206045 ** Session handle structure.
206046 */
206047 struct sqlite3_session {
206048 sqlite3 *db; /* Database handle session is attached to */
206049 char *zDb; /* Name of database session is attached to */
 
206050 int bEnable; /* True if currently recording */
206051 int bIndirect; /* True if all changes are indirect */
206052 int bAutoAttach; /* True to auto-attach tables */
206053 int rc; /* Non-zero if an error has occurred */
206054 void *pFilterCtx; /* First argument to pass to xTableFilter */
206055 int (*xTableFilter)(void *pCtx, const char *zTab);
206056 i64 nMalloc; /* Number of bytes of data allocated */
 
206057 sqlite3_value *pZeroBlob; /* Value containing X'' */
206058 sqlite3_session *pNext; /* Next session object on same db. */
206059 SessionTable *pTable; /* List of attached tables */
206060 SessionHook hook; /* APIs to grab new and old data with */
206061 };
@@ -206294,12 +206922,13 @@
206294 /*
206295 ** For each row modified during a session, there exists a single instance of
206296 ** this structure stored in a SessionTable.aChange[] hash table.
206297 */
206298 struct SessionChange {
206299 int op; /* One of UPDATE, DELETE, INSERT */
206300 int bIndirect; /* True if this change is "indirect" */
 
206301 int nRecord; /* Number of bytes in buffer aRecord[] */
206302 u8 *aRecord; /* Buffer containing old.* record */
206303 SessionChange *pNext; /* For hash-table collisions */
206304 };
206305
@@ -207124,10 +207753,16 @@
207124 }
207125 }
207126 if( 0==sqlite3_stricmp("sqlite_stat1", pTab->zName) ){
207127 pTab->bStat1 = 1;
207128 }
 
 
 
 
 
 
207129 }
207130 }
207131 return (pSession->rc || pTab->abPK==0);
207132 }
207133
@@ -207169,10 +207804,107 @@
207169 static int sessionStat1Depth(void *pCtx){
207170 SessionStat1Ctx *p = (SessionStat1Ctx*)pCtx;
207171 return p->hook.xDepth(p->hook.pCtx);
207172 }
207173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207174
207175 /*
207176 ** This function is only called from with a pre-update-hook reporting a
207177 ** change on table pTab (attached to session pSession). The type of change
207178 ** (UPDATE, INSERT, DELETE) is specified by the first argument.
@@ -207242,11 +207974,10 @@
207242
207243 if( pC==0 ){
207244 /* Create a new change object containing all the old values (if
207245 ** this is an SQLITE_UPDATE or SQLITE_DELETE), or just the PK
207246 ** values (if this is an INSERT). */
207247 SessionChange *pChange; /* New change object */
207248 sqlite3_int64 nByte; /* Number of bytes to allocate */
207249 int i; /* Used to iterate through columns */
207250
207251 assert( rc==SQLITE_OK );
207252 pTab->nEntry++;
@@ -207268,17 +207999,17 @@
207268 rc = sessionSerializeValue(0, p, &nByte);
207269 if( rc!=SQLITE_OK ) goto error_out;
207270 }
207271
207272 /* Allocate the change object */
207273 pChange = (SessionChange *)sessionMalloc64(pSession, nByte);
207274 if( !pChange ){
207275 rc = SQLITE_NOMEM;
207276 goto error_out;
207277 }else{
207278 memset(pChange, 0, sizeof(SessionChange));
207279 pChange->aRecord = (u8 *)&pChange[1];
207280 }
207281
207282 /* Populate the change object. None of the preupdate_old(),
207283 ** preupdate_new() or SerializeValue() calls below may fail as all
207284 ** required values and encodings have already been cached in memory.
@@ -207289,21 +208020,21 @@
207289 if( op!=SQLITE_INSERT ){
207290 pSession->hook.xOld(pSession->hook.pCtx, i, &p);
207291 }else if( pTab->abPK[i] ){
207292 pSession->hook.xNew(pSession->hook.pCtx, i, &p);
207293 }
207294 sessionSerializeValue(&pChange->aRecord[nByte], p, &nByte);
207295 }
207296
207297 /* Add the change to the hash-table */
207298 if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){
207299 pChange->bIndirect = 1;
207300 }
207301 pChange->nRecord = nByte;
207302 pChange->op = op;
207303 pChange->pNext = pTab->apChange[iHash];
207304 pTab->apChange[iHash] = pChange;
207305
207306 }else if( pC->bIndirect ){
207307 /* If the existing change is considered "indirect", but this current
207308 ** change is "direct", mark the change object as direct. */
207309 if( pSession->hook.xDepth(pSession->hook.pCtx)==0
@@ -207310,11 +208041,17 @@
207310 && pSession->bIndirect==0
207311 ){
207312 pC->bIndirect = 0;
207313 }
207314 }
 
 
 
 
 
207315 }
 
207316
207317 /* If an error has occurred, mark the session object as failed. */
207318 error_out:
207319 if( pTab->bStat1 ){
207320 pSession->hook = stat1.hook;
@@ -207866,17 +208603,33 @@
207866 ** If not, use sqlite3_realloc() to grow the buffer so that there is.
207867 **
207868 ** If successful, return zero. Otherwise, if an OOM condition is encountered,
207869 ** set *pRc to SQLITE_NOMEM and return non-zero.
207870 */
207871 static int sessionBufferGrow(SessionBuffer *p, size_t nByte, int *pRc){
207872 if( *pRc==SQLITE_OK && (size_t)(p->nAlloc-p->nBuf)<nByte ){
 
 
207873 u8 *aNew;
207874 i64 nNew = p->nAlloc ? p->nAlloc : 128;
 
207875 do {
207876 nNew = nNew*2;
207877 }while( (size_t)(nNew-p->nBuf)<nByte );
 
 
 
 
 
 
 
 
 
 
 
 
 
207878
207879 aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew);
207880 if( 0==aNew ){
207881 *pRc = SQLITE_NOMEM;
207882 }else{
@@ -208523,11 +209276,15 @@
208523 SQLITE_API int sqlite3session_changeset(
208524 sqlite3_session *pSession, /* Session object */
208525 int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
208526 void **ppChangeset /* OUT: Buffer containing changeset */
208527 ){
208528 return sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset, ppChangeset);
 
 
 
 
208529 }
208530
208531 /*
208532 ** Streaming version of sqlite3session_changeset().
208533 */
@@ -208614,10 +209371,43 @@
208614 ** Return the amount of heap memory in use.
208615 */
208616 SQLITE_API sqlite3_int64 sqlite3session_memory_used(sqlite3_session *pSession){
208617 return pSession->nMalloc;
208618 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208619
208620 /*
208621 ** Do the work for either sqlite3changeset_start() or start_strm().
208622 */
208623 static int sessionChangesetStart(
@@ -215435,10 +216225,11 @@
215435 return 1;
215436 }else{
215437 i64 iOff = *piOff;
215438 int iVal;
215439 fts5FastGetVarint32(a, i, iVal);
 
215440 if( iVal<=1 ){
215441 if( iVal==0 ){
215442 *pi = i;
215443 return 0;
215444 }
@@ -215448,13 +216239,16 @@
215448 if( iVal<2 ){
215449 /* This is a corrupt record. So stop parsing it here. */
215450 *piOff = -1;
215451 return 1;
215452 }
 
 
 
215453 }
215454 *piOff = iOff + ((iVal-2) & 0x7FFFFFFF);
215455 *pi = i;
 
215456 return 0;
215457 }
215458 }
215459
215460
@@ -215489,18 +216283,20 @@
215489 static void sqlite3Fts5PoslistSafeAppend(
215490 Fts5Buffer *pBuf,
215491 i64 *piPrev,
215492 i64 iPos
215493 ){
215494 static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32;
215495 if( (iPos & colmask) != (*piPrev & colmask) ){
215496 pBuf->p[pBuf->n++] = 1;
215497 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32));
215498 *piPrev = (iPos & colmask);
215499 }
215500 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2);
215501 *piPrev = iPos;
 
 
215502 }
215503
215504 static int sqlite3Fts5PoslistWriterAppend(
215505 Fts5Buffer *pBuf,
215506 Fts5PoslistWriter *pWriter,
@@ -216198,11 +216994,11 @@
216198 pRet->db = db;
216199 pRet->iCookie = -1;
216200
216201 nByte = nArg * (sizeof(char*) + sizeof(u8));
216202 pRet->azCol = (char**)sqlite3Fts5MallocZero(&rc, nByte);
216203 pRet->abUnindexed = (u8*)&pRet->azCol[nArg];
216204 pRet->zDb = sqlite3Fts5Strndup(&rc, azArg[1], -1);
216205 pRet->zName = sqlite3Fts5Strndup(&rc, azArg[2], -1);
216206 pRet->bColumnsize = 1;
216207 pRet->eDetail = FTS5_DETAIL_FULL;
216208 #ifdef SQLITE_DEBUG
@@ -219034,10 +219830,11 @@
219034 }
219035
219036 return pRet;
219037 }
219038
 
219039 static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){
219040 sqlite3_int64 nByte = 0;
219041 Fts5ExprTerm *p;
219042 char *zQuoted;
219043
@@ -219400,16 +220197,18 @@
219400 iCode = sqlite3_value_int(apVal[0]);
219401 if( nArg==2 ) bRemoveDiacritics = sqlite3_value_int(apVal[1]);
219402 sqlite3_result_int(pCtx, sqlite3Fts5UnicodeFold(iCode, bRemoveDiacritics));
219403 }
219404 }
 
219405
219406 /*
219407 ** This is called during initialization to register the fts5_expr() scalar
219408 ** UDF with the SQLite handle passed as the only argument.
219409 */
219410 static int sqlite3Fts5ExprInit(Fts5Global *pGlobal, sqlite3 *db){
 
219411 struct Fts5ExprFunc {
219412 const char *z;
219413 void (*x)(sqlite3_context*,int,sqlite3_value**);
219414 } aFunc[] = {
219415 { "fts5_expr", fts5ExprFunctionHr },
@@ -219423,10 +220222,14 @@
219423
219424 for(i=0; rc==SQLITE_OK && i<ArraySize(aFunc); i++){
219425 struct Fts5ExprFunc *p = &aFunc[i];
219426 rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0);
219427 }
 
 
 
 
219428
219429 /* Avoid warnings indicating that sqlite3Fts5ParserTrace() and
219430 ** sqlite3Fts5ParserFallback() are unused */
219431 #ifndef NDEBUG
219432 (void)sqlite3Fts5ParserTrace;
@@ -220669,11 +221472,11 @@
220669 Fts5StructureSegment *pSeg; /* Segment to iterate through */
220670 int flags; /* Mask of configuration flags */
220671 int iLeafPgno; /* Current leaf page number */
220672 Fts5Data *pLeaf; /* Current leaf data */
220673 Fts5Data *pNextLeaf; /* Leaf page (iLeafPgno+1) */
220674 int iLeafOffset; /* Byte offset within current leaf */
220675
220676 /* Next method */
220677 void (*xNext)(Fts5Index*, Fts5SegIter*, int*);
220678
220679 /* The page and offset from which the current term was read. The offset
@@ -221849,11 +222652,11 @@
221849 }
221850 }
221851
221852 static void fts5SegIterLoadRowid(Fts5Index *p, Fts5SegIter *pIter){
221853 u8 *a = pIter->pLeaf->p; /* Buffer to read data from */
221854 int iOff = pIter->iLeafOffset;
221855
221856 ASSERT_SZLEAF_OK(pIter->pLeaf);
221857 if( iOff>=pIter->pLeaf->szLeaf ){
221858 fts5SegIterNextPage(p, pIter);
221859 if( pIter->pLeaf==0 ){
@@ -221882,11 +222685,11 @@
221882 ** the first position list. The position list belonging to document
221883 ** (Fts5SegIter.iRowid).
221884 */
221885 static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){
221886 u8 *a = pIter->pLeaf->p; /* Buffer to read data from */
221887 int iOff = pIter->iLeafOffset; /* Offset to read at */
221888 int nNew; /* Bytes of new data */
221889
221890 iOff += fts5GetVarint32(&a[iOff], nNew);
221891 if( iOff+nNew>pIter->pLeaf->szLeaf || nKeep>pIter->term.n || nNew==0 ){
221892 p->rc = FTS5_CORRUPT;
@@ -222310,11 +223113,10 @@
222310 }else{
222311 /* The following could be done by calling fts5SegIterLoadNPos(). But
222312 ** this block is particularly performance critical, so equivalent
222313 ** code is inlined. */
222314 int nSz;
222315 assert( p->rc==SQLITE_OK );
222316 assert_nc( pIter->iLeafOffset<=pIter->pLeaf->nn );
222317 fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz);
222318 pIter->bDel = (nSz & 0x0001);
222319 pIter->nPos = nSz>>1;
222320 assert_nc( pIter->nPos>=0 );
@@ -223422,11 +224224,11 @@
223422 pIter->base.nData = p-aCopy;
223423 return;
223424 }
223425 fts5BufferSafeAppendBlob(&pIter->poslist, aCopy, p-aCopy);
223426 }
223427 if( p==pEnd ){
223428 pIter->base.pData = pIter->poslist.p;
223429 pIter->base.nData = pIter->poslist.n;
223430 return;
223431 }
223432 aCopy = p++;
@@ -224779,18 +225581,18 @@
224779 if( pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){
224780 /* The entire doclist will fit on the current leaf. */
224781 fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist);
224782 }else{
224783 i64 iRowid = 0;
224784 i64 iDelta = 0;
224785 int iOff = 0;
224786
224787 /* The entire doclist will not fit on this leaf. The following
224788 ** loop iterates through the poslists that make up the current
224789 ** doclist. */
224790 while( p->rc==SQLITE_OK && iOff<nDoclist ){
224791 iOff += fts5GetVarint(&pDoclist[iOff], (u64*)&iDelta);
224792 iRowid += iDelta;
224793
224794 if( writer.bFirstRowidInPage ){
224795 fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */
224796 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);
@@ -225218,11 +226020,11 @@
225218 Fts5Buffer *p1, /* First list to merge */
225219 int nBuf, /* Number of buffers in array aBuf[] */
225220 Fts5Buffer *aBuf /* Other lists to merge in */
225221 ){
225222 #define fts5PrefixMergerNextPosition(p) \
225223 sqlite3Fts5PoslistNext64((p)->aPos,(p)->iter.nPoslist,&(p)->iOff,&(p)->iPos);
225224 #define FTS5_MERGE_NLIST 16
225225 PrefixMerger aMerger[FTS5_MERGE_NLIST];
225226 PrefixMerger *pHead = 0;
225227 int i;
225228 int nOut = 0;
@@ -225317,11 +226119,12 @@
225317 sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, pHead->iPos);
225318 }
225319 nTail = pHead->iter.nPoslist - pHead->iOff;
225320
225321 /* WRITEPOSLISTSIZE */
225322 assert( tmp.n+nTail<=nTmp );
 
225323 if( tmp.n+nTail>nTmp-FTS5_DATA_ZERO_PADDING ){
225324 if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT;
225325 break;
225326 }
225327 fts5BufferSafeAppendVarint(&out, (tmp.n+nTail) * 2);
@@ -226958,10 +227761,11 @@
226958 );
226959 }
226960 return rc;
226961 #else
226962 return SQLITE_OK;
 
226963 #endif
226964 }
226965
226966
226967 static int sqlite3Fts5IndexReset(Fts5Index *p){
@@ -228921,17 +229725,19 @@
228921 }
228922 if( iBest<0 ) break;
228923
228924 nInst++;
228925 if( nInst>=pCsr->nInstAlloc ){
228926 pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32;
228927 aInst = (int*)sqlite3_realloc64(
228928 pCsr->aInst, pCsr->nInstAlloc*sizeof(int)*3
228929 );
228930 if( aInst ){
228931 pCsr->aInst = aInst;
 
228932 }else{
 
228933 rc = SQLITE_NOMEM;
228934 break;
228935 }
228936 }
228937
@@ -229762,11 +230568,11 @@
229762 int nArg, /* Number of args */
229763 sqlite3_value **apUnused /* Function arguments */
229764 ){
229765 assert( nArg==0 );
229766 UNUSED_PARAM2(nArg, apUnused);
229767 sqlite3_result_text(pCtx, "fts5: 2021-04-07 13:20:34 c22e47c77a35ebcd1fdfc0caea9119dd5e24e76d5fdd0f2ffbb58205a7242297", -1, SQLITE_TRANSIENT);
229768 }
229769
229770 /*
229771 ** Return true if zName is the extension on one of the shadow tables used
229772 ** by this module.
@@ -234688,12 +235494,12 @@
234688 }
234689 #endif /* SQLITE_CORE */
234690 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
234691
234692 /************** End of stmt.c ************************************************/
234693 #if __LINE__!=234693
234694 #undef SQLITE_SOURCE_ID
234695 #define SQLITE_SOURCE_ID "2021-04-07 18:17:53 a2ddb89b206c13876d34c5f9e3db41cda72d6eb3fea31ffa8cc6daa1e158alt2"
234696 #endif
234697 /* Return the source-id for this library */
234698 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
234699 /************************** End of sqlite3.c ******************************/
234700
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -81,12 +81,14 @@
81 "4_BYTE_ALIGNED_MALLOC",
82 #endif
83 #if SQLITE_64BIT_STATS
84 "64BIT_STATS",
85 #endif
86 #ifdef SQLITE_ALLOW_COVERING_INDEX_SCAN
87 # if SQLITE_ALLOW_COVERING_INDEX_SCAN != 1
88 "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN),
89 # endif
90 #endif
91 #if SQLITE_ALLOW_URI_AUTHORITY
92 "ALLOW_URI_AUTHORITY",
93 #endif
94 #ifdef SQLITE_BITMASK_TYPE
@@ -144,12 +146,14 @@
146 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
147 #endif
148 #ifdef SQLITE_DEFAULT_LOOKASIDE
149 "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE),
150 #endif
151 #ifdef SQLITE_DEFAULT_MEMSTATUS
152 # if SQLITE_DEFAULT_MEMSTATUS != 1
153 "DEFAULT_MEMSTATUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_MEMSTATUS),
154 # endif
155 #endif
156 #ifdef SQLITE_DEFAULT_MMAP_SIZE
157 "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
158 #endif
159 #ifdef SQLITE_DEFAULT_PAGE_SIZE
@@ -219,11 +223,11 @@
223 "ENABLE_BATCH_ATOMIC_WRITE",
224 #endif
225 #if SQLITE_ENABLE_BYTECODE_VTAB
226 "ENABLE_BYTECODE_VTAB",
227 #endif
228 #ifdef SQLITE_ENABLE_CEROD
229 "ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD),
230 #endif
231 #if SQLITE_ENABLE_COLUMN_METADATA
232 "ENABLE_COLUMN_METADATA",
233 #endif
@@ -233,22 +237,22 @@
237 #if SQLITE_ENABLE_COSTMULT
238 "ENABLE_COSTMULT",
239 #endif
240 #if SQLITE_ENABLE_CURSOR_HINTS
241 "ENABLE_CURSOR_HINTS",
242 #endif
243 #if SQLITE_ENABLE_DBPAGE_VTAB
244 "ENABLE_DBPAGE_VTAB",
245 #endif
246 #if SQLITE_ENABLE_DBSTAT_VTAB
247 "ENABLE_DBSTAT_VTAB",
248 #endif
249 #if SQLITE_ENABLE_EXPENSIVE_ASSERT
250 "ENABLE_EXPENSIVE_ASSERT",
251 #endif
252 #if SQLITE_ENABLE_EXPLAIN_COMMENTS
253 "ENABLE_EXPLAIN_COMMENTS",
 
 
 
254 #endif
255 #if SQLITE_ENABLE_FTS3
256 "ENABLE_FTS3",
257 #endif
258 #if SQLITE_ENABLE_FTS3_PARENTHESIS
@@ -302,10 +306,13 @@
306 #if SQLITE_ENABLE_NORMALIZE
307 "ENABLE_NORMALIZE",
308 #endif
309 #if SQLITE_ENABLE_NULL_TRIM
310 "ENABLE_NULL_TRIM",
311 #endif
312 #if SQLITE_ENABLE_OFFSET_SQL_FUNC
313 "ENABLE_OFFSET_SQL_FUNC",
314 #endif
315 #if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
316 "ENABLE_OVERSIZE_CELL_CHECK",
317 #endif
318 #if SQLITE_ENABLE_PREUPDATE_HOOK
@@ -333,11 +340,11 @@
340 "ENABLE_SORTER_REFERENCES",
341 #endif
342 #if SQLITE_ENABLE_SQLLOG
343 "ENABLE_SQLLOG",
344 #endif
345 #if SQLITE_ENABLE_STAT4
346 "ENABLE_STAT4",
347 #endif
348 #if SQLITE_ENABLE_STMTVTAB
349 "ENABLE_STMTVTAB",
350 #endif
@@ -387,12 +394,14 @@
394 "FTS5_NO_WITHOUT_ROWID",
395 #endif
396 #if HAVE_ISNAN || SQLITE_HAVE_ISNAN
397 "HAVE_ISNAN",
398 #endif
399 #ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
400 # if SQLITE_HOMEGROWN_RECURSIVE_MUTEX != 1
401 "HOMEGROWN_RECURSIVE_MUTEX=" CTIMEOPT_VAL(SQLITE_HOMEGROWN_RECURSIVE_MUTEX),
402 # endif
403 #endif
404 #if SQLITE_IGNORE_AFP_LOCK_ERRORS
405 "IGNORE_AFP_LOCK_ERRORS",
406 #endif
407 #if SQLITE_IGNORE_FLOCK_LOCK_ERRORS
@@ -486,13 +495,10 @@
495 "MMAP_READWRITE",
496 #endif
497 #if SQLITE_MUTEX_NOOP
498 "MUTEX_NOOP",
499 #endif
 
 
 
500 #if SQLITE_MUTEX_OMIT
501 "MUTEX_OMIT",
502 #endif
503 #if SQLITE_MUTEX_PTHREADS
504 "MUTEX_PTHREADS",
@@ -558,18 +564,21 @@
564 "OMIT_CONFLICT_CLAUSE",
565 #endif
566 #if SQLITE_OMIT_CTE
567 "OMIT_CTE",
568 #endif
569 #if defined(SQLITE_OMIT_DATETIME_FUNCS) || defined(SQLITE_OMIT_FLOATING_POINT)
570 "OMIT_DATETIME_FUNCS",
571 #endif
572 #if SQLITE_OMIT_DECLTYPE
573 "OMIT_DECLTYPE",
574 #endif
575 #if SQLITE_OMIT_DEPRECATED
576 "OMIT_DEPRECATED",
577 #endif
578 #if SQLITE_OMIT_DESERIALIZE
579 "OMIT_DESERIALIZE",
580 #endif
581 #if SQLITE_OMIT_DISKIO
582 "OMIT_DISKIO",
583 #endif
584 #if SQLITE_OMIT_EXPLAIN
@@ -593,10 +602,13 @@
602 #if SQLITE_OMIT_INCRBLOB
603 "OMIT_INCRBLOB",
604 #endif
605 #if SQLITE_OMIT_INTEGRITY_CHECK
606 "OMIT_INTEGRITY_CHECK",
607 #endif
608 #if SQLITE_OMIT_INTROSPECTION_PRAGMAS
609 "OMIT_INTROSPECTION_PRAGMAS",
610 #endif
611 #if SQLITE_OMIT_LIKE_OPTIMIZATION
612 "OMIT_LIKE_OPTIMIZATION",
613 #endif
614 #if SQLITE_OMIT_LOAD_EXTENSION
@@ -657,12 +669,14 @@
669 "OMIT_TEMPDB",
670 #endif
671 #if SQLITE_OMIT_TEST_CONTROL
672 "OMIT_TEST_CONTROL",
673 #endif
674 #ifdef SQLITE_OMIT_TRACE
675 # if SQLITE_OMIT_TRACE != 1
676 "OMIT_TRACE=" CTIMEOPT_VAL(SQLITE_OMIT_TRACE),
677 # endif
678 #endif
679 #if SQLITE_OMIT_TRIGGER
680 "OMIT_TRIGGER",
681 #endif
682 #if SQLITE_OMIT_TRUNCATE_OPTIMIZATION
@@ -693,12 +707,14 @@
707 "PCACHE_SEPARATE_HEADER",
708 #endif
709 #if SQLITE_PERFORMANCE_TRACE
710 "PERFORMANCE_TRACE",
711 #endif
712 #ifdef SQLITE_POWERSAFE_OVERWRITE
713 # if SQLITE_POWERSAFE_OVERWRITE != 1
714 "POWERSAFE_OVERWRITE=" CTIMEOPT_VAL(SQLITE_POWERSAFE_OVERWRITE),
715 # endif
716 #endif
717 #if SQLITE_PREFER_PROXY_LOCKING
718 "PREFER_PROXY_LOCKING",
719 #endif
720 #if SQLITE_PROXY_DEBUG
@@ -729,11 +745,14 @@
745 "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),
746 #endif
747 #if SQLITE_SUBSTR_COMPATIBILITY
748 "SUBSTR_COMPATIBILITY",
749 #endif
750 #if (!defined(SQLITE_WIN32_MALLOC) \
751 && !defined(SQLITE_ZERO_MALLOC) \
752 && !defined(SQLITE_MEMDEBUG) \
753 ) || defined(SQLITE_SYSTEM_MALLOC)
754 "SYSTEM_MALLOC",
755 #endif
756 #if SQLITE_TCL
757 "TCL",
758 #endif
@@ -1186,11 +1205,11 @@
1205 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1206 ** [sqlite_version()] and [sqlite_source_id()].
1207 */
1208 #define SQLITE_VERSION "3.36.0"
1209 #define SQLITE_VERSION_NUMBER 3036000
1210 #define SQLITE_SOURCE_ID "2021-06-14 20:41:20 e5a5acd6006133c5da4a7dd79726dbaa41c0d60ebeda890f848a6aafe5f9ef70"
1211
1212 /*
1213 ** CAPI3REF: Run-Time Library Version Numbers
1214 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1215 **
@@ -2202,10 +2221,14 @@
2221 ** currently has an SQL transaction open on the database. It is set to 0 if
2222 ** the database is not a wal-mode db, or if there is no such connection in any
2223 ** other process. This opcode cannot be used to detect transactions opened
2224 ** by clients within the current process, only within other processes.
2225 ** </ul>
2226 **
2227 ** <li>[[SQLITE_FCNTL_CKSM_FILE]]
2228 ** Used by the cksmvfs VFS module only.
2229 ** </ul>
2230 */
2231 #define SQLITE_FCNTL_LOCKSTATE 1
2232 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
2233 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
2234 #define SQLITE_FCNTL_LAST_ERRNO 4
@@ -2241,12 +2264,12 @@
2264 #define SQLITE_FCNTL_DATA_VERSION 35
2265 #define SQLITE_FCNTL_SIZE_LIMIT 36
2266 #define SQLITE_FCNTL_CKPT_DONE 37
2267 #define SQLITE_FCNTL_RESERVE_BYTES 38
2268 #define SQLITE_FCNTL_CKPT_START 39
 
2269 #define SQLITE_FCNTL_EXTERNAL_READER 40
2270 #define SQLITE_FCNTL_CKSM_FILE 41
2271
2272 /* deprecated names */
2273 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
2274 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
2275 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -5255,10 +5278,19 @@
5278 ** changes to the content of the database files on disk.
5279 ** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since
5280 ** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and
5281 ** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so
5282 ** sqlite3_stmt_readonly() returns false for those commands.
5283 **
5284 ** ^This routine returns false if there is any possibility that the
5285 ** statement might change the database file. ^A false return does
5286 ** not guarantee that the statement will change the database file.
5287 ** ^For example, an UPDATE statement might have a WHERE clause that
5288 ** makes it a no-op, but the sqlite3_stmt_readonly() result would still
5289 ** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a
5290 ** read-only no-op if the table already exists, but
5291 ** sqlite3_stmt_readonly() still returns false for such a statement.
5292 */
5293 SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
5294
5295 /*
5296 ** CAPI3REF: Query The EXPLAIN Setting For A Prepared Statement
@@ -5424,22 +5456,26 @@
5456 ** terminated. If any NUL characters occurs at byte offsets less than
5457 ** the value of the fourth parameter then the resulting string value will
5458 ** contain embedded NULs. The result of expressions involving strings
5459 ** with embedded NULs is undefined.
5460 **
5461 ** ^The fifth argument to the BLOB and string binding interfaces controls
5462 ** or indicates the lifetime of the object referenced by the third parameter.
5463 ** ^These three options exist:
5464 ** ^(1) A destructor to dispose of the BLOB or string after SQLite has finished
5465 ** with it may be passed. ^It is called to dispose of the BLOB or string even
5466 ** if the call to the bind API fails, except the destructor is not called if
5467 ** the third parameter is a NULL pointer or the fourth parameter is negative.
5468 ** ^(2) The special constant, [SQLITE_STATIC], may be passsed to indicate that
5469 ** the application remains responsible for disposing of the object. ^In this
5470 ** case, the object and the provided pointer to it must remain valid until
5471 ** either the prepared statement is finalized or the same SQL parameter is
5472 ** bound to something else, whichever occurs sooner.
5473 ** ^(3) The constant, [SQLITE_TRANSIENT], may be passed to indicate that the
5474 ** object is to be copied prior to the return from sqlite3_bind_*(). ^The
5475 ** object and pointer to it must remain valid until then. ^SQLite will then
5476 ** manage the lifetime of its private copy.
5477 **
5478 ** ^The sixth argument to sqlite3_bind_text64() must be one of
5479 ** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]
5480 ** to specify the encoding of the text in the third parameter. If
5481 ** the sixth argument to sqlite3_bind_text64() is not one of the
@@ -6177,21 +6213,19 @@
6213 ** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY]
6214 ** flag, which if present prevents the function from being invoked from
6215 ** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions,
6216 ** index expressions, or the WHERE clause of partial indexes.
6217 **
 
6218 ** For best security, the [SQLITE_DIRECTONLY] flag is recommended for
6219 ** all application-defined SQL functions that do not need to be
6220 ** used inside of triggers, view, CHECK constraints, or other elements of
6221 ** the database schema. This flags is especially recommended for SQL
6222 ** functions that have side effects or reveal internal application state.
6223 ** Without this flag, an attacker might be able to modify the schema of
6224 ** a database file to include invocations of the function with parameters
6225 ** chosen by the attacker, which the application will then execute when
6226 ** the database file is opened and read.
 
6227 **
6228 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
6229 ** function can gain access to this pointer using [sqlite3_user_data()].)^
6230 **
6231 ** ^The sixth, seventh and eighth parameters passed to the three
@@ -8855,11 +8889,12 @@
8889 #define SQLITE_TESTCTRL_RESULT_INTREAL 27
8890 #define SQLITE_TESTCTRL_PRNG_SEED 28
8891 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
8892 #define SQLITE_TESTCTRL_SEEK_COUNT 30
8893 #define SQLITE_TESTCTRL_TRACEFLAGS 31
8894 #define SQLITE_TESTCTRL_TUNE 32
8895 #define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */
8896
8897 /*
8898 ** CAPI3REF: SQL Keyword Checking
8899 **
8900 ** These routines provide access to the set of SQL language keywords
@@ -10607,10 +10642,19 @@
10642 ** callback was invoked as a result of a direct insert, update, or delete
10643 ** operation; or 1 for inserts, updates, or deletes invoked by top-level
10644 ** triggers; or 2 for changes resulting from triggers called by top-level
10645 ** triggers; and so forth.
10646 **
10647 ** When the [sqlite3_blob_write()] API is used to update a blob column,
10648 ** the pre-update hook is invoked with SQLITE_DELETE. This is because the
10649 ** in this case the new values are not available. In this case, when a
10650 ** callback made with op==SQLITE_DELETE is actuall a write using the
10651 ** sqlite3_blob_write() API, the [sqlite3_preupdate_blobwrite()] returns
10652 ** the index of the column being written. In other cases, where the
10653 ** pre-update hook is being invoked for some other reason, including a
10654 ** regular DELETE, sqlite3_preupdate_blobwrite() returns -1.
10655 **
10656 ** See also: [sqlite3_update_hook()]
10657 */
10658 #if defined(SQLITE_ENABLE_PREUPDATE_HOOK)
10659 SQLITE_API void *sqlite3_preupdate_hook(
10660 sqlite3 *db,
@@ -10627,10 +10671,11 @@
10671 );
10672 SQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);
10673 SQLITE_API int sqlite3_preupdate_count(sqlite3 *);
10674 SQLITE_API int sqlite3_preupdate_depth(sqlite3 *);
10675 SQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);
10676 SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *);
10677 #endif
10678
10679 /*
10680 ** CAPI3REF: Low-level system error code
10681 ** METHOD: sqlite3
@@ -10865,12 +10910,12 @@
10910 **
10911 ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
10912 ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory
10913 ** allocation error occurs.
10914 **
10915 ** This interface is omitted if SQLite is compiled with the
10916 ** [SQLITE_OMIT_DESERIALIZE] option.
10917 */
10918 SQLITE_API unsigned char *sqlite3_serialize(
10919 sqlite3 *db, /* The database connection */
10920 const char *zSchema, /* Which DB to serialize. ex: "main", "temp", ... */
10921 sqlite3_int64 *piSize, /* Write size of the DB here, if not NULL */
@@ -10917,12 +10962,12 @@
10962 **
10963 ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
10964 ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
10965 ** [sqlite3_free()] is invoked on argument P prior to returning.
10966 **
10967 ** This interface is omitted if SQLite is compiled with the
10968 ** [SQLITE_OMIT_DESERIALIZE] option.
10969 */
10970 SQLITE_API int sqlite3_deserialize(
10971 sqlite3 *db, /* The database connection */
10972 const char *zSchema, /* Which DB to reopen with the deserialization */
10973 unsigned char *pData, /* The serialized database content */
@@ -11167,10 +11212,42 @@
11212 ** are attached is closed. Refer to the documentation for
11213 ** [sqlite3session_create()] for details.
11214 */
11215 SQLITE_API void sqlite3session_delete(sqlite3_session *pSession);
11216
11217 /*
11218 ** CAPIREF: Conigure a Session Object
11219 ** METHOD: sqlite3_session
11220 **
11221 ** This method is used to configure a session object after it has been
11222 ** created. At present the only valid value for the second parameter is
11223 ** [SQLITE_SESSION_OBJCONFIG_SIZE].
11224 **
11225 ** Arguments for sqlite3session_object_config()
11226 **
11227 ** The following values may passed as the the 4th parameter to
11228 ** sqlite3session_object_config().
11229 **
11230 ** <dt>SQLITE_SESSION_OBJCONFIG_SIZE <dd>
11231 ** This option is used to set, clear or query the flag that enables
11232 ** the [sqlite3session_changeset_size()] API. Because it imposes some
11233 ** computational overhead, this API is disabled by default. Argument
11234 ** pArg must point to a value of type (int). If the value is initially
11235 ** 0, then the sqlite3session_changeset_size() API is disabled. If it
11236 ** is greater than 0, then the same API is enabled. Or, if the initial
11237 ** value is less than zero, no change is made. In all cases the (int)
11238 ** variable is set to 1 if the sqlite3session_changeset_size() API is
11239 ** enabled following the current call, or 0 otherwise.
11240 **
11241 ** It is an error (SQLITE_MISUSE) to attempt to modify this setting after
11242 ** the first table has been attached to the session object.
11243 */
11244 SQLITE_API int sqlite3session_object_config(sqlite3_session*, int op, void *pArg);
11245
11246 /*
11247 */
11248 #define SQLITE_SESSION_OBJCONFIG_SIZE 1
11249
11250 /*
11251 ** CAPI3REF: Enable Or Disable A Session Object
11252 ** METHOD: sqlite3_session
11253 **
@@ -11411,10 +11488,26 @@
11488 sqlite3_session *pSession, /* Session object */
11489 int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
11490 void **ppChangeset /* OUT: Buffer containing changeset */
11491 );
11492
11493 /*
11494 ** CAPI3REF: Return An Upper-limit For The Size Of The Changeset
11495 ** METHOD: sqlite3_session
11496 **
11497 ** By default, this function always returns 0. For it to return
11498 ** a useful result, the sqlite3_session object must have been configured
11499 ** to enable this API using sqlite3session_object_config() with the
11500 ** SQLITE_SESSION_OBJCONFIG_SIZE verb.
11501 **
11502 ** When enabled, this function returns an upper limit, in bytes, for the size
11503 ** of the changeset that might be produced if sqlite3session_changeset() were
11504 ** called. The final changeset size might be equal to or smaller than the
11505 ** size in bytes returned by this function.
11506 */
11507 SQLITE_API sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession);
11508
11509 /*
11510 ** CAPI3REF: Load The Difference Between Tables Into A Session
11511 ** METHOD: sqlite3_session
11512 **
11513 ** If it is not already attached to the session object passed as the first
@@ -14235,12 +14328,13 @@
14328 #define TK_VECTOR 176
14329 #define TK_SELECT_COLUMN 177
14330 #define TK_IF_NULL_ROW 178
14331 #define TK_ASTERISK 179
14332 #define TK_SPAN 180
14333 #define TK_ERROR 181
14334 #define TK_SPACE 182
14335 #define TK_ILLEGAL 183
14336
14337 /************** End of parse.h ***********************************************/
14338 /************** Continuing where we left off in sqliteInt.h ******************/
14339 #include <stdio.h>
14340 #include <stdlib.h>
@@ -15931,11 +16025,11 @@
16025 /* 152 */ 0x10, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00,\
16026 /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
16027 /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
16028 /* 176 */ 0x00, 0x00, 0x00, 0x00,}
16029
16030 /* The resolve3P2Values() routine is able to run faster if it knows
16031 ** the value of the largest JUMP opcode. The smaller the maximum
16032 ** JUMP opcode the better, so the mkopcodeh.tcl script that
16033 ** generated this include file strives to group all JUMP opcodes
16034 ** together near the beginning of the list.
16035 */
@@ -16463,10 +16557,16 @@
16557 ** a no-op
16558 */
16559 #ifndef SET_FULLSYNC
16560 # define SET_FULLSYNC(x,y)
16561 #endif
16562
16563 /* Maximum pathname length. Note: FILENAME_MAX defined by stdio.h
16564 */
16565 #ifndef SQLITE_MAX_PATHLEN
16566 # define SQLITE_MAX_PATHLEN FILENAME_MAX
16567 #endif
16568
16569 /*
16570 ** The default size of a disk sector
16571 */
16572 #ifndef SQLITE_DEFAULT_SECTOR_SIZE
@@ -17219,11 +17319,11 @@
17319 #define SQLITE_PushDown 0x00001000 /* The push-down optimization */
17320 #define SQLITE_SimplifyJoin 0x00002000 /* Convert LEFT JOIN to JOIN */
17321 #define SQLITE_SkipScan 0x00004000 /* Skip-scans */
17322 #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */
17323 #define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */
17324 #define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */
17325 #define SQLITE_AllOpts 0xffffffff /* All optimizations */
17326
17327 /*
17328 ** Macros for testing whether or not optimizations are enabled or disabled.
17329 */
@@ -17724,10 +17824,11 @@
17824 #define TF_OOOHidden 0x0400 /* Out-of-Order hidden columns */
17825 #define TF_HasNotNull 0x0800 /* Contains NOT NULL constraints */
17826 #define TF_Shadow 0x1000 /* True for a shadow table */
17827 #define TF_HasStat4 0x2000 /* STAT4 info available for this table */
17828 #define TF_Ephemeral 0x4000 /* An ephemeral table */
17829 #define TF_Eponymous 0x8000 /* An eponymous virtual table */
17830
17831 /*
17832 ** Test to see whether or not a table is a virtual table. This is
17833 ** done as a macro so that it will be optimized out when virtual
17834 ** table support is omitted from the build.
@@ -18436,10 +18537,11 @@
18537 unsigned isCorrelated :1; /* True if sub-query is correlated */
18538 unsigned viaCoroutine :1; /* Implemented as a co-routine */
18539 unsigned isRecursive :1; /* True for recursive reference in WITH */
18540 unsigned fromDDL :1; /* Comes from sqlite_schema */
18541 unsigned isCte :1; /* This is a CTE */
18542 unsigned notCte :1; /* This item may not match a CTE */
18543 } fg;
18544 int iCursor; /* The VDBE cursor number used to access this table */
18545 Expr *pOn; /* The ON clause of a join */
18546 IdList *pUsing; /* The USING clause of a join */
18547 Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */
@@ -18553,11 +18655,11 @@
18655 Upsert *pUpsert; /* ON CONFLICT clause information from an upsert */
18656 int iBaseReg; /* For TK_REGISTER when parsing RETURNING */
18657 } uNC;
18658 NameContext *pNext; /* Next outer name context. NULL for outermost */
18659 int nRef; /* Number of names resolved by this context */
18660 int nNcErr; /* Number of errors encountered while resolving names */
18661 int ncFlags; /* Zero or more NC_* flags defined below */
18662 Select *pWinSelect; /* SELECT statement for any window functions */
18663 };
18664
18665 /*
@@ -18586,10 +18688,11 @@
18688 #define NC_AllowWin 0x04000 /* Window functions are allowed here */
18689 #define NC_HasWin 0x08000 /* One or more window functions seen */
18690 #define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */
18691 #define NC_InAggFunc 0x20000 /* True if analyzing arguments to an agg func */
18692 #define NC_FromDDL 0x40000 /* SQL text comes from sqlite_schema */
18693 #define NC_NoSelect 0x80000 /* Do not descend into sub-selects */
18694
18695 /*
18696 ** An instance of the following object describes a single ON CONFLICT
18697 ** clause in an upsert.
18698 **
@@ -18698,10 +18801,11 @@
18801 #define SF_View 0x0200000 /* SELECT statement is a view */
18802 #define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */
18803 #define SF_UpdateFrom 0x0800000 /* Statement is an UPDATE...FROM */
18804 #define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */
18805 #define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */
18806 #define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */
18807
18808 /*
18809 ** The results of a SELECT can be distributed in several ways, as defined
18810 ** by one of the following macros. The "SRT" prefix means "SELECT Result
18811 ** Type".
@@ -19226,10 +19330,26 @@
19330 ** Allowed values for mInitFlags
19331 */
19332 #define INITFLAG_AlterRename 0x0001 /* Reparse after a RENAME */
19333 #define INITFLAG_AlterDrop 0x0002 /* Reparse after a DROP COLUMN */
19334
19335 /* Tuning parameters are set using SQLITE_TESTCTRL_TUNE and are controlled
19336 ** on debug-builds of the CLI using ".testctrl tune ID VALUE". Tuning
19337 ** parameters are for temporary use during development, to help find
19338 ** optimial values for parameters in the query planner. The should not
19339 ** be used on trunk check-ins. They are a temporary mechanism available
19340 ** for transient development builds only.
19341 **
19342 ** Tuning parameters are numbered starting with 1.
19343 */
19344 #define SQLITE_NTUNE 6 /* Should be zero for all trunk check-ins */
19345 #ifdef SQLITE_DEBUG
19346 # define Tuning(X) (sqlite3Config.aTune[(X)-1])
19347 #else
19348 # define Tuning(X) 0
19349 #endif
19350
19351 /*
19352 ** Structure containing global configuration data for the SQLite library.
19353 **
19354 ** This structure also contains some state information.
19355 */
@@ -19280,20 +19400,24 @@
19400 ** operation. Set the callback using SQLITE_TESTCTRL_VDBE_COVERAGE.
19401 */
19402 void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx); /* Callback */
19403 void *pVdbeBranchArg; /* 1st argument */
19404 #endif
19405 #ifndef SQLITE_OMIT_DESERIALIZE
19406 sqlite3_int64 mxMemdbSize; /* Default max memdb size */
19407 #endif
19408 #ifndef SQLITE_UNTESTABLE
19409 int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
19410 #endif
19411 int bLocaltimeFault; /* True to fail localtime() calls */
19412 int iOnceResetThreshold; /* When to reset OP_Once counters */
19413 u32 szSorterRef; /* Min size in bytes to use sorter-refs */
19414 unsigned int iPrngSeed; /* Alternative fixed seed for the PRNG */
19415 /* vvvv--- must be last ---vvv */
19416 #ifdef SQLITE_DEBUG
19417 sqlite3_int64 aTune[SQLITE_NTUNE]; /* Tuning parameters */
19418 #endif
19419 };
19420
19421 /*
19422 ** This macro is used inside of assert() statements to indicate that
19423 ** the assert is only valid on a well-formed database. Instead of:
@@ -19367,14 +19491,21 @@
19491 SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker*, Expr*);
19492 SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker*, Select*);
19493 SQLITE_PRIVATE int sqlite3SelectWalkFail(Walker*, Select*);
19494 SQLITE_PRIVATE int sqlite3WalkerDepthIncrease(Walker*,Select*);
19495 SQLITE_PRIVATE void sqlite3WalkerDepthDecrease(Walker*,Select*);
19496 SQLITE_PRIVATE void sqlite3WalkWinDefnDummyCallback(Walker*,Select*);
19497
19498 #ifdef SQLITE_DEBUG
19499 SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*);
19500 #endif
19501
19502 #ifndef SQLITE_OMIT_CTE
19503 SQLITE_PRIVATE void sqlite3SelectPopWith(Walker*, Select*);
19504 #else
19505 # define sqlite3SelectPopWith 0
19506 #endif
19507
19508 /*
19509 ** Return code from the parse-tree walking primitives and their
19510 ** callbacks.
19511 */
@@ -19405,10 +19536,11 @@
19536 ** An instance of the With object represents a WITH clause containing
19537 ** one or more CTEs (common table expressions).
19538 */
19539 struct With {
19540 int nCte; /* Number of CTEs in the WITH clause */
19541 int bView; /* Belongs to the outermost Select of a view */
19542 With *pOuter; /* Containing WITH clause, or NULL */
19543 Cte a[1]; /* For each CTE in the WITH clause.... */
19544 };
19545
19546 /*
@@ -19797,10 +19929,11 @@
19929 SQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*);
19930 SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int);
19931 SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*);
19932 SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*);
19933 SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*);
19934 SQLITE_PRIVATE void sqlite3GenerateColumnNames(Parse *pParse, Select *pSelect);
19935 SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
19936 SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*,char);
19937 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*,char);
19938 SQLITE_PRIVATE void sqlite3OpenSchemaTable(Parse *, int);
19939 SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
@@ -20032,10 +20165,11 @@
20165 SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
20166 SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
20167 SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*);
20168 SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*);
20169 SQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int);
20170 SQLITE_PRIVATE With *sqlite3WithDup(sqlite3 *db, With *p);
20171
20172 #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
20173 SQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int);
20174 #endif
20175
@@ -20175,11 +20309,11 @@
20309
20310 #if defined(SQLITE_NEED_ERR_NAME)
20311 SQLITE_PRIVATE const char *sqlite3ErrName(int);
20312 #endif
20313
20314 #ifndef SQLITE_OMIT_DESERIALIZE
20315 SQLITE_PRIVATE int sqlite3MemdbInit(void);
20316 #endif
20317
20318 SQLITE_PRIVATE const char *sqlite3ErrStr(int);
20319 SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);
@@ -20442,11 +20576,11 @@
20576 #ifndef SQLITE_OMIT_CTE
20577 SQLITE_PRIVATE Cte *sqlite3CteNew(Parse*,Token*,ExprList*,Select*,u8);
20578 SQLITE_PRIVATE void sqlite3CteDelete(sqlite3*,Cte*);
20579 SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Cte*);
20580 SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*);
20581 SQLITE_PRIVATE With *sqlite3WithPush(Parse*, With*, u8);
20582 #else
20583 # define sqlite3CteNew(P,T,E,S) ((void*)0)
20584 # define sqlite3CteDelete(D,C)
20585 # define sqlite3CteWithAdd(P,W,C) ((void*)0)
20586 # define sqlite3WithDelete(x,y)
@@ -20937,11 +21071,11 @@
21071 #endif
21072 #ifdef SQLITE_VDBE_COVERAGE
21073 0, /* xVdbeBranch */
21074 0, /* pVbeBranchArg */
21075 #endif
21076 #ifndef SQLITE_OMIT_DESERIALIZE
21077 SQLITE_MEMDB_DEFAULT_MAXSIZE, /* mxMemdbSize */
21078 #endif
21079 #ifndef SQLITE_UNTESTABLE
21080 0, /* xTestCallback */
21081 #endif
@@ -21500,10 +21634,11 @@
21634 u8 *aRecord; /* old.* database record */
21635 KeyInfo keyinfo;
21636 UnpackedRecord *pUnpacked; /* Unpacked version of aRecord[] */
21637 UnpackedRecord *pNewUnpacked; /* Unpacked version of new.* record */
21638 int iNewReg; /* Register for new.* values */
21639 int iBlobWrite; /* Value returned by preupdate_blobwrite() */
21640 i64 iKey1; /* First key value passed to hook */
21641 i64 iKey2; /* Second key value passed to hook */
21642 Mem *aNew; /* Array of new.* values */
21643 Table *pTab; /* Schema object being upated */
21644 Index *pPk; /* PK index if pTab is WITHOUT ROWID */
@@ -21543,11 +21678,11 @@
21678 SQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem*);
21679 SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem*, const Mem*);
21680 SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);
21681 SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*);
21682 SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*);
21683 SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, i64, u8, void(*)(void*));
21684 SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64);
21685 #ifdef SQLITE_OMIT_FLOATING_POINT
21686 # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
21687 #else
21688 SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double);
@@ -21588,11 +21723,12 @@
21723 #endif
21724 SQLITE_PRIVATE void sqlite3VdbeFrameMemDel(void*); /* Destructor on Mem */
21725 SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*); /* Actually deletes the Frame */
21726 SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
21727 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
21728 SQLITE_PRIVATE void sqlite3VdbePreUpdateHook(
21729 Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int,int);
21730 #endif
21731 SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p);
21732
21733 SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *);
21734 SQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *);
@@ -23539,10 +23675,12 @@
23675 zPathOut[0] = 0;
23676 return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);
23677 }
23678 #ifndef SQLITE_OMIT_LOAD_EXTENSION
23679 SQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){
23680 assert( zPath!=0 );
23681 assert( strlen(zPath)<=SQLITE_MAX_PATHLEN ); /* tag-20210611-1 */
23682 return pVfs->xDlOpen(pVfs, zPath);
23683 }
23684 SQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
23685 pVfs->xDlError(pVfs, nByte, zBufOut);
23686 }
@@ -27806,11 +27944,10 @@
27944 SQLITE_PRIVATE int sqlite3MallocInit(void){
27945 int rc;
27946 if( sqlite3GlobalConfig.m.xMalloc==0 ){
27947 sqlite3MemSetDefault();
27948 }
 
27949 mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
27950 if( sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.szPage<512
27951 || sqlite3GlobalConfig.nPage<=0 ){
27952 sqlite3GlobalConfig.pPage = 0;
27953 sqlite3GlobalConfig.szPage = 0;
@@ -29932,10 +30069,11 @@
30069 for(i=0; i<pSrc->nSrc; i++){
30070 const SrcItem *pItem = &pSrc->a[i];
30071 StrAccum x;
30072 char zLine[100];
30073 sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
30074 x.printfFlags |= SQLITE_PRINTF_INTERNAL;
30075 sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem);
30076 if( pItem->pTab ){
30077 sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx",
30078 pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed);
30079 }
@@ -30502,10 +30640,18 @@
30640 }
30641 case TK_IF_NULL_ROW: {
30642 sqlite3TreeViewLine(pView, "IF-NULL-ROW %d", pExpr->iTable);
30643 sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
30644 break;
30645 }
30646 case TK_ERROR: {
30647 Expr tmp;
30648 sqlite3TreeViewLine(pView, "ERROR");
30649 tmp = *pExpr;
30650 tmp.op = pExpr->op2;
30651 sqlite3TreeViewExpr(pView, &tmp, 0);
30652 break;
30653 }
30654 default: {
30655 sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
30656 break;
30657 }
@@ -41972,10 +42118,26 @@
42118 /* Register all VFSes defined in the aVfs[] array */
42119 for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){
42120 sqlite3_vfs_register(&aVfs[i], i==0);
42121 }
42122 unixBigLock = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1);
42123
42124 /* Validate lock assumptions */
42125 assert( SQLITE_SHM_NLOCK==8 ); /* Number of available locks */
42126 assert( UNIX_SHM_BASE==120 ); /* Start of locking area */
42127 /* Locks:
42128 ** WRITE UNIX_SHM_BASE 120
42129 ** CKPT UNIX_SHM_BASE+1 121
42130 ** RECOVER UNIX_SHM_BASE+2 122
42131 ** READ-0 UNIX_SHM_BASE+3 123
42132 ** READ-1 UNIX_SHM_BASE+4 124
42133 ** READ-2 UNIX_SHM_BASE+5 125
42134 ** READ-3 UNIX_SHM_BASE+6 126
42135 ** READ-4 UNIX_SHM_BASE+7 127
42136 ** DMS UNIX_SHM_BASE+8 128
42137 */
42138 assert( UNIX_SHM_DMS==128 ); /* Byte offset of the deadman-switch */
42139 return SQLITE_OK;
42140 }
42141
42142 /*
42143 ** Shutdown the operating system interface.
@@ -48365,35 +48527,92 @@
48527 **
48528 ** This file also implements interface sqlite3_serialize() and
48529 ** sqlite3_deserialize().
48530 */
48531 /* #include "sqliteInt.h" */
48532 #ifndef SQLITE_OMIT_DESERIALIZE
48533
48534 /*
48535 ** Forward declaration of objects used by this utility
48536 */
48537 typedef struct sqlite3_vfs MemVfs;
48538 typedef struct MemFile MemFile;
48539 typedef struct MemStore MemStore;
48540
48541 /* Access to a lower-level VFS that (might) implement dynamic loading,
48542 ** access to randomness, etc.
48543 */
48544 #define ORIGVFS(p) ((sqlite3_vfs*)((p)->pAppData))
48545
48546 /* Storage for a memdb file.
48547 **
48548 ** An memdb object can be shared or separate. Shared memdb objects can be
48549 ** used by more than one database connection. Mutexes are used by shared
48550 ** memdb objects to coordinate access. Separate memdb objects are only
48551 ** connected to a single database connection and do not require additional
48552 ** mutexes.
48553 **
48554 ** Shared memdb objects have .zFName!=0 and .pMutex!=0. They are created
48555 ** using "file:/name?vfs=memdb". The first character of the name must be
48556 ** "/" or else the object will be a separate memdb object. All shared
48557 ** memdb objects are stored in memdb_g.apMemStore[] in an arbitrary order.
48558 **
48559 ** Separate memdb objects are created using a name that does not begin
48560 ** with "/" or using sqlite3_deserialize().
48561 **
48562 ** Access rules for shared MemStore objects:
48563 **
48564 ** * .zFName is initialized when the object is created and afterwards
48565 ** is unchanged until the object is destroyed. So it can be accessed
48566 ** at any time as long as we know the object is not being destroyed,
48567 ** which means while either the SQLITE_MUTEX_STATIC_VFS1 or
48568 ** .pMutex is held or the object is not part of memdb_g.apMemStore[].
48569 **
48570 ** * Can .pMutex can only be changed while holding the
48571 ** SQLITE_MUTEX_STATIC_VFS1 mutex or while the object is not part
48572 ** of memdb_g.apMemStore[].
48573 **
48574 ** * Other fields can only be changed while holding the .pMutex mutex
48575 ** or when the .nRef is less than zero and the object is not part of
48576 ** memdb_g.apMemStore[].
48577 **
48578 ** * The .aData pointer has the added requirement that it can can only
48579 ** be changed (for resizing) when nMmap is zero.
48580 **
48581 */
48582 struct MemStore {
48583 sqlite3_int64 sz; /* Size of the file */
48584 sqlite3_int64 szAlloc; /* Space allocated to aData */
48585 sqlite3_int64 szMax; /* Maximum allowed size of the file */
48586 unsigned char *aData; /* content of the file */
48587 sqlite3_mutex *pMutex; /* Used by shared stores only */
48588 int nMmap; /* Number of memory mapped pages */
48589 unsigned mFlags; /* Flags */
48590 int nRdLock; /* Number of readers */
48591 int nWrLock; /* Number of writers. (Always 0 or 1) */
48592 int nRef; /* Number of users of this MemStore */
48593 char *zFName; /* The filename for shared stores */
48594 };
48595
48596 /* An open file */
48597 struct MemFile {
48598 sqlite3_file base; /* IO methods */
48599 MemStore *pStore; /* The storage */
48600 int eLock; /* Most recent lock against this file */
48601 };
48602
48603 /*
48604 ** File-scope variables for holding the memdb files that are accessible
48605 ** to multiple database connections in separate threads.
48606 **
48607 ** Must hold SQLITE_MUTEX_STATIC_VFS1 to access any part of this object.
48608 */
48609 static struct MemFS {
48610 int nMemStore; /* Number of shared MemStore objects */
48611 MemStore **apMemStore; /* Array of all shared MemStore objects */
48612 } memdb_g;
48613
48614 /*
48615 ** Methods for MemFile
48616 */
48617 static int memdbClose(sqlite3_file*);
48618 static int memdbRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
@@ -48443,11 +48662,14 @@
48662 memdbDlClose, /* xDlClose */
48663 memdbRandomness, /* xRandomness */
48664 memdbSleep, /* xSleep */
48665 0, /* memdbCurrentTime, */ /* xCurrentTime */
48666 memdbGetLastError, /* xGetLastError */
48667 memdbCurrentTimeInt64, /* xCurrentTimeInt64 */
48668 0, /* xSetSystemCall */
48669 0, /* xGetSystemCall */
48670 0, /* xNextSystemCall */
48671 };
48672
48673 static const sqlite3_io_methods memdb_io_methods = {
48674 3, /* iVersion */
48675 memdbClose, /* xClose */
@@ -48468,23 +48690,71 @@
48690 0, /* xShmUnmap */
48691 memdbFetch, /* xFetch */
48692 memdbUnfetch /* xUnfetch */
48693 };
48694
48695 /*
48696 ** Enter/leave the mutex on a MemStore
48697 */
48698 #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0
48699 static void memdbEnter(MemStore *p){
48700 UNUSED_PARAMETER(p);
48701 }
48702 static void memdbLeave(MemStore *p){
48703 UNUSED_PARAMETER(p);
48704 }
48705 #else
48706 static void memdbEnter(MemStore *p){
48707 sqlite3_mutex_enter(p->pMutex);
48708 }
48709 static void memdbLeave(MemStore *p){
48710 sqlite3_mutex_leave(p->pMutex);
48711 }
48712 #endif
48713
48714
48715
48716 /*
48717 ** Close an memdb-file.
48718 ** Free the underlying MemStore object when its refcount drops to zero
48719 ** or less.
 
 
48720 */
48721 static int memdbClose(sqlite3_file *pFile){
48722 MemStore *p = ((MemFile*)pFile)->pStore;
48723 if( p->zFName ){
48724 int i;
48725 #ifndef SQLITE_MUTEX_OMIT
48726 sqlite3_mutex *pVfsMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1);
48727 #endif
48728 sqlite3_mutex_enter(pVfsMutex);
48729 for(i=0; ALWAYS(i<memdb_g.nMemStore); i++){
48730 if( memdb_g.apMemStore[i]==p ){
48731 memdbEnter(p);
48732 if( p->nRef==1 ){
48733 memdb_g.apMemStore[i] = memdb_g.apMemStore[--memdb_g.nMemStore];
48734 if( memdb_g.nMemStore==0 ){
48735 sqlite3_free(memdb_g.apMemStore);
48736 memdb_g.apMemStore = 0;
48737 }
48738 }
48739 break;
48740 }
48741 }
48742 sqlite3_mutex_leave(pVfsMutex);
48743 }else{
48744 memdbEnter(p);
48745 }
48746 p->nRef--;
48747 if( p->nRef<=0 ){
48748 if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ){
48749 sqlite3_free(p->aData);
48750 }
48751 memdbLeave(p);
48752 sqlite3_mutex_free(p->pMutex);
48753 sqlite3_free(p);
48754 }else{
48755 memdbLeave(p);
48756 }
48757 return SQLITE_OK;
48758 }
48759
48760 /*
@@ -48494,24 +48764,27 @@
48764 sqlite3_file *pFile,
48765 void *zBuf,
48766 int iAmt,
48767 sqlite_int64 iOfst
48768 ){
48769 MemStore *p = ((MemFile*)pFile)->pStore;
48770 memdbEnter(p);
48771 if( iOfst+iAmt>p->sz ){
48772 memset(zBuf, 0, iAmt);
48773 if( iOfst<p->sz ) memcpy(zBuf, p->aData+iOfst, p->sz - iOfst);
48774 memdbLeave(p);
48775 return SQLITE_IOERR_SHORT_READ;
48776 }
48777 memcpy(zBuf, p->aData+iOfst, iAmt);
48778 memdbLeave(p);
48779 return SQLITE_OK;
48780 }
48781
48782 /*
48783 ** Try to enlarge the memory allocation to hold at least sz bytes
48784 */
48785 static int memdbEnlarge(MemStore *p, sqlite3_int64 newSz){
48786 unsigned char *pNew;
48787 if( (p->mFlags & SQLITE_DESERIALIZE_RESIZEABLE)==0 || p->nMmap>0 ){
48788 return SQLITE_FULL;
48789 }
48790 if( newSz>p->szMax ){
@@ -48518,11 +48791,11 @@
48791 return SQLITE_FULL;
48792 }
48793 newSz *= 2;
48794 if( newSz>p->szMax ) newSz = p->szMax;
48795 pNew = sqlite3Realloc(p->aData, newSz);
48796 if( pNew==0 ) return SQLITE_IOERR_NOMEM;
48797 p->aData = pNew;
48798 p->szAlloc = newSz;
48799 return SQLITE_OK;
48800 }
48801
@@ -48533,23 +48806,31 @@
48806 sqlite3_file *pFile,
48807 const void *z,
48808 int iAmt,
48809 sqlite_int64 iOfst
48810 ){
48811 MemStore *p = ((MemFile*)pFile)->pStore;
48812 memdbEnter(p);
48813 if( NEVER(p->mFlags & SQLITE_DESERIALIZE_READONLY) ){
48814 /* Can't happen: memdbLock() will return SQLITE_READONLY before
48815 ** reaching this point */
48816 memdbLeave(p);
48817 return SQLITE_IOERR_WRITE;
48818 }
48819 if( iOfst+iAmt>p->sz ){
48820 int rc;
48821 if( iOfst+iAmt>p->szAlloc
48822 && (rc = memdbEnlarge(p, iOfst+iAmt))!=SQLITE_OK
48823 ){
48824 memdbLeave(p);
48825 return rc;
48826 }
48827 if( iOfst>p->sz ) memset(p->aData+p->sz, 0, iOfst-p->sz);
48828 p->sz = iOfst+iAmt;
48829 }
48830 memcpy(p->aData+iOfst, z, iAmt);
48831 memdbLeave(p);
48832 return SQLITE_OK;
48833 }
48834
48835 /*
48836 ** Truncate an memdb-file.
@@ -48557,62 +48838,103 @@
48838 ** In rollback mode (which is always the case for memdb, as it does not
48839 ** support WAL mode) the truncate() method is only used to reduce
48840 ** the size of a file, never to increase the size.
48841 */
48842 static int memdbTruncate(sqlite3_file *pFile, sqlite_int64 size){
48843 MemStore *p = ((MemFile*)pFile)->pStore;
48844 int rc = SQLITE_OK;
48845 memdbEnter(p);
48846 if( NEVER(size>p->sz) ){
48847 rc = SQLITE_FULL;
48848 }else{
48849 p->sz = size;
48850 }
48851 memdbLeave(p);
48852 return rc;
48853 }
48854
48855 /*
48856 ** Sync an memdb-file.
48857 */
48858 static int memdbSync(sqlite3_file *pFile, int flags){
48859 UNUSED_PARAMETER(pFile);
48860 UNUSED_PARAMETER(flags);
48861 return SQLITE_OK;
48862 }
48863
48864 /*
48865 ** Return the current file-size of an memdb-file.
48866 */
48867 static int memdbFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){
48868 MemStore *p = ((MemFile*)pFile)->pStore;
48869 memdbEnter(p);
48870 *pSize = p->sz;
48871 memdbLeave(p);
48872 return SQLITE_OK;
48873 }
48874
48875 /*
48876 ** Lock an memdb-file.
48877 */
48878 static int memdbLock(sqlite3_file *pFile, int eLock){
48879 MemFile *pThis = (MemFile*)pFile;
48880 MemStore *p = pThis->pStore;
48881 int rc = SQLITE_OK;
48882 if( eLock==pThis->eLock ) return SQLITE_OK;
48883 memdbEnter(p);
48884 if( eLock>SQLITE_LOCK_SHARED ){
48885 if( p->mFlags & SQLITE_DESERIALIZE_READONLY ){
48886 rc = SQLITE_READONLY;
48887 }else if( pThis->eLock<=SQLITE_LOCK_SHARED ){
48888 if( p->nWrLock ){
48889 rc = SQLITE_BUSY;
48890 }else{
48891 p->nWrLock = 1;
48892 }
48893 }
48894 }else if( eLock==SQLITE_LOCK_SHARED ){
48895 if( pThis->eLock > SQLITE_LOCK_SHARED ){
48896 assert( p->nWrLock==1 );
48897 p->nWrLock = 0;
48898 }else if( p->nWrLock ){
48899 rc = SQLITE_BUSY;
48900 }else{
48901 p->nRdLock++;
48902 }
48903 }else{
48904 assert( eLock==SQLITE_LOCK_NONE );
48905 if( pThis->eLock>SQLITE_LOCK_SHARED ){
48906 assert( p->nWrLock==1 );
48907 p->nWrLock = 0;
48908 }
48909 assert( p->nRdLock>0 );
48910 p->nRdLock--;
48911 }
48912 if( rc==SQLITE_OK ) pThis->eLock = eLock;
48913 memdbLeave(p);
48914 return rc;
48915 }
48916
48917 #if 0
48918 /*
48919 ** This interface is only used for crash recovery, which does not
48920 ** occur on an in-memory database.
48921 */
48922 static int memdbCheckReservedLock(sqlite3_file *pFile, int *pResOut){
48923 *pResOut = 0;
48924 return SQLITE_OK;
48925 }
48926 #endif
48927
48928
48929 /*
48930 ** File control method. For custom operations on an memdb-file.
48931 */
48932 static int memdbFileControl(sqlite3_file *pFile, int op, void *pArg){
48933 MemStore *p = ((MemFile*)pFile)->pStore;
48934 int rc = SQLITE_NOTFOUND;
48935 memdbEnter(p);
48936 if( op==SQLITE_FCNTL_VFSNAME ){
48937 *(char**)pArg = sqlite3_mprintf("memdb(%p,%lld)", p->aData, p->sz);
48938 rc = SQLITE_OK;
48939 }
48940 if( op==SQLITE_FCNTL_SIZE_LIMIT ){
@@ -48626,10 +48948,11 @@
48948 }
48949 p->szMax = iLimit;
48950 *(sqlite3_int64*)pArg = iLimit;
48951 rc = SQLITE_OK;
48952 }
48953 memdbLeave(p);
48954 return rc;
48955 }
48956
48957 #if 0 /* Not used because of SQLITE_IOCAP_POWERSAFE_OVERWRITE */
48958 /*
@@ -48642,10 +48965,11 @@
48965
48966 /*
48967 ** Return the device characteristic flags supported by an memdb-file.
48968 */
48969 static int memdbDeviceCharacteristics(sqlite3_file *pFile){
48970 UNUSED_PARAMETER(pFile);
48971 return SQLITE_IOCAP_ATOMIC |
48972 SQLITE_IOCAP_POWERSAFE_OVERWRITE |
48973 SQLITE_IOCAP_SAFE_APPEND |
48974 SQLITE_IOCAP_SEQUENTIAL;
48975 }
@@ -48655,47 +48979,112 @@
48979 sqlite3_file *pFile,
48980 sqlite3_int64 iOfst,
48981 int iAmt,
48982 void **pp
48983 ){
48984 MemStore *p = ((MemFile*)pFile)->pStore;
48985 memdbEnter(p);
48986 if( iOfst+iAmt>p->sz ){
48987 *pp = 0;
48988 }else{
48989 p->nMmap++;
48990 *pp = (void*)(p->aData + iOfst);
48991 }
48992 memdbLeave(p);
48993 return SQLITE_OK;
48994 }
48995
48996 /* Release a memory-mapped page */
48997 static int memdbUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){
48998 MemStore *p = ((MemFile*)pFile)->pStore;
48999 UNUSED_PARAMETER(iOfst);
49000 UNUSED_PARAMETER(pPage);
49001 memdbEnter(p);
49002 p->nMmap--;
49003 memdbLeave(p);
49004 return SQLITE_OK;
49005 }
49006
49007 /*
49008 ** Open an mem file handle.
49009 */
49010 static int memdbOpen(
49011 sqlite3_vfs *pVfs,
49012 const char *zName,
49013 sqlite3_file *pFd,
49014 int flags,
49015 int *pOutFlags
49016 ){
49017 MemFile *pFile = (MemFile*)pFd;
49018 MemStore *p = 0;
49019 int szName;
49020 if( (flags & SQLITE_OPEN_MAIN_DB)==0 ){
49021 return ORIGVFS(pVfs)->xOpen(ORIGVFS(pVfs), zName, pFd, flags, pOutFlags);
49022 }
49023 memset(pFile, 0, sizeof(*p));
49024 szName = sqlite3Strlen30(zName);
49025 if( szName>1 && zName[0]=='/' ){
49026 int i;
49027 #ifndef SQLITE_MUTEX_OMIT
49028 sqlite3_mutex *pVfsMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1);
49029 #endif
49030 sqlite3_mutex_enter(pVfsMutex);
49031 for(i=0; i<memdb_g.nMemStore; i++){
49032 if( strcmp(memdb_g.apMemStore[i]->zFName,zName)==0 ){
49033 p = memdb_g.apMemStore[i];
49034 break;
49035 }
49036 }
49037 if( p==0 ){
49038 MemStore **apNew;
49039 p = sqlite3Malloc( sizeof(*p) + szName + 3 );
49040 if( p==0 ){
49041 sqlite3_mutex_leave(pVfsMutex);
49042 return SQLITE_NOMEM;
49043 }
49044 apNew = sqlite3Realloc(memdb_g.apMemStore,
49045 sizeof(apNew[0])*(memdb_g.nMemStore+1) );
49046 if( apNew==0 ){
49047 sqlite3_free(p);
49048 sqlite3_mutex_leave(pVfsMutex);
49049 return SQLITE_NOMEM;
49050 }
49051 apNew[memdb_g.nMemStore++] = p;
49052 memdb_g.apMemStore = apNew;
49053 memset(p, 0, sizeof(*p));
49054 p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE|SQLITE_DESERIALIZE_FREEONCLOSE;
49055 p->szMax = sqlite3GlobalConfig.mxMemdbSize;
49056 p->zFName = (char*)&p[1];
49057 memcpy(p->zFName, zName, szName+1);
49058 p->pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
49059 if( p->pMutex==0 ){
49060 memdb_g.nMemStore--;
49061 sqlite3_free(p);
49062 sqlite3_mutex_leave(pVfsMutex);
49063 return SQLITE_NOMEM;
49064 }
49065 p->nRef = 1;
49066 memdbEnter(p);
49067 }else{
49068 memdbEnter(p);
49069 p->nRef++;
49070 }
49071 sqlite3_mutex_leave(pVfsMutex);
49072 }else{
49073 p = sqlite3Malloc( sizeof(*p) );
49074 if( p==0 ){
49075 return SQLITE_NOMEM;
49076 }
49077 memset(p, 0, sizeof(*p));
49078 p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE;
49079 p->szMax = sqlite3GlobalConfig.mxMemdbSize;
49080 }
49081 pFile->pStore = p;
49082 assert( pOutFlags!=0 ); /* True because flags==SQLITE_OPEN_MAIN_DB */
49083 *pOutFlags = flags | SQLITE_OPEN_MEMORY;
49084 pFd->pMethods = &memdb_io_methods;
49085 memdbLeave(p);
49086 return SQLITE_OK;
49087 }
49088
49089 #if 0 /* Only used to delete rollback journals, super-journals, and WAL
49090 ** files, none of which exist in memdb. So this routine is never used */
@@ -48719,10 +49108,13 @@
49108 sqlite3_vfs *pVfs,
49109 const char *zPath,
49110 int flags,
49111 int *pResOut
49112 ){
49113 UNUSED_PARAMETER(pVfs);
49114 UNUSED_PARAMETER(zPath);
49115 UNUSED_PARAMETER(flags);
49116 *pResOut = 0;
49117 return SQLITE_OK;
49118 }
49119
49120 /*
@@ -48734,10 +49126,11 @@
49126 sqlite3_vfs *pVfs,
49127 const char *zPath,
49128 int nOut,
49129 char *zOut
49130 ){
49131 UNUSED_PARAMETER(pVfs);
49132 sqlite3_snprintf(nOut, zOut, "%s", zPath);
49133 return SQLITE_OK;
49134 }
49135
49136 /*
@@ -48806,13 +49199,18 @@
49199 ** Translate a database connection pointer and schema name into a
49200 ** MemFile pointer.
49201 */
49202 static MemFile *memdbFromDbSchema(sqlite3 *db, const char *zSchema){
49203 MemFile *p = 0;
49204 MemStore *pStore;
49205 int rc = sqlite3_file_control(db, zSchema, SQLITE_FCNTL_FILE_POINTER, &p);
49206 if( rc ) return 0;
49207 if( p->base.pMethods!=&memdb_io_methods ) return 0;
49208 pStore = p->pStore;
49209 memdbEnter(pStore);
49210 if( pStore->zFName!=0 ) p = 0;
49211 memdbLeave(pStore);
49212 return p;
49213 }
49214
49215 /*
49216 ** Return the serialization of a database
@@ -48844,16 +49242,18 @@
49242 p = memdbFromDbSchema(db, zSchema);
49243 iDb = sqlite3FindDbName(db, zSchema);
49244 if( piSize ) *piSize = -1;
49245 if( iDb<0 ) return 0;
49246 if( p ){
49247 MemStore *pStore = p->pStore;
49248 assert( pStore->pMutex==0 );
49249 if( piSize ) *piSize = pStore->sz;
49250 if( mFlags & SQLITE_SERIALIZE_NOCOPY ){
49251 pOut = pStore->aData;
49252 }else{
49253 pOut = sqlite3_malloc64( pStore->sz );
49254 if( pOut ) memcpy(pOut, pStore->aData, pStore->sz);
49255 }
49256 return pOut;
49257 }
49258 pBt = db->aDb[iDb].pBt;
49259 if( pBt==0 ) return 0;
@@ -48943,19 +49343,20 @@
49343 }
49344 p = memdbFromDbSchema(db, zSchema);
49345 if( p==0 ){
49346 rc = SQLITE_ERROR;
49347 }else{
49348 MemStore *pStore = p->pStore;
49349 pStore->aData = pData;
49350 pData = 0;
49351 pStore->sz = szDb;
49352 pStore->szAlloc = szBuf;
49353 pStore->szMax = szBuf;
49354 if( pStore->szMax<sqlite3GlobalConfig.mxMemdbSize ){
49355 pStore->szMax = sqlite3GlobalConfig.mxMemdbSize;
49356 }
49357 pStore->mFlags = mFlags;
49358 rc = SQLITE_OK;
49359 }
49360
49361 end_deserialize:
49362 sqlite3_finalize(pStmt);
@@ -48970,21 +49371,21 @@
49371 ** This routine is called when the extension is loaded.
49372 ** Register the new VFS.
49373 */
49374 SQLITE_PRIVATE int sqlite3MemdbInit(void){
49375 sqlite3_vfs *pLower = sqlite3_vfs_find(0);
49376 unsigned int sz = pLower->szOsFile;
49377 memdb_vfs.pAppData = pLower;
49378 /* The following conditional can only be true when compiled for
49379 ** Windows x86 and SQLITE_MAX_MMAP_SIZE=0. We always leave
49380 ** it in, to be safe, but it is marked as NO_TEST since there
49381 ** is no way to reach it under most builds. */
49382 if( sz<sizeof(MemFile) ) sz = sizeof(MemFile); /*NO_TEST*/
49383 memdb_vfs.szOsFile = sz;
49384 return sqlite3_vfs_register(&memdb_vfs, 0);
49385 }
49386 #endif /* SQLITE_OMIT_DESERIALIZE */
49387
49388 /************** End of memdb.c ***********************************************/
49389 /************** Begin file bitvec.c ******************************************/
49390 /*
49391 ** 2008 February 16
@@ -56895,11 +57296,11 @@
57296 u8 *pPtr;
57297 Pager *pPager = 0; /* Pager object to allocate and return */
57298 int rc = SQLITE_OK; /* Return code */
57299 int tempFile = 0; /* True for temp files (incl. in-memory files) */
57300 int memDb = 0; /* True if this is an in-memory file */
57301 #ifndef SQLITE_OMIT_DESERIALIZE
57302 int memJM = 0; /* Memory journal mode */
57303 #else
57304 # define memJM 0
57305 #endif
57306 int readOnly = 0; /* True if this is a read-only file */
@@ -57099,11 +57500,11 @@
57500 */
57501 if( zFilename && zFilename[0] ){
57502 int fout = 0; /* VFS flags returned by xOpen() */
57503 rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout);
57504 assert( !memDb );
57505 #ifndef SQLITE_OMIT_DESERIALIZE
57506 memJM = (fout&SQLITE_OPEN_MEMORY)!=0;
57507 #endif
57508 readOnly = (fout&SQLITE_OPEN_READONLY)!=0;
57509
57510 /* If the file was successfully opened for read/write access,
@@ -58067,11 +58468,11 @@
58468
58469 if( pPager->errCode ) return pPager->errCode;
58470 assert( pPager->eState>=PAGER_READER && pPager->eState<PAGER_ERROR );
58471 pPager->subjInMemory = (u8)subjInMemory;
58472
58473 if( pPager->eState==PAGER_READER ){
58474 assert( pPager->pInJournal==0 );
58475
58476 if( pagerUseWal(pPager) ){
58477 /* If the pager is configured to use locking_mode=exclusive, and an
58478 ** exclusive lock on the database is not already held, obtain it now.
@@ -60941,11 +61342,10 @@
61342 static void walCleanupHash(Wal *pWal){
61343 WalHashLoc sLoc; /* Hash table location */
61344 int iLimit = 0; /* Zero values greater than this */
61345 int nByte; /* Number of bytes to zero in aPgno[] */
61346 int i; /* Used to iterate through aHash[] */
 
61347
61348 assert( pWal->writeLock );
61349 testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 );
61350 testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE );
61351 testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 );
@@ -60956,12 +61356,12 @@
61356 ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed
61357 ** that the page said hash-table and array reside on is already mapped.(1)
61358 */
61359 assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );
61360 assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );
61361 i = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
61362 if( NEVER(i) ) return; /* Defense-in-depth, in case (1) above is wrong */
61363
61364 /* Zero all hash-table entries that correspond to frame numbers greater
61365 ** than pWal->hdr.mxFrame.
61366 */
61367 iLimit = pWal->hdr.mxFrame - sLoc.iZero;
@@ -65587,11 +65987,11 @@
65987 Pgno pgnoRoot, /* The table that might be changing */
65988 i64 iRow, /* The rowid that might be changing */
65989 int isClearTable /* True if all rows are being deleted */
65990 ){
65991 BtCursor *p;
65992 assert( pBtree->hasIncrblobCur );
65993 assert( sqlite3BtreeHoldsMutex(pBtree) );
65994 pBtree->hasIncrblobCur = 0;
65995 for(p=pBtree->pBt->pCursor; p; p=p->pNext){
65996 if( (p->curFlags & BTCF_Incrblob)!=0 ){
65997 pBtree->hasIncrblobCur = 1;
@@ -66488,10 +66888,11 @@
66888 unsigned char *data; /* The page data */
66889 unsigned char *temp; /* Temp area for cell content */
66890 unsigned char *src; /* Source of content */
66891 int iCellFirst; /* First allowable cell index */
66892 int iCellLast; /* Last possible cell index */
66893 int iCellStart; /* First cell offset in input */
66894
66895 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
66896 assert( pPage->pBt!=0 );
66897 assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE );
66898 assert( pPage->nOverflow==0 );
@@ -66529,11 +66930,11 @@
66930 if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage);
66931 sz2 = get2byte(&data[iFree2+2]);
66932 if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage);
66933 memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));
66934 sz += sz2;
66935 }else if( iFree+sz>usableSize ){
66936 return SQLITE_CORRUPT_PAGE(pPage);
66937 }
66938
66939 cbrk = top+sz;
66940 assert( cbrk+(iFree-top) <= usableSize );
@@ -66548,38 +66949,37 @@
66949 }
66950 }
66951
66952 cbrk = usableSize;
66953 iCellLast = usableSize - 4;
66954 iCellStart = get2byte(&data[hdr+5]);
66955 for(i=0; i<nCell; i++){
66956 u8 *pAddr; /* The i-th cell pointer */
66957 pAddr = &data[cellOffset + i*2];
66958 pc = get2byte(pAddr);
66959 testcase( pc==iCellFirst );
66960 testcase( pc==iCellLast );
66961 /* These conditions have already been verified in btreeInitPage()
66962 ** if PRAGMA cell_size_check=ON.
66963 */
66964 if( pc<iCellStart || pc>iCellLast ){
66965 return SQLITE_CORRUPT_PAGE(pPage);
66966 }
66967 assert( pc>=iCellStart && pc<=iCellLast );
66968 size = pPage->xCellSize(pPage, &src[pc]);
66969 cbrk -= size;
66970 if( cbrk<iCellStart || pc+size>usableSize ){
66971 return SQLITE_CORRUPT_PAGE(pPage);
66972 }
66973 assert( cbrk+size<=usableSize && cbrk>=iCellStart );
66974 testcase( cbrk+size==usableSize );
66975 testcase( pc+size==usableSize );
66976 put2byte(pAddr, cbrk);
66977 if( temp==0 ){
 
66978 if( cbrk==pc ) continue;
66979 temp = sqlite3PagerTempSpace(pPage->pBt->pPager);
66980 memcpy(&temp[iCellStart], &data[iCellStart], usableSize - iCellStart);
 
66981 src = temp;
66982 }
66983 memcpy(&data[cbrk], &src[pc], size);
66984 }
66985 data[hdr+7] = 0;
@@ -71459,14 +71859,13 @@
71859 *pRC = freePage2(pPage->pBt, pPage, pPage->pgno);
71860 }
71861 }
71862
71863 /*
71864 ** Free the overflow pages associated with the given Cell.
 
71865 */
71866 static SQLITE_NOINLINE int clearCellOverflow(
71867 MemPage *pPage, /* The page that contains the Cell */
71868 unsigned char *pCell, /* First byte of the Cell */
71869 CellInfo *pInfo /* Size information about the cell */
71870 ){
71871 BtShared *pBt;
@@ -71474,14 +71873,11 @@
71873 int rc;
71874 int nOvfl;
71875 u32 ovflPageSize;
71876
71877 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
71878 assert( pInfo->nLocal!=pInfo->nPayload );
 
 
 
71879 testcase( pCell + pInfo->nSize == pPage->aDataEnd );
71880 testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd );
71881 if( pCell + pInfo->nSize > pPage->aDataEnd ){
71882 /* Cell extends past end of page */
71883 return SQLITE_CORRUPT_PAGE(pPage);
@@ -71532,10 +71928,25 @@
71928 if( rc ) return rc;
71929 ovflPgno = iNext;
71930 }
71931 return SQLITE_OK;
71932 }
71933
71934 /* Call xParseCell to compute the size of a cell. If the cell contains
71935 ** overflow, then invoke cellClearOverflow to clear out that overflow.
71936 ** STore the result code (SQLITE_OK or some error code) in rc.
71937 **
71938 ** Implemented as macro to force inlining for performance.
71939 */
71940 #define BTREE_CLEAR_CELL(rc, pPage, pCell, sInfo) \
71941 pPage->xParseCell(pPage, pCell, &sInfo); \
71942 if( sInfo.nLocal!=sInfo.nPayload ){ \
71943 rc = clearCellOverflow(pPage, pCell, &sInfo); \
71944 }else{ \
71945 rc = SQLITE_OK; \
71946 }
71947
71948
71949 /*
71950 ** Create the byte sequence used to represent a cell on page pPage
71951 ** and write that byte sequence into pCell[]. Overflow pages are
71952 ** allocated and filled in as necessary. The calling procedure
@@ -72055,11 +72466,11 @@
72466 pData = pEnd;
72467 while( 1/*exit by break*/ ){
72468 u8 *pCell = pCArray->apCell[i];
72469 u16 sz = pCArray->szCell[i];
72470 assert( sz>0 );
72471 if( SQLITE_WITHIN(pCell,aData+j,pEnd) ){
72472 if( ((uptr)(pCell+sz))>(uptr)pEnd ) return SQLITE_CORRUPT_BKPT;
72473 pCell = &pTmp[pCell - aData];
72474 }else if( (uptr)(pCell+sz)>(uptr)pSrcEnd
72475 && (uptr)(pCell)<(uptr)pSrcEnd
72476 ){
@@ -72068,13 +72479,12 @@
72479
72480 pData -= sz;
72481 put2byte(pCellptr, (pData - aData));
72482 pCellptr += 2;
72483 if( pData < pCellptr ) return SQLITE_CORRUPT_BKPT;
72484 memmove(pData, pCell, sz);
72485 assert( sz==pPg->xCellSize(pPg, pCell) || CORRUPT_DB );
 
72486 i++;
72487 if( i>=iEnd ) break;
72488 if( pCArray->ixNx[k]<=i ){
72489 k++;
72490 pSrcEnd = pCArray->apEnd[k];
@@ -72209,11 +72619,13 @@
72619 assert( pFree>aData && (pFree - aData)<65536 );
72620 freeSpace(pPg, (u16)(pFree - aData), szFree);
72621 }
72622 pFree = pCell;
72623 szFree = sz;
72624 if( pFree+sz>pEnd ){
72625 return 0;
72626 }
72627 }else{
72628 pFree = pCell;
72629 szFree += sz;
72630 }
72631 nRet++;
@@ -72862,11 +73274,11 @@
73274 b.apCell[b.nCell] = pTemp+leafCorrection;
73275 assert( leafCorrection==0 || leafCorrection==4 );
73276 b.szCell[b.nCell] = b.szCell[b.nCell] - leafCorrection;
73277 if( !pOld->leaf ){
73278 assert( leafCorrection==0 );
73279 assert( pOld->hdrOffset==0 || CORRUPT_DB );
73280 /* The right pointer of the child page pOld becomes the left
73281 ** pointer of the divider cell */
73282 memcpy(b.apCell[b.nCell], &pOld->aData[8], 4);
73283 }else{
73284 assert( leafCorrection==4 );
@@ -73185,10 +73597,11 @@
73597 /* Insert new divider cells into pParent. */
73598 for(i=0; i<nNew-1; i++){
73599 u8 *pCell;
73600 u8 *pTemp;
73601 int sz;
73602 u8 *pSrcEnd;
73603 MemPage *pNew = apNew[i];
73604 j = cntNew[i];
73605
73606 assert( j<nMaxCells );
73607 assert( b.apCell[j]!=0 );
@@ -73228,10 +73641,16 @@
73641 }
73642 }
73643 iOvflSpace += sz;
73644 assert( sz<=pBt->maxLocal+23 );
73645 assert( iOvflSpace <= (int)pBt->pageSize );
73646 for(k=0; b.ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
73647 pSrcEnd = b.apEnd[k];
73648 if( SQLITE_WITHIN(pSrcEnd, pCell, pCell+sz) ){
73649 rc = SQLITE_CORRUPT_BKPT;
73650 goto balance_cleanup;
73651 }
73652 insertCell(pParent, nxDiv+i, pCell, sz, pTemp, pNew->pgno, &rc);
73653 if( rc!=SQLITE_OK ) goto balance_cleanup;
73654 assert( sqlite3PagerIswriteable(pParent->pDbPage) );
73655 }
73656
@@ -73770,17 +74189,27 @@
74189 ** not to clear the cursor here.
74190 */
74191 if( pCur->curFlags & BTCF_Multiple ){
74192 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
74193 if( rc ) return rc;
74194 if( loc && pCur->iPage<0 ){
74195 /* This can only happen if the schema is corrupt such that there is more
74196 ** than one table or index with the same root page as used by the cursor.
74197 ** Which can only happen if the SQLITE_NoSchemaError flag was set when
74198 ** the schema was loaded. This cannot be asserted though, as a user might
74199 ** set the flag, load the schema, and then unset the flag. */
74200 return SQLITE_CORRUPT_BKPT;
74201 }
74202 }
74203
74204 if( pCur->pKeyInfo==0 ){
74205 assert( pX->pKey==0 );
74206 /* If this is an insert into a table b-tree, invalidate any incrblob
74207 ** cursors open on the row being replaced */
74208 if( p->hasIncrblobCur ){
74209 invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0);
74210 }
74211
74212 /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing
74213 ** to a row with the same key as the new entry being inserted.
74214 */
74215 #ifdef SQLITE_DEBUG
@@ -73857,21 +74286,20 @@
74286 x2.nData = pX->nKey;
74287 x2.nZero = 0;
74288 return btreeOverwriteCell(pCur, &x2);
74289 }
74290 }
 
74291 }
74292 assert( pCur->eState==CURSOR_VALID
74293 || (pCur->eState==CURSOR_INVALID && loc)
74294 || CORRUPT_DB );
74295
74296 pPage = pCur->pPage;
74297 assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) );
74298 assert( pPage->leaf || !pPage->intKey );
74299 if( pPage->nFree<0 ){
74300 if( NEVER(pCur->eState>CURSOR_INVALID) ){
74301 rc = SQLITE_CORRUPT_BKPT;
74302 }else{
74303 rc = btreeComputeFreeSpace(pPage);
74304 }
74305 if( rc ) return rc;
@@ -73911,11 +74339,11 @@
74339 }
74340 oldCell = findCell(pPage, idx);
74341 if( !pPage->leaf ){
74342 memcpy(newCell, oldCell, 4);
74343 }
74344 BTREE_CLEAR_CELL(rc, pPage, oldCell, info);
74345 testcase( pCur->curFlags & BTCF_ValidOvfl );
74346 invalidateOverflowCache(pCur);
74347 if( info.nSize==szNew && info.nLocal==info.nPayload
74348 && (!ISAUTOVACUUM || szNew<pPage->minLocal)
74349 ){
@@ -74148,11 +74576,12 @@
74576 assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );
74577 assert( !hasReadConflicts(p, pCur->pgnoRoot) );
74578 assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 );
74579 if( pCur->eState==CURSOR_REQUIRESEEK ){
74580 rc = btreeRestoreCursorPosition(pCur);
74581 assert( rc!=SQLITE_OK || CORRUPT_DB || pCur->eState==CURSOR_VALID );
74582 if( rc || pCur->eState!=CURSOR_VALID ) return rc;
74583 }
74584 assert( CORRUPT_DB || pCur->eState==CURSOR_VALID );
74585
74586 iCellDepth = pCur->iPage;
74587 iCellIdx = pCur->ix;
@@ -74203,20 +74632,20 @@
74632 if( rc ) return rc;
74633 }
74634
74635 /* If this is a delete operation to remove a row from a table b-tree,
74636 ** invalidate any incrblob cursors open on the row being deleted. */
74637 if( pCur->pKeyInfo==0 && p->hasIncrblobCur ){
74638 invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0);
74639 }
74640
74641 /* Make the page containing the entry to be deleted writable. Then free any
74642 ** overflow pages associated with the entry and finally remove the cell
74643 ** itself from within the page. */
74644 rc = sqlite3PagerWrite(pPage->pDbPage);
74645 if( rc ) return rc;
74646 BTREE_CLEAR_CELL(rc, pPage, pCell, info);
74647 dropCell(pPage, iCellIdx, info.nSize, &rc);
74648 if( rc ) return rc;
74649
74650 /* If the cell deleted was not located on a leaf page, then the cursor
74651 ** is currently pointing to the largest entry in the sub-tree headed
@@ -74499,18 +74928,18 @@
74928 pCell = findCell(pPage, i);
74929 if( !pPage->leaf ){
74930 rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
74931 if( rc ) goto cleardatabasepage_out;
74932 }
74933 BTREE_CLEAR_CELL(rc, pPage, pCell, info);
74934 if( rc ) goto cleardatabasepage_out;
74935 }
74936 if( !pPage->leaf ){
74937 rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
74938 if( rc ) goto cleardatabasepage_out;
74939 }
74940 if( pnChange ){
74941 testcase( !pPage->intKey );
74942 *pnChange += pPage->nCell;
74943 }
74944 if( freePageFlag ){
74945 freePage(pPage, &rc);
@@ -74531,13 +74960,12 @@
74960 **
74961 ** This routine will fail with SQLITE_LOCKED if there are any open
74962 ** read cursors on the table. Open write cursors are moved to the
74963 ** root of the table.
74964 **
74965 ** If pnChange is not NULL, then the integer value pointed to by pnChange
74966 ** is incremented by the number of entries in the table.
 
74967 */
74968 SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){
74969 int rc;
74970 BtShared *pBt = p->pBt;
74971 sqlite3BtreeEnter(p);
@@ -74547,11 +74975,13 @@
74975
74976 if( SQLITE_OK==rc ){
74977 /* Invalidate all incrblob cursors open on table iTable (assuming iTable
74978 ** is the root of a table b-tree - if it is not, the following call is
74979 ** a no-op). */
74980 if( p->hasIncrblobCur ){
74981 invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1);
74982 }
74983 rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
74984 }
74985 sqlite3BtreeLeave(p);
74986 return rc;
74987 }
@@ -76630,11 +77060,13 @@
77060 assert( (p->flags & MEM_Cleared)==0 );
77061 }
77062
77063 /* The szMalloc field holds the correct memory allocation size */
77064 assert( p->szMalloc==0
77065 || (p->flags==MEM_Undefined
77066 && p->szMalloc<=sqlite3DbMallocSize(p->db,p->zMalloc))
77067 || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc));
77068
77069 /* If p holds a string or blob, the Mem.z must point to exactly
77070 ** one of the following:
77071 **
77072 ** (1) Memory in Mem.zMalloc and managed by the Mem object
@@ -76794,11 +77226,13 @@
77226 ** contain a valid string or blob value. */
77227 assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
77228 testcase( bPreserve && pMem->z==0 );
77229
77230 assert( pMem->szMalloc==0
77231 || (pMem->flags==MEM_Undefined
77232 && pMem->szMalloc<=sqlite3DbMallocSize(pMem->db,pMem->zMalloc))
77233 || pMem->szMalloc==sqlite3DbMallocSize(pMem->db,pMem->zMalloc));
77234 if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){
77235 if( pMem->db ){
77236 pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
77237 }else{
77238 pMem->zMalloc = sqlite3Realloc(pMem->z, n);
@@ -77623,15 +78057,15 @@
78057 ** either case, SQLITE_TOOBIG is returned.
78058 */
78059 SQLITE_PRIVATE int sqlite3VdbeMemSetStr(
78060 Mem *pMem, /* Memory cell to set to string value */
78061 const char *z, /* String pointer */
78062 i64 n, /* Bytes in string, or negative */
78063 u8 enc, /* Encoding of z. 0 for BLOBs */
78064 void (*xDel)(void*) /* Destructor function */
78065 ){
78066 i64 nByte = n; /* New value for pMem->n */
78067 int iLimit; /* Maximum allowed string or blob size */
78068 u16 flags = 0; /* New value for pMem->flags */
78069
78070 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
78071 assert( !sqlite3VdbeMemIsRowSet(pMem) );
@@ -77649,11 +78083,11 @@
78083 }
78084 flags = (enc==0?MEM_Blob:MEM_Str);
78085 if( nByte<0 ){
78086 assert( enc!=0 );
78087 if( enc==SQLITE_UTF8 ){
78088 nByte = strlen(z);
78089 }else{
78090 for(nByte=0; nByte<=iLimit && (z[nByte] | z[nByte+1]); nByte+=2){}
78091 }
78092 flags |= MEM_Term;
78093 }
@@ -77661,11 +78095,11 @@
78095 /* The following block sets the new values of Mem.z and Mem.xDel. It
78096 ** also sets a flag in local variable "flags" to indicate the memory
78097 ** management (one of MEM_Dyn or MEM_Static).
78098 */
78099 if( xDel==SQLITE_TRANSIENT ){
78100 i64 nAlloc = nByte;
78101 if( flags&MEM_Term ){
78102 nAlloc += (enc==SQLITE_UTF8?1:2);
78103 }
78104 if( nByte>iLimit ){
78105 return sqlite3ErrorToParser(pMem->db, SQLITE_TOOBIG);
@@ -77687,11 +78121,11 @@
78121 pMem->xDel = xDel;
78122 flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn);
78123 }
78124 }
78125
78126 pMem->n = (int)(nByte & 0x7fffffff);
78127 pMem->flags = flags;
78128 if( enc ){
78129 pMem->enc = enc;
78130 #ifdef SQLITE_ENABLE_SESSION
78131 }else if( pMem->db==0 ){
@@ -77707,11 +78141,11 @@
78141 return SQLITE_NOMEM_BKPT;
78142 }
78143 #endif
78144
78145 if( nByte>iLimit ){
78146 return sqlite3ErrorToParser(pMem->db, SQLITE_TOOBIG);
78147 }
78148
78149 return SQLITE_OK;
78150 }
78151
@@ -83652,11 +84086,12 @@
84086 VdbeCursor *pCsr, /* Cursor to grab old.* values from */
84087 int op, /* SQLITE_INSERT, UPDATE or DELETE */
84088 const char *zDb, /* Database name */
84089 Table *pTab, /* Modified table */
84090 i64 iKey1, /* Initial key value */
84091 int iReg, /* Register for new.* record */
84092 int iBlobWrite
84093 ){
84094 sqlite3 *db = v->db;
84095 i64 iKey2;
84096 PreUpdate preupdate;
84097 const char *zTbl = pTab->zName;
@@ -83688,10 +84123,11 @@
84123 preupdate.keyinfo.nKeyField = pTab->nCol;
84124 preupdate.keyinfo.aSortFlags = (u8*)&fakeSortOrder;
84125 preupdate.iKey1 = iKey1;
84126 preupdate.iKey2 = iKey2;
84127 preupdate.pTab = pTab;
84128 preupdate.iBlobWrite = iBlobWrite;
84129
84130 db->pPreUpdate = &preupdate;
84131 db->xPreUpdateCallback(db->pPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2);
84132 db->pPreUpdate = 0;
84133 sqlite3DbFree(db, preupdate.aRecord);
@@ -84101,11 +84537,11 @@
84537 }else if( xDel==SQLITE_TRANSIENT ){
84538 /* noop */
84539 }else{
84540 xDel((void*)p);
84541 }
84542 sqlite3_result_error_toobig(pCtx);
84543 return SQLITE_TOOBIG;
84544 }
84545 SQLITE_API void sqlite3_result_blob(
84546 sqlite3_context *pCtx,
84547 const void *z,
@@ -85083,11 +85519,11 @@
85519 */
85520 static int bindText(
85521 sqlite3_stmt *pStmt, /* The statement to bind against */
85522 int i, /* Index of the parameter to bind */
85523 const void *zData, /* Pointer to the data to be bound */
85524 i64 nData, /* Number of bytes of data to be bound */
85525 void (*xDel)(void*), /* Destructor for the data */
85526 u8 encoding /* Encoding for the data */
85527 ){
85528 Vdbe *p = (Vdbe *)pStmt;
85529 Mem *pVar;
@@ -85135,15 +85571,11 @@
85571 const void *zData,
85572 sqlite3_uint64 nData,
85573 void (*xDel)(void*)
85574 ){
85575 assert( xDel!=SQLITE_DYNAMIC );
85576 return bindText(pStmt, i, zData, nData, xDel, 0);
 
 
 
 
85577 }
85578 SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
85579 int rc;
85580 Vdbe *p = (Vdbe *)pStmt;
85581 rc = vdbeUnbind(p, i);
@@ -85209,16 +85641,12 @@
85641 sqlite3_uint64 nData,
85642 void (*xDel)(void*),
85643 unsigned char enc
85644 ){
85645 assert( xDel!=SQLITE_DYNAMIC );
85646 if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
85647 return bindText(pStmt, i, zData, nData, xDel, enc);
 
 
 
 
85648 }
85649 #ifndef SQLITE_OMIT_UTF16
85650 SQLITE_API int sqlite3_bind_text16(
85651 sqlite3_stmt *pStmt,
85652 int i,
@@ -85613,10 +86041,21 @@
86041 SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){
86042 PreUpdate *p = db->pPreUpdate;
86043 return (p ? p->v->nFrame : 0);
86044 }
86045 #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
86046
86047 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
86048 /*
86049 ** This function is designed to be called from within a pre-update callback
86050 ** only.
86051 */
86052 SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){
86053 PreUpdate *p = db->pPreUpdate;
86054 return (p ? p->iBlobWrite : -1);
86055 }
86056 #endif
86057
86058 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
86059 /*
86060 ** This function is called from within a pre-update callback to retrieve
86061 ** a field of the row currently being updated or inserted.
@@ -86235,22 +86674,40 @@
86674 assert( iCur>=0 && iCur<p->nCursor );
86675 if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/
86676 sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);
86677 p->apCsr[iCur] = 0;
86678 }
86679
86680 /* There used to be a call to sqlite3VdbeMemClearAndResize() to make sure
86681 ** the pMem used to hold space for the cursor has enough storage available
86682 ** in pMem->zMalloc. But for the special case of the aMem[] entries used
86683 ** to hold cursors, it is faster to in-line the logic. */
86684 assert( pMem->flags==MEM_Undefined );
86685 assert( (pMem->flags & MEM_Dyn)==0 );
86686 assert( pMem->szMalloc==0 || pMem->z==pMem->zMalloc );
86687 if( pMem->szMalloc<nByte ){
86688 if( pMem->szMalloc>0 ){
86689 sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
86690 }
86691 pMem->z = pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, nByte);
86692 if( pMem->zMalloc==0 ){
86693 pMem->szMalloc = 0;
86694 return 0;
86695 }
86696 pMem->szMalloc = nByte;
86697 }
86698
86699 p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->zMalloc;
86700 memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));
86701 pCx->eCurType = eCurType;
86702 pCx->iDb = iDb;
86703 pCx->nField = nField;
86704 pCx->aOffset = &pCx->aType[nField];
86705 if( eCurType==CURTYPE_BTREE ){
86706 pCx->uc.pCursor = (BtCursor*)
86707 &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];
86708 sqlite3BtreeCursorZero(pCx->uc.pCursor);
86709 }
86710 return pCx;
86711 }
86712
86713 /*
@@ -86393,11 +86850,14 @@
86850 static u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){
86851 int rc;
86852 sqlite3_int64 ix;
86853 assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal))==0 );
86854 assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 );
86855 if( ExpandBlob(pMem) ){
86856 pMem->u.i = 0;
86857 return MEM_Int;
86858 }
86859 rc = sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc);
86860 if( rc<=0 ){
86861 if( rc==0 && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1 ){
86862 pMem->u.i = ix;
86863 return MEM_Int;
@@ -86530,10 +86990,15 @@
86990 if( p->pScopyFrom ){
86991 printf(" <== R[%d]", (int)(p->pScopyFrom - &p[-iReg]));
86992 }
86993 printf("\n");
86994 sqlite3VdbeCheckMemInvariants(p);
86995 }
86996 /**/ void sqlite3PrintMem(Mem *pMem){
86997 memTracePrint(pMem);
86998 printf("\n");
86999 fflush(stdout);
87000 }
87001 #endif
87002
87003 #ifdef SQLITE_DEBUG
87004 /*
@@ -88067,10 +88532,35 @@
88532
88533 pIn1 = &aMem[pOp->p1];
88534 pIn3 = &aMem[pOp->p3];
88535 flags1 = pIn1->flags;
88536 flags3 = pIn3->flags;
88537 if( (flags1 & flags3 & MEM_Int)!=0 ){
88538 assert( (pOp->p5 & SQLITE_AFF_MASK)!=SQLITE_AFF_TEXT || CORRUPT_DB );
88539 /* Common case of comparison of two integers */
88540 if( pIn3->u.i > pIn1->u.i ){
88541 iCompare = +1;
88542 if( sqlite3aGTb[pOp->opcode] ){
88543 VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88544 goto jump_to_p2;
88545 }
88546 }else if( pIn3->u.i < pIn1->u.i ){
88547 iCompare = -1;
88548 if( sqlite3aLTb[pOp->opcode] ){
88549 VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88550 goto jump_to_p2;
88551 }
88552 }else{
88553 iCompare = 0;
88554 if( sqlite3aEQb[pOp->opcode] ){
88555 VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88556 goto jump_to_p2;
88557 }
88558 }
88559 VdbeBranchTaken(0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88560 break;
88561 }
88562 if( (flags1 | flags3)&MEM_Null ){
88563 /* One or both operands are NULL */
88564 if( pOp->p5 & SQLITE_NULLEQ ){
88565 /* If SQLITE_NULLEQ is set (which will only happen if the operator is
88566 ** OP_Eq or OP_Ne) then take the jump or not depending on whether
@@ -88097,11 +88587,12 @@
88587 goto jump_to_p2;
88588 }
88589 break;
88590 }
88591 }else{
88592 /* Neither operand is NULL and we couldn't do the special high-speed
88593 ** integer comparison case. So do a general-case comparison. */
88594 affinity = pOp->p5 & SQLITE_AFF_MASK;
88595 if( affinity>=SQLITE_AFF_NUMERIC ){
88596 if( (flags1 | flags3)&MEM_Str ){
88597 if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
88598 applyNumericAffinity(pIn1,0);
@@ -88110,18 +88601,10 @@
88601 }
88602 if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
88603 applyNumericAffinity(pIn3,0);
88604 }
88605 }
 
 
 
 
 
 
 
 
88606 }else if( affinity==SQLITE_AFF_TEXT ){
88607 if( (flags1 & MEM_Str)==0 && (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
88608 testcase( pIn1->flags & MEM_Int );
88609 testcase( pIn1->flags & MEM_Real );
88610 testcase( pIn1->flags & MEM_IntReal );
@@ -88140,11 +88623,11 @@
88623 }
88624 }
88625 assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
88626 res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
88627 }
88628
88629 /* At this point, res is negative, zero, or positive if reg[P1] is
88630 ** less than, equal to, or greater than reg[P3], respectively. Compute
88631 ** the answer to this operator in res2, depending on what the comparison
88632 ** operator actually is. The next block of code depends on the fact
88633 ** that the 6 comparison operators are consecutive integers in this
@@ -90581,12 +91064,22 @@
91064 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
91065 pC = p->apCsr[pOp->p1];
91066 assert( pC!=0 );
91067 assert( pOp->p3>=pOp->p2 );
91068 if( pC->seekHit<pOp->p2 ){
91069 #ifdef SQLITE_DEBUG
91070 if( db->flags&SQLITE_VdbeTrace ){
91071 printf("seekHit changes from %d to %d\n", pC->seekHit, pOp->p2);
91072 }
91073 #endif
91074 pC->seekHit = pOp->p2;
91075 }else if( pC->seekHit>pOp->p3 ){
91076 #ifdef SQLITE_DEBUG
91077 if( db->flags&SQLITE_VdbeTrace ){
91078 printf("seekHit changes from %d to %d\n", pC->seekHit, pOp->p3);
91079 }
91080 #endif
91081 pC->seekHit = pOp->p3;
91082 }
91083 break;
91084 }
91085
@@ -90697,10 +91190,15 @@
91190 case OP_IfNoHope: { /* jump, in3 */
91191 VdbeCursor *pC;
91192 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
91193 pC = p->apCsr[pOp->p1];
91194 assert( pC!=0 );
91195 #ifdef SQLITE_DEBUG
91196 if( db->flags&SQLITE_VdbeTrace ){
91197 printf("seekHit is %d\n", pC->seekHit);
91198 }
91199 #endif
91200 if( pC->seekHit>=pOp->p4.i ) break;
91201 /* Fall through into OP_NotFound */
91202 /* no break */ deliberate_fall_through
91203 }
91204 case OP_NoConflict: /* jump, in3 */
@@ -91126,11 +91624,11 @@
91624
91625 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
91626 /* Invoke the pre-update hook, if any */
91627 if( pTab ){
91628 if( db->xPreUpdateCallback && !(pOp->p5 & OPFLAG_ISUPDATE) ){
91629 sqlite3VdbePreUpdateHook(p,pC,SQLITE_INSERT,zDb,pTab,x.nKey,pOp->p2,-1);
91630 }
91631 if( db->xUpdateCallback==0 || pTab->aCol==0 ){
91632 /* Prevent post-update hook from running in cases when it should not */
91633 pTab = 0;
91634 }
@@ -91286,11 +91784,11 @@
91784 || (aMem[pOp->p3].flags & MEM_Int)
91785 );
91786 sqlite3VdbePreUpdateHook(p, pC,
91787 (opflags & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_DELETE,
91788 zDb, pTab, pC->movetoTarget,
91789 pOp->p3, -1
91790 );
91791 }
91792 if( opflags & OPFLAG_ISNOOP ) break;
91793 #endif
91794
@@ -92232,15 +92730,14 @@
92730 **
92731 ** The table being clear is in the main database file if P2==0. If
92732 ** P2==1 then the table to be clear is in the auxiliary database file
92733 ** that is used to store tables create using CREATE TEMPORARY TABLE.
92734 **
92735 ** If the P3 value is non-zero, then the row change count is incremented
92736 ** by the number of rows in the table being cleared. If P3 is greater
92737 ** than zero, then the value stored in register P3 is also incremented
92738 ** by the number of rows in the table being cleared.
 
92739 **
92740 ** See also: Destroy
92741 */
92742 case OP_Clear: {
92743 int nChange;
@@ -92247,13 +92744,11 @@
92744
92745 sqlite3VdbeIncrWriteCounter(p, 0);
92746 nChange = 0;
92747 assert( p->readOnly==0 );
92748 assert( DbMaskTest(p->btreeMask, pOp->p2) );
92749 rc = sqlite3BtreeClearTable(db->aDb[pOp->p2].pBt, (u32)pOp->p1, &nChange);
 
 
92750 if( pOp->p3 ){
92751 p->nChange += nChange;
92752 if( pOp->p3>0 ){
92753 assert( memIsValid(&aMem[pOp->p3]) );
92754 memAboutToChange(p, &aMem[pOp->p3]);
@@ -92355,11 +92850,13 @@
92850 }
92851 #endif
92852
92853 iDb = pOp->p1;
92854 assert( iDb>=0 && iDb<db->nDb );
92855 assert( DbHasProperty(db, iDb, DB_SchemaLoaded)
92856 || db->mallocFailed
92857 || (CORRUPT_DB && (db->flags & SQLITE_NoSchemaError)!=0) );
92858
92859 #ifndef SQLITE_OMIT_ALTERTABLE
92860 if( pOp->p4.z==0 ){
92861 sqlite3SchemaClear(db->aDb[iDb].pSchema);
92862 db->mDbFlags &= ~DBFLAG_SchemaKnownOk;
@@ -93237,10 +93734,11 @@
93734
93735 pBt = db->aDb[pOp->p1].pBt;
93736 pPager = sqlite3BtreePager(pBt);
93737 eOld = sqlite3PagerGetJournalMode(pPager);
93738 if( eNew==PAGER_JOURNALMODE_QUERY ) eNew = eOld;
93739 assert( sqlite3BtreeHoldsMutex(pBt) );
93740 if( !sqlite3PagerOkToChangeJournalMode(pPager) ) eNew = eOld;
93741
93742 #ifndef SQLITE_OMIT_WAL
93743 zFilename = sqlite3PagerFilename(pPager, 1);
93744
@@ -94715,11 +95213,11 @@
95213 ** anyhow.
95214 */
95215 sqlite3_int64 iKey;
95216 iKey = sqlite3BtreeIntegerKey(p->pCsr);
95217 sqlite3VdbePreUpdateHook(
95218 v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1, p->iCol
95219 );
95220 }
95221 #endif
95222
95223 rc = xCall(p->pCsr, iOffset+p->iOffset, n, z);
@@ -94786,10 +95284,11 @@
95284 ** already been invalidated. Return SQLITE_ABORT in this case.
95285 */
95286 rc = SQLITE_ABORT;
95287 }else{
95288 char *zErr;
95289 ((Vdbe*)p->pStmt)->rc = SQLITE_OK;
95290 rc = blobSeekToRow(p, iRow, &zErr);
95291 if( rc!=SQLITE_OK ){
95292 sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr);
95293 sqlite3DbFree(db, zErr);
95294 }
@@ -98256,30 +98755,32 @@
98755 /*
98756 ** Truncate the in-memory file.
98757 */
98758 static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){
98759 MemJournal *p = (MemJournal *)pJfd;
98760 assert( p->endpoint.pChunk==0 || p->endpoint.pChunk->pNext==0 );
98761 if( size<p->endpoint.iOffset ){
98762 FileChunk *pIter = 0;
98763 if( size==0 ){
98764 memjrnlFreeChunks(p->pFirst);
98765 p->pFirst = 0;
98766 }else{
98767 i64 iOff = p->nChunkSize;
98768 for(pIter=p->pFirst; ALWAYS(pIter) && iOff<=size; pIter=pIter->pNext){
98769 iOff += p->nChunkSize;
98770 }
98771 if( ALWAYS(pIter) ){
98772 memjrnlFreeChunks(pIter->pNext);
98773 pIter->pNext = 0;
98774 }
98775 }
98776
98777 p->endpoint.pChunk = pIter;
98778 p->endpoint.iOffset = size;
98779 p->readpoint.pChunk = 0;
98780 p->readpoint.iOffset = 0;
98781 }
98782 return SQLITE_OK;
98783 }
98784
98785 /*
98786 ** Close the file.
@@ -98468,19 +98969,14 @@
98969 if( rc ) return WRC_Abort;
98970 rc = sqlite3WalkExprList(pWalker, pWin->pPartition);
98971 if( rc ) return WRC_Abort;
98972 rc = sqlite3WalkExpr(pWalker, pWin->pFilter);
98973 if( rc ) return WRC_Abort;
 
 
 
 
 
98974 rc = sqlite3WalkExpr(pWalker, pWin->pStart);
98975 if( rc ) return WRC_Abort;
98976 rc = sqlite3WalkExpr(pWalker, pWin->pEnd);
98977 if( rc ) return WRC_Abort;
98978 if( bOneOnly ) break;
98979 }
98980 return WRC_Continue;
98981 }
98982 #endif
@@ -98552,10 +99048,20 @@
99048 if( sqlite3WalkExpr(pWalker, pItem->pExpr) ) return WRC_Abort;
99049 }
99050 }
99051 return WRC_Continue;
99052 }
99053
99054 /*
99055 ** This is a no-op callback for Walker->xSelectCallback2. If this
99056 ** callback is set, then the Select->pWinDefn list is traversed.
99057 */
99058 SQLITE_PRIVATE void sqlite3WalkWinDefnDummyCallback(Walker *pWalker, Select *p){
99059 UNUSED_PARAMETER(pWalker);
99060 UNUSED_PARAMETER(p);
99061 /* No-op */
99062 }
99063
99064 /*
99065 ** Walk all expressions associated with SELECT statement p. Do
99066 ** not invoke the SELECT callback on p, but do (of course) invoke
99067 ** any expr callbacks and SELECT callbacks that come from subqueries.
@@ -98566,14 +99072,19 @@
99072 if( sqlite3WalkExpr(pWalker, p->pWhere) ) return WRC_Abort;
99073 if( sqlite3WalkExprList(pWalker, p->pGroupBy) ) return WRC_Abort;
99074 if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort;
99075 if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort;
99076 if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort;
99077 #if !defined(SQLITE_OMIT_WINDOWFUNC)
99078 if( p->pWinDefn ){
99079 Parse *pParse;
99080 if( pWalker->xSelectCallback2==sqlite3WalkWinDefnDummyCallback
99081 || ((pParse = pWalker->pParse)!=0 && IN_RENAME_OBJECT)
99082 #ifndef SQLITE_OMIT_CTE
99083 || pWalker->xSelectCallback2==sqlite3SelectPopWith
99084 #endif
99085 ){
99086 /* The following may return WRC_Abort if there are unresolvable
99087 ** symbols (e.g. a table that does not exist) in a window definition. */
99088 int rc = walkWindowList(pWalker, p->pWinDefn, 0);
99089 return rc;
99090 }
@@ -98593,11 +99104,11 @@
99104 SrcList *pSrc;
99105 int i;
99106 SrcItem *pItem;
99107
99108 pSrc = p->pSrc;
99109 if( ALWAYS(pSrc) ){
99110 for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){
99111 if( pItem->pSelect && sqlite3WalkSelect(pWalker, pItem->pSelect) ){
99112 return WRC_Abort;
99113 }
99114 if( pItem->fg.isTabFunc
@@ -98767,11 +99278,14 @@
99278 assert( iCol>=0 && iCol<pEList->nExpr );
99279 pOrig = pEList->a[iCol].pExpr;
99280 assert( pOrig!=0 );
99281 db = pParse->db;
99282 pDup = sqlite3ExprDup(db, pOrig, 0);
99283 if( db->mallocFailed ){
99284 sqlite3ExprDelete(db, pDup);
99285 pDup = 0;
99286 }else{
99287 incrAggFunctionDepth(pDup, nSubquery);
99288 if( pExpr->op==TK_COLLATE ){
99289 pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken);
99290 }
99291
@@ -98789,14 +99303,12 @@
99303 assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );
99304 pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);
99305 pExpr->flags |= EP_MemToken;
99306 }
99307 if( ExprHasProperty(pExpr, EP_WinFunc) ){
99308 if( ALWAYS(pExpr->y.pWin!=0) ){
99309 pExpr->y.pWin->pOwner = pExpr;
 
 
99310 }
99311 }
99312 sqlite3DbFree(db, pDup);
99313 }
99314 }
@@ -99184,12 +99696,12 @@
99696 ** or HAVING clauses, or as part of a larger expression in the ORDER BY
99697 ** clause is not standard SQL. This is a (goofy) SQLite extension, that
99698 ** is supported for backwards compatibility only. Hence, we issue a warning
99699 ** on sqlite3_log() whenever the capability is used.
99700 */
99701 if( cnt==0
99702 && (pNC->ncFlags & NC_UEList)!=0
99703 && zTab==0
99704 ){
99705 pEList = pNC->uNC.pEList;
99706 assert( pEList!=0 );
99707 for(j=0; j<pEList->nExpr; j++){
@@ -99293,11 +99805,11 @@
99805 sqlite3ErrorMsg(pParse, "%s: %s.%s", zErr, zTab, zCol);
99806 }else{
99807 sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol);
99808 }
99809 pParse->checkSchema = 1;
99810 pTopNC->nNcErr++;
99811 }
99812
99813 /* If a column from a table in pSrcList is referenced, then record
99814 ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes
99815 ** bit 0 to be set. Column 1 sets bit 1. And so forth. Bit 63 is
@@ -99600,11 +100112,11 @@
100112 pExpr->iTable = exprProbability(pList->a[1].pExpr);
100113 if( pExpr->iTable<0 ){
100114 sqlite3ErrorMsg(pParse,
100115 "second argument to likelihood() must be a "
100116 "constant between 0.0 and 1.0");
100117 pNC->nNcErr++;
100118 }
100119 }else{
100120 /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is
100121 ** equivalent to likelihood(X, 0.0625).
100122 ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is
@@ -99622,11 +100134,11 @@
100134 int auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0,pDef->zName,0);
100135 if( auth!=SQLITE_OK ){
100136 if( auth==SQLITE_DENY ){
100137 sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
100138 pDef->zName);
100139 pNC->nNcErr++;
100140 }
100141 pExpr->op = TK_NULL;
100142 return WRC_Prune;
100143 }
100144 }
@@ -99678,11 +100190,11 @@
100190 );
100191 if( pDef && pDef->xValue==0 && pWin ){
100192 sqlite3ErrorMsg(pParse,
100193 "%.*s() may not be used as a window function", nId, zId
100194 );
100195 pNC->nNcErr++;
100196 }else if(
100197 (is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
100198 || (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !pWin)
100199 || (is_agg && pWin && (pNC->ncFlags & NC_AllowWin)==0)
100200 ){
@@ -99691,39 +100203,39 @@
100203 zType = "window";
100204 }else{
100205 zType = "aggregate";
100206 }
100207 sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
100208 pNC->nNcErr++;
100209 is_agg = 0;
100210 }
100211 #else
100212 if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){
100213 sqlite3ErrorMsg(pParse,"misuse of aggregate function %.*s()",nId,zId);
100214 pNC->nNcErr++;
100215 is_agg = 0;
100216 }
100217 #endif
100218 else if( no_such_func && pParse->db->init.busy==0
100219 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
100220 && pParse->explain==0
100221 #endif
100222 ){
100223 sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
100224 pNC->nNcErr++;
100225 }else if( wrong_num_args ){
100226 sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
100227 nId, zId);
100228 pNC->nNcErr++;
100229 }
100230 #ifndef SQLITE_OMIT_WINDOWFUNC
100231 else if( is_agg==0 && ExprHasProperty(pExpr, EP_WinFunc) ){
100232 sqlite3ErrorMsg(pParse,
100233 "FILTER may not be used with non-aggregate %.*s()",
100234 nId, zId
100235 );
100236 pNC->nNcErr++;
100237 }
100238 #endif
100239 if( is_agg ){
100240 /* Window functions may not be arguments of aggregate functions.
100241 ** Or arguments of other window functions. But aggregate functions
@@ -99943,15 +100455,15 @@
100455 */
100456 memset(&nc, 0, sizeof(nc));
100457 nc.pParse = pParse;
100458 nc.pSrcList = pSelect->pSrc;
100459 nc.uNC.pEList = pEList;
100460 nc.ncFlags = NC_AllowAgg|NC_UEList|NC_NoSelect;
100461 nc.nNcErr = 0;
100462 db = pParse->db;
100463 savedSuppErr = db->suppressErr;
100464 db->suppressErr = 1;
100465 rc = sqlite3ResolveExprNames(&nc, pE);
100466 db->suppressErr = savedSuppErr;
100467 if( rc ) return 0;
100468
100469 /* Try to match the ORDER BY expression against an expression
@@ -100046,33 +100558,28 @@
100558 ** expression, resolving any symbols in it, and then comparing
100559 ** it against each expression returned by the SELECT statement.
100560 ** Once the comparisons are finished, the duplicate expression
100561 ** is deleted.
100562 **
100563 ** If this is running as part of an ALTER TABLE operation and
100564 ** the symbols resolve successfully, also resolve the symbols in the
100565 ** actual expression. This allows the code in alter.c to modify
100566 ** column references within the ORDER BY expression as required. */
100567 pDup = sqlite3ExprDup(db, pE, 0);
 
 
 
 
 
 
100568 if( !db->mallocFailed ){
100569 assert(pDup);
100570 iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup);
100571 if( IN_RENAME_OBJECT && iCol>0 ){
100572 resolveOrderByTermToExprList(pParse, pSelect, pE);
100573 }
100574 }
100575 sqlite3ExprDelete(db, pDup);
 
 
100576 }
100577 }
100578 if( iCol>0 ){
100579 /* Convert the ORDER BY term into an integer column number iCol,
100580 ** taking care to preserve the COLLATE clause if it exists. */
100581 if( !IN_RENAME_OBJECT ){
100582 Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);
100583 if( pNew==0 ) return 1;
100584 pNew->flags |= EP_IntValue;
100585 pNew->u.iValue = iCol;
@@ -100203,11 +100710,11 @@
100710 int iCol; /* Column number */
100711 struct ExprList_item *pItem; /* A term of the ORDER BY clause */
100712 Parse *pParse; /* Parsing context */
100713 int nResult; /* Number of terms in the result set */
100714
100715 assert( pOrderBy!=0 );
100716 nResult = pSelect->pEList->nExpr;
100717 pParse = pNC->pParse;
100718 for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){
100719 Expr *pE = pItem->pExpr;
100720 Expr *pE2 = sqlite3ExprSkipCollateAndLikely(pE);
@@ -100293,11 +100800,13 @@
100800 nCompound = 0;
100801 pLeftmost = p;
100802 while( p ){
100803 assert( (p->selFlags & SF_Expanded)!=0 );
100804 assert( (p->selFlags & SF_Resolved)==0 );
100805 assert( db->suppressErr==0 ); /* SF_Resolved not set if errors suppressed */
100806 p->selFlags |= SF_Resolved;
100807
100808
100809 /* Resolve the expressions in the LIMIT and OFFSET clauses. These
100810 ** are not allowed to refer to any names, so pass an empty NameContext.
100811 */
100812 memset(&sNC, 0, sizeof(sNC));
@@ -100368,17 +100877,10 @@
100877 p->selFlags |= SF_Aggregate | (sNC.ncFlags&NC_MinMaxAgg);
100878 }else{
100879 sNC.ncFlags &= ~NC_AllowAgg;
100880 }
100881
 
 
 
 
 
 
 
100882 /* Add the output column list to the name-context before parsing the
100883 ** other expressions in the SELECT statement. This is so that
100884 ** expressions in the WHERE clause (etc.) can refer to expressions by
100885 ** aliases in the result set.
100886 **
@@ -100386,11 +100888,17 @@
100888 ** re-evaluated for each reference to it.
100889 */
100890 assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert|NC_UBaseReg))==0 );
100891 sNC.uNC.pEList = p->pEList;
100892 sNC.ncFlags |= NC_UEList;
100893 if( p->pHaving ){
100894 if( !pGroupBy ){
100895 sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING");
100896 return WRC_Abort;
100897 }
100898 if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
100899 }
100900 if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;
100901
100902 /* Resolve names in table-valued-function arguments */
100903 for(i=0; i<p->pSrc->nSrc; i++){
100904 SrcItem *pItem = &p->pSrc->a[i];
@@ -100398,10 +100906,23 @@
100906 && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg)
100907 ){
100908 return WRC_Abort;
100909 }
100910 }
100911
100912 #ifndef SQLITE_OMIT_WINDOWFUNC
100913 if( IN_RENAME_OBJECT ){
100914 Window *pWin;
100915 for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){
100916 if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy)
100917 || sqlite3ResolveExprListNames(&sNC, pWin->pPartition)
100918 ){
100919 return WRC_Abort;
100920 }
100921 }
100922 }
100923 #endif
100924
100925 /* The ORDER BY and GROUP BY clauses may not refer to terms in
100926 ** outer queries
100927 */
100928 sNC.pNext = 0;
@@ -100426,11 +100947,12 @@
100947 ** If there is an ORDER BY clause on a term of a compound-select other
100948 ** than the right-most term, then that is a syntax error. But the error
100949 ** is not detected until much later, and so we need to go ahead and
100950 ** resolve those symbols on the incorrect ORDER BY for consistency.
100951 */
100952 if( p->pOrderBy!=0
100953 && isCompound<=nCompound /* Defer right-most ORDER BY of a compound */
100954 && resolveOrderGroupBy(&sNC, p, p->pOrderBy, "ORDER")
100955 ){
100956 return WRC_Abort;
100957 }
100958 if( db->mallocFailed ){
@@ -100454,23 +100976,10 @@
100976 return WRC_Abort;
100977 }
100978 }
100979 }
100980
 
 
 
 
 
 
 
 
 
 
 
 
 
100981 /* If this is part of a compound SELECT, check that it has the right
100982 ** number of expressions in the select list. */
100983 if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){
100984 sqlite3SelectWrongNumTermsError(pParse, p->pNext);
100985 return WRC_Abort;
@@ -100550,11 +101059,11 @@
101059 if( pExpr==0 ) return SQLITE_OK;
101060 savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101061 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101062 w.pParse = pNC->pParse;
101063 w.xExprCallback = resolveExprStep;
101064 w.xSelectCallback = (pNC->ncFlags & NC_NoSelect) ? 0 : resolveSelectStep;
101065 w.xSelectCallback2 = 0;
101066 w.u.pNC = pNC;
101067 #if SQLITE_MAX_EXPR_DEPTH>0
101068 w.pParse->nHeight += pExpr->nHeight;
101069 if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){
@@ -100569,11 +101078,11 @@
101078 assert( EP_Win==NC_HasWin );
101079 testcase( pNC->ncFlags & NC_HasAgg );
101080 testcase( pNC->ncFlags & NC_HasWin );
101081 ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) );
101082 pNC->ncFlags |= savedHasAgg;
101083 return pNC->nNcErr>0 || w.pParse->nErr>0;
101084 }
101085
101086 /*
101087 ** Resolve all names for all expression in an expression list. This is
101088 ** just like sqlite3ResolveExprNames() except that it works for an expression
@@ -100614,11 +101123,11 @@
101123 if( pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin) ){
101124 ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) );
101125 savedHasAgg |= pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101126 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101127 }
101128 if( w.pParse->nErr>0 ) return WRC_Abort;
101129 }
101130 pNC->ncFlags |= savedHasAgg;
101131 return WRC_Continue;
101132 }
101133
@@ -100757,27 +101266,27 @@
101266 || (pExpr->op==TK_REGISTER && pExpr->op2==TK_IF_NULL_ROW) );
101267 pExpr = pExpr->pLeft;
101268 assert( pExpr!=0 );
101269 }
101270 op = pExpr->op;
101271 if( op==TK_REGISTER ) op = pExpr->op2;
101272 if( (op==TK_COLUMN || op==TK_AGG_COLUMN) && pExpr->y.pTab ){
101273 return sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
101274 }
101275 if( op==TK_SELECT ){
101276 assert( pExpr->flags&EP_xIsSelect );
101277 assert( pExpr->x.pSelect!=0 );
101278 assert( pExpr->x.pSelect->pEList!=0 );
101279 assert( pExpr->x.pSelect->pEList->a[0].pExpr!=0 );
101280 return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);
101281 }
 
101282 #ifndef SQLITE_OMIT_CAST
101283 if( op==TK_CAST ){
101284 assert( !ExprHasProperty(pExpr, EP_IntValue) );
101285 return sqlite3AffinityType(pExpr->u.zToken, 0);
101286 }
101287 #endif
 
 
 
101288 if( op==TK_SELECT_COLUMN ){
101289 assert( pExpr->pLeft->flags&EP_xIsSelect );
101290 return sqlite3ExprAffinity(
101291 pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
101292 );
@@ -100800,22 +101309,11 @@
101309 Parse *pParse, /* Parsing context */
101310 Expr *pExpr, /* Add the "COLLATE" clause to this expression */
101311 const Token *pCollName, /* Name of collating sequence */
101312 int dequote /* True to dequote pCollName */
101313 ){
101314 if( pCollName->n>0 ){
 
 
 
 
 
 
 
 
 
 
 
101315 Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote);
101316 if( pNew ){
101317 pNew->pLeft = pExpr;
101318 pNew->flags |= EP_Collate|EP_Skip;
101319 pExpr = pNew;
@@ -101161,11 +101659,11 @@
101659 ** just the expression for the i-th term of the result set, and may
101660 ** not be ready for evaluation because the table cursor has not yet
101661 ** been positioned.
101662 */
101663 SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr *pVector, int i){
101664 assert( i<sqlite3ExprVectorSize(pVector) || pVector->op==TK_ERROR );
101665 if( sqlite3ExprIsVector(pVector) ){
101666 assert( pVector->op2==0 || pVector->op==TK_REGISTER );
101667 if( pVector->op==TK_SELECT || pVector->op2==TK_SELECT ){
101668 return pVector->x.pSelect->pEList->a[i].pExpr;
101669 }else{
@@ -101277,21 +101775,24 @@
101775 int regSelect, /* First in array of registers */
101776 Expr **ppExpr, /* OUT: Expression element */
101777 int *pRegFree /* OUT: Temp register to free */
101778 ){
101779 u8 op = pVector->op;
101780 assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT || op==TK_ERROR );
101781 if( op==TK_REGISTER ){
101782 *ppExpr = sqlite3VectorFieldSubexpr(pVector, iField);
101783 return pVector->iTable+iField;
101784 }
101785 if( op==TK_SELECT ){
101786 *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr;
101787 return regSelect+iField;
101788 }
101789 if( op==TK_VECTOR ){
101790 *ppExpr = pVector->x.pList->a[iField].pExpr;
101791 return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree);
101792 }
101793 return 0;
101794 }
101795
101796 /*
101797 ** Expression pExpr is a comparison between two vector values. Compute
101798 ** the result of the comparison (1, 0, or NULL) and write that
@@ -101346,11 +101847,11 @@
101847 regRight = exprCodeSubselect(pParse, pRight);
101848
101849 sqlite3VdbeAddOp2(v, OP_Integer, 1, dest);
101850 for(i=0; 1 /*Loop exits by "break"*/; i++){
101851 int regFree1 = 0, regFree2 = 0;
101852 Expr *pL = 0, *pR = 0;
101853 int r1, r2;
101854 assert( i>=0 && i<nLeft );
101855 if( addrCmp ) sqlite3VdbeJumpHere(v, addrCmp);
101856 r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, &regFree1);
101857 r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, &regFree2);
@@ -102029,10 +102530,11 @@
102530
102531 /* Figure out where to write the new Expr structure. */
102532 if( pzBuffer ){
102533 zAlloc = *pzBuffer;
102534 staticFlag = EP_Static;
102535 assert( zAlloc!=0 );
102536 }else{
102537 zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags));
102538 staticFlag = 0;
102539 }
102540 pNew = (Expr *)zAlloc;
@@ -102107,11 +102609,12 @@
102609 }else{
102610 if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
102611 if( pNew->op==TK_SELECT_COLUMN ){
102612 pNew->pLeft = p->pLeft;
102613 assert( p->iColumn==0 || p->pRight==0 );
102614 assert( p->pRight==0 || p->pRight==p->pLeft
102615 || ExprHasProperty(p->pLeft, EP_Subquery) );
102616 }else{
102617 pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
102618 }
102619 pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
102620 }
@@ -102124,11 +102627,11 @@
102627 ** Create and return a deep copy of the object passed as the second
102628 ** argument. If an OOM condition is encountered, NULL is returned
102629 ** and the db->mallocFailed flag set.
102630 */
102631 #ifndef SQLITE_OMIT_CTE
102632 SQLITE_PRIVATE With *sqlite3WithDup(sqlite3 *db, With *p){
102633 With *pRet = 0;
102634 if( p ){
102635 sqlite3_int64 nByte = sizeof(*p) + sizeof(p->a[0]) * (p->nCte-1);
102636 pRet = sqlite3DbMallocZero(db, nByte);
102637 if( pRet ){
@@ -102142,11 +102645,11 @@
102645 }
102646 }
102647 return pRet;
102648 }
102649 #else
102650 # define sqlite3WithDup(x,y) 0
102651 #endif
102652
102653 #ifndef SQLITE_OMIT_WINDOWFUNC
102654 /*
102655 ** The gatherSelectWindows() procedure and its helper routine
@@ -102222,11 +102725,12 @@
102725 && pOldExpr->op==TK_SELECT_COLUMN
102726 && (pNewExpr = pItem->pExpr)!=0
102727 ){
102728 assert( pNewExpr->iColumn==0 || i>0 );
102729 if( pNewExpr->iColumn==0 ){
102730 assert( pOldExpr->pLeft==pOldExpr->pRight
102731 || ExprHasProperty(pOldExpr->pLeft, EP_Subquery) );
102732 pPriorSelectCol = pNewExpr->pLeft = pNewExpr->pRight;
102733 }else{
102734 assert( i>0 );
102735 assert( pItem[-1].pExpr!=0 );
102736 assert( pNewExpr->iColumn==pItem[-1].pExpr->iColumn+1 );
@@ -102345,17 +102849,25 @@
102849 pNew->iOffset = 0;
102850 pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;
102851 pNew->addrOpenEphm[0] = -1;
102852 pNew->addrOpenEphm[1] = -1;
102853 pNew->nSelectRow = p->nSelectRow;
102854 pNew->pWith = sqlite3WithDup(db, p->pWith);
102855 #ifndef SQLITE_OMIT_WINDOWFUNC
102856 pNew->pWin = 0;
102857 pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
102858 if( p->pWin && db->mallocFailed==0 ) gatherSelectWindows(pNew);
102859 #endif
102860 pNew->selId = p->selId;
102861 if( db->mallocFailed ){
102862 /* Any prior OOM might have left the Select object incomplete.
102863 ** Delete the whole thing rather than allow an incomplete Select
102864 ** to be used by the code generator. */
102865 pNew->pNext = 0;
102866 sqlite3SelectDelete(db, pNew);
102867 break;
102868 }
102869 *pp = pNew;
102870 pp = &pNew->pPrior;
102871 pNext = pNew;
102872 }
102873
@@ -103052,12 +103564,14 @@
103564 ** will likely result in an incorrect answer. So when in doubt, return
103565 ** TRUE.
103566 */
103567 SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){
103568 u8 op;
103569 assert( p!=0 );
103570 while( p->op==TK_UPLUS || p->op==TK_UMINUS ){
103571 p = p->pLeft;
103572 assert( p!=0 );
103573 }
103574 op = p->op;
103575 if( op==TK_REGISTER ) op = p->op2;
103576 switch( op ){
103577 case TK_INTEGER:
@@ -103685,23 +104199,27 @@
104199 addrOnce?"":"CORRELATED ", pSelect->selId
104200 ));
104201 /* If the LHS and RHS of the IN operator do not match, that
104202 ** error will have been caught long before we reach this point. */
104203 if( ALWAYS(pEList->nExpr==nVal) ){
104204 Select *pCopy;
104205 SelectDest dest;
104206 int i;
104207 int rc;
104208 sqlite3SelectDestInit(&dest, SRT_Set, iTab);
104209 dest.zAffSdst = exprINAffinity(pParse, pExpr);
104210 pSelect->iLimit = 0;
104211 testcase( pSelect->selFlags & SF_Distinct );
104212 testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
104213 pCopy = sqlite3SelectDup(pParse->db, pSelect, 0);
104214 rc = pParse->db->mallocFailed ? 1 :sqlite3Select(pParse, pCopy, &dest);
104215 sqlite3SelectDelete(pParse->db, pCopy);
104216 sqlite3DbFree(pParse->db, dest.zAffSdst);
104217 if( rc ){
104218 sqlite3KeyInfoUnref(pKeyInfo);
104219 return;
104220 }
 
104221 assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */
104222 assert( pEList!=0 );
104223 assert( pEList->nExpr>0 );
104224 assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
104225 for(i=0; i<nVal; i++){
@@ -103796,15 +104314,33 @@
104314 int nReg; /* Registers to allocate */
104315 Expr *pLimit; /* New limit expression */
104316
104317 Vdbe *v = pParse->pVdbe;
104318 assert( v!=0 );
104319 if( pParse->nErr ) return 0;
104320 testcase( pExpr->op==TK_EXISTS );
104321 testcase( pExpr->op==TK_SELECT );
104322 assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
104323 assert( ExprHasProperty(pExpr, EP_xIsSelect) );
104324 pSel = pExpr->x.pSelect;
104325
104326 /* If this routine has already been coded, then invoke it as a
104327 ** subroutine. */
104328 if( ExprHasProperty(pExpr, EP_Subrtn) ){
104329 ExplainQueryPlan((pParse, 0, "REUSE SUBQUERY %d", pSel->selId));
104330 sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn,
104331 pExpr->y.sub.iAddr);
104332 return pExpr->iTable;
104333 }
104334
104335 /* Begin coding the subroutine */
104336 ExprSetProperty(pExpr, EP_Subrtn);
104337 pExpr->y.sub.regReturn = ++pParse->nMem;
104338 pExpr->y.sub.iAddr =
104339 sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
104340 VdbeComment((v, "return address"));
104341
104342
104343 /* The evaluation of the EXISTS/SELECT must be repeated every time it
104344 ** is encountered if any of the following is true:
104345 **
104346 ** * The right-hand side is a correlated subquery
@@ -103813,26 +104349,10 @@
104349 **
104350 ** If all of the above are false, then we can run this code just once
104351 ** save the results, and reuse the same result on subsequent invocations.
104352 */
104353 if( !ExprHasProperty(pExpr, EP_VarSelect) ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104354 addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
104355 }
104356
104357 /* For a SELECT, generate code to put the values for all columns of
104358 ** the first row into an array of registers and return the index of
@@ -103877,23 +104397,26 @@
104397 pLimit = sqlite3Expr(pParse->db, TK_INTEGER, "1");
104398 pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0);
104399 }
104400 pSel->iLimit = 0;
104401 if( sqlite3Select(pParse, pSel, &dest) ){
104402 if( pParse->nErr ){
104403 pExpr->op2 = pExpr->op;
104404 pExpr->op = TK_ERROR;
104405 }
104406 return 0;
104407 }
104408 pExpr->iTable = rReg = dest.iSDParm;
104409 ExprSetVVAProperty(pExpr, EP_NoReduce);
104410 if( addrOnce ){
104411 sqlite3VdbeJumpHere(v, addrOnce);
 
 
 
 
 
104412 }
104413
104414 /* Subroutine return */
104415 sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
104416 sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
104417 sqlite3ClearTempRegCache(pParse);
104418 return rReg;
104419 }
104420 #endif /* SQLITE_OMIT_SUBQUERY */
104421
104422 #ifndef SQLITE_OMIT_SUBQUERY
@@ -103903,11 +104426,11 @@
104426 ** columns as the vector on the LHS. Or, if the RHS of the IN() is not
104427 ** a sub-query, that the LHS is a vector of size 1.
104428 */
104429 SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse *pParse, Expr *pIn){
104430 int nVector = sqlite3ExprVectorSize(pIn->pLeft);
104431 if( (pIn->flags & EP_xIsSelect)!=0 && !pParse->db->mallocFailed ){
104432 if( nVector!=pIn->x.pSelect->pEList->nExpr ){
104433 sqlite3SubselectError(pParse, pIn->x.pSelect->pEList->nExpr, nVector);
104434 return 1;
104435 }
104436 }else if( nVector!=1 ){
@@ -104720,11 +105243,11 @@
105243 default: {
105244 /* Make NULL the default case so that if a bug causes an illegal
105245 ** Expr node to be passed into this function, it will be handled
105246 ** sanely and not crash. But keep the assert() to bring the problem
105247 ** to the attention of the developers. */
105248 assert( op==TK_NULL || op==TK_ERROR || pParse->db->mallocFailed );
105249 sqlite3VdbeAddOp2(v, OP_Null, 0, target);
105250 return target;
105251 }
105252 #ifndef SQLITE_OMIT_BLOB_LITERAL
105253 case TK_BLOB: {
@@ -105063,11 +105586,12 @@
105586 case TK_SELECT_COLUMN: {
105587 int n;
105588 if( pExpr->pLeft->iTable==0 ){
105589 pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft);
105590 }
105591 assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT
105592 || pExpr->pLeft->op==TK_ERROR );
105593 if( pExpr->iTable!=0
105594 && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft))
105595 ){
105596 sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
105597 pExpr->iTable, n);
@@ -106695,10 +107219,11 @@
107219 /* Check to see if pExpr is a duplicate of another aggregate
107220 ** function that is already in the pAggInfo structure
107221 */
107222 struct AggInfo_func *pItem = pAggInfo->aFunc;
107223 for(i=0; i<pAggInfo->nFunc; i++, pItem++){
107224 if( pItem->pFExpr==pExpr ) break;
107225 if( sqlite3ExprCompare(0, pItem->pFExpr, pExpr, -1)==0 ){
107226 break;
107227 }
107228 }
107229 if( i>=pAggInfo->nFunc ){
@@ -106895,10 +107420,11 @@
107420 ** Or, if zName is not a system table, zero is returned.
107421 */
107422 static int isAlterableTable(Parse *pParse, Table *pTab){
107423 if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7)
107424 #ifndef SQLITE_OMIT_VIRTUALTABLE
107425 || (pTab->tabFlags & TF_Eponymous)!=0
107426 || ( (pTab->tabFlags & TF_Shadow)!=0
107427 && sqlite3ReadOnlyShadowTables(pParse->db)
107428 )
107429 #endif
107430 ){
@@ -107663,19 +108189,34 @@
108189 ** to select statement pSelect.
108190 */
108191 static void renameWalkWith(Walker *pWalker, Select *pSelect){
108192 With *pWith = pSelect->pWith;
108193 if( pWith ){
108194 Parse *pParse = pWalker->pParse;
108195 int i;
108196 With *pCopy = 0;
108197 assert( pWith->nCte>0 );
108198 if( (pWith->a[0].pSelect->selFlags & SF_Expanded)==0 ){
108199 /* Push a copy of the With object onto the with-stack. We use a copy
108200 ** here as the original will be expanded and resolved (flags SF_Expanded
108201 ** and SF_Resolved) below. And the parser code that uses the with-stack
108202 ** fails if the Select objects on it have already been expanded and
108203 ** resolved. */
108204 pCopy = sqlite3WithDup(pParse->db, pWith);
108205 pCopy = sqlite3WithPush(pParse, pCopy, 1);
108206 }
108207 for(i=0; i<pWith->nCte; i++){
108208 Select *p = pWith->a[i].pSelect;
108209 NameContext sNC;
108210 memset(&sNC, 0, sizeof(sNC));
108211 sNC.pParse = pParse;
108212 if( pCopy ) sqlite3SelectPrep(sNC.pParse, p, &sNC);
108213 sqlite3WalkSelect(pWalker, p);
108214 sqlite3RenameExprlistUnmap(pParse, pWith->a[i].pCols);
108215 }
108216 if( pCopy && pParse->pWith==pCopy ){
108217 pParse->pWith = pCopy->pOuter;
108218 }
108219 }
108220 }
108221
108222 /*
@@ -107698,11 +108239,15 @@
108239 */
108240 static int renameUnmapSelectCb(Walker *pWalker, Select *p){
108241 Parse *pParse = pWalker->pParse;
108242 int i;
108243 if( pParse->nErr ) return WRC_Abort;
108244 if( p->selFlags & (SF_View|SF_CopyCte) ){
108245 testcase( pSelect->selFlags & SF_View );
108246 testcase( pSelect->selFlags & SF_CopyCte );
108247 return WRC_Prune;
108248 }
108249 if( ALWAYS(p->pEList) ){
108250 ExprList *pList = p->pEList;
108251 for(i=0; i<pList->nExpr; i++){
108252 if( pList->a[i].zEName && pList->a[i].eEName==ENAME_NAME ){
108253 sqlite3RenameTokenRemap(pParse, 0, (void*)pList->a[i].zEName);
@@ -107782,11 +108327,13 @@
108327 Parse *pParse,
108328 struct RenameCtx *pCtx,
108329 void *pPtr
108330 ){
108331 RenameToken **pp;
108332 if( NEVER(pPtr==0) ){
108333 return 0;
108334 }
108335 for(pp=&pParse->pRename; (*pp); pp=&(*pp)->pNext){
108336 if( (*pp)->p==pPtr ){
108337 RenameToken *pToken = *pp;
108338 if( pCtx ){
108339 *pp = pToken->pNext;
@@ -107804,11 +108351,15 @@
108351 ** This is a Walker select callback. It does nothing. It is only required
108352 ** because without a dummy callback, sqlite3WalkExpr() and similar do not
108353 ** descend into sub-select statements.
108354 */
108355 static int renameColumnSelectCb(Walker *pWalker, Select *p){
108356 if( p->selFlags & (SF_View|SF_CopyCte) ){
108357 testcase( pSelect->selFlags & SF_View );
108358 testcase( pSelect->selFlags & SF_CopyCte );
108359 return WRC_Prune;
108360 }
108361 renameWalkWith(pWalker, p);
108362 return WRC_Continue;
108363 }
108364
108365 /*
@@ -108334,13 +108885,15 @@
108885 int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName);
108886 FKey *pFKey;
108887 assert( sParse.pNewTable->pSelect==0 );
108888 sCtx.pTab = sParse.pNewTable;
108889 if( bFKOnly==0 ){
108890 if( iCol<sParse.pNewTable->nCol ){
108891 renameTokenFind(
108892 &sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zName
108893 );
108894 }
108895 if( sCtx.iCol<0 ){
108896 renameTokenFind(&sParse, &sCtx, (void*)&sParse.pNewTable->iPKey);
108897 }
108898 sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck);
108899 for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){
@@ -108438,12 +108991,16 @@
108991 */
108992 static int renameTableSelectCb(Walker *pWalker, Select *pSelect){
108993 int i;
108994 RenameCtx *p = pWalker->u.pRename;
108995 SrcList *pSrc = pSelect->pSrc;
108996 if( pSelect->selFlags & (SF_View|SF_CopyCte) ){
108997 testcase( pSelect->selFlags & SF_View );
108998 testcase( pSelect->selFlags & SF_CopyCte );
108999 return WRC_Prune;
109000 }
109001 if( NEVER(pSrc==0) ){
109002 assert( pWalker->pParse->db->mallocFailed );
109003 return WRC_Abort;
109004 }
109005 for(i=0; i<pSrc->nSrc; i++){
109006 SrcItem *pItem = &pSrc->a[i];
@@ -108983,20 +109540,25 @@
109540 if( iPos<pPk->nKeyCol ) continue;
109541 regOut = reg+1+iPos-(iPos>iColPos);
109542 }else{
109543 regOut = reg+1+nField;
109544 }
109545 if( i==pTab->iPKey ){
109546 sqlite3VdbeAddOp2(v, OP_Null, 0, regOut);
109547 }else{
109548 sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOut);
109549 }
109550 nField++;
109551 }
109552 }
109553 sqlite3VdbeAddOp3(v, OP_MakeRecord, reg+1, nField, regRec);
109554 if( pPk ){
109555 sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iCur, regRec, reg+1, pPk->nKeyCol);
109556 }else{
109557 sqlite3VdbeAddOp3(v, OP_Insert, iCur, regRec, reg);
109558 }
109559 sqlite3VdbeChangeP5(v, OPFLAG_SAVEPOSITION);
109560
109561 sqlite3VdbeAddOp2(v, OP_Next, iCur, addr+1); VdbeCoverage(v);
109562 sqlite3VdbeJumpHere(v, addr);
109563 }
109564
@@ -111063,11 +111625,11 @@
111625 zFile = (const char *)sqlite3_value_text(argv[0]);
111626 zName = (const char *)sqlite3_value_text(argv[1]);
111627 if( zFile==0 ) zFile = "";
111628 if( zName==0 ) zName = "";
111629
111630 #ifndef SQLITE_OMIT_DESERIALIZE
111631 # define REOPEN_AS_MEMDB(db) (db->init.reopenMemdb)
111632 #else
111633 # define REOPEN_AS_MEMDB(db) (0)
111634 #endif
111635
@@ -111432,18 +111994,21 @@
111994 SrcList *pList = pSelect->pSrc;
111995
111996 if( NEVER(pList==0) ) return WRC_Continue;
111997 for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
111998 if( pFix->bTemp==0 ){
111999 if( pItem->zDatabase ){
112000 if( iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){
112001 sqlite3ErrorMsg(pFix->pParse,
112002 "%s %T cannot reference objects in database %s",
112003 pFix->zType, pFix->pName, pItem->zDatabase);
112004 return WRC_Abort;
112005 }
112006 sqlite3DbFree(db, pItem->zDatabase);
112007 pItem->zDatabase = 0;
112008 pItem->fg.notCte = 1;
112009 }
112010 pItem->pSchema = pFix->pSchema;
112011 pItem->fg.fromDDL = 1;
112012 }
112013 #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
112014 if( sqlite3WalkExpr(&pFix->w, pList->a[i].pOn) ) return WRC_Abort;
@@ -111479,11 +112044,11 @@
112044 pFix->pName = pName;
112045 pFix->bTemp = (iDb==1);
112046 pFix->w.pParse = pParse;
112047 pFix->w.xExprCallback = fixExprCb;
112048 pFix->w.xSelectCallback = fixSelectCb;
112049 pFix->w.xSelectCallback2 = sqlite3WalkWinDefnDummyCallback;
112050 pFix->w.walkerDepth = 0;
112051 pFix->w.eCode = 0;
112052 pFix->w.u.pFix = pFix;
112053 }
112054
@@ -111541,18 +112106,20 @@
112106 || sqlite3FixSrcList(pFix, pStep->pFrom)
112107 ){
112108 return 1;
112109 }
112110 #ifndef SQLITE_OMIT_UPSERT
112111 {
112112 Upsert *pUp;
112113 for(pUp=pStep->pUpsert; pUp; pUp=pUp->pNextUpsert){
112114 if( sqlite3WalkExprList(&pFix->w, pUp->pUpsertTarget)
112115 || sqlite3WalkExpr(&pFix->w, pUp->pUpsertTargetWhere)
112116 || sqlite3WalkExprList(&pFix->w, pUp->pUpsertSet)
112117 || sqlite3WalkExpr(&pFix->w, pUp->pUpsertWhere)
112118 ){
112119 return 1;
112120 }
112121 }
112122 }
112123 #endif
112124 pStep = pStep->pNext;
112125 }
@@ -111880,11 +112447,11 @@
112447 **
112448 ** This routine just records the fact that the lock is desired. The
112449 ** code to make the lock occur is generated by a later call to
112450 ** codeTableLocks() which occurs during sqlite3FinishCoding().
112451 */
112452 static SQLITE_NOINLINE void lockTable(
112453 Parse *pParse, /* Parsing context */
112454 int iDb, /* Index of the database containing the table to lock */
112455 Pgno iTab, /* Root page number of the table to be locked */
112456 u8 isWriteLock, /* True for a write lock */
112457 const char *zName /* Name of the table to be locked */
@@ -111893,12 +112460,10 @@
112460 int i;
112461 int nBytes;
112462 TableLock *p;
112463 assert( iDb>=0 );
112464
 
 
112465 pToplevel = sqlite3ParseToplevel(pParse);
112466 for(i=0; i<pToplevel->nTableLock; i++){
112467 p = &pToplevel->aTableLock[i];
112468 if( p->iDb==iDb && p->iTab==iTab ){
112469 p->isWriteLock = (p->isWriteLock || isWriteLock);
@@ -111918,10 +112483,21 @@
112483 }else{
112484 pToplevel->nTableLock = 0;
112485 sqlite3OomFault(pToplevel->db);
112486 }
112487 }
112488 SQLITE_PRIVATE void sqlite3TableLock(
112489 Parse *pParse, /* Parsing context */
112490 int iDb, /* Index of the database containing the table to lock */
112491 Pgno iTab, /* Root page number of the table to be locked */
112492 u8 isWriteLock, /* True for a write lock */
112493 const char *zName /* Name of the table to be locked */
112494 ){
112495 if( iDb==1 ) return;
112496 if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return;
112497 lockTable(pParse, iDb, iTab, isWriteLock, zName);
112498 }
112499
112500 /*
112501 ** Code an OP_TableLock instruction for each table locked by the
112502 ** statement (configured by calls to sqlite3TableLock()).
112503 */
@@ -112272,11 +112848,11 @@
112848 if( p==0 ){
112849 #ifndef SQLITE_OMIT_VIRTUALTABLE
112850 /* If zName is the not the name of a table in the schema created using
112851 ** CREATE, then check to see if it is the name of an virtual table that
112852 ** can be an eponymous virtual table. */
112853 if( pParse->disableVtab==0 && db->init.busy==0 ){
112854 Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
112855 if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
112856 pMod = sqlite3PragmaVtabRegister(db, zName);
112857 }
112858 if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
@@ -112295,10 +112871,12 @@
112871 if( zDbase ){
112872 sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
112873 }else{
112874 sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
112875 }
112876 }else{
112877 assert( HasRowid(p) || p->iPKey<0 );
112878 }
112879
112880 return p;
112881 }
112882
@@ -112711,11 +113289,11 @@
113289 if( iDb<0 ){
113290 sqlite3ErrorMsg(pParse, "unknown database %T", pName1);
113291 return -1;
113292 }
113293 }else{
113294 assert( db->init.iDb==0 || db->init.busy || IN_SPECIAL_PARSE
113295 || (db->mDbFlags & DBFLAG_Vacuum)!=0);
113296 iDb = db->init.iDb;
113297 *pUnqual = pName1;
113298 }
113299 return iDb;
@@ -112879,10 +113457,27 @@
113457 /* iCol is a normal or stored column */
113458 return n;
113459 }
113460 }
113461 #endif
113462
113463 /*
113464 ** Insert a single OP_JournalMode query opcode in order to force the
113465 ** prepared statement to return false for sqlite3_stmt_readonly(). This
113466 ** is used by CREATE TABLE IF NOT EXISTS and similar if the table already
113467 ** exists, so that the prepared statement for CREATE TABLE IF NOT EXISTS
113468 ** will return false for sqlite3_stmt_readonly() even if that statement
113469 ** is a read-only no-op.
113470 */
113471 static void sqlite3ForceNotReadOnly(Parse *pParse){
113472 int iReg = ++pParse->nMem;
113473 Vdbe *v = sqlite3GetVdbe(pParse);
113474 if( v ){
113475 sqlite3VdbeAddOp3(v, OP_JournalMode, 0, iReg, PAGER_JOURNALMODE_QUERY);
113476 sqlite3VdbeUsesBtree(v, 0);
113477 }
113478 }
113479
113480 /*
113481 ** Begin constructing a new table representation in memory. This is
113482 ** the first of several action routines that get called in response
113483 ** to a CREATE TABLE statement. In particular, this routine is called
@@ -112979,10 +113574,11 @@
113574 if( !noErr ){
113575 sqlite3ErrorMsg(pParse, "table %T already exists", pName);
113576 }else{
113577 assert( !db->init.busy || CORRUPT_DB );
113578 sqlite3CodeVerifySchema(pParse, iDb);
113579 sqlite3ForceNotReadOnly(pParse);
113580 }
113581 goto begin_table_error;
113582 }
113583 if( sqlite3FindIndex(db, zName, zDb)!=0 ){
113584 sqlite3ErrorMsg(pParse, "there is already an index named %s", zName);
@@ -113155,10 +113751,11 @@
113751 pRet->retTrig.zName = RETURNING_TRIGGER_NAME;
113752 pRet->retTrig.op = TK_RETURNING;
113753 pRet->retTrig.tr_tm = TRIGGER_AFTER;
113754 pRet->retTrig.bReturning = 1;
113755 pRet->retTrig.pSchema = db->aDb[1].pSchema;
113756 pRet->retTrig.pTabSchema = db->aDb[1].pSchema;
113757 pRet->retTrig.step_list = &pRet->retTStep;
113758 pRet->retTStep.op = TK_RETURNING;
113759 pRet->retTStep.pTrig = &pRet->retTrig;
113760 pRet->retTStep.pExprList = pList;
113761 pHash = &(db->aDb[1].pSchema->trigHash);
@@ -114013,20 +114610,26 @@
114610 ExprList *pList;
114611 Token ipkToken;
114612 sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName);
114613 pList = sqlite3ExprListAppend(pParse, 0,
114614 sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
114615 if( pList==0 ){
114616 pTab->tabFlags &= ~TF_WithoutRowid;
114617 return;
114618 }
114619 if( IN_RENAME_OBJECT ){
114620 sqlite3RenameTokenRemap(pParse, pList->a[0].pExpr, &pTab->iPKey);
114621 }
114622 pList->a[0].sortFlags = pParse->iPkSortOrder;
114623 assert( pParse->pNewTable==pTab );
114624 pTab->iPKey = -1;
114625 sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
114626 SQLITE_IDXTYPE_PRIMARYKEY);
114627 if( db->mallocFailed || pParse->nErr ){
114628 pTab->tabFlags &= ~TF_WithoutRowid;
114629 return;
114630 }
114631 pPk = sqlite3PrimaryKeyIndex(pTab);
114632 assert( pPk->nKeyCol==1 );
114633 }else{
114634 pPk = sqlite3PrimaryKeyIndex(pTab);
114635 assert( pPk!=0 );
@@ -114226,11 +114829,10 @@
114829 Index *pIdx; /* An implied index of the table */
114830
114831 if( pEnd==0 && pSelect==0 ){
114832 return;
114833 }
 
114834 p = pParse->pNewTable;
114835 if( p==0 ) return;
114836
114837 if( pSelect==0 && sqlite3ShadowTableName(db, p->zName) ){
114838 p->tabFlags |= TF_Shadow;
@@ -114474,10 +115076,11 @@
115076 */
115077 if( db->init.busy ){
115078 Table *pOld;
115079 Schema *pSchema = p->pSchema;
115080 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
115081 assert( HasRowid(p) || p->iPKey<0 );
115082 pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName, p);
115083 if( pOld ){
115084 assert( p==pOld ); /* Malloc must have failed inside HashInsert() */
115085 sqlite3OomFault(db);
115086 return;
@@ -115022,11 +115625,14 @@
115625 assert( isView==0 || isView==LOCATE_VIEW );
115626 pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);
115627 if( noErr ) db->suppressErr--;
115628
115629 if( pTab==0 ){
115630 if( noErr ){
115631 sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
115632 sqlite3ForceNotReadOnly(pParse);
115633 }
115634 goto exit_drop_table;
115635 }
115636 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
115637 assert( iDb>=0 && iDb<db->nDb );
115638
@@ -115592,10 +116198,11 @@
116198 if( !ifNotExist ){
116199 sqlite3ErrorMsg(pParse, "index %s already exists", zName);
116200 }else{
116201 assert( !db->init.busy );
116202 sqlite3CodeVerifySchema(pParse, iDb);
116203 sqlite3ForceNotReadOnly(pParse);
116204 }
116205 goto exit_create_index;
116206 }
116207 }
116208 }else{
@@ -116072,11 +116679,11 @@
116679 x = pIdx->pTable->nRowLogEst;
116680 assert( 99==sqlite3LogEst(1000) );
116681 if( x<99 ){
116682 pIdx->pTable->nRowLogEst = x = 99;
116683 }
116684 if( pIdx->pPartIdxWhere!=0 ){ x -= 10; assert( 10==sqlite3LogEst(2) ); }
116685 a[0] = x;
116686
116687 /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is
116688 ** 6 and each subsequent value (if any) is 5. */
116689 memcpy(&a[1], aVal, nCopy*sizeof(LogEst));
@@ -116110,10 +116717,11 @@
116717 if( pIndex==0 ){
116718 if( !ifExists ){
116719 sqlite3ErrorMsg(pParse, "no such index: %S", pName->a);
116720 }else{
116721 sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
116722 sqlite3ForceNotReadOnly(pParse);
116723 }
116724 pParse->checkSchema = 1;
116725 goto exit_drop_index;
116726 }
116727 if( pIndex->idxType!=SQLITE_IDXTYPE_APPDEF ){
@@ -116129,11 +116737,11 @@
116737 const char *zDb = db->aDb[iDb].zDbSName;
116738 const char *zTab = SCHEMA_TABLE(iDb);
116739 if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){
116740 goto exit_drop_index;
116741 }
116742 if( !OMIT_TEMPDB && iDb==1 ) code = SQLITE_DROP_TEMP_INDEX;
116743 if( sqlite3AuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){
116744 goto exit_drop_index;
116745 }
116746 }
116747 #endif
@@ -116421,12 +117029,12 @@
117029 ** Assign VdbeCursor index numbers to all tables in a SrcList
117030 */
117031 SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){
117032 int i;
117033 SrcItem *pItem;
117034 assert( pList || pParse->db->mallocFailed );
117035 if( ALWAYS(pList) ){
117036 for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
117037 if( pItem->iCursor>=0 ) continue;
117038 pItem->iCursor = pParse->nTab++;
117039 if( pItem->pSelect ){
117040 sqlite3SrcListAssignCursors(pParse, pItem->pSelect->pSrc);
@@ -118147,10 +118755,13 @@
118755 pTab->zName, P4_STATIC);
118756 }
118757 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
118758 assert( pIdx->pSchema==pTab->pSchema );
118759 sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);
118760 if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
118761 sqlite3VdbeChangeP3(v, -1, memCnt ? memCnt : -1);
118762 }
118763 }
118764 }else
118765 #endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */
118766 {
118767 u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK;
@@ -118658,17 +119269,19 @@
119269 ){
119270 /* This column was already computed by the previous index */
119271 continue;
119272 }
119273 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j);
119274 if( pIdx->aiColumn[j]>=0 ){
119275 /* If the column affinity is REAL but the number is an integer, then it
119276 ** might be stored in the table as an integer (using a compact
119277 ** representation) then converted to REAL by an OP_RealAffinity opcode.
119278 ** But we are getting ready to store this value back into an index, where
119279 ** it should be converted by to INTEGER again. So omit the
119280 ** OP_RealAffinity opcode if it is present */
119281 sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);
119282 }
119283 }
119284 if( regOut ){
119285 sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut);
119286 }
119287 sqlite3ReleaseTempRange(pParse, regBase, nCol);
@@ -120759,13 +121372,11 @@
121372 ans = x(v0, v1);
121373 sqlite3_result_double(context, ans);
121374 }
121375
121376 /*
121377 ** Implementation of 0-argument pi() function.
 
 
121378 */
121379 static void piFunc(
121380 sqlite3_context *context,
121381 int argc,
121382 sqlite3_value **argv
@@ -122791,11 +123402,11 @@
123402 /* Verify that the sqlite_sequence table exists and is an ordinary
123403 ** rowid table with exactly two columns.
123404 ** Ticket d8dc2b3a58cd5dc2918a1d4acb 2018-05-23 */
123405 if( pSeqTab==0
123406 || !HasRowid(pSeqTab)
123407 || NEVER(IsVirtual(pSeqTab))
123408 || pSeqTab->nCol!=2
123409 ){
123410 pParse->nErr++;
123411 pParse->rc = SQLITE_CORRUPT_SEQUENCE;
123412 return 0;
@@ -126824,11 +127435,11 @@
127435 sqlite3_loadext_entry xInit;
127436 char *zErrmsg = 0;
127437 const char *zEntry;
127438 char *zAltEntry = 0;
127439 void **aHandle;
127440 u64 nMsg = strlen(zFile);
127441 int ii;
127442 int rc;
127443
127444 /* Shared library endings to try if zFile cannot be loaded as written */
127445 static const char *azEndings[] = {
@@ -126858,30 +127469,26 @@
127469 return SQLITE_ERROR;
127470 }
127471
127472 zEntry = zProc ? zProc : "sqlite3_extension_init";
127473
127474 /* tag-20210611-1. Some dlopen() implementations will segfault if given
127475 ** an oversize filename. Most filesystems have a pathname limit of 4K,
127476 ** so limit the extension filename length to about twice that.
127477 ** https://sqlite.org/forum/forumpost/08a0d6d9bf */
127478 if( nMsg>SQLITE_MAX_PATHLEN ) goto extension_not_found;
127479
127480 handle = sqlite3OsDlOpen(pVfs, zFile);
127481 #if SQLITE_OS_UNIX || SQLITE_OS_WIN
127482 for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){
127483 char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEndings[ii]);
127484 if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;
127485 handle = sqlite3OsDlOpen(pVfs, zAltFile);
127486 sqlite3_free(zAltFile);
127487 }
127488 #endif
127489 if( handle==0 ) goto extension_not_found;
 
 
 
 
 
 
 
 
 
 
127490 xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
127491
127492 /* If no entry point was specified and the default legacy
127493 ** entry point name "sqlite3_extension_init" was not found, then
127494 ** construct an entry point name "sqlite3_X_init" where the X is
@@ -126914,14 +127521,15 @@
127521 zEntry = zAltEntry;
127522 xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
127523 }
127524 if( xInit==0 ){
127525 if( pzErrMsg ){
127526 nMsg += strlen(zEntry) + 300;
127527 *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
127528 if( zErrmsg ){
127529 assert( nMsg<0x7fffffff ); /* zErrmsg would be NULL if not so */
127530 sqlite3_snprintf((int)nMsg, zErrmsg,
127531 "no entry point [%s] in shared library [%s]", zEntry, zFile);
127532 sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
127533 }
127534 }
127535 sqlite3OsDlClose(pVfs, handle);
@@ -126951,10 +127559,23 @@
127559 sqlite3DbFree(db, db->aExtension);
127560 db->aExtension = aHandle;
127561
127562 db->aExtension[db->nExtension++] = handle;
127563 return SQLITE_OK;
127564
127565 extension_not_found:
127566 if( pzErrMsg ){
127567 nMsg += 300;
127568 *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
127569 if( zErrmsg ){
127570 assert( nMsg<0x7fffffff ); /* zErrmsg would be NULL if not so */
127571 sqlite3_snprintf((int)nMsg, zErrmsg,
127572 "unable to open shared library [%.*s]", SQLITE_MAX_PATHLEN, zFile);
127573 sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
127574 }
127575 }
127576 return SQLITE_ERROR;
127577 }
127578 SQLITE_API int sqlite3_load_extension(
127579 sqlite3 *db, /* Load the extension into this database connection */
127580 const char *zFile, /* Name of the shared library containing extension */
127581 const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
@@ -130510,18 +131131,18 @@
131131
131132 assert( argc==5 );
131133 UNUSED_PARAMETER2(NotUsed, argc);
131134 assert( sqlite3_mutex_held(db->mutex) );
131135 db->mDbFlags |= DBFLAG_EncodingFixed;
131136 if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */
131137 pData->nInitRow++;
131138 if( db->mallocFailed ){
131139 corruptSchema(pData, argv, 0);
131140 return 1;
131141 }
131142
131143 assert( iDb>=0 && iDb<db->nDb );
 
131144 if( argv[3]==0 ){
131145 corruptSchema(pData, argv, 0);
131146 }else if( argv[4]
131147 && 'c'==sqlite3UpperToLower[(unsigned char)argv[4][0]]
131148 && 'r'==sqlite3UpperToLower[(unsigned char)argv[4][1]] ){
@@ -130791,22 +131412,26 @@
131412 if( rc==SQLITE_OK ){
131413 sqlite3AnalysisLoad(db, iDb);
131414 }
131415 #endif
131416 }
131417 assert( pDb == &(db->aDb[iDb]) );
131418 if( db->mallocFailed ){
131419 rc = SQLITE_NOMEM_BKPT;
131420 sqlite3ResetAllSchemasOfConnection(db);
131421 pDb = &db->aDb[iDb];
131422 }else
131423 if( rc==SQLITE_OK || (db->flags&SQLITE_NoSchemaError)){
131424 /* Hack: If the SQLITE_NoSchemaError flag is set, then consider
131425 ** the schema loaded, even if errors (other than OOM) occurred. In
131426 ** this situation the current sqlite3_prepare() operation will fail,
131427 ** but the following one will attempt to compile the supplied statement
131428 ** against whatever subset of the schema was loaded before the error
131429 ** occurred.
131430 **
131431 ** The primary purpose of this is to allow access to the sqlite_schema
131432 ** table even when its contents have been corrupted.
131433 */
131434 DbSetProperty(db, iDb, DB_SchemaLoaded);
131435 rc = SQLITE_OK;
131436 }
131437
@@ -133387,11 +134012,11 @@
134012 **
134013 ** full=ON, short=ANY: If the result refers directly to a table column,
134014 ** then the result column name with the table name
134015 ** prefix, ex: TABLE.COLUMN. Otherwise use zSpan.
134016 */
134017 SQLITE_PRIVATE void sqlite3GenerateColumnNames(
134018 Parse *pParse, /* Parser context */
134019 Select *pSelect /* Generate column names for this SELECT statement */
134020 ){
134021 Vdbe *v = pParse->pVdbe;
134022 int i;
@@ -133477,11 +134102,11 @@
134102 ** That is the only documented guarantee. However, countless applications
134103 ** developed over the years have made baseless assumptions about column names
134104 ** and will break if those assumptions changes. Hence, use extreme caution
134105 ** when modifying this routine to avoid breaking legacy.
134106 **
134107 ** See Also: sqlite3GenerateColumnNames()
134108 */
134109 SQLITE_PRIVATE int sqlite3ColumnsFromExprList(
134110 Parse *pParse, /* Parsing context */
134111 ExprList *pEList, /* Expr list from which to derive column names */
134112 i16 *pnCol, /* Write the number of columns here */
@@ -134180,10 +134805,11 @@
134805 int nLimit = 0; /* Initialize to suppress harmless compiler warning */
134806 assert( !pPrior->pLimit );
134807 pPrior->iLimit = p->iLimit;
134808 pPrior->iOffset = p->iOffset;
134809 pPrior->pLimit = p->pLimit;
134810 SELECTTRACE(1, pParse, p, ("multiSelect UNION ALL left...\n"));
134811 rc = sqlite3Select(pParse, pPrior, &dest);
134812 pPrior->pLimit = 0;
134813 if( rc ){
134814 goto multi_select_end;
134815 }
@@ -134197,10 +134823,11 @@
134823 sqlite3VdbeAddOp3(v, OP_OffsetLimit,
134824 p->iLimit, p->iOffset+1, p->iOffset);
134825 }
134826 }
134827 ExplainQueryPlan((pParse, 1, "UNION ALL"));
134828 SELECTTRACE(1, pParse, p, ("multiSelect UNION ALL right...\n"));
134829 rc = sqlite3Select(pParse, p, &dest);
134830 testcase( rc!=SQLITE_OK );
134831 pDelete = p->pPrior;
134832 p->pPrior = pPrior;
134833 p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
@@ -134249,10 +134876,11 @@
134876
134877 /* Code the SELECT statements to our left
134878 */
134879 assert( !pPrior->pOrderBy );
134880 sqlite3SelectDestInit(&uniondest, priorOp, unionTab);
134881 SELECTTRACE(1, pParse, p, ("multiSelect EXCEPT/UNION left...\n"));
134882 rc = sqlite3Select(pParse, pPrior, &uniondest);
134883 if( rc ){
134884 goto multi_select_end;
134885 }
134886
@@ -134268,10 +134896,11 @@
134896 pLimit = p->pLimit;
134897 p->pLimit = 0;
134898 uniondest.eDest = op;
134899 ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
134900 sqlite3SelectOpName(p->op)));
134901 SELECTTRACE(1, pParse, p, ("multiSelect EXCEPT/UNION right...\n"));
134902 rc = sqlite3Select(pParse, p, &uniondest);
134903 testcase( rc!=SQLITE_OK );
134904 assert( p->pOrderBy==0 );
134905 pDelete = p->pPrior;
134906 p->pPrior = pPrior;
@@ -134328,10 +134957,11 @@
134957 assert( p->pEList );
134958
134959 /* Code the SELECTs to our left into temporary table "tab1".
134960 */
134961 sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1);
134962 SELECTTRACE(1, pParse, p, ("multiSelect INTERSECT left...\n"));
134963 rc = sqlite3Select(pParse, pPrior, &intersectdest);
134964 if( rc ){
134965 goto multi_select_end;
134966 }
134967
@@ -134344,10 +134974,11 @@
134974 pLimit = p->pLimit;
134975 p->pLimit = 0;
134976 intersectdest.iSDParm = tab2;
134977 ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
134978 sqlite3SelectOpName(p->op)));
134979 SELECTTRACE(1, pParse, p, ("multiSelect INTERSECT right...\n"));
134980 rc = sqlite3Select(pParse, p, &intersectdest);
134981 testcase( rc!=SQLITE_OK );
134982 pDelete = p->pPrior;
134983 p->pPrior = pPrior;
134984 if( p->nSelectRow>pPrior->nSelectRow ){
@@ -134976,10 +135607,13 @@
135607 if( p->pPrior ){
135608 sqlite3SelectDelete(db, p->pPrior);
135609 }
135610 p->pPrior = pPrior;
135611 pPrior->pNext = p;
135612
135613 sqlite3ExprListDelete(db, pPrior->pOrderBy);
135614 pPrior->pOrderBy = 0;
135615
135616 /*** TBD: Insert subroutine calls to close cursors on incomplete
135617 **** subqueries ****/
135618 ExplainQueryPlanPop(pParse);
135619 return pParse->nErr!=0;
@@ -135056,30 +135690,32 @@
135690 ifNullRow.flags = EP_IfNullRow;
135691 pCopy = &ifNullRow;
135692 }
135693 testcase( ExprHasProperty(pCopy, EP_Subquery) );
135694 pNew = sqlite3ExprDup(db, pCopy, 0);
135695 if( db->mallocFailed ){
135696 sqlite3ExprDelete(db, pNew);
135697 return pExpr;
135698 }
135699 if( pSubst->isLeftJoin ){
135700 ExprSetProperty(pNew, EP_CanBeNull);
135701 }
135702 if( ExprHasProperty(pExpr,EP_FromJoin) ){
135703 sqlite3SetJoinExpr(pNew, pExpr->iRightJoinTable);
135704 }
135705 sqlite3ExprDelete(db, pExpr);
135706 pExpr = pNew;
135707
135708 /* Ensure that the expression now has an implicit collation sequence,
135709 ** just as it did when it was a column of a view or sub-query. */
135710 if( pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE ){
135711 CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, pExpr);
135712 pExpr = sqlite3ExprAddCollateString(pSubst->pParse, pExpr,
135713 (pColl ? pColl->zName : "BINARY")
135714 );
135715 }
135716 ExprClearProperty(pExpr, EP_Collate);
 
 
135717 }
135718 }
135719 }else{
135720 if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){
135721 pExpr->iTable = pSubst->iNewTable;
@@ -135194,11 +135830,14 @@
135830 int i;
135831 SrcItem *pItem;
135832 for(i=0, pItem=pSrc->a; i<pSrc->nSrc; i++, pItem++){
135833 if( i!=iExcept ){
135834 Select *p;
135835 if( !pItem->fg.isRecursive || aCsrMap[pItem->iCursor]==0 ){
135836 aCsrMap[pItem->iCursor] = pParse->nTab++;
135837 }
135838 pItem->iCursor = aCsrMap[pItem->iCursor];
135839 for(p=pItem->pSelect; p; p=p->pPrior){
135840 srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1);
135841 }
135842 }
135843 }
@@ -135634,11 +136273,11 @@
136273 pSubitem->pTab = pItemTab;
136274 if( pNew==0 ){
136275 p->pPrior = pPrior;
136276 }else{
136277 pNew->selId = ++pParse->nSelect;
136278 if( aCsrMap && ALWAYS(db->mallocFailed==0) ){
136279 renumberCursors(pParse, pNew, iFrom, aCsrMap);
136280 }
136281 pNew->pPrior = pPrior;
136282 if( pPrior ) pPrior->pNext = pNew;
136283 pNew->pNext = p;
@@ -135833,12 +136472,14 @@
136472 ** a known value due to WHERE clause constraints of the form COLUMN=VALUE.
136473 */
136474 typedef struct WhereConst WhereConst;
136475 struct WhereConst {
136476 Parse *pParse; /* Parsing context */
136477 u8 *pOomFault; /* Pointer to pParse->db->mallocFailed */
136478 int nConst; /* Number for COLUMN=CONSTANT terms */
136479 int nChng; /* Number of times a constant is propagated */
136480 int bHasAffBlob; /* At least one column in apExpr[] as affinity BLOB */
136481 Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */
136482 };
136483
136484 /*
136485 ** Add a new entry to the pConst object. Except, do not add duplicate
@@ -135873,10 +136514,13 @@
136514 && pE2->iColumn==pColumn->iColumn
136515 ){
136516 return; /* Already present. Return without doing anything. */
136517 }
136518 }
136519 if( sqlite3ExprAffinity(pColumn)==SQLITE_AFF_BLOB ){
136520 pConst->bHasAffBlob = 1;
136521 }
136522
136523 pConst->nConst++;
136524 pConst->apExpr = sqlite3DbReallocOrFree(pConst->pParse->db, pConst->apExpr,
136525 pConst->nConst*2*sizeof(Expr*));
136526 if( pConst->apExpr==0 ){
@@ -135893,11 +136537,11 @@
136537 ** is part of the AND-connected terms of the expression. For each term
136538 ** found, add it to the pConst structure.
136539 */
136540 static void findConstInWhere(WhereConst *pConst, Expr *pExpr){
136541 Expr *pRight, *pLeft;
136542 if( NEVER(pExpr==0) ) return;
136543 if( ExprHasProperty(pExpr, EP_FromJoin) ) return;
136544 if( pExpr->op==TK_AND ){
136545 findConstInWhere(pConst, pExpr->pRight);
136546 findConstInWhere(pConst, pExpr->pLeft);
136547 return;
@@ -135914,40 +136558,86 @@
136558 constInsert(pConst,pLeft,pRight,pExpr);
136559 }
136560 }
136561
136562 /*
136563 ** This is a helper function for Walker callback propagateConstantExprRewrite().
136564 **
136565 ** Argument pExpr is a candidate expression to be replaced by a value. If
136566 ** pExpr is equivalent to one of the columns named in pWalker->u.pConst,
136567 ** then overwrite it with the corresponding value. Except, do not do so
136568 ** if argument bIgnoreAffBlob is non-zero and the affinity of pExpr
136569 ** is SQLITE_AFF_BLOB.
136570 */
136571 static int propagateConstantExprRewriteOne(
136572 WhereConst *pConst,
136573 Expr *pExpr,
136574 int bIgnoreAffBlob
136575 ){
136576 int i;
136577 if( pConst->pOomFault[0] ) return WRC_Prune;
136578 if( pExpr->op!=TK_COLUMN ) return WRC_Continue;
136579 if( ExprHasProperty(pExpr, EP_FixedCol|EP_FromJoin) ){
136580 testcase( ExprHasProperty(pExpr, EP_FixedCol) );
136581 testcase( ExprHasProperty(pExpr, EP_FromJoin) );
136582 return WRC_Continue;
136583 }
 
136584 for(i=0; i<pConst->nConst; i++){
136585 Expr *pColumn = pConst->apExpr[i*2];
136586 if( pColumn==pExpr ) continue;
136587 if( pColumn->iTable!=pExpr->iTable ) continue;
136588 if( pColumn->iColumn!=pExpr->iColumn ) continue;
136589 if( bIgnoreAffBlob && sqlite3ExprAffinity(pColumn)==SQLITE_AFF_BLOB ){
136590 break;
136591 }
136592 /* A match is found. Add the EP_FixedCol property */
136593 pConst->nChng++;
136594 ExprClearProperty(pExpr, EP_Leaf);
136595 ExprSetProperty(pExpr, EP_FixedCol);
136596 assert( pExpr->pLeft==0 );
136597 pExpr->pLeft = sqlite3ExprDup(pConst->pParse->db, pConst->apExpr[i*2+1], 0);
136598 if( pConst->pParse->db->mallocFailed ) return WRC_Prune;
136599 break;
136600 }
136601 return WRC_Prune;
136602 }
136603
136604 /*
136605 ** This is a Walker expression callback. pExpr is a node from the WHERE
136606 ** clause of a SELECT statement. This function examines pExpr to see if
136607 ** any substitutions based on the contents of pWalker->u.pConst should
136608 ** be made to pExpr or its immediate children.
136609 **
136610 ** A substitution is made if:
136611 **
136612 ** + pExpr is a column with an affinity other than BLOB that matches
136613 ** one of the columns in pWalker->u.pConst, or
136614 **
136615 ** + pExpr is a binary comparison operator (=, <=, >=, <, >) that
136616 ** uses an affinity other than TEXT and one of its immediate
136617 ** children is a column that matches one of the columns in
136618 ** pWalker->u.pConst.
136619 */
136620 static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){
136621 WhereConst *pConst = pWalker->u.pConst;
136622 assert( TK_GT==TK_EQ+1 );
136623 assert( TK_LE==TK_EQ+2 );
136624 assert( TK_LT==TK_EQ+3 );
136625 assert( TK_GE==TK_EQ+4 );
136626 if( pConst->bHasAffBlob ){
136627 if( (pExpr->op>=TK_EQ && pExpr->op<=TK_GE)
136628 || pExpr->op==TK_IS
136629 ){
136630 propagateConstantExprRewriteOne(pConst, pExpr->pLeft, 0);
136631 if( pConst->pOomFault[0] ) return WRC_Prune;
136632 if( sqlite3ExprAffinity(pExpr->pLeft)!=SQLITE_AFF_TEXT ){
136633 propagateConstantExprRewriteOne(pConst, pExpr->pRight, 0);
136634 }
136635 }
136636 }
136637 return propagateConstantExprRewriteOne(pConst, pExpr, pConst->bHasAffBlob);
136638 }
136639
136640 /*
136641 ** The WHERE-clause constant propagation optimization.
136642 **
136643 ** If the WHERE clause contains terms of the form COLUMN=CONSTANT or
@@ -135980,23 +136670,40 @@
136670 ** "b=a" to "b=123" but rather the "a" in "b=a" is tagged with EP_FixedCol
136671 ** and the "123" value is hung off of the pLeft pointer. Code generator
136672 ** routines know to generate the constant "123" instead of looking up the
136673 ** column value. Also, to avoid collation problems, this optimization is
136674 ** only attempted if the "a=123" term uses the default BINARY collation.
136675 **
136676 ** 2021-05-25 forum post 6a06202608: Another troublesome case is...
136677 **
136678 ** CREATE TABLE t1(x);
136679 ** INSERT INTO t1 VALUES(10.0);
136680 ** SELECT 1 FROM t1 WHERE x=10 AND x LIKE 10;
136681 **
136682 ** The query should return no rows, because the t1.x value is '10.0' not '10'
136683 ** and '10.0' is not LIKE '10'. But if we are not careful, the first WHERE
136684 ** term "x=10" will cause the second WHERE term to become "10 LIKE 10",
136685 ** resulting in a false positive. To avoid this, constant propagation for
136686 ** columns with BLOB affinity is only allowed if the constant is used with
136687 ** operators ==, <=, <, >=, >, or IS in a way that will cause the correct
136688 ** type conversions to occur. See logic associated with the bHasAffBlob flag
136689 ** for details.
136690 */
136691 static int propagateConstants(
136692 Parse *pParse, /* The parsing context */
136693 Select *p /* The query in which to propagate constants */
136694 ){
136695 WhereConst x;
136696 Walker w;
136697 int nChng = 0;
136698 x.pParse = pParse;
136699 x.pOomFault = &pParse->db->mallocFailed;
136700 do{
136701 x.nConst = 0;
136702 x.nChng = 0;
136703 x.apExpr = 0;
136704 x.bHasAffBlob = 0;
136705 findConstInWhere(&x, p->pWhere);
136706 if( x.nConst ){
136707 memset(&w, 0, sizeof(w));
136708 w.pParse = pParse;
136709 w.xExprCallback = propagateConstantExprRewrite;
@@ -136429,36 +137136,47 @@
137136 if( sqlite3StrICmp(zName, p->a[i].zName)==0 ){
137137 *ppContext = p;
137138 return &p->a[i];
137139 }
137140 }
137141 if( p->bView ) break;
137142 }
137143 return 0;
137144 }
137145
137146 /* The code generator maintains a stack of active WITH clauses
137147 ** with the inner-most WITH clause being at the top of the stack.
137148 **
137149 ** This routine pushes the WITH clause passed as the second argument
137150 ** onto the top of the stack. If argument bFree is true, then this
137151 ** WITH clause will never be popped from the stack but should instead
137152 ** be freed along with the Parse object. In other cases, when
137153 ** bFree==0, the With object will be freed along with the SELECT
137154 ** statement with which it is associated.
137155 **
137156 ** This routine returns a copy of pWith. Or, if bFree is true and
137157 ** the pWith object is destroyed immediately due to an OOM condition,
137158 ** then this routine return NULL.
137159 **
137160 ** If bFree is true, do not continue to use the pWith pointer after
137161 ** calling this routine, Instead, use only the return value.
137162 */
137163 SQLITE_PRIVATE With *sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){
137164 if( pWith ){
 
 
 
137165 if( bFree ){
137166 pWith = (With*)sqlite3ParserAddCleanup(pParse,
137167 (void(*)(sqlite3*,void*))sqlite3WithDelete,
137168 pWith);
137169 if( pWith==0 ) return 0;
137170 }
137171 if( pParse->nErr==0 ){
137172 assert( pParse->pWith!=pWith );
137173 pWith->pOuter = pParse->pWith;
137174 pParse->pWith = pWith;
137175 }
137176 }
137177 return pWith;
137178 }
137179
137180 /*
137181 ** This function checks if argument pFrom refers to a CTE declared by
137182 ** a WITH clause on the stack currently maintained by the parser (on the
@@ -136483,15 +137201,28 @@
137201
137202 assert( pFrom->pTab==0 );
137203 if( pParse->pWith==0 ){
137204 /* There are no WITH clauses in the stack. No match is possible */
137205 return 0;
137206 }
137207 if( pParse->nErr ){
137208 /* Prior errors might have left pParse->pWith in a goofy state, so
137209 ** go no further. */
137210 return 0;
137211 }
137212 if( pFrom->zDatabase!=0 ){
137213 /* The FROM term contains a schema qualifier (ex: main.t1) and so
137214 ** it cannot possibly be a CTE reference. */
137215 return 0;
137216 }
137217 if( pFrom->fg.notCte ){
137218 /* The FROM term is specifically excluded from matching a CTE.
137219 ** (1) It is part of a trigger that used to have zDatabase but had
137220 ** zDatabase removed by sqlite3FixTriggerStep().
137221 ** (2) This is the first term in the FROM clause of an UPDATE.
137222 */
137223 return 0;
137224 }
137225 pCte = searchWith(pParse->pWith, pFrom, &pWith);
137226 if( pCte ){
137227 sqlite3 *db = pParse->db;
137228 Table *pTab;
@@ -136534,10 +137265,11 @@
137265 pTab->iPKey = -1;
137266 pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
137267 pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid;
137268 pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0);
137269 if( db->mallocFailed ) return 2;
137270 pFrom->pSelect->selFlags |= SF_CopyCte;
137271 assert( pFrom->pSelect );
137272 pFrom->fg.isCte = 1;
137273 pFrom->u2.pCteUse = pCteUse;
137274 pCteUse->nUse++;
137275 if( pCteUse->nUse>=2 && pCteUse->eM10d==M10d_Any ){
@@ -136637,22 +137369,20 @@
137369 **
137370 ** This function is used as the xSelectCallback2() callback by
137371 ** sqlite3SelectExpand() when walking a SELECT tree to resolve table
137372 ** names and other FROM clause elements.
137373 */
137374 SQLITE_PRIVATE void sqlite3SelectPopWith(Walker *pWalker, Select *p){
137375 Parse *pParse = pWalker->pParse;
137376 if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){
137377 With *pWith = findRightmost(p)->pWith;
137378 if( pWith!=0 ){
137379 assert( pParse->pWith==pWith || pParse->nErr );
137380 pParse->pWith = pWith->pOuter;
137381 }
137382 }
137383 }
 
 
137384 #endif
137385
137386 /*
137387 ** The SrcList_item structure passed as the second argument represents a
137388 ** sub-query in the FROM clause of a SELECT statement. This function
@@ -136735,10 +137465,19 @@
137465 /* Renumber selId because it has been copied from a view */
137466 p->selId = ++pParse->nSelect;
137467 }
137468 pTabList = p->pSrc;
137469 pEList = p->pEList;
137470 if( pParse->pWith && (p->selFlags & SF_View) ){
137471 if( p->pWith==0 ){
137472 p->pWith = (With*)sqlite3DbMallocZero(db, sizeof(With));
137473 if( p->pWith==0 ){
137474 return WRC_Abort;
137475 }
137476 }
137477 p->pWith->bView = 1;
137478 }
137479 sqlite3WithPush(pParse, p->pWith, 0);
137480
137481 /* Make sure cursor numbers have been assigned to all entries in
137482 ** the FROM clause of the SELECT statement.
137483 */
@@ -136795,10 +137534,11 @@
137534 ){
137535 sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited",
137536 pTab->zName);
137537 }
137538 #ifndef SQLITE_OMIT_VIRTUALTABLE
137539 assert( SQLITE_VTABRISK_Normal==1 && SQLITE_VTABRISK_High==2 );
137540 if( IsVirtual(pTab)
137541 && pFrom->fg.fromDDL
137542 && ALWAYS(pTab->pVTable!=0)
137543 && pTab->pVTable->eVtabRisk > ((db->flags & SQLITE_TrustedSchema)!=0)
137544 ){
@@ -137035,11 +137775,11 @@
137775 w.xSelectCallback = convertCompoundSelectToSubquery;
137776 w.xSelectCallback2 = 0;
137777 sqlite3WalkSelect(&w, pSelect);
137778 }
137779 w.xSelectCallback = selectExpander;
137780 w.xSelectCallback2 = sqlite3SelectPopWith;
137781 w.eCode = 0;
137782 sqlite3WalkSelect(&w, pSelect);
137783 }
137784
137785
@@ -137622,16 +138362,15 @@
138362 }
138363 }
138364 }
138365
138366 if( pDest->eDest==SRT_Output ){
138367 sqlite3GenerateColumnNames(pParse, p);
138368 }
138369
138370 #ifndef SQLITE_OMIT_WINDOWFUNC
138371 if( sqlite3WindowRewrite(pParse, p) ){
 
138372 assert( db->mallocFailed || pParse->nErr>0 );
138373 goto select_end;
138374 }
138375 #if SELECTTRACE_ENABLED
138376 if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){
@@ -137753,11 +138492,12 @@
138492 /* Do the WHERE-clause constant propagation optimization if this is
138493 ** a join. No need to speed time on this operation for non-join queries
138494 ** as the equivalent optimization will be handled by query planner in
138495 ** sqlite3WhereBegin().
138496 */
138497 if( p->pWhere!=0
138498 && p->pWhere->op==TK_AND
138499 && OptimizationEnabled(db, SQLITE_PropagateConst)
138500 && propagateConstants(pParse, p)
138501 ){
138502 #if SELECTTRACE_ENABLED
138503 if( sqlite3SelectTrace & 0x100 ){
@@ -137816,23 +138556,12 @@
138556 /* Generate code for all sub-queries in the FROM clause
138557 */
138558 pSub = pItem->pSelect;
138559 if( pSub==0 ) continue;
138560
138561 /* The code for a subquery should only be generated once. */
138562 assert( pItem->addrFillSub==0 );
 
 
 
 
 
 
 
 
 
 
 
138563
138564 /* Increment Parse.nHeight by the height of the largest expression
138565 ** tree referred to by this, the parent select. The child select
138566 ** may contain expression trees of at most
138567 ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit
@@ -137915,18 +138644,17 @@
138644 sqlite3VdbeAddOp2(v, OP_Gosub, pPrior->regReturn, pPrior->addrFillSub);
138645 }
138646 sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);
138647 pSub->nSelectRow = pPrior->pSelect->nSelectRow;
138648 }else{
138649 /* Materialize the view. If the view is not correlated, generate a
138650 ** subroutine to do the materialization so that subsequent uses of
138651 ** the same view can reuse the materialization. */
138652 int topAddr;
138653 int onceAddr = 0;
138654 int retAddr;
138655
 
138656 pItem->regReturn = ++pParse->nMem;
138657 topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn);
138658 pItem->addrFillSub = topAddr+1;
138659 if( pItem->fg.isCorrelated==0 ){
138660 /* If the subquery is not correlated and if we are not inside of
@@ -138344,12 +139072,14 @@
139072 sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);
139073 SELECTTRACE(1,pParse,p,("WhereBegin\n"));
139074 pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pGroupBy, pDistinct,
139075 WHERE_GROUPBY | (orderByGrp ? WHERE_SORTBYGROUP : 0) | distFlag, 0
139076 );
139077 if( pWInfo==0 ){
139078 sqlite3ExprListDelete(db, pDistinct);
139079 goto select_end;
139080 }
139081 eDist = sqlite3WhereIsDistinct(pWInfo);
139082 SELECTTRACE(1,pParse,p,("WhereBegin returns\n"));
139083 if( sqlite3WhereIsOrdered(pWInfo)==pGroupBy->nExpr ){
139084 /* The optimizer is able to deliver rows in group by order so
139085 ** we do not have to sort. The OP_OpenEphemeral table will be
@@ -138478,10 +139208,11 @@
139208 }else{
139209 SELECTTRACE(1,pParse,p,("WhereEnd\n"));
139210 sqlite3WhereEnd(pWInfo);
139211 sqlite3VdbeChangeToNoop(v, addrSortingIdx);
139212 }
139213 sqlite3ExprListDelete(db, pDistinct);
139214
139215 /* Output the final row of result
139216 */
139217 sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);
139218 VdbeComment((v, "output final row"));
@@ -138692,10 +139423,12 @@
139423
139424 /* Control jumps to here if an error is encountered above, or upon
139425 ** successful coding of the SELECT.
139426 */
139427 select_end:
139428 assert( db->mallocFailed==0 || db->mallocFailed==1 );
139429 pParse->nErr += db->mallocFailed;
139430 sqlite3ExprListDelete(db, pMinMaxOrderBy);
139431 #ifdef SQLITE_DEBUG
139432 if( pAggInfo && !db->mallocFailed ){
139433 for(i=0; i<pAggInfo->nColumn; i++){
139434 Expr *pExpr = pAggInfo->aCol[i].pCExpr;
@@ -138982,37 +139715,45 @@
139715 if( pParse->disableTriggers ){
139716 return 0;
139717 }
139718 pTmpSchema = pParse->db->aDb[1].pSchema;
139719 p = sqliteHashFirst(&pTmpSchema->trigHash);
 
 
 
139720 pList = pTab->pTrigger;
139721 while( p ){
139722 Trigger *pTrig = (Trigger *)sqliteHashData(p);
139723 if( pTrig->pTabSchema==pTab->pSchema
139724 && pTrig->table
139725 && 0==sqlite3StrICmp(pTrig->table, pTab->zName)
139726 && pTrig->pTabSchema!=pTmpSchema
139727 ){
139728 pTrig->pNext = pList;
139729 pList = pTrig;
139730 }else if( pTrig->op==TK_RETURNING
139731 #ifndef SQLITE_OMIT_VIRTUALTABLE
139732 && pParse->db->pVtabCtx==0
139733 #endif
139734 ){
139735 assert( pParse->bReturning );
139736 assert( &(pParse->u1.pReturning->retTrig) == pTrig );
139737 pTrig->table = pTab->zName;
139738 pTrig->pTabSchema = pTab->pSchema;
139739 pTrig->pNext = pList;
139740 pList = pTrig;
139741 }
139742 p = sqliteHashNext(p);
139743 }
139744 #if 0
139745 if( pList ){
139746 Trigger *pX;
139747 printf("Triggers for %s:", pTab->zName);
139748 for(pX=pList; pX; pX=pX->pNext){
139749 printf(" %s", pX->zName);
139750 }
139751 printf("\n");
139752 fflush(stdout);
139753 }
139754 #endif
139755 return pList;
139756 }
139757
139758 /*
139759 ** This is called by the parser when it sees a CREATE TRIGGER statement
@@ -139812,19 +140553,10 @@
140553 pItem->zEName = sqlite3DbStrDup(db, pList->a[i].zEName);
140554 pItem->eEName = pList->a[i].eEName;
140555 }
140556 }
140557 }
 
 
 
 
 
 
 
 
 
140558 return pNew;
140559 }
140560
140561 /*
140562 ** Generate code for the RETURNING trigger. Unlike other triggers
@@ -139836,17 +140568,31 @@
140568 Trigger *pTrigger, /* The trigger step that defines the RETURNING */
140569 Table *pTab, /* The table to code triggers from */
140570 int regIn /* The first in an array of registers */
140571 ){
140572 Vdbe *v = pParse->pVdbe;
140573 sqlite3 *db = pParse->db;
140574 ExprList *pNew;
140575 Returning *pReturning;
140576 Select sSelect;
140577 SrcList sFrom;
140578
140579 assert( v!=0 );
140580 assert( pParse->bReturning );
140581 pReturning = pParse->u1.pReturning;
140582 assert( pTrigger == &(pReturning->retTrig) );
140583 memset(&sSelect, 0, sizeof(sSelect));
140584 memset(&sFrom, 0, sizeof(sFrom));
140585 sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0);
140586 sSelect.pSrc = &sFrom;
140587 sFrom.nSrc = 1;
140588 sFrom.a[0].pTab = pTab;
140589 sqlite3SelectPrep(pParse, &sSelect, 0);
140590 if( db->mallocFailed==0 && pParse->nErr==0 ){
140591 sqlite3GenerateColumnNames(pParse, &sSelect);
140592 }
140593 sqlite3ExprListDelete(db, sSelect.pEList);
140594 pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab);
140595 if( pNew ){
140596 NameContext sNC;
140597 memset(&sNC, 0, sizeof(sNC));
140598 if( pReturning->nRetCol==0 ){
@@ -139863,17 +140609,18 @@
140609 int nCol = pNew->nExpr;
140610 int reg = pParse->nMem+1;
140611 pParse->nMem += nCol+2;
140612 pReturning->iRetReg = reg;
140613 for(i=0; i<nCol; i++){
140614 Expr *pCol = pNew->a[i].pExpr;
140615 sqlite3ExprCodeFactorable(pParse, pCol, reg+i);
140616 }
140617 sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, i, reg+i);
140618 sqlite3VdbeAddOp2(v, OP_NewRowid, pReturning->iRetCur, reg+i+1);
140619 sqlite3VdbeAddOp3(v, OP_Insert, pReturning->iRetCur, reg+i, reg+i+1);
140620 }
140621 sqlite3ExprListDelete(db, pNew);
140622 pParse->eTriggerOp = 0;
140623 pParse->pTriggerTab = 0;
140624 }
140625 }
140626
@@ -140552,10 +141299,11 @@
141299 pSrc = sqlite3SrcListDup(db, pTabList, 0);
141300 pWhere2 = sqlite3ExprDup(db, pWhere, 0);
141301
141302 assert( pTabList->nSrc>1 );
141303 if( pSrc ){
141304 pSrc->a[0].fg.notCte = 1;
141305 pSrc->a[0].iCursor = -1;
141306 pSrc->a[0].pTab->nTabRef--;
141307 pSrc->a[0].pTab = 0;
141308 }
141309 if( pPk ){
@@ -140581,11 +141329,12 @@
141329 if( pLimit ){
141330 pGrp = sqlite3ExprListAppend(pParse, 0, sqlite3PExpr(pParse,TK_ROW,0,0));
141331 }
141332 #endif
141333 }
141334 assert( pChanges!=0 || pParse->db->mallocFailed );
141335 if( pChanges ){
141336 for(i=0; i<pChanges->nExpr; i++){
141337 pList = sqlite3ExprListAppend(pParse, pList,
141338 sqlite3ExprDup(db, pChanges->a[i].pExpr, 0)
141339 );
141340 }
@@ -143607,10 +144356,11 @@
144356 pMod->pEpoTab = pTab;
144357 pTab->nTabRef = 1;
144358 pTab->pSchema = db->aDb[0].pSchema;
144359 assert( pTab->nModuleArg==0 );
144360 pTab->iPKey = -1;
144361 pTab->tabFlags |= TF_Eponymous;
144362 addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName));
144363 addModuleArgument(pParse, pTab, 0);
144364 addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName));
144365 rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr);
144366 if( rc ){
@@ -144023,12 +144773,12 @@
144773 WhereClause *pOrigWC; /* Original, innermost WhereClause */
144774 WhereClause *pWC; /* WhereClause currently being scanned */
144775 const char *zCollName; /* Required collating sequence, if not NULL */
144776 Expr *pIdxExpr; /* Search for this index expression */
144777 char idxaff; /* Must match this affinity, if zCollName!=NULL */
144778 unsigned char nEquiv; /* Number of entries in aiCur[] and aiColumn[] */
144779 unsigned char iEquiv; /* Next unused slot in aiCur[] and aiColumn[] */
144780 u32 opMask; /* Acceptable operators */
144781 int k; /* Resume scanning at this->pWC->a[this->k] */
144782 int aiCur[11]; /* Cursors in the equivalence class */
144783 i16 aiColumn[11]; /* Corresponding column number in the eq-class */
144784 };
@@ -144333,10 +145083,11 @@
145083 #define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
145084 #define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
145085 #define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */
145086 #define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */
145087 #define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */
145088 #define WHERE_TRANSCONS 0x00200000 /* Uses a transitive constraint */
145089
145090 #endif /* !defined(SQLITE_WHEREINT_H) */
145091
145092 /************** End of whereInt.h ********************************************/
145093 /************** Continuing where we left off in wherecode.c ******************/
@@ -144616,10 +145367,16 @@
145367 if( nLoop && (pTerm->wtFlags & TERM_LIKE)!=0 ){
145368 pTerm->wtFlags |= TERM_LIKECOND;
145369 }else{
145370 pTerm->wtFlags |= TERM_CODED;
145371 }
145372 #ifdef WHERETRACE_ENABLED
145373 if( sqlite3WhereTrace & 0x20000 ){
145374 sqlite3DebugPrintf("DISABLE-");
145375 sqlite3WhereTermPrint(pTerm, (int)(pTerm - (pTerm->pWC->a)));
145376 }
145377 #endif
145378 if( pTerm->iParent<0 ) break;
145379 pTerm = &pTerm->pWC->a[pTerm->iParent];
145380 assert( pTerm!=0 );
145381 pTerm->nChild--;
145382 if( pTerm->nChild!=0 ) break;
@@ -144933,11 +145690,26 @@
145690 pLevel->u.in.nIn = 0;
145691 }
145692 sqlite3DbFree(pParse->db, aiMap);
145693 #endif
145694 }
145695
145696 /* As an optimization, try to disable the WHERE clause term that is
145697 ** driving the index as it will always be true. The correct answer is
145698 ** obtained regardless, but we might get the answer with fewer CPU cycles
145699 ** by omitting the term.
145700 **
145701 ** But do not disable the term unless we are certain that the term is
145702 ** not a transitive constraint. For an example of where that does not
145703 ** work, see https://sqlite.org/forum/forumpost/eb8613976a (2021-05-04)
145704 */
145705 if( (pLevel->pWLoop->wsFlags & WHERE_TRANSCONS)==0
145706 || (pTerm->eOperator & WO_EQUIV)==0
145707 ){
145708 disableTerm(pLevel, pTerm);
145709 }
145710
145711 return iReg;
145712 }
145713
145714 /*
145715 ** Generate code that will evaluate all == and IN constraints for an
@@ -145019,10 +145791,11 @@
145791 zAff = sqlite3DbStrDup(pParse->db,sqlite3IndexAffinityStr(pParse->db,pIdx));
145792 assert( zAff!=0 || pParse->db->mallocFailed );
145793
145794 if( nSkip ){
145795 int iIdxCur = pLevel->iIdxCur;
145796 sqlite3VdbeAddOp3(v, OP_Null, 0, regBase, regBase+nSkip-1);
145797 sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur);
145798 VdbeCoverageIf(v, bRev==0);
145799 VdbeCoverageIf(v, bRev!=0);
145800 VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
145801 j = sqlite3VdbeAddOp0(v, OP_Goto);
@@ -145053,11 +145826,11 @@
145826 if( r1!=regBase+j ){
145827 if( nReg==1 ){
145828 sqlite3ReleaseTempReg(pParse, regBase);
145829 regBase = r1;
145830 }else{
145831 sqlite3VdbeAddOp2(v, OP_Copy, r1, regBase+j);
145832 }
145833 }
145834 if( pTerm->eOperator & WO_IN ){
145835 if( pTerm->pExpr->flags & EP_xIsSelect ){
145836 /* No affinity ever needs to be (or should be) applied to a value
@@ -145070,11 +145843,11 @@
145843 Expr *pRight = pTerm->pExpr->pRight;
145844 if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){
145845 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
145846 VdbeCoverage(v);
145847 }
145848 if( pParse->db->mallocFailed==0 && pParse->nErr==0 ){
145849 if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){
145850 zAff[j] = SQLITE_AFF_BLOB;
145851 }
145852 if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){
145853 zAff[j] = SQLITE_AFF_BLOB;
@@ -145419,11 +146192,11 @@
146192 for(i=0; i<nReg; i++){
146193 sqlite3ExprCode(pParse, pList->a[i].pExpr, iReg+i);
146194 }
146195 }
146196 }else{
146197 assert( nReg==1 || pParse->nErr );
146198 sqlite3ExprCode(pParse, p, iReg);
146199 }
146200 }
146201
146202 /* An instance of the IdxExprTrans object carries information about a
@@ -146046,13 +146819,11 @@
146819
146820 /* If we are doing a reverse order scan on an ascending index, or
146821 ** a forward order scan on a descending index, interchange the
146822 ** start and end terms (pRangeStart and pRangeEnd).
146823 */
146824 if( (nEq<pIdx->nColumn && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC)) ){
 
 
146825 SWAP(WhereTerm *, pRangeEnd, pRangeStart);
146826 SWAP(u8, bSeekPastNull, bStopAtNull);
146827 SWAP(u8, nBtm, nTop);
146828 }
146829
@@ -146469,11 +147240,11 @@
147240 }
147241 if( pAndExpr ){
147242 /* The extra 0x10000 bit on the opcode is masked off and does not
147243 ** become part of the new Expr.op. However, it does make the
147244 ** op==TK_AND comparison inside of sqlite3PExpr() false, and this
147245 ** prevents sqlite3PExpr() from applying the AND short-circuit
147246 ** optimization, which we do not want here. */
147247 pAndExpr = sqlite3PExpr(pParse, TK_AND|0x10000, 0, pAndExpr);
147248 }
147249 }
147250
@@ -146485,14 +147256,20 @@
147256 for(ii=0; ii<pOrWc->nTerm; ii++){
147257 WhereTerm *pOrTerm = &pOrWc->a[ii];
147258 if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
147259 WhereInfo *pSubWInfo; /* Info for single OR-term scan */
147260 Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
147261 Expr *pDelete; /* Local copy of OR clause term */
147262 int jmp1 = 0; /* Address of jump operation */
147263 testcase( (pTabItem[0].fg.jointype & JT_LEFT)!=0
147264 && !ExprHasProperty(pOrExpr, EP_FromJoin)
147265 ); /* See TH3 vtab25.400 and ticket 614b25314c766238 */
147266 pDelete = pOrExpr = sqlite3ExprDup(db, pOrExpr, 0);
147267 if( db->mallocFailed ){
147268 sqlite3ExprDelete(db, pDelete);
147269 continue;
147270 }
147271 if( pAndExpr ){
147272 pAndExpr->pLeft = pOrExpr;
147273 pOrExpr = pAndExpr;
147274 }
147275 /* Loop through table entries that match term pOrTerm. */
@@ -146603,10 +147380,11 @@
147380
147381 /* Finish the loop through table entries that match term pOrTerm. */
147382 sqlite3WhereEnd(pSubWInfo);
147383 ExplainQueryPlanPop(pParse);
147384 }
147385 sqlite3ExprDelete(db, pDelete);
147386 }
147387 }
147388 ExplainQueryPlanPop(pParse);
147389 pLevel->u.pCovidx = pCov;
147390 if( pCov ) pLevel->iIdxCur = iCovCur;
@@ -147320,10 +148098,11 @@
148098 sqlite3 *db; /* Database connection (for malloc) */
148099 Expr *pNew; /* New virtual expression */
148100 int op; /* Operator for the combined expression */
148101 int idxNew; /* Index in pWC of the next virtual term */
148102
148103 if( (pOne->wtFlags | pTwo->wtFlags) & TERM_VNULL ) return;
148104 if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
148105 if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
148106 if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
148107 && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;
148108 assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );
@@ -147680,11 +148459,11 @@
148459 assert( !ExprHasProperty(pNew, EP_xIsSelect) );
148460 pNew->x.pList = pList;
148461 idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);
148462 testcase( idxNew==0 );
148463 exprAnalyze(pSrc, pWC, idxNew);
148464 /* pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where reused */
148465 markTermAsChild(pWC, idxNew, idxTerm);
148466 }else{
148467 sqlite3ExprListDelete(db, pList);
148468 }
148469 }
@@ -147804,10 +148583,11 @@
148583 assert( TK_GT+1==TK_LE && TK_GT+2==TK_LT && TK_GT+3==TK_GE );
148584 assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE );
148585 assert( op<=TK_GE );
148586 if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){
148587 pExpr = pExpr->x.pList->a[0].pExpr;
148588
148589 }
148590
148591 if( pExpr->op==TK_COLUMN ){
148592 aiCurCol[0] = pExpr->iTable;
148593 aiCurCol[1] = pExpr->iColumn;
@@ -147816,280 +148596,10 @@
148596 if( mPrereq==0 ) return 0; /* No table references */
148597 if( (mPrereq&(mPrereq-1))!=0 ) return 0; /* Refs more than one table */
148598 return exprMightBeIndexed2(pFrom,mPrereq,aiCurCol,pExpr);
148599 }
148600
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148601
148602 /*
148603 ** The input to this routine is an WhereTerm structure with only the
148604 ** "pExpr" field filled in. The job of this routine is to analyze the
148605 ** subexpression and populate all the other fields of the WhereTerm
@@ -148185,10 +148695,11 @@
148695 pTerm->eOperator = operatorMask(op) & opMask;
148696 }
148697 if( op==TK_IS ) pTerm->wtFlags |= TERM_IS;
148698 if( pRight
148699 && exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op)
148700 && !ExprHasProperty(pRight, EP_FixedCol)
148701 ){
148702 WhereTerm *pNew;
148703 Expr *pDup;
148704 u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */
148705 assert( pTerm->u.x.iField==0 );
@@ -148277,20 +148788,10 @@
148788 assert( pWC->op==TK_AND );
148789 exprAnalyzeOrTerm(pSrc, pWC, idxTerm);
148790 pTerm = &pWC->a[idxTerm];
148791 }
148792 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
 
 
 
 
 
 
 
 
 
 
148793 /* The form "x IS NOT NULL" can sometimes be evaluated more efficiently
148794 ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
148795 ** virtual term of that form.
148796 **
148797 ** The virtual term must be tagged with TERM_VNULL.
@@ -148973,11 +149474,13 @@
149474 ** If the right-hand branch of the expression is a TK_COLUMN, then return
149475 ** a pointer to the right-hand branch. Otherwise, return NULL.
149476 */
149477 static Expr *whereRightSubexprIsColumn(Expr *p){
149478 p = sqlite3ExprSkipCollateAndLikely(p->pRight);
149479 if( ALWAYS(p!=0) && p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){
149480 return p;
149481 }
149482 return 0;
149483 }
149484
149485 /*
149486 ** Advance to the next WhereTerm that matches according to the criteria
@@ -149048,10 +149551,22 @@
149551 testcase( pTerm->eOperator & WO_IS );
149552 continue;
149553 }
149554 pScan->pWC = pWC;
149555 pScan->k = k+1;
149556 #ifdef WHERETRACE_ENABLED
149557 if( sqlite3WhereTrace & 0x20000 ){
149558 int ii;
149559 sqlite3DebugPrintf("SCAN-TERM %p: nEquiv=%d",
149560 pTerm, pScan->nEquiv);
149561 for(ii=0; ii<pScan->nEquiv; ii++){
149562 sqlite3DebugPrintf(" {%d:%d}",
149563 pScan->aiCur[ii], pScan->aiColumn[ii]);
149564 }
149565 sqlite3DebugPrintf("\n");
149566 }
149567 #endif
149568 return pTerm;
149569 }
149570 }
149571 }
149572 pWC = pWC->pOuter;
@@ -150652,11 +151167,11 @@
151167 ** Transfer content from the second pLoop into the first.
151168 */
151169 static int whereLoopXfer(sqlite3 *db, WhereLoop *pTo, WhereLoop *pFrom){
151170 whereLoopClearUnion(db, pTo);
151171 if( whereLoopResize(db, pTo, pFrom->nLTerm) ){
151172 memset(pTo, 0, WHERE_LOOP_XFER_SZ);
151173 return SQLITE_NOMEM_BKPT;
151174 }
151175 memcpy(pTo, pFrom, WHERE_LOOP_XFER_SZ);
151176 memcpy(pTo->aLTerm, pFrom->aLTerm, pTo->nLTerm*sizeof(pTo->aLTerm[0]));
151177 if( pFrom->wsFlags & WHERE_VIRTUALTABLE ){
@@ -150694,10 +151209,21 @@
151209 whereLoopDelete(db, p);
151210 }
151211 assert( pWInfo->pExprMods==0 );
151212 sqlite3DbFreeNN(db, pWInfo);
151213 }
151214
151215 /* Undo all Expr node modifications
151216 */
151217 static void whereUndoExprMods(WhereInfo *pWInfo){
151218 while( pWInfo->pExprMods ){
151219 WhereExprMod *p = pWInfo->pExprMods;
151220 pWInfo->pExprMods = p->pNext;
151221 memcpy(p->pExpr, &p->orig, sizeof(p->orig));
151222 sqlite3DbFree(pWInfo->pParse->db, p);
151223 }
151224 }
151225
151226 /*
151227 ** Return TRUE if all of the following are true:
151228 **
151229 ** (1) X has the same or lower cost that Y
@@ -151200,10 +151726,12 @@
151726 opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
151727 }
151728 if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
151729
151730 assert( pNew->u.btree.nEq<pProbe->nColumn );
151731 assert( pNew->u.btree.nEq<pProbe->nKeyCol
151732 || pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY );
151733
151734 saved_nEq = pNew->u.btree.nEq;
151735 saved_nBtm = pNew->u.btree.nBtm;
151736 saved_nTop = pNew->u.btree.nTop;
151737 saved_nSkip = pNew->nSkip;
@@ -151282,11 +151810,11 @@
151810 }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
151811 /* "x IN (value, value, ...)" */
151812 nIn = sqlite3LogEst(pExpr->x.pList->nExpr);
151813 }
151814 if( pProbe->hasStat1 && rLogSize>=10 ){
151815 LogEst M, logK, x;
151816 /* Let:
151817 ** N = the total number of rows in the table
151818 ** K = the number of entries on the RHS of the IN operator
151819 ** M = the number of rows in the table that match terms to the
151820 ** to the left in the same index. If the IN operator is on
@@ -151305,20 +151833,29 @@
151833 ** the index. Do not bother with this optimization on very small
151834 ** tables (less than 2 rows) as it is pointless in that case.
151835 */
151836 M = pProbe->aiRowLogEst[saved_nEq];
151837 logK = estLog(nIn);
151838 /* TUNING v----- 10 to bias toward indexed IN */
151839 x = M + logK + 10 - (nIn + rLogSize);
151840 if( x>=0 ){
151841 WHERETRACE(0x40,
151842 ("IN operator (N=%d M=%d logK=%d nIn=%d rLogSize=%d x=%d) "
151843 "prefers indexed lookup\n",
151844 saved_nEq, M, logK, nIn, rLogSize, x));
151845 }else if( nInMul<2 && OptimizationEnabled(db, SQLITE_SeekScan) ){
151846 WHERETRACE(0x40,
151847 ("IN operator (N=%d M=%d logK=%d nIn=%d rLogSize=%d x=%d"
151848 " nInMul=%d) prefers skip-scan\n",
151849 saved_nEq, M, logK, nIn, rLogSize, x, nInMul));
151850 pNew->wsFlags |= WHERE_IN_SEEKSCAN;
151851 }else{
151852 WHERETRACE(0x40,
151853 ("IN operator (N=%d M=%d logK=%d nIn=%d rLogSize=%d x=%d"
151854 " nInMul=%d) prefers normal scan\n",
151855 saved_nEq, M, logK, nIn, rLogSize, x, nInMul));
151856 continue;
151857 }
151858 }
151859 pNew->wsFlags |= WHERE_COLUMN_IN;
151860 }else if( eOp & (WO_EQ|WO_IS) ){
151861 int iCol = pProbe->aiColumn[saved_nEq];
@@ -151333,10 +151870,11 @@
151870 pNew->wsFlags |= WHERE_ONEROW;
151871 }else{
151872 pNew->wsFlags |= WHERE_UNQ_WANTED;
151873 }
151874 }
151875 if( scan.iEquiv>1 ) pNew->wsFlags |= WHERE_TRANSCONS;
151876 }else if( eOp & WO_ISNULL ){
151877 pNew->wsFlags |= WHERE_COLUMN_NULL;
151878 }else if( eOp & (WO_GT|WO_GE) ){
151879 testcase( eOp & WO_GT );
151880 testcase( eOp & WO_GE );
@@ -151476,10 +152014,12 @@
152014 pNew->nOut = nOutUnadjusted;
152015 }
152016
152017 if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
152018 && pNew->u.btree.nEq<pProbe->nColumn
152019 && (pNew->u.btree.nEq<pProbe->nKeyCol ||
152020 pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY)
152021 ){
152022 whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
152023 }
152024 pNew->nOut = saved_nOut;
152025 #ifdef SQLITE_ENABLE_STAT4
@@ -151597,10 +152137,11 @@
152137 Expr *pExpr;
152138 pExpr = pTerm->pExpr;
152139 if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
152140 && (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin))
152141 && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
152142 && (pTerm->wtFlags & TERM_VNULL)==0
152143 ){
152144 return 1;
152145 }
152146 }
152147 return 0;
@@ -152307,11 +152848,13 @@
152848 rc = whereLoopAddBtree(&sSubBuild, mPrereq);
152849 }
152850 if( rc==SQLITE_OK ){
152851 rc = whereLoopAddOr(&sSubBuild, mPrereq, mUnusable);
152852 }
152853 assert( rc==SQLITE_OK || rc==SQLITE_DONE || sCur.n==0
152854 || rc==SQLITE_NOMEM );
152855 testcase( rc==SQLITE_NOMEM && sCur.n>0 );
152856 testcase( rc==SQLITE_DONE );
152857 if( sCur.n==0 ){
152858 sSum.n = 0;
152859 break;
152860 }else if( once ){
@@ -152576,10 +153119,14 @@
153119 nKeyCol = pIndex->nKeyCol;
153120 nColumn = pIndex->nColumn;
153121 assert( nColumn==nKeyCol+1 || !HasRowid(pIndex->pTable) );
153122 assert( pIndex->aiColumn[nColumn-1]==XN_ROWID
153123 || !HasRowid(pIndex->pTable));
153124 /* All relevant terms of the index must also be non-NULL in order
153125 ** for isOrderDistinct to be true. So the isOrderDistint value
153126 ** computed here might be a false positive. Corrections will be
153127 ** made at tag-20210426-1 below */
153128 isOrderDistinct = IsUniqueIndex(pIndex)
153129 && (pLoop->wsFlags & WHERE_SKIPSCAN)==0;
153130 }
153131
153132 /* Loop through all columns of the index and deal with the ones
@@ -152643,18 +153190,22 @@
153190 iColumn = XN_ROWID;
153191 revIdx = 0;
153192 }
153193
153194 /* An unconstrained column that might be NULL means that this
153195 ** WhereLoop is not well-ordered. tag-20210426-1
153196 */
153197 if( isOrderDistinct ){
153198 if( iColumn>=0
153199 && j>=pLoop->u.btree.nEq
153200 && pIndex->pTable->aCol[iColumn].notNull==0
153201 ){
153202 isOrderDistinct = 0;
153203 }
153204 if( iColumn==XN_EXPR ){
153205 isOrderDistinct = 0;
153206 }
153207 }
153208
153209 /* Find the ORDER BY term that corresponds to the j-th column
153210 ** of the index and mark that ORDER BY term off
153211 */
@@ -152834,11 +153385,11 @@
153385 if( (pWInfo->wctrlFlags & WHERE_USE_LIMIT)!=0 && pWInfo->iLimit<nRow ){
153386 nRow = pWInfo->iLimit;
153387 }else if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT) ){
153388 /* TUNING: In the sort for a DISTINCT operator, assume that the DISTINCT
153389 ** reduces the number of output rows by a factor of 2 */
153390 if( nRow>10 ){ nRow -= 10; assert( 10==sqlite3LogEst(2) ); }
153391 }
153392 rSortCost += estLog(nRow);
153393 return rSortCost;
153394 }
153395
@@ -154026,10 +154577,12 @@
154577 return pWInfo;
154578
154579 /* Jump here if malloc fails */
154580 whereBeginError:
154581 if( pWInfo ){
154582 testcase( pWInfo->pExprMods!=0 );
154583 whereUndoExprMods(pWInfo);
154584 pParse->nQueryLoop = pWInfo->savedNQueryLoop;
154585 whereInfoFree(db, pWInfo);
154586 }
154587 return 0;
154588 }
@@ -154122,10 +154675,12 @@
154675 if( pLoop->wsFlags & WHERE_IN_ABLE && pLevel->u.in.nIn>0 ){
154676 struct InLoop *pIn;
154677 int j;
154678 sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
154679 for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
154680 assert( sqlite3VdbeGetOp(v, pIn->addrInTop+1)->opcode==OP_IsNull
154681 || pParse->db->mallocFailed );
154682 sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
154683 if( pIn->eEndLoopOp!=OP_Noop ){
154684 if( pIn->nPrefix ){
154685 int bEarlyOut =
154686 (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0
@@ -154146,10 +154701,15 @@
154701 if( bEarlyOut ){
154702 sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur,
154703 sqlite3VdbeCurrentAddr(v)+2,
154704 pIn->iBase, pIn->nPrefix);
154705 VdbeCoverage(v);
154706 /* Retarget the OP_IsNull against the left operand of IN so
154707 ** it jumps past the OP_IfNoHope. This is because the
154708 ** OP_IsNull also bypasses the OP_Affinity opcode that is
154709 ** required by OP_IfNoHope. */
154710 sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
154711 }
154712 }
154713 sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
154714 VdbeCoverage(v);
154715 VdbeCoverageIf(v, pIn->eEndLoopOp==OP_Prev);
@@ -154325,20 +154885,13 @@
154885 if( db->flags & SQLITE_VdbeAddopTrace ) printf("TRANSLATE complete\n");
154886 #endif
154887 }
154888 }
154889
 
 
 
 
 
 
 
 
154890 /* Final cleanup
154891 */
154892 if( pWInfo->pExprMods ) whereUndoExprMods(pWInfo);
154893 pParse->nQueryLoop = pWInfo->savedNQueryLoop;
154894 whereInfoFree(db, pWInfo);
154895 return;
154896 }
154897
@@ -155284,10 +155837,18 @@
155837 ){
155838 pExpr->op2++;
155839 }
155840 return WRC_Continue;
155841 }
155842
155843 static int disallowAggregatesInOrderByCb(Walker *pWalker, Expr *pExpr){
155844 if( pExpr->op==TK_AGG_FUNCTION && pExpr->pAggInfo==0 ){
155845 sqlite3ErrorMsg(pWalker->pParse,
155846 "misuse of aggregate: %s()", pExpr->u.zToken);
155847 }
155848 return WRC_Continue;
155849 }
155850
155851 /*
155852 ** If the SELECT statement passed as the second argument does not invoke
155853 ** any SQL window functions, this function is a no-op. Otherwise, it
155854 ** rewrites the SELECT statement so that window function xStep functions
@@ -155294,11 +155855,11 @@
155855 ** are invoked in the correct order as described under "SELECT REWRITING"
155856 ** at the top of this file.
155857 */
155858 SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
155859 int rc = SQLITE_OK;
155860 if( p->pWin && p->pPrior==0 && ALWAYS((p->selFlags & SF_WinRewrite)==0) ){
155861 Vdbe *v = sqlite3GetVdbe(pParse);
155862 sqlite3 *db = pParse->db;
155863 Select *pSub = 0; /* The subquery */
155864 SrcList *pSrc = p->pSrc;
155865 Expr *pWhere = p->pWhere;
@@ -155318,10 +155879,15 @@
155879 if( pTab==0 ){
155880 return sqlite3ErrorToParser(db, SQLITE_NOMEM);
155881 }
155882 sqlite3AggInfoPersistWalkerInit(&w, pParse);
155883 sqlite3WalkSelect(&w, p);
155884 if( (p->selFlags & SF_Aggregate)==0 ){
155885 w.xExprCallback = disallowAggregatesInOrderByCb;
155886 w.xSelectCallback = 0;
155887 sqlite3WalkExprList(&w, p->pOrderBy);
155888 }
155889
155890 p->pSrc = 0;
155891 p->pWhere = 0;
155892 p->pGroupBy = 0;
155893 p->pHaving = 0;
@@ -155914,10 +156480,11 @@
156480 Vdbe *pVdbe; /* VDBE object */
156481 int addrGosub; /* OP_Gosub to this address to return one row */
156482 int regGosub; /* Register used with OP_Gosub(addrGosub) */
156483 int regArg; /* First in array of accumulator registers */
156484 int eDelete; /* See above */
156485 int regRowid;
156486
156487 WindowCsrAndReg start;
156488 WindowCsrAndReg current;
156489 WindowCsrAndReg end;
156490 };
@@ -156590,20 +157157,28 @@
157157 addrContinue = sqlite3VdbeCurrentAddr(v);
157158
157159 /* If this is a (RANGE BETWEEN a FOLLOWING AND b FOLLOWING) or
157160 ** (RANGE BETWEEN b PRECEDING AND a PRECEDING) frame, ensure the
157161 ** start cursor does not advance past the end cursor within the
157162 ** temporary table. It otherwise might, if (a>b). Also ensure that,
157163 ** if the input cursor is still finding new rows, that the end
157164 ** cursor does not go past it to EOF. */
157165 if( pMWin->eStart==pMWin->eEnd && regCountdown
157166 && pMWin->eFrmType==TK_RANGE
157167 ){
157168 int regRowid1 = sqlite3GetTempReg(pParse);
157169 int regRowid2 = sqlite3GetTempReg(pParse);
157170 if( op==WINDOW_AGGINVERSE ){
157171 sqlite3VdbeAddOp2(v, OP_Rowid, p->start.csr, regRowid1);
157172 sqlite3VdbeAddOp2(v, OP_Rowid, p->end.csr, regRowid2);
157173 sqlite3VdbeAddOp3(v, OP_Ge, regRowid2, lblDone, regRowid1);
157174 VdbeCoverage(v);
157175 }else if( p->regRowid ){
157176 sqlite3VdbeAddOp2(v, OP_Rowid, p->end.csr, regRowid1);
157177 sqlite3VdbeAddOp3(v, OP_Ge, p->regRowid, lblDone, regRowid1);
157178 VdbeCoverageNeverNull(v);
157179 }
157180 sqlite3ReleaseTempReg(pParse, regRowid1);
157181 sqlite3ReleaseTempReg(pParse, regRowid2);
157182 assert( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_FOLLOWING );
157183 }
157184
@@ -157096,11 +157671,10 @@
157671 int addrGosubFlush = 0; /* Address of OP_Gosub to flush: */
157672 int addrInteger = 0; /* Address of OP_Integer */
157673 int addrEmpty; /* Address of OP_Rewind in flush: */
157674 int regNew; /* Array of registers holding new input row */
157675 int regRecord; /* regNew array in record form */
 
157676 int regNewPeer = 0; /* Peer values for new row (part of regNew) */
157677 int regPeer = 0; /* Peer values for current row */
157678 int regFlushPart = 0; /* Register for "Gosub flush_partition" */
157679 WindowCodeArg s; /* Context object for sub-routines */
157680 int lblWhereEnd; /* Label just before sqlite3WhereEnd() code */
@@ -157168,11 +157742,11 @@
157742 ** samve values in record form, and the rowid used to insert said record
157743 ** into the ephemeral table. */
157744 regNew = pParse->nMem+1;
157745 pParse->nMem += nInput;
157746 regRecord = ++pParse->nMem;
157747 s.regRowid = ++pParse->nMem;
157748
157749 /* If the window frame contains an "<expr> PRECEDING" or "<expr> FOLLOWING"
157750 ** clause, allocate registers to store the results of evaluating each
157751 ** <expr>. */
157752 if( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_FOLLOWING ){
@@ -157224,13 +157798,13 @@
157798 VdbeComment((v, "call flush_partition"));
157799 sqlite3VdbeAddOp3(v, OP_Copy, regNewPart, pMWin->regPart, nPart-1);
157800 }
157801
157802 /* Insert the new row into the ephemeral table */
157803 sqlite3VdbeAddOp2(v, OP_NewRowid, csrWrite, s.regRowid);
157804 sqlite3VdbeAddOp3(v, OP_Insert, csrWrite, regRecord, s.regRowid);
157805 addrNe = sqlite3VdbeAddOp3(v, OP_Ne, pMWin->regOne, 0, s.regRowid);
157806 VdbeCoverageNeverNull(v);
157807
157808 /* This block is run for the first row of each partition */
157809 s.regArg = windowInitAccum(pParse, pMWin);
157810
@@ -157344,10 +157918,11 @@
157918 if( pMWin->pPartition ){
157919 addrInteger = sqlite3VdbeAddOp2(v, OP_Integer, 0, regFlushPart);
157920 sqlite3VdbeJumpHere(v, addrGosubFlush);
157921 }
157922
157923 s.regRowid = 0;
157924 addrEmpty = sqlite3VdbeAddOp1(v, OP_Rewind, csrWrite);
157925 VdbeCoverage(v);
157926 if( pMWin->eEnd==TK_PRECEDING ){
157927 int bRPS = (pMWin->eStart==TK_PRECEDING && pMWin->eFrmType==TK_RANGE);
157928 windowCodeOp(&s, WINDOW_AGGSTEP, regEnd, 0);
@@ -157817,12 +158392,13 @@
158392 #define TK_VECTOR 176
158393 #define TK_SELECT_COLUMN 177
158394 #define TK_IF_NULL_ROW 178
158395 #define TK_ASTERISK 179
158396 #define TK_SPAN 180
158397 #define TK_ERROR 181
158398 #define TK_SPACE 182
158399 #define TK_ILLEGAL 183
158400 #endif
158401 /**************** End token definitions ***************************************/
158402
158403 /* The next sections is a series of control #defines.
158404 ** various aspects of the generated parser.
@@ -157878,33 +158454,33 @@
158454 #ifndef INTERFACE
158455 # define INTERFACE 1
158456 #endif
158457 /************* Begin control #defines *****************************************/
158458 #define YYCODETYPE unsigned short int
158459 #define YYNOCODE 317
158460 #define YYACTIONTYPE unsigned short int
158461 #define YYWILDCARD 101
158462 #define sqlite3ParserTOKENTYPE Token
158463 typedef union {
158464 int yyinit;
158465 sqlite3ParserTOKENTYPE yy0;
158466 Window* yy49;
158467 ExprList* yy70;
158468 Select* yy81;
158469 With* yy103;
158470 struct FrameBound yy117;
158471 struct {int value; int mask;} yy139;
158472 SrcList* yy153;
158473 TriggerStep* yy157;
158474 Upsert* yy190;
158475 struct TrigEvent yy262;
158476 Cte* yy329;
158477 int yy376;
158478 Expr* yy404;
158479 IdList* yy436;
158480 const char* yy504;
158481 u8 yy552;
158482 } YYMINORTYPE;
158483 #ifndef YYSTACKDEPTH
158484 #define YYSTACKDEPTH 100
158485 #endif
158486 #define sqlite3ParserARG_SDECL
@@ -157919,11 +158495,11 @@
158495 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
158496 #define YYFALLBACK 1
158497 #define YYNSTATE 570
158498 #define YYNRULE 398
158499 #define YYNRULE_WITH_ACTION 337
158500 #define YYNTOKEN 184
158501 #define YY_MAX_SHIFT 569
158502 #define YY_MIN_SHIFTREDUCE 825
158503 #define YY_MAX_SHIFTREDUCE 1222
158504 #define YY_ERROR_ACTION 1223
158505 #define YY_ACCEPT_ACTION 1224
@@ -157994,545 +158570,546 @@
158570 ** yy_reduce_ofst[] For each state, the offset into yy_action for
158571 ** shifting non-terminals after a reduce.
158572 ** yy_default[] Default action for each state.
158573 **
158574 *********** Begin parsing tables **********************************************/
158575 #define YY_ACTTAB_COUNT (2023)
158576 static const YYACTIONTYPE yy_action[] = {
158577 /* 0 */ 563, 1295, 563, 1274, 168, 1257, 115, 112, 218, 373,
158578 /* 10 */ 563, 1295, 374, 563, 488, 563, 115, 112, 218, 406,
158579 /* 20 */ 1300, 1300, 41, 41, 41, 41, 514, 1504, 520, 1298,
158580 /* 30 */ 1298, 959, 41, 41, 1260, 71, 71, 51, 51, 960,
158581 /* 40 */ 557, 557, 557, 122, 123, 113, 1200, 1200, 1035, 1038,
158582 /* 50 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 414, 406,
158583 /* 60 */ 273, 273, 273, 273, 115, 112, 218, 115, 112, 218,
158584 /* 70 */ 197, 268, 545, 560, 515, 560, 211, 563, 385, 248,
158585 /* 80 */ 215, 521, 399, 122, 123, 113, 1200, 1200, 1035, 1038,
158586 /* 90 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 540, 13,
158587 /* 100 */ 13, 1259, 119, 119, 119, 119, 118, 118, 117, 117,
158588 /* 110 */ 117, 116, 441, 1176, 419, 197, 446, 320, 512, 1539,
158589 /* 120 */ 1545, 372, 1547, 6, 371, 1176, 1148, 394, 1148, 406,
158590 /* 130 */ 1545, 534, 115, 112, 218, 1415, 99, 30, 121, 121,
158591 /* 140 */ 121, 121, 119, 119, 119, 119, 118, 118, 117, 117,
158592 /* 150 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038,
158593 /* 160 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 31, 1176,
158594 /* 170 */ 1177, 1178, 241, 357, 1558, 501, 498, 497, 317, 124,
158595 /* 180 */ 319, 1176, 1177, 1178, 1176, 496, 119, 119, 119, 119,
158596 /* 190 */ 118, 118, 117, 117, 117, 116, 441, 139, 96, 406,
158597 /* 200 */ 121, 121, 121, 121, 114, 117, 117, 117, 116, 441,
158598 /* 210 */ 541, 1532, 119, 119, 119, 119, 118, 118, 117, 117,
158599 /* 220 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038,
158600 /* 230 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 406, 441,
158601 /* 240 */ 1176, 1177, 1178, 81, 439, 439, 439, 80, 119, 119,
158602 /* 250 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 488,
158603 /* 260 */ 1176, 318, 122, 123, 113, 1200, 1200, 1035, 1038, 1028,
158604 /* 270 */ 1028, 120, 120, 121, 121, 121, 121, 493, 1025, 1025,
158605 /* 280 */ 1036, 1039, 119, 119, 119, 119, 118, 118, 117, 117,
158606 /* 290 */ 117, 116, 441, 1584, 995, 1224, 1, 1, 569, 2,
158607 /* 300 */ 1228, 1267, 137, 1503, 245, 305, 473, 140, 406, 860,
158608 /* 310 */ 561, 1176, 914, 914, 1308, 359, 1176, 1177, 1178, 462,
158609 /* 320 */ 330, 119, 119, 119, 119, 118, 118, 117, 117, 117,
158610 /* 330 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028,
158611 /* 340 */ 1028, 120, 120, 121, 121, 121, 121, 328, 273, 273,
158612 /* 350 */ 1015, 83, 1029, 425, 1564, 569, 2, 1228, 304, 554,
158613 /* 360 */ 925, 560, 305, 944, 140, 860, 1006, 1176, 1177, 1178,
158614 /* 370 */ 1005, 1308, 411, 213, 511, 229, 119, 119, 119, 119,
158615 /* 380 */ 118, 118, 117, 117, 117, 116, 441, 519, 347, 116,
158616 /* 390 */ 441, 119, 119, 119, 119, 118, 118, 117, 117, 117,
158617 /* 400 */ 116, 441, 1005, 1005, 1007, 273, 273, 445, 563, 16,
158618 /* 410 */ 16, 1590, 563, 1540, 563, 406, 1176, 6, 560, 344,
158619 /* 420 */ 182, 118, 118, 117, 117, 117, 116, 441, 416, 142,
158620 /* 430 */ 71, 71, 229, 563, 71, 71, 55, 55, 203, 122,
158621 /* 440 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120,
158622 /* 450 */ 121, 121, 121, 121, 217, 13, 13, 1176, 406, 568,
158623 /* 460 */ 1400, 1228, 502, 137, 445, 168, 305, 545, 140, 1180,
158624 /* 470 */ 424, 545, 1176, 1177, 1178, 1308, 544, 438, 437, 944,
158625 /* 480 */ 513, 452, 122, 123, 113, 1200, 1200, 1035, 1038, 1028,
158626 /* 490 */ 1028, 120, 120, 121, 121, 121, 121, 315, 119, 119,
158627 /* 500 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 273,
158628 /* 510 */ 273, 1143, 416, 1176, 1177, 1178, 543, 563, 1143, 304,
158629 /* 520 */ 554, 1561, 560, 1207, 1143, 1207, 1180, 1143, 406, 530,
158630 /* 530 */ 421, 1143, 864, 183, 1143, 143, 229, 562, 32, 71,
158631 /* 540 */ 71, 119, 119, 119, 119, 118, 118, 117, 117, 117,
158632 /* 550 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028,
158633 /* 560 */ 1028, 120, 120, 121, 121, 121, 121, 406, 445, 241,
158634 /* 570 */ 1176, 857, 501, 498, 497, 1176, 526, 189, 245, 538,
158635 /* 580 */ 1539, 282, 496, 370, 6, 563, 529, 477, 5, 279,
158636 /* 590 */ 1015, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028,
158637 /* 600 */ 120, 120, 121, 121, 121, 121, 1006, 13, 13, 1414,
158638 /* 610 */ 1005, 119, 119, 119, 119, 118, 118, 117, 117, 117,
158639 /* 620 */ 116, 441, 426, 273, 273, 1176, 1176, 1177, 1178, 1619,
158640 /* 630 */ 392, 1176, 1177, 1178, 1176, 342, 560, 406, 525, 361,
158641 /* 640 */ 430, 1161, 1005, 1005, 1007, 348, 411, 357, 1558, 488,
158642 /* 650 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
158643 /* 660 */ 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028,
158644 /* 670 */ 120, 120, 121, 121, 121, 121, 406, 830, 831, 832,
158645 /* 680 */ 1016, 1176, 1177, 1178, 396, 285, 148, 1312, 304, 554,
158646 /* 690 */ 1176, 1177, 1178, 1467, 216, 3, 337, 137, 340, 560,
158647 /* 700 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120,
158648 /* 710 */ 120, 121, 121, 121, 121, 563, 504, 946, 273, 273,
158649 /* 720 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
158650 /* 730 */ 441, 560, 1176, 427, 563, 451, 98, 13, 13, 259,
158651 /* 740 */ 276, 356, 507, 351, 506, 246, 406, 361, 469, 1530,
158652 /* 750 */ 1000, 347, 293, 304, 554, 1589, 71, 71, 889, 119,
158653 /* 760 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441,
158654 /* 770 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120,
158655 /* 780 */ 120, 121, 121, 121, 121, 406, 1143, 1078, 1176, 1177,
158656 /* 790 */ 1178, 416, 1080, 300, 150, 995, 1080, 361, 361, 1143,
158657 /* 800 */ 361, 378, 1143, 477, 563, 244, 243, 242, 1278, 122,
158658 /* 810 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120,
158659 /* 820 */ 121, 121, 121, 121, 563, 880, 13, 13, 483, 119,
158660 /* 830 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441,
158661 /* 840 */ 1176, 191, 540, 563, 147, 149, 13, 13, 328, 457,
158662 /* 850 */ 316, 1083, 1083, 485, 1537, 406, 505, 1530, 6, 1514,
158663 /* 860 */ 284, 192, 1277, 145, 881, 71, 71, 488, 119, 119,
158664 /* 870 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 122,
158665 /* 880 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120,
158666 /* 890 */ 121, 121, 121, 121, 563, 471, 1176, 1177, 1178, 406,
158667 /* 900 */ 852, 327, 301, 462, 330, 1516, 270, 1530, 1530, 944,
158668 /* 910 */ 1531, 1307, 313, 9, 842, 251, 71, 71, 477, 428,
158669 /* 920 */ 146, 488, 38, 945, 101, 113, 1200, 1200, 1035, 1038,
158670 /* 930 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 119, 119,
158671 /* 940 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 563,
158672 /* 950 */ 1197, 1099, 563, 436, 563, 1533, 563, 852, 1122, 1617,
158673 /* 960 */ 454, 290, 1617, 546, 251, 1303, 1100, 267, 267, 281,
158674 /* 970 */ 404, 70, 70, 460, 71, 71, 71, 71, 13, 13,
158675 /* 980 */ 560, 1101, 119, 119, 119, 119, 118, 118, 117, 117,
158676 /* 990 */ 117, 116, 441, 542, 104, 273, 273, 273, 273, 1197,
158677 /* 1000 */ 217, 1468, 900, 471, 450, 563, 1473, 1197, 560, 447,
158678 /* 1010 */ 560, 545, 901, 440, 406, 1058, 292, 274, 274, 198,
158679 /* 1020 */ 547, 450, 449, 1473, 1475, 944, 455, 56, 56, 410,
158680 /* 1030 */ 560, 1122, 1618, 379, 406, 1618, 404, 1120, 122, 123,
158681 /* 1040 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121,
158682 /* 1050 */ 121, 121, 121, 1460, 406, 12, 1197, 1512, 122, 123,
158683 /* 1060 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121,
158684 /* 1070 */ 121, 121, 121, 308, 471, 126, 359, 286, 122, 111,
158685 /* 1080 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121,
158686 /* 1090 */ 121, 121, 121, 309, 450, 471, 1473, 119, 119, 119,
158687 /* 1100 */ 119, 118, 118, 117, 117, 117, 116, 441, 1176, 563,
158688 /* 1110 */ 1120, 482, 563, 312, 433, 479, 197, 119, 119, 119,
158689 /* 1120 */ 119, 118, 118, 117, 117, 117, 116, 441, 405, 12,
158690 /* 1130 */ 536, 15, 15, 478, 43, 43, 509, 119, 119, 119,
158691 /* 1140 */ 119, 118, 118, 117, 117, 117, 116, 441, 289, 535,
158692 /* 1150 */ 294, 563, 294, 391, 1220, 438, 437, 406, 1154, 403,
158693 /* 1160 */ 402, 1400, 920, 1204, 1176, 1177, 1178, 919, 1206, 291,
158694 /* 1170 */ 1306, 1249, 412, 57, 57, 488, 1205, 563, 556, 412,
158695 /* 1180 */ 1176, 1344, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028,
158696 /* 1190 */ 120, 120, 121, 121, 121, 121, 1400, 1143, 563, 44,
158697 /* 1200 */ 44, 1207, 194, 1207, 273, 273, 1400, 461, 537, 1154,
158698 /* 1210 */ 1143, 108, 555, 1143, 4, 391, 1121, 560, 1538, 335,
158699 /* 1220 */ 58, 58, 6, 1246, 1099, 380, 1400, 376, 558, 1536,
158700 /* 1230 */ 563, 422, 1221, 6, 304, 554, 1176, 1177, 1178, 1100,
158701 /* 1240 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
158702 /* 1250 */ 441, 442, 59, 59, 1101, 516, 1535, 273, 273, 563,
158703 /* 1260 */ 6, 563, 110, 552, 563, 528, 423, 413, 169, 548,
158704 /* 1270 */ 560, 108, 555, 137, 4, 551, 484, 272, 215, 222,
158705 /* 1280 */ 211, 60, 60, 61, 61, 98, 62, 62, 558, 273,
158706 /* 1290 */ 273, 563, 1015, 467, 1221, 563, 434, 563, 106, 106,
158707 /* 1300 */ 8, 920, 560, 273, 273, 107, 919, 442, 565, 564,
158708 /* 1310 */ 563, 442, 1005, 45, 45, 464, 560, 46, 46, 47,
158709 /* 1320 */ 47, 84, 202, 552, 1215, 404, 468, 563, 205, 304,
158710 /* 1330 */ 554, 563, 49, 49, 563, 522, 404, 532, 563, 867,
158711 /* 1340 */ 563, 105, 531, 103, 1005, 1005, 1007, 1008, 27, 50,
158712 /* 1350 */ 50, 563, 1015, 63, 63, 475, 64, 64, 106, 106,
158713 /* 1360 */ 65, 65, 14, 14, 17, 107, 563, 442, 565, 564,
158714 /* 1370 */ 563, 303, 1005, 66, 66, 563, 226, 563, 959, 563,
158715 /* 1380 */ 543, 404, 1196, 1343, 871, 278, 960, 456, 128, 128,
158716 /* 1390 */ 563, 1065, 67, 67, 563, 206, 867, 52, 52, 68,
158717 /* 1400 */ 68, 69, 69, 417, 1005, 1005, 1007, 1008, 27, 1563,
158718 /* 1410 */ 1165, 444, 53, 53, 277, 1519, 156, 156, 307, 389,
158719 /* 1420 */ 389, 388, 262, 386, 1165, 444, 839, 321, 277, 108,
158720 /* 1430 */ 555, 523, 4, 389, 389, 388, 262, 386, 563, 223,
158721 /* 1440 */ 839, 311, 326, 1492, 1117, 98, 558, 393, 1065, 310,
158722 /* 1450 */ 563, 476, 563, 223, 563, 311, 879, 878, 1009, 277,
158723 /* 1460 */ 157, 157, 463, 310, 389, 389, 388, 262, 386, 442,
158724 /* 1470 */ 518, 839, 76, 76, 54, 54, 72, 72, 355, 225,
158725 /* 1480 */ 563, 552, 275, 563, 223, 325, 311, 161, 354, 465,
158726 /* 1490 */ 135, 563, 228, 225, 310, 532, 563, 206, 886, 887,
158727 /* 1500 */ 533, 161, 129, 129, 135, 73, 73, 224, 962, 963,
158728 /* 1510 */ 1015, 563, 287, 130, 130, 1009, 106, 106, 131, 131,
158729 /* 1520 */ 563, 224, 563, 107, 225, 442, 565, 564, 997, 1276,
158730 /* 1530 */ 1005, 250, 161, 127, 127, 135, 108, 555, 1077, 4,
158731 /* 1540 */ 1077, 407, 155, 155, 154, 154, 304, 554, 1126, 563,
158732 /* 1550 */ 1331, 563, 224, 558, 470, 407, 563, 250, 563, 1491,
158733 /* 1560 */ 304, 554, 1005, 1005, 1007, 1008, 27, 563, 480, 332,
158734 /* 1570 */ 448, 136, 136, 134, 134, 1340, 442, 336, 132, 132,
158735 /* 1580 */ 133, 133, 563, 1076, 448, 1076, 407, 563, 552, 75,
158736 /* 1590 */ 75, 304, 554, 339, 341, 343, 108, 555, 563, 4,
158737 /* 1600 */ 1577, 299, 532, 563, 77, 77, 1291, 531, 472, 74,
158738 /* 1610 */ 74, 250, 1275, 558, 350, 448, 331, 1015, 360, 98,
158739 /* 1620 */ 42, 42, 1352, 106, 106, 48, 48, 1399, 494, 1327,
158740 /* 1630 */ 107, 247, 442, 565, 564, 345, 442, 1005, 98, 1061,
158741 /* 1640 */ 953, 917, 247, 250, 110, 1552, 550, 850, 552, 918,
158742 /* 1650 */ 144, 1338, 110, 549, 1405, 1256, 1248, 1237, 1236, 1238,
158743 /* 1660 */ 1571, 1324, 208, 390, 489, 265, 363, 200, 365, 1005,
158744 /* 1670 */ 1005, 1007, 1008, 27, 11, 280, 221, 1015, 323, 474,
158745 /* 1680 */ 1274, 367, 212, 106, 106, 924, 1386, 324, 288, 1381,
158746 /* 1690 */ 107, 453, 442, 565, 564, 283, 329, 1005, 1391, 499,
158747 /* 1700 */ 353, 1374, 1464, 108, 555, 1463, 4, 1574, 1390, 397,
158748 /* 1710 */ 1215, 171, 254, 369, 383, 207, 195, 196, 1511, 553,
158749 /* 1720 */ 558, 1509, 415, 1212, 100, 555, 83, 4, 204, 1005,
158750 /* 1730 */ 1005, 1007, 1008, 27, 180, 166, 173, 219, 79, 82,
158751 /* 1740 */ 458, 558, 175, 442, 35, 1387, 176, 459, 177, 178,
158752 /* 1750 */ 492, 231, 96, 1469, 395, 552, 1393, 1392, 36, 466,
158753 /* 1760 */ 1395, 184, 398, 481, 442, 1458, 235, 89, 1480, 487,
158754 /* 1770 */ 266, 334, 237, 188, 490, 400, 552, 338, 238, 508,
158755 /* 1780 */ 1239, 239, 1294, 1293, 1015, 1292, 1285, 429, 91, 871,
158756 /* 1790 */ 106, 106, 1588, 213, 401, 1587, 431, 107, 1264, 442,
158757 /* 1800 */ 565, 564, 1263, 352, 1005, 1015, 1262, 1586, 1557, 517,
158758 /* 1810 */ 432, 106, 106, 1284, 297, 298, 358, 524, 107, 1335,
158759 /* 1820 */ 442, 565, 564, 95, 1336, 1005, 252, 253, 435, 125,
158760 /* 1830 */ 543, 1543, 10, 1444, 377, 1542, 1005, 1005, 1007, 1008,
158761 /* 1840 */ 27, 97, 527, 375, 362, 102, 260, 364, 381, 1317,
158762 /* 1850 */ 382, 1334, 366, 1245, 1333, 1316, 368, 1005, 1005, 1007,
158763 /* 1860 */ 1008, 27, 1359, 1358, 34, 199, 1171, 566, 261, 263,
158764 /* 1870 */ 264, 567, 1234, 158, 1229, 141, 295, 159, 1496, 302,
158765 /* 1880 */ 1497, 1495, 1494, 160, 826, 209, 443, 201, 306, 210,
158766 /* 1890 */ 78, 220, 1075, 138, 1073, 314, 162, 172, 1196, 227,
158767 /* 1900 */ 174, 903, 322, 230, 1089, 179, 163, 164, 418, 408,
158768 /* 1910 */ 409, 170, 181, 85, 86, 420, 87, 165, 1092, 88,
158769 /* 1920 */ 233, 232, 1088, 151, 18, 234, 1081, 250, 333, 1209,
158770 /* 1930 */ 185, 486, 236, 186, 37, 841, 491, 354, 240, 346,
158771 /* 1940 */ 495, 187, 90, 869, 19, 20, 500, 503, 349, 92,
158772 /* 1950 */ 167, 152, 296, 882, 93, 510, 94, 1159, 153, 1041,
158773 /* 1960 */ 1128, 39, 214, 269, 1127, 271, 249, 952, 190, 947,
158774 /* 1970 */ 110, 1149, 21, 7, 1153, 22, 1145, 23, 1147, 24,
158775 /* 1980 */ 1133, 25, 1152, 33, 539, 193, 26, 1056, 98, 1042,
158776 /* 1990 */ 1040, 1044, 1098, 1045, 1097, 256, 255, 28, 40, 257,
158777 /* 2000 */ 1010, 851, 109, 29, 913, 559, 384, 387, 258, 1167,
158778 /* 2010 */ 1166, 1225, 1225, 1225, 1579, 1225, 1225, 1225, 1225, 1225,
158779 /* 2020 */ 1225, 1225, 1578,
158780 };
158781 static const YYCODETYPE yy_lookahead[] = {
158782 /* 0 */ 192, 221, 192, 223, 192, 214, 272, 273, 274, 217,
158783 /* 10 */ 192, 231, 217, 192, 192, 192, 272, 273, 274, 19,
158784 /* 20 */ 233, 234, 214, 215, 214, 215, 203, 293, 203, 233,
158785 /* 30 */ 234, 31, 214, 215, 214, 214, 215, 214, 215, 39,
158786 /* 40 */ 208, 209, 210, 43, 44, 45, 46, 47, 48, 49,
158787 /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 236, 19,
158788 /* 60 */ 237, 238, 237, 238, 272, 273, 274, 272, 273, 274,
158789 /* 70 */ 192, 211, 251, 250, 251, 250, 26, 192, 200, 254,
158790 /* 80 */ 255, 260, 204, 43, 44, 45, 46, 47, 48, 49,
158791 /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 192, 214,
158792 /* 100 */ 215, 214, 102, 103, 104, 105, 106, 107, 108, 109,
158793 /* 110 */ 110, 111, 112, 59, 229, 192, 294, 16, 306, 307,
158794 /* 120 */ 312, 313, 312, 311, 314, 59, 86, 204, 88, 19,
158795 /* 130 */ 312, 313, 272, 273, 274, 271, 26, 22, 54, 55,
158796 /* 140 */ 56, 57, 102, 103, 104, 105, 106, 107, 108, 109,
158797 /* 150 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49,
158798 /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 53, 115,
158799 /* 170 */ 116, 117, 118, 309, 310, 121, 122, 123, 77, 69,
158800 /* 180 */ 79, 115, 116, 117, 59, 131, 102, 103, 104, 105,
158801 /* 190 */ 106, 107, 108, 109, 110, 111, 112, 72, 148, 19,
158802 /* 200 */ 54, 55, 56, 57, 58, 108, 109, 110, 111, 112,
158803 /* 210 */ 304, 305, 102, 103, 104, 105, 106, 107, 108, 109,
158804 /* 220 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49,
158805 /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 112,
158806 /* 240 */ 115, 116, 117, 24, 208, 209, 210, 67, 102, 103,
158807 /* 250 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 192,
158808 /* 260 */ 59, 160, 43, 44, 45, 46, 47, 48, 49, 50,
158809 /* 270 */ 51, 52, 53, 54, 55, 56, 57, 19, 46, 47,
158810 /* 280 */ 48, 49, 102, 103, 104, 105, 106, 107, 108, 109,
158811 /* 290 */ 110, 111, 112, 213, 73, 184, 185, 186, 187, 188,
158812 /* 300 */ 189, 221, 81, 236, 46, 194, 192, 196, 19, 59,
158813 /* 310 */ 133, 59, 135, 136, 203, 192, 115, 116, 117, 127,
158814 /* 320 */ 128, 102, 103, 104, 105, 106, 107, 108, 109, 110,
158815 /* 330 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50,
158816 /* 340 */ 51, 52, 53, 54, 55, 56, 57, 126, 237, 238,
158817 /* 350 */ 100, 150, 120, 230, 186, 187, 188, 189, 137, 138,
158818 /* 360 */ 108, 250, 194, 26, 196, 115, 116, 115, 116, 117,
158819 /* 370 */ 120, 203, 114, 164, 165, 264, 102, 103, 104, 105,
158820 /* 380 */ 106, 107, 108, 109, 110, 111, 112, 192, 130, 111,
158821 /* 390 */ 112, 102, 103, 104, 105, 106, 107, 108, 109, 110,
158822 /* 400 */ 111, 112, 152, 153, 154, 237, 238, 296, 192, 214,
158823 /* 410 */ 215, 228, 192, 307, 192, 19, 59, 311, 250, 23,
158824 /* 420 */ 22, 106, 107, 108, 109, 110, 111, 112, 192, 72,
158825 /* 430 */ 214, 215, 264, 192, 214, 215, 214, 215, 149, 43,
158826 /* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
158827 /* 450 */ 54, 55, 56, 57, 117, 214, 215, 59, 19, 187,
158828 /* 460 */ 192, 189, 23, 81, 296, 192, 194, 251, 196, 59,
158829 /* 470 */ 229, 251, 115, 116, 117, 203, 260, 106, 107, 142,
158830 /* 480 */ 260, 267, 43, 44, 45, 46, 47, 48, 49, 50,
158831 /* 490 */ 51, 52, 53, 54, 55, 56, 57, 261, 102, 103,
158832 /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 237,
158833 /* 510 */ 238, 76, 192, 115, 116, 117, 144, 192, 76, 137,
158834 /* 520 */ 138, 192, 250, 152, 89, 154, 116, 92, 19, 87,
158835 /* 530 */ 262, 89, 23, 22, 92, 163, 264, 192, 22, 214,
158836 /* 540 */ 215, 102, 103, 104, 105, 106, 107, 108, 109, 110,
158837 /* 550 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50,
158838 /* 560 */ 51, 52, 53, 54, 55, 56, 57, 19, 296, 118,
158839 /* 570 */ 59, 23, 121, 122, 123, 59, 251, 26, 46, 306,
158840 /* 580 */ 307, 261, 131, 192, 311, 192, 144, 192, 22, 203,
158841 /* 590 */ 100, 43, 44, 45, 46, 47, 48, 49, 50, 51,
158842 /* 600 */ 52, 53, 54, 55, 56, 57, 116, 214, 215, 271,
158843 /* 610 */ 120, 102, 103, 104, 105, 106, 107, 108, 109, 110,
158844 /* 620 */ 111, 112, 229, 237, 238, 59, 115, 116, 117, 299,
158845 /* 630 */ 300, 115, 116, 117, 59, 16, 250, 19, 192, 192,
158846 /* 640 */ 19, 23, 152, 153, 154, 24, 114, 309, 310, 192,
158847 /* 650 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
158848 /* 660 */ 112, 43, 44, 45, 46, 47, 48, 49, 50, 51,
158849 /* 670 */ 52, 53, 54, 55, 56, 57, 19, 7, 8, 9,
158850 /* 680 */ 23, 115, 116, 117, 203, 290, 239, 238, 137, 138,
158851 /* 690 */ 115, 116, 117, 236, 192, 22, 77, 81, 79, 250,
158852 /* 700 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
158853 /* 710 */ 53, 54, 55, 56, 57, 192, 95, 142, 237, 238,
158854 /* 720 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
158855 /* 730 */ 112, 250, 59, 112, 192, 119, 26, 214, 215, 118,
158856 /* 740 */ 119, 120, 121, 122, 123, 124, 19, 192, 267, 302,
158857 /* 750 */ 23, 130, 229, 137, 138, 23, 214, 215, 26, 102,
158858 /* 760 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
158859 /* 770 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
158860 /* 780 */ 53, 54, 55, 56, 57, 19, 76, 11, 115, 116,
158861 /* 790 */ 117, 192, 29, 251, 239, 73, 33, 192, 192, 89,
158862 /* 800 */ 192, 192, 92, 192, 192, 126, 127, 128, 224, 43,
158863 /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
158864 /* 820 */ 54, 55, 56, 57, 192, 35, 214, 215, 65, 102,
158865 /* 830 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
158866 /* 840 */ 59, 229, 192, 192, 239, 239, 214, 215, 126, 127,
158867 /* 850 */ 128, 126, 127, 128, 307, 19, 66, 302, 311, 192,
158868 /* 860 */ 261, 229, 224, 22, 74, 214, 215, 192, 102, 103,
158869 /* 870 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 43,
158870 /* 880 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
158871 /* 890 */ 54, 55, 56, 57, 192, 192, 115, 116, 117, 19,
158872 /* 900 */ 59, 290, 251, 127, 128, 192, 23, 302, 302, 26,
158873 /* 910 */ 302, 236, 192, 22, 21, 24, 214, 215, 192, 129,
158874 /* 920 */ 22, 192, 24, 142, 158, 45, 46, 47, 48, 49,
158875 /* 930 */ 50, 51, 52, 53, 54, 55, 56, 57, 102, 103,
158876 /* 940 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 192,
158877 /* 950 */ 59, 12, 192, 251, 192, 305, 192, 116, 22, 23,
158878 /* 960 */ 242, 203, 26, 203, 24, 236, 27, 237, 238, 266,
158879 /* 970 */ 252, 214, 215, 80, 214, 215, 214, 215, 214, 215,
158880 /* 980 */ 250, 42, 102, 103, 104, 105, 106, 107, 108, 109,
158881 /* 990 */ 110, 111, 112, 229, 158, 237, 238, 237, 238, 59,
158882 /* 1000 */ 117, 281, 63, 192, 192, 192, 192, 116, 250, 192,
158883 /* 1010 */ 250, 251, 73, 251, 19, 122, 290, 237, 238, 24,
158884 /* 1020 */ 260, 209, 210, 209, 210, 142, 242, 214, 215, 197,
158885 /* 1030 */ 250, 22, 23, 276, 19, 26, 252, 101, 43, 44,
158886 /* 1040 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
158887 /* 1050 */ 55, 56, 57, 160, 19, 211, 116, 192, 43, 44,
158888 /* 1060 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
158889 /* 1070 */ 55, 56, 57, 192, 192, 22, 192, 266, 43, 44,
158890 /* 1080 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
158891 /* 1090 */ 55, 56, 57, 192, 282, 192, 282, 102, 103, 104,
158892 /* 1100 */ 105, 106, 107, 108, 109, 110, 111, 112, 59, 192,
158893 /* 1110 */ 101, 279, 192, 192, 230, 283, 192, 102, 103, 104,
158894 /* 1120 */ 105, 106, 107, 108, 109, 110, 111, 112, 204, 211,
158895 /* 1130 */ 66, 214, 215, 289, 214, 215, 108, 102, 103, 104,
158896 /* 1140 */ 105, 106, 107, 108, 109, 110, 111, 112, 266, 85,
158897 /* 1150 */ 226, 192, 228, 22, 23, 106, 107, 19, 94, 106,
158898 /* 1160 */ 107, 192, 134, 114, 115, 116, 117, 139, 119, 266,
158899 /* 1170 */ 203, 206, 207, 214, 215, 192, 127, 192, 206, 207,
158900 /* 1180 */ 59, 192, 44, 45, 46, 47, 48, 49, 50, 51,
158901 /* 1190 */ 52, 53, 54, 55, 56, 57, 192, 76, 192, 214,
158902 /* 1200 */ 215, 152, 284, 154, 237, 238, 192, 289, 87, 145,
158903 /* 1210 */ 89, 19, 20, 92, 22, 22, 23, 250, 307, 236,
158904 /* 1220 */ 214, 215, 311, 203, 12, 247, 192, 249, 36, 307,
158905 /* 1230 */ 192, 262, 101, 311, 137, 138, 115, 116, 117, 27,
158906 /* 1240 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
158907 /* 1250 */ 112, 59, 214, 215, 42, 203, 307, 237, 238, 192,
158908 /* 1260 */ 311, 192, 26, 71, 192, 144, 262, 297, 298, 203,
158909 /* 1270 */ 250, 19, 20, 81, 22, 63, 262, 254, 255, 15,
158910 /* 1280 */ 26, 214, 215, 214, 215, 26, 214, 215, 36, 237,
158911 /* 1290 */ 238, 192, 100, 114, 101, 192, 262, 192, 106, 107,
158912 /* 1300 */ 48, 134, 250, 237, 238, 113, 139, 115, 116, 117,
158913 /* 1310 */ 192, 59, 120, 214, 215, 242, 250, 214, 215, 214,
158914 /* 1320 */ 215, 148, 149, 71, 60, 252, 242, 192, 149, 137,
158915 /* 1330 */ 138, 192, 214, 215, 192, 19, 252, 85, 192, 59,
158916 /* 1340 */ 192, 157, 90, 159, 152, 153, 154, 155, 156, 214,
158917 /* 1350 */ 215, 192, 100, 214, 215, 19, 214, 215, 106, 107,
158918 /* 1360 */ 214, 215, 214, 215, 22, 113, 192, 115, 116, 117,
158919 /* 1370 */ 192, 242, 120, 214, 215, 192, 24, 192, 31, 192,
158920 /* 1380 */ 144, 252, 26, 192, 125, 99, 39, 192, 214, 215,
158921 /* 1390 */ 192, 59, 214, 215, 192, 141, 116, 214, 215, 214,
158922 /* 1400 */ 215, 214, 215, 61, 152, 153, 154, 155, 156, 0,
158923 /* 1410 */ 1, 2, 214, 215, 5, 192, 214, 215, 132, 10,
158924 /* 1420 */ 11, 12, 13, 14, 1, 2, 17, 192, 5, 19,
158925 /* 1430 */ 20, 115, 22, 10, 11, 12, 13, 14, 192, 30,
158926 /* 1440 */ 17, 32, 23, 192, 23, 26, 36, 26, 116, 40,
158927 /* 1450 */ 192, 115, 192, 30, 192, 32, 119, 120, 59, 5,
158928 /* 1460 */ 214, 215, 128, 40, 10, 11, 12, 13, 14, 59,
158929 /* 1470 */ 19, 17, 214, 215, 214, 215, 214, 215, 120, 70,
158930 /* 1480 */ 192, 71, 22, 192, 30, 151, 32, 78, 130, 128,
158931 /* 1490 */ 81, 192, 140, 70, 40, 85, 192, 141, 7, 8,
158932 /* 1500 */ 90, 78, 214, 215, 81, 214, 215, 98, 83, 84,
158933 /* 1510 */ 100, 192, 151, 214, 215, 116, 106, 107, 214, 215,
158934 /* 1520 */ 192, 98, 192, 113, 70, 115, 116, 117, 23, 224,
158935 /* 1530 */ 120, 26, 78, 214, 215, 81, 19, 20, 152, 22,
158936 /* 1540 */ 154, 132, 214, 215, 214, 215, 137, 138, 97, 192,
158937 /* 1550 */ 256, 192, 98, 36, 23, 132, 192, 26, 192, 192,
158938 /* 1560 */ 137, 138, 152, 153, 154, 155, 156, 192, 192, 192,
158939 /* 1570 */ 161, 214, 215, 214, 215, 192, 59, 192, 214, 215,
158940 /* 1580 */ 214, 215, 192, 152, 161, 154, 132, 192, 71, 214,
158941 /* 1590 */ 215, 137, 138, 192, 192, 192, 19, 20, 192, 22,
158942 /* 1600 */ 140, 253, 85, 192, 214, 215, 192, 90, 23, 214,
158943 /* 1610 */ 215, 26, 192, 36, 192, 161, 23, 100, 192, 26,
158944 /* 1620 */ 214, 215, 192, 106, 107, 214, 215, 192, 23, 192,
158945 /* 1630 */ 113, 26, 115, 116, 117, 23, 59, 120, 26, 23,
158946 /* 1640 */ 23, 23, 26, 26, 26, 316, 234, 23, 71, 23,
158947 /* 1650 */ 26, 192, 26, 192, 192, 192, 192, 192, 192, 192,
158948 /* 1660 */ 192, 253, 212, 190, 286, 285, 253, 240, 253, 152,
158949 /* 1670 */ 153, 154, 155, 156, 241, 243, 295, 100, 291, 291,
158950 /* 1680 */ 223, 253, 227, 106, 107, 108, 269, 244, 244, 265,
158951 /* 1690 */ 113, 257, 115, 116, 117, 257, 243, 120, 269, 218,
158952 /* 1700 */ 217, 265, 217, 19, 20, 217, 22, 195, 269, 269,
158953 /* 1710 */ 60, 295, 140, 257, 243, 241, 247, 247, 199, 278,
158954 /* 1720 */ 36, 199, 199, 38, 19, 20, 150, 22, 149, 152,
158955 /* 1730 */ 153, 154, 155, 156, 22, 43, 232, 295, 292, 292,
158956 /* 1740 */ 18, 36, 235, 59, 268, 270, 235, 199, 235, 235,
158957 /* 1750 */ 18, 198, 148, 281, 244, 71, 270, 270, 268, 244,
158958 /* 1760 */ 232, 232, 244, 199, 59, 244, 198, 157, 288, 62,
158959 /* 1770 */ 199, 287, 198, 22, 219, 219, 71, 199, 198, 114,
158960 /* 1780 */ 199, 198, 216, 216, 100, 216, 225, 64, 22, 125,
158961 /* 1790 */ 106, 107, 222, 164, 219, 222, 24, 113, 216, 115,
158962 /* 1800 */ 116, 117, 218, 216, 120, 100, 216, 216, 310, 303,
158963 /* 1810 */ 112, 106, 107, 225, 280, 280, 219, 143, 113, 259,
158964 /* 1820 */ 115, 116, 117, 114, 259, 120, 199, 91, 82, 147,
158965 /* 1830 */ 144, 315, 22, 275, 199, 315, 152, 153, 154, 155,
158966 /* 1840 */ 156, 146, 145, 247, 258, 157, 25, 258, 245, 248,
158967 /* 1850 */ 244, 259, 258, 202, 259, 248, 258, 152, 153, 154,
158968 /* 1860 */ 155, 156, 263, 263, 26, 246, 13, 201, 193, 193,
158969 /* 1870 */ 6, 191, 191, 205, 191, 220, 220, 205, 211, 277,
158970 /* 1880 */ 211, 211, 211, 205, 4, 212, 3, 22, 162, 212,
158971 /* 1890 */ 211, 15, 23, 16, 23, 138, 129, 150, 26, 24,
158972 /* 1900 */ 141, 20, 16, 143, 1, 141, 129, 129, 61, 301,
158973 /* 1910 */ 301, 298, 150, 53, 53, 37, 53, 129, 115, 53,
158974 /* 1920 */ 140, 34, 1, 5, 22, 114, 68, 26, 160, 75,
158975 /* 1930 */ 68, 41, 140, 114, 24, 20, 19, 130, 124, 23,
158976 /* 1940 */ 67, 22, 22, 59, 22, 22, 67, 96, 24, 22,
158977 /* 1950 */ 37, 23, 67, 28, 148, 22, 26, 23, 23, 23,
158978 /* 1960 */ 23, 22, 140, 23, 97, 23, 34, 115, 22, 142,
158979 /* 1970 */ 26, 75, 34, 44, 75, 34, 88, 34, 86, 34,
158980 /* 1980 */ 23, 34, 93, 22, 24, 26, 34, 23, 26, 23,
158981 /* 1990 */ 23, 23, 23, 11, 23, 22, 26, 22, 22, 140,
158982 /* 2000 */ 23, 23, 22, 22, 134, 26, 23, 15, 140, 1,
158983 /* 2010 */ 1, 317, 317, 317, 140, 317, 317, 317, 317, 317,
158984 /* 2020 */ 317, 317, 140, 317, 317, 317, 317, 317, 317, 317,
158985 /* 2030 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158986 /* 2040 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158987 /* 2050 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158988 /* 2060 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158989 /* 2070 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158990 /* 2080 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158991 /* 2090 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158992 /* 2100 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158993 /* 2110 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158994 /* 2120 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158995 /* 2130 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158996 /* 2140 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158997 /* 2150 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158998 /* 2160 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
158999 /* 2170 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
159000 /* 2180 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
159001 /* 2190 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
159002 /* 2200 */ 317, 317, 317, 317, 317, 317, 317,
159003 };
159004 #define YY_SHIFT_COUNT (569)
159005 #define YY_SHIFT_MIN (0)
159006 #define YY_SHIFT_MAX (2009)
159007 static const unsigned short int yy_shift_ofst[] = {
159008 /* 0 */ 1423, 1409, 1454, 1192, 1192, 382, 1252, 1410, 1517, 1684,
159009 /* 10 */ 1684, 1684, 221, 0, 0, 180, 1015, 1684, 1684, 1684,
159010 /* 20 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
159011 /* 30 */ 1049, 1049, 1121, 1121, 54, 616, 382, 382, 382, 382,
159012 /* 40 */ 382, 40, 110, 219, 289, 396, 439, 509, 548, 618,
159013 /* 50 */ 657, 727, 766, 836, 995, 1015, 1015, 1015, 1015, 1015,
159014 /* 60 */ 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015,
159015 /* 70 */ 1015, 1015, 1015, 1035, 1015, 1138, 880, 880, 1577, 1684,
159016 /* 80 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
159017 /* 90 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
159018 /* 100 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
159019 /* 110 */ 1684, 1684, 1684, 1705, 1684, 1684, 1684, 1684, 1684, 1684,
159020 /* 120 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 146, 84, 84,
159021 /* 130 */ 84, 84, 84, 274, 315, 125, 97, 357, 66, 66,
159022 /* 140 */ 893, 258, 66, 66, 371, 371, 66, 551, 551, 551,
159023 /* 150 */ 551, 192, 209, 209, 278, 127, 2023, 2023, 621, 621,
159024 /* 160 */ 621, 201, 398, 398, 398, 398, 939, 939, 442, 936,
159025 /* 170 */ 1009, 66, 66, 66, 66, 66, 66, 66, 66, 66,
159026 /* 180 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
159027 /* 190 */ 66, 710, 710, 66, 776, 435, 435, 410, 410, 372,
159028 /* 200 */ 1097, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 250, 490,
159029 /* 210 */ 490, 511, 451, 516, 252, 566, 575, 781, 673, 66,
159030 /* 220 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 722,
159031 /* 230 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
159032 /* 240 */ 66, 66, 790, 790, 790, 66, 66, 66, 883, 66,
159033 /* 250 */ 66, 66, 891, 1064, 66, 66, 1212, 66, 66, 66,
159034 /* 260 */ 66, 66, 66, 66, 66, 725, 763, 177, 940, 940,
159035 /* 270 */ 940, 940, 337, 177, 177, 1028, 1053, 670, 1264, 1179,
159036 /* 280 */ 1173, 1254, 1316, 1173, 1316, 1336, 50, 1179, 1179, 50,
159037 /* 290 */ 1179, 1254, 1336, 1259, 732, 532, 1347, 1347, 1347, 1316,
159038 /* 300 */ 1236, 1236, 1184, 1356, 1167, 898, 1650, 1650, 1572, 1572,
159039 /* 310 */ 1685, 1685, 1572, 1576, 1579, 1712, 1692, 1722, 1722, 1722,
159040 /* 320 */ 1722, 1572, 1732, 1604, 1579, 1579, 1604, 1712, 1692, 1604,
159041 /* 330 */ 1692, 1604, 1572, 1732, 1610, 1707, 1572, 1732, 1751, 1572,
159042 /* 340 */ 1732, 1572, 1732, 1751, 1665, 1665, 1665, 1723, 1766, 1766,
159043 /* 350 */ 1751, 1665, 1664, 1665, 1723, 1665, 1665, 1629, 1772, 1698,
159044 /* 360 */ 1698, 1751, 1674, 1709, 1674, 1709, 1674, 1709, 1674, 1709,
159045 /* 370 */ 1572, 1736, 1736, 1746, 1746, 1682, 1686, 1810, 1572, 1688,
159046 /* 380 */ 1682, 1695, 1697, 1604, 1821, 1838, 1853, 1853, 1864, 1864,
159047 /* 390 */ 1864, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023,
159048 /* 400 */ 2023, 2023, 2023, 2023, 2023, 2023, 232, 101, 1131, 1193,
159049 /* 410 */ 619, 679, 841, 1421, 1286, 115, 1352, 1334, 1361, 1419,
159050 /* 420 */ 1342, 1505, 1531, 1585, 1593, 1605, 1612, 1280, 1337, 1491,
159051 /* 430 */ 1358, 1451, 1332, 1616, 1617, 1425, 1618, 1386, 1431, 1624,
159052 /* 440 */ 1626, 1399, 1460, 1880, 1883, 1865, 1726, 1876, 1877, 1869,
159053 /* 450 */ 1871, 1757, 1747, 1767, 1872, 1872, 1875, 1759, 1881, 1760,
159054 /* 460 */ 1886, 1903, 1764, 1777, 1872, 1778, 1847, 1878, 1872, 1762,
159055 /* 470 */ 1860, 1861, 1863, 1866, 1788, 1803, 1887, 1780, 1921, 1918,
159056 /* 480 */ 1902, 1811, 1768, 1858, 1901, 1862, 1854, 1890, 1792, 1819,
159057 /* 490 */ 1910, 1915, 1917, 1807, 1814, 1919, 1873, 1920, 1922, 1916,
159058 /* 500 */ 1923, 1879, 1884, 1924, 1851, 1925, 1927, 1885, 1913, 1928,
159059 /* 510 */ 1806, 1933, 1934, 1935, 1936, 1930, 1937, 1939, 1867, 1822,
159060 /* 520 */ 1940, 1942, 1852, 1932, 1946, 1827, 1944, 1938, 1941, 1943,
159061 /* 530 */ 1945, 1888, 1896, 1892, 1929, 1899, 1889, 1947, 1957, 1961,
159062 /* 540 */ 1960, 1959, 1962, 1952, 1964, 1944, 1966, 1967, 1968, 1969,
159063 /* 550 */ 1970, 1971, 1973, 1982, 1975, 1976, 1977, 1978, 1980, 1981,
159064 /* 560 */ 1979, 1870, 1859, 1868, 1874, 1882, 1983, 1992, 2008, 2009,
159065 };
159066 #define YY_REDUCE_COUNT (405)
159067 #define YY_REDUCE_MIN (-266)
159068 #define YY_REDUCE_MAX (1683)
159069 static const short yy_reduce_ofst[] = {
159070 /* 0 */ 111, 168, 272, 760, -177, -175, -192, -190, -182, -179,
159071 /* 10 */ 216, 220, 481, -208, -205, -266, -140, -115, 241, 393,
159072 /* 20 */ 523, 325, 612, 632, 542, 651, 764, 757, 702, 762,
159073 /* 30 */ 812, 814, -188, 273, 924, 386, 758, 967, 1020, 1052,
159074 /* 40 */ 1066, -256, -256, -256, -256, -256, -256, -256, -256, -256,
159075 /* 50 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256,
159076 /* 60 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256,
159077 /* 70 */ -256, -256, -256, -256, -256, -256, -256, -256, 195, 222,
159078 /* 80 */ 813, 917, 920, 959, 985, 1006, 1038, 1067, 1069, 1072,
159079 /* 90 */ 1099, 1103, 1105, 1118, 1135, 1139, 1142, 1146, 1148, 1159,
159080 /* 100 */ 1174, 1178, 1183, 1185, 1187, 1198, 1202, 1246, 1258, 1260,
159081 /* 110 */ 1262, 1288, 1291, 1299, 1304, 1319, 1328, 1330, 1357, 1359,
159082 /* 120 */ 1364, 1366, 1375, 1390, 1395, 1406, 1411, -256, -256, -256,
159083 /* 130 */ -256, -256, -256, -256, -256, 447, -256, 555, -178, 605,
159084 /* 140 */ 832, -220, 606, -94, -168, 36, -122, 730, 780, 730,
159085 /* 150 */ 780, 918, -136, 338, -256, -256, -256, -256, 80, 80,
159086 /* 160 */ 80, 720, 703, 811, 882, 903, -213, -204, 106, 330,
159087 /* 170 */ 330, -77, 236, 320, 599, 67, 457, 675, 729, 395,
159088 /* 180 */ 268, 611, 969, 1004, 726, 1014, 983, 123, 884, 608,
159089 /* 190 */ 1034, 547, 911, 650, 844, 922, 949, 965, 972, 978,
159090 /* 200 */ 449, 970, 718, 784, 1073, 1084, 1023, 1129, -209, -180,
159091 /* 210 */ -113, 114, 183, 329, 345, 391, 446, 502, 609, 667,
159092 /* 220 */ 713, 817, 865, 881, 901, 921, 989, 1191, 1195, 214,
159093 /* 230 */ 1223, 1235, 1251, 1367, 1376, 1377, 1383, 1385, 1401, 1402,
159094 /* 240 */ 1403, 1414, 584, 638, 1305, 1420, 1422, 1426, 1294, 1430,
159095 /* 250 */ 1435, 1437, 1348, 1329, 1459, 1461, 1412, 1462, 345, 1463,
159096 /* 260 */ 1464, 1465, 1466, 1467, 1468, 1378, 1380, 1427, 1408, 1413,
159097 /* 270 */ 1415, 1428, 1294, 1427, 1427, 1433, 1450, 1473, 1381, 1417,
159098 /* 280 */ 1424, 1432, 1434, 1436, 1438, 1387, 1443, 1429, 1439, 1444,
159099 /* 290 */ 1440, 1453, 1388, 1481, 1455, 1457, 1483, 1485, 1488, 1456,
159100 /* 300 */ 1469, 1470, 1441, 1471, 1474, 1512, 1416, 1442, 1519, 1522,
159101 /* 310 */ 1446, 1447, 1523, 1472, 1475, 1476, 1504, 1507, 1511, 1513,
159102 /* 320 */ 1514, 1548, 1553, 1510, 1486, 1487, 1515, 1490, 1528, 1518,
159103 /* 330 */ 1529, 1521, 1564, 1568, 1480, 1484, 1571, 1574, 1555, 1578,
159104 /* 340 */ 1580, 1581, 1583, 1556, 1566, 1567, 1569, 1561, 1570, 1573,
159105 /* 350 */ 1575, 1582, 1584, 1587, 1588, 1590, 1591, 1498, 1506, 1534,
159106 /* 360 */ 1535, 1597, 1560, 1586, 1565, 1589, 1592, 1594, 1595, 1598,
159107 /* 370 */ 1627, 1516, 1520, 1599, 1600, 1601, 1596, 1558, 1635, 1602,
159108 /* 380 */ 1607, 1619, 1603, 1606, 1651, 1666, 1675, 1676, 1680, 1681,
159109 /* 390 */ 1683, 1608, 1609, 1613, 1668, 1667, 1669, 1670, 1671, 1672,
159110 /* 400 */ 1655, 1656, 1673, 1677, 1679, 1678,
159111 };
159112 static const YYACTIONTYPE yy_default[] = {
159113 /* 0 */ 1623, 1623, 1623, 1453, 1223, 1332, 1223, 1223, 1223, 1453,
159114 /* 10 */ 1453, 1453, 1223, 1362, 1362, 1506, 1254, 1223, 1223, 1223,
159115 /* 20 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1452, 1223, 1223,
@@ -158788,10 +159365,11 @@
159365 0, /* VECTOR => nothing */
159366 0, /* SELECT_COLUMN => nothing */
159367 0, /* IF_NULL_ROW => nothing */
159368 0, /* ASTERISK => nothing */
159369 0, /* SPAN => nothing */
159370 0, /* ERROR => nothing */
159371 0, /* SPACE => nothing */
159372 0, /* ILLEGAL => nothing */
159373 };
159374 #endif /* YYFALLBACK */
159375
@@ -159059,145 +159637,146 @@
159637 /* 176 */ "VECTOR",
159638 /* 177 */ "SELECT_COLUMN",
159639 /* 178 */ "IF_NULL_ROW",
159640 /* 179 */ "ASTERISK",
159641 /* 180 */ "SPAN",
159642 /* 181 */ "ERROR",
159643 /* 182 */ "SPACE",
159644 /* 183 */ "ILLEGAL",
159645 /* 184 */ "input",
159646 /* 185 */ "cmdlist",
159647 /* 186 */ "ecmd",
159648 /* 187 */ "cmdx",
159649 /* 188 */ "explain",
159650 /* 189 */ "cmd",
159651 /* 190 */ "transtype",
159652 /* 191 */ "trans_opt",
159653 /* 192 */ "nm",
159654 /* 193 */ "savepoint_opt",
159655 /* 194 */ "create_table",
159656 /* 195 */ "create_table_args",
159657 /* 196 */ "createkw",
159658 /* 197 */ "temp",
159659 /* 198 */ "ifnotexists",
159660 /* 199 */ "dbnm",
159661 /* 200 */ "columnlist",
159662 /* 201 */ "conslist_opt",
159663 /* 202 */ "table_options",
159664 /* 203 */ "select",
159665 /* 204 */ "columnname",
159666 /* 205 */ "carglist",
159667 /* 206 */ "typetoken",
159668 /* 207 */ "typename",
159669 /* 208 */ "signed",
159670 /* 209 */ "plus_num",
159671 /* 210 */ "minus_num",
159672 /* 211 */ "scanpt",
159673 /* 212 */ "scantok",
159674 /* 213 */ "ccons",
159675 /* 214 */ "term",
159676 /* 215 */ "expr",
159677 /* 216 */ "onconf",
159678 /* 217 */ "sortorder",
159679 /* 218 */ "autoinc",
159680 /* 219 */ "eidlist_opt",
159681 /* 220 */ "refargs",
159682 /* 221 */ "defer_subclause",
159683 /* 222 */ "generated",
159684 /* 223 */ "refarg",
159685 /* 224 */ "refact",
159686 /* 225 */ "init_deferred_pred_opt",
159687 /* 226 */ "conslist",
159688 /* 227 */ "tconscomma",
159689 /* 228 */ "tcons",
159690 /* 229 */ "sortlist",
159691 /* 230 */ "eidlist",
159692 /* 231 */ "defer_subclause_opt",
159693 /* 232 */ "orconf",
159694 /* 233 */ "resolvetype",
159695 /* 234 */ "raisetype",
159696 /* 235 */ "ifexists",
159697 /* 236 */ "fullname",
159698 /* 237 */ "selectnowith",
159699 /* 238 */ "oneselect",
159700 /* 239 */ "wqlist",
159701 /* 240 */ "multiselect_op",
159702 /* 241 */ "distinct",
159703 /* 242 */ "selcollist",
159704 /* 243 */ "from",
159705 /* 244 */ "where_opt",
159706 /* 245 */ "groupby_opt",
159707 /* 246 */ "having_opt",
159708 /* 247 */ "orderby_opt",
159709 /* 248 */ "limit_opt",
159710 /* 249 */ "window_clause",
159711 /* 250 */ "values",
159712 /* 251 */ "nexprlist",
159713 /* 252 */ "sclp",
159714 /* 253 */ "as",
159715 /* 254 */ "seltablist",
159716 /* 255 */ "stl_prefix",
159717 /* 256 */ "joinop",
159718 /* 257 */ "indexed_opt",
159719 /* 258 */ "on_opt",
159720 /* 259 */ "using_opt",
159721 /* 260 */ "exprlist",
159722 /* 261 */ "xfullname",
159723 /* 262 */ "idlist",
159724 /* 263 */ "nulls",
159725 /* 264 */ "with",
159726 /* 265 */ "where_opt_ret",
159727 /* 266 */ "setlist",
159728 /* 267 */ "insert_cmd",
159729 /* 268 */ "idlist_opt",
159730 /* 269 */ "upsert",
159731 /* 270 */ "returning",
159732 /* 271 */ "filter_over",
159733 /* 272 */ "likeop",
159734 /* 273 */ "between_op",
159735 /* 274 */ "in_op",
159736 /* 275 */ "paren_exprlist",
159737 /* 276 */ "case_operand",
159738 /* 277 */ "case_exprlist",
159739 /* 278 */ "case_else",
159740 /* 279 */ "uniqueflag",
159741 /* 280 */ "collate",
159742 /* 281 */ "vinto",
159743 /* 282 */ "nmnum",
159744 /* 283 */ "trigger_decl",
159745 /* 284 */ "trigger_cmd_list",
159746 /* 285 */ "trigger_time",
159747 /* 286 */ "trigger_event",
159748 /* 287 */ "foreach_clause",
159749 /* 288 */ "when_clause",
159750 /* 289 */ "trigger_cmd",
159751 /* 290 */ "trnm",
159752 /* 291 */ "tridxby",
159753 /* 292 */ "database_kw_opt",
159754 /* 293 */ "key_opt",
159755 /* 294 */ "add_column_fullname",
159756 /* 295 */ "kwcolumn_opt",
159757 /* 296 */ "create_vtab",
159758 /* 297 */ "vtabarglist",
159759 /* 298 */ "vtabarg",
159760 /* 299 */ "vtabargtoken",
159761 /* 300 */ "lp",
159762 /* 301 */ "anylist",
159763 /* 302 */ "wqitem",
159764 /* 303 */ "wqas",
159765 /* 304 */ "windowdefn_list",
159766 /* 305 */ "windowdefn",
159767 /* 306 */ "window",
159768 /* 307 */ "frame_opt",
159769 /* 308 */ "part_opt",
159770 /* 309 */ "filter_clause",
159771 /* 310 */ "over_clause",
159772 /* 311 */ "range_or_rows",
159773 /* 312 */ "frame_bound",
159774 /* 313 */ "frame_bound_s",
159775 /* 314 */ "frame_bound_e",
159776 /* 315 */ "frame_exclude_opt",
159777 /* 316 */ "frame_exclude",
159778 };
159779 #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
159780
159781 #ifndef NDEBUG
159782 /* For tracing reduce actions, the names of all rules are required.
@@ -159724,103 +160303,103 @@
160303 ** Note: during a reduce, the only symbols destroyed are those
160304 ** which appear on the RHS of the rule, but which are *not* used
160305 ** inside the C code.
160306 */
160307 /********* Begin destructor definitions ***************************************/
160308 case 203: /* select */
160309 case 237: /* selectnowith */
160310 case 238: /* oneselect */
160311 case 250: /* values */
160312 {
160313 sqlite3SelectDelete(pParse->db, (yypminor->yy81));
160314 }
160315 break;
160316 case 214: /* term */
160317 case 215: /* expr */
160318 case 244: /* where_opt */
160319 case 246: /* having_opt */
160320 case 258: /* on_opt */
160321 case 265: /* where_opt_ret */
160322 case 276: /* case_operand */
160323 case 278: /* case_else */
160324 case 281: /* vinto */
160325 case 288: /* when_clause */
160326 case 293: /* key_opt */
160327 case 309: /* filter_clause */
160328 {
160329 sqlite3ExprDelete(pParse->db, (yypminor->yy404));
160330 }
160331 break;
160332 case 219: /* eidlist_opt */
160333 case 229: /* sortlist */
160334 case 230: /* eidlist */
160335 case 242: /* selcollist */
160336 case 245: /* groupby_opt */
160337 case 247: /* orderby_opt */
160338 case 251: /* nexprlist */
160339 case 252: /* sclp */
160340 case 260: /* exprlist */
160341 case 266: /* setlist */
160342 case 275: /* paren_exprlist */
160343 case 277: /* case_exprlist */
160344 case 308: /* part_opt */
160345 {
160346 sqlite3ExprListDelete(pParse->db, (yypminor->yy70));
160347 }
160348 break;
160349 case 236: /* fullname */
160350 case 243: /* from */
160351 case 254: /* seltablist */
160352 case 255: /* stl_prefix */
160353 case 261: /* xfullname */
160354 {
160355 sqlite3SrcListDelete(pParse->db, (yypminor->yy153));
160356 }
160357 break;
160358 case 239: /* wqlist */
160359 {
160360 sqlite3WithDelete(pParse->db, (yypminor->yy103));
160361 }
160362 break;
160363 case 249: /* window_clause */
160364 case 304: /* windowdefn_list */
160365 {
160366 sqlite3WindowListDelete(pParse->db, (yypminor->yy49));
160367 }
160368 break;
160369 case 259: /* using_opt */
160370 case 262: /* idlist */
160371 case 268: /* idlist_opt */
160372 {
160373 sqlite3IdListDelete(pParse->db, (yypminor->yy436));
160374 }
160375 break;
160376 case 271: /* filter_over */
160377 case 305: /* windowdefn */
160378 case 306: /* window */
160379 case 307: /* frame_opt */
160380 case 310: /* over_clause */
160381 {
160382 sqlite3WindowDelete(pParse->db, (yypminor->yy49));
160383 }
160384 break;
160385 case 284: /* trigger_cmd_list */
160386 case 289: /* trigger_cmd */
160387 {
160388 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy157));
160389 }
160390 break;
160391 case 286: /* trigger_event */
160392 {
160393 sqlite3IdListDelete(pParse->db, (yypminor->yy262).b);
160394 }
160395 break;
160396 case 312: /* frame_bound */
160397 case 313: /* frame_bound_s */
160398 case 314: /* frame_bound_e */
160399 {
160400 sqlite3ExprDelete(pParse->db, (yypminor->yy117).pExpr);
160401 }
160402 break;
160403 /********* End destructor definitions *****************************************/
160404 default: break; /* If no destructor action specified: do nothing */
160405 }
@@ -160107,408 +160686,408 @@
160686 }
160687
160688 /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
160689 ** of that rule */
160690 static const YYCODETYPE yyRuleInfoLhs[] = {
160691 188, /* (0) explain ::= EXPLAIN */
160692 188, /* (1) explain ::= EXPLAIN QUERY PLAN */
160693 187, /* (2) cmdx ::= cmd */
160694 189, /* (3) cmd ::= BEGIN transtype trans_opt */
160695 190, /* (4) transtype ::= */
160696 190, /* (5) transtype ::= DEFERRED */
160697 190, /* (6) transtype ::= IMMEDIATE */
160698 190, /* (7) transtype ::= EXCLUSIVE */
160699 189, /* (8) cmd ::= COMMIT|END trans_opt */
160700 189, /* (9) cmd ::= ROLLBACK trans_opt */
160701 189, /* (10) cmd ::= SAVEPOINT nm */
160702 189, /* (11) cmd ::= RELEASE savepoint_opt nm */
160703 189, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
160704 194, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
160705 196, /* (14) createkw ::= CREATE */
160706 198, /* (15) ifnotexists ::= */
160707 198, /* (16) ifnotexists ::= IF NOT EXISTS */
160708 197, /* (17) temp ::= TEMP */
160709 197, /* (18) temp ::= */
160710 195, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
160711 195, /* (20) create_table_args ::= AS select */
160712 202, /* (21) table_options ::= */
160713 202, /* (22) table_options ::= WITHOUT nm */
160714 204, /* (23) columnname ::= nm typetoken */
160715 206, /* (24) typetoken ::= */
160716 206, /* (25) typetoken ::= typename LP signed RP */
160717 206, /* (26) typetoken ::= typename LP signed COMMA signed RP */
160718 207, /* (27) typename ::= typename ID|STRING */
160719 211, /* (28) scanpt ::= */
160720 212, /* (29) scantok ::= */
160721 213, /* (30) ccons ::= CONSTRAINT nm */
160722 213, /* (31) ccons ::= DEFAULT scantok term */
160723 213, /* (32) ccons ::= DEFAULT LP expr RP */
160724 213, /* (33) ccons ::= DEFAULT PLUS scantok term */
160725 213, /* (34) ccons ::= DEFAULT MINUS scantok term */
160726 213, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */
160727 213, /* (36) ccons ::= NOT NULL onconf */
160728 213, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */
160729 213, /* (38) ccons ::= UNIQUE onconf */
160730 213, /* (39) ccons ::= CHECK LP expr RP */
160731 213, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
160732 213, /* (41) ccons ::= defer_subclause */
160733 213, /* (42) ccons ::= COLLATE ID|STRING */
160734 222, /* (43) generated ::= LP expr RP */
160735 222, /* (44) generated ::= LP expr RP ID */
160736 218, /* (45) autoinc ::= */
160737 218, /* (46) autoinc ::= AUTOINCR */
160738 220, /* (47) refargs ::= */
160739 220, /* (48) refargs ::= refargs refarg */
160740 223, /* (49) refarg ::= MATCH nm */
160741 223, /* (50) refarg ::= ON INSERT refact */
160742 223, /* (51) refarg ::= ON DELETE refact */
160743 223, /* (52) refarg ::= ON UPDATE refact */
160744 224, /* (53) refact ::= SET NULL */
160745 224, /* (54) refact ::= SET DEFAULT */
160746 224, /* (55) refact ::= CASCADE */
160747 224, /* (56) refact ::= RESTRICT */
160748 224, /* (57) refact ::= NO ACTION */
160749 221, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
160750 221, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
160751 225, /* (60) init_deferred_pred_opt ::= */
160752 225, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */
160753 225, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
160754 201, /* (63) conslist_opt ::= */
160755 227, /* (64) tconscomma ::= COMMA */
160756 228, /* (65) tcons ::= CONSTRAINT nm */
160757 228, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
160758 228, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */
160759 228, /* (68) tcons ::= CHECK LP expr RP onconf */
160760 228, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
160761 231, /* (70) defer_subclause_opt ::= */
160762 216, /* (71) onconf ::= */
160763 216, /* (72) onconf ::= ON CONFLICT resolvetype */
160764 232, /* (73) orconf ::= */
160765 232, /* (74) orconf ::= OR resolvetype */
160766 233, /* (75) resolvetype ::= IGNORE */
160767 233, /* (76) resolvetype ::= REPLACE */
160768 189, /* (77) cmd ::= DROP TABLE ifexists fullname */
160769 235, /* (78) ifexists ::= IF EXISTS */
160770 235, /* (79) ifexists ::= */
160771 189, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
160772 189, /* (81) cmd ::= DROP VIEW ifexists fullname */
160773 189, /* (82) cmd ::= select */
160774 203, /* (83) select ::= WITH wqlist selectnowith */
160775 203, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */
160776 203, /* (85) select ::= selectnowith */
160777 237, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */
160778 240, /* (87) multiselect_op ::= UNION */
160779 240, /* (88) multiselect_op ::= UNION ALL */
160780 240, /* (89) multiselect_op ::= EXCEPT|INTERSECT */
160781 238, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
160782 238, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
160783 250, /* (92) values ::= VALUES LP nexprlist RP */
160784 250, /* (93) values ::= values COMMA LP nexprlist RP */
160785 241, /* (94) distinct ::= DISTINCT */
160786 241, /* (95) distinct ::= ALL */
160787 241, /* (96) distinct ::= */
160788 252, /* (97) sclp ::= */
160789 242, /* (98) selcollist ::= sclp scanpt expr scanpt as */
160790 242, /* (99) selcollist ::= sclp scanpt STAR */
160791 242, /* (100) selcollist ::= sclp scanpt nm DOT STAR */
160792 253, /* (101) as ::= AS nm */
160793 253, /* (102) as ::= */
160794 243, /* (103) from ::= */
160795 243, /* (104) from ::= FROM seltablist */
160796 255, /* (105) stl_prefix ::= seltablist joinop */
160797 255, /* (106) stl_prefix ::= */
160798 254, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
160799 254, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
160800 254, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
160801 254, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
160802 199, /* (111) dbnm ::= */
160803 199, /* (112) dbnm ::= DOT nm */
160804 236, /* (113) fullname ::= nm */
160805 236, /* (114) fullname ::= nm DOT nm */
160806 261, /* (115) xfullname ::= nm */
160807 261, /* (116) xfullname ::= nm DOT nm */
160808 261, /* (117) xfullname ::= nm DOT nm AS nm */
160809 261, /* (118) xfullname ::= nm AS nm */
160810 256, /* (119) joinop ::= COMMA|JOIN */
160811 256, /* (120) joinop ::= JOIN_KW JOIN */
160812 256, /* (121) joinop ::= JOIN_KW nm JOIN */
160813 256, /* (122) joinop ::= JOIN_KW nm nm JOIN */
160814 258, /* (123) on_opt ::= ON expr */
160815 258, /* (124) on_opt ::= */
160816 257, /* (125) indexed_opt ::= */
160817 257, /* (126) indexed_opt ::= INDEXED BY nm */
160818 257, /* (127) indexed_opt ::= NOT INDEXED */
160819 259, /* (128) using_opt ::= USING LP idlist RP */
160820 259, /* (129) using_opt ::= */
160821 247, /* (130) orderby_opt ::= */
160822 247, /* (131) orderby_opt ::= ORDER BY sortlist */
160823 229, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */
160824 229, /* (133) sortlist ::= expr sortorder nulls */
160825 217, /* (134) sortorder ::= ASC */
160826 217, /* (135) sortorder ::= DESC */
160827 217, /* (136) sortorder ::= */
160828 263, /* (137) nulls ::= NULLS FIRST */
160829 263, /* (138) nulls ::= NULLS LAST */
160830 263, /* (139) nulls ::= */
160831 245, /* (140) groupby_opt ::= */
160832 245, /* (141) groupby_opt ::= GROUP BY nexprlist */
160833 246, /* (142) having_opt ::= */
160834 246, /* (143) having_opt ::= HAVING expr */
160835 248, /* (144) limit_opt ::= */
160836 248, /* (145) limit_opt ::= LIMIT expr */
160837 248, /* (146) limit_opt ::= LIMIT expr OFFSET expr */
160838 248, /* (147) limit_opt ::= LIMIT expr COMMA expr */
160839 189, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
160840 244, /* (149) where_opt ::= */
160841 244, /* (150) where_opt ::= WHERE expr */
160842 265, /* (151) where_opt_ret ::= */
160843 265, /* (152) where_opt_ret ::= WHERE expr */
160844 265, /* (153) where_opt_ret ::= RETURNING selcollist */
160845 265, /* (154) where_opt_ret ::= WHERE expr RETURNING selcollist */
160846 189, /* (155) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
160847 266, /* (156) setlist ::= setlist COMMA nm EQ expr */
160848 266, /* (157) setlist ::= setlist COMMA LP idlist RP EQ expr */
160849 266, /* (158) setlist ::= nm EQ expr */
160850 266, /* (159) setlist ::= LP idlist RP EQ expr */
160851 189, /* (160) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
160852 189, /* (161) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
160853 269, /* (162) upsert ::= */
160854 269, /* (163) upsert ::= RETURNING selcollist */
160855 269, /* (164) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
160856 269, /* (165) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
160857 269, /* (166) upsert ::= ON CONFLICT DO NOTHING returning */
160858 269, /* (167) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
160859 270, /* (168) returning ::= RETURNING selcollist */
160860 267, /* (169) insert_cmd ::= INSERT orconf */
160861 267, /* (170) insert_cmd ::= REPLACE */
160862 268, /* (171) idlist_opt ::= */
160863 268, /* (172) idlist_opt ::= LP idlist RP */
160864 262, /* (173) idlist ::= idlist COMMA nm */
160865 262, /* (174) idlist ::= nm */
160866 215, /* (175) expr ::= LP expr RP */
160867 215, /* (176) expr ::= ID|INDEXED */
160868 215, /* (177) expr ::= JOIN_KW */
160869 215, /* (178) expr ::= nm DOT nm */
160870 215, /* (179) expr ::= nm DOT nm DOT nm */
160871 214, /* (180) term ::= NULL|FLOAT|BLOB */
160872 214, /* (181) term ::= STRING */
160873 214, /* (182) term ::= INTEGER */
160874 215, /* (183) expr ::= VARIABLE */
160875 215, /* (184) expr ::= expr COLLATE ID|STRING */
160876 215, /* (185) expr ::= CAST LP expr AS typetoken RP */
160877 215, /* (186) expr ::= ID|INDEXED LP distinct exprlist RP */
160878 215, /* (187) expr ::= ID|INDEXED LP STAR RP */
160879 215, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
160880 215, /* (189) expr ::= ID|INDEXED LP STAR RP filter_over */
160881 214, /* (190) term ::= CTIME_KW */
160882 215, /* (191) expr ::= LP nexprlist COMMA expr RP */
160883 215, /* (192) expr ::= expr AND expr */
160884 215, /* (193) expr ::= expr OR expr */
160885 215, /* (194) expr ::= expr LT|GT|GE|LE expr */
160886 215, /* (195) expr ::= expr EQ|NE expr */
160887 215, /* (196) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
160888 215, /* (197) expr ::= expr PLUS|MINUS expr */
160889 215, /* (198) expr ::= expr STAR|SLASH|REM expr */
160890 215, /* (199) expr ::= expr CONCAT expr */
160891 272, /* (200) likeop ::= NOT LIKE_KW|MATCH */
160892 215, /* (201) expr ::= expr likeop expr */
160893 215, /* (202) expr ::= expr likeop expr ESCAPE expr */
160894 215, /* (203) expr ::= expr ISNULL|NOTNULL */
160895 215, /* (204) expr ::= expr NOT NULL */
160896 215, /* (205) expr ::= expr IS expr */
160897 215, /* (206) expr ::= expr IS NOT expr */
160898 215, /* (207) expr ::= NOT expr */
160899 215, /* (208) expr ::= BITNOT expr */
160900 215, /* (209) expr ::= PLUS|MINUS expr */
160901 273, /* (210) between_op ::= BETWEEN */
160902 273, /* (211) between_op ::= NOT BETWEEN */
160903 215, /* (212) expr ::= expr between_op expr AND expr */
160904 274, /* (213) in_op ::= IN */
160905 274, /* (214) in_op ::= NOT IN */
160906 215, /* (215) expr ::= expr in_op LP exprlist RP */
160907 215, /* (216) expr ::= LP select RP */
160908 215, /* (217) expr ::= expr in_op LP select RP */
160909 215, /* (218) expr ::= expr in_op nm dbnm paren_exprlist */
160910 215, /* (219) expr ::= EXISTS LP select RP */
160911 215, /* (220) expr ::= CASE case_operand case_exprlist case_else END */
160912 277, /* (221) case_exprlist ::= case_exprlist WHEN expr THEN expr */
160913 277, /* (222) case_exprlist ::= WHEN expr THEN expr */
160914 278, /* (223) case_else ::= ELSE expr */
160915 278, /* (224) case_else ::= */
160916 276, /* (225) case_operand ::= expr */
160917 276, /* (226) case_operand ::= */
160918 260, /* (227) exprlist ::= */
160919 251, /* (228) nexprlist ::= nexprlist COMMA expr */
160920 251, /* (229) nexprlist ::= expr */
160921 275, /* (230) paren_exprlist ::= */
160922 275, /* (231) paren_exprlist ::= LP exprlist RP */
160923 189, /* (232) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
160924 279, /* (233) uniqueflag ::= UNIQUE */
160925 279, /* (234) uniqueflag ::= */
160926 219, /* (235) eidlist_opt ::= */
160927 219, /* (236) eidlist_opt ::= LP eidlist RP */
160928 230, /* (237) eidlist ::= eidlist COMMA nm collate sortorder */
160929 230, /* (238) eidlist ::= nm collate sortorder */
160930 280, /* (239) collate ::= */
160931 280, /* (240) collate ::= COLLATE ID|STRING */
160932 189, /* (241) cmd ::= DROP INDEX ifexists fullname */
160933 189, /* (242) cmd ::= VACUUM vinto */
160934 189, /* (243) cmd ::= VACUUM nm vinto */
160935 281, /* (244) vinto ::= INTO expr */
160936 281, /* (245) vinto ::= */
160937 189, /* (246) cmd ::= PRAGMA nm dbnm */
160938 189, /* (247) cmd ::= PRAGMA nm dbnm EQ nmnum */
160939 189, /* (248) cmd ::= PRAGMA nm dbnm LP nmnum RP */
160940 189, /* (249) cmd ::= PRAGMA nm dbnm EQ minus_num */
160941 189, /* (250) cmd ::= PRAGMA nm dbnm LP minus_num RP */
160942 209, /* (251) plus_num ::= PLUS INTEGER|FLOAT */
160943 210, /* (252) minus_num ::= MINUS INTEGER|FLOAT */
160944 189, /* (253) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
160945 283, /* (254) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
160946 285, /* (255) trigger_time ::= BEFORE|AFTER */
160947 285, /* (256) trigger_time ::= INSTEAD OF */
160948 285, /* (257) trigger_time ::= */
160949 286, /* (258) trigger_event ::= DELETE|INSERT */
160950 286, /* (259) trigger_event ::= UPDATE */
160951 286, /* (260) trigger_event ::= UPDATE OF idlist */
160952 288, /* (261) when_clause ::= */
160953 288, /* (262) when_clause ::= WHEN expr */
160954 284, /* (263) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
160955 284, /* (264) trigger_cmd_list ::= trigger_cmd SEMI */
160956 290, /* (265) trnm ::= nm DOT nm */
160957 291, /* (266) tridxby ::= INDEXED BY nm */
160958 291, /* (267) tridxby ::= NOT INDEXED */
160959 289, /* (268) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
160960 289, /* (269) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
160961 289, /* (270) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
160962 289, /* (271) trigger_cmd ::= scanpt select scanpt */
160963 215, /* (272) expr ::= RAISE LP IGNORE RP */
160964 215, /* (273) expr ::= RAISE LP raisetype COMMA nm RP */
160965 234, /* (274) raisetype ::= ROLLBACK */
160966 234, /* (275) raisetype ::= ABORT */
160967 234, /* (276) raisetype ::= FAIL */
160968 189, /* (277) cmd ::= DROP TRIGGER ifexists fullname */
160969 189, /* (278) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
160970 189, /* (279) cmd ::= DETACH database_kw_opt expr */
160971 293, /* (280) key_opt ::= */
160972 293, /* (281) key_opt ::= KEY expr */
160973 189, /* (282) cmd ::= REINDEX */
160974 189, /* (283) cmd ::= REINDEX nm dbnm */
160975 189, /* (284) cmd ::= ANALYZE */
160976 189, /* (285) cmd ::= ANALYZE nm dbnm */
160977 189, /* (286) cmd ::= ALTER TABLE fullname RENAME TO nm */
160978 189, /* (287) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
160979 189, /* (288) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
160980 294, /* (289) add_column_fullname ::= fullname */
160981 189, /* (290) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
160982 189, /* (291) cmd ::= create_vtab */
160983 189, /* (292) cmd ::= create_vtab LP vtabarglist RP */
160984 296, /* (293) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
160985 298, /* (294) vtabarg ::= */
160986 299, /* (295) vtabargtoken ::= ANY */
160987 299, /* (296) vtabargtoken ::= lp anylist RP */
160988 300, /* (297) lp ::= LP */
160989 264, /* (298) with ::= WITH wqlist */
160990 264, /* (299) with ::= WITH RECURSIVE wqlist */
160991 303, /* (300) wqas ::= AS */
160992 303, /* (301) wqas ::= AS MATERIALIZED */
160993 303, /* (302) wqas ::= AS NOT MATERIALIZED */
160994 302, /* (303) wqitem ::= nm eidlist_opt wqas LP select RP */
160995 239, /* (304) wqlist ::= wqitem */
160996 239, /* (305) wqlist ::= wqlist COMMA wqitem */
160997 304, /* (306) windowdefn_list ::= windowdefn */
160998 304, /* (307) windowdefn_list ::= windowdefn_list COMMA windowdefn */
160999 305, /* (308) windowdefn ::= nm AS LP window RP */
161000 306, /* (309) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
161001 306, /* (310) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
161002 306, /* (311) window ::= ORDER BY sortlist frame_opt */
161003 306, /* (312) window ::= nm ORDER BY sortlist frame_opt */
161004 306, /* (313) window ::= frame_opt */
161005 306, /* (314) window ::= nm frame_opt */
161006 307, /* (315) frame_opt ::= */
161007 307, /* (316) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
161008 307, /* (317) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
161009 311, /* (318) range_or_rows ::= RANGE|ROWS|GROUPS */
161010 313, /* (319) frame_bound_s ::= frame_bound */
161011 313, /* (320) frame_bound_s ::= UNBOUNDED PRECEDING */
161012 314, /* (321) frame_bound_e ::= frame_bound */
161013 314, /* (322) frame_bound_e ::= UNBOUNDED FOLLOWING */
161014 312, /* (323) frame_bound ::= expr PRECEDING|FOLLOWING */
161015 312, /* (324) frame_bound ::= CURRENT ROW */
161016 315, /* (325) frame_exclude_opt ::= */
161017 315, /* (326) frame_exclude_opt ::= EXCLUDE frame_exclude */
161018 316, /* (327) frame_exclude ::= NO OTHERS */
161019 316, /* (328) frame_exclude ::= CURRENT ROW */
161020 316, /* (329) frame_exclude ::= GROUP|TIES */
161021 249, /* (330) window_clause ::= WINDOW windowdefn_list */
161022 271, /* (331) filter_over ::= filter_clause over_clause */
161023 271, /* (332) filter_over ::= over_clause */
161024 271, /* (333) filter_over ::= filter_clause */
161025 310, /* (334) over_clause ::= OVER LP window RP */
161026 310, /* (335) over_clause ::= OVER nm */
161027 309, /* (336) filter_clause ::= FILTER LP WHERE expr RP */
161028 184, /* (337) input ::= cmdlist */
161029 185, /* (338) cmdlist ::= cmdlist ecmd */
161030 185, /* (339) cmdlist ::= ecmd */
161031 186, /* (340) ecmd ::= SEMI */
161032 186, /* (341) ecmd ::= cmdx SEMI */
161033 186, /* (342) ecmd ::= explain cmdx SEMI */
161034 191, /* (343) trans_opt ::= */
161035 191, /* (344) trans_opt ::= TRANSACTION */
161036 191, /* (345) trans_opt ::= TRANSACTION nm */
161037 193, /* (346) savepoint_opt ::= SAVEPOINT */
161038 193, /* (347) savepoint_opt ::= */
161039 189, /* (348) cmd ::= create_table create_table_args */
161040 200, /* (349) columnlist ::= columnlist COMMA columnname carglist */
161041 200, /* (350) columnlist ::= columnname carglist */
161042 192, /* (351) nm ::= ID|INDEXED */
161043 192, /* (352) nm ::= STRING */
161044 192, /* (353) nm ::= JOIN_KW */
161045 206, /* (354) typetoken ::= typename */
161046 207, /* (355) typename ::= ID|STRING */
161047 208, /* (356) signed ::= plus_num */
161048 208, /* (357) signed ::= minus_num */
161049 205, /* (358) carglist ::= carglist ccons */
161050 205, /* (359) carglist ::= */
161051 213, /* (360) ccons ::= NULL onconf */
161052 213, /* (361) ccons ::= GENERATED ALWAYS AS generated */
161053 213, /* (362) ccons ::= AS generated */
161054 201, /* (363) conslist_opt ::= COMMA conslist */
161055 226, /* (364) conslist ::= conslist tconscomma tcons */
161056 226, /* (365) conslist ::= tcons */
161057 227, /* (366) tconscomma ::= */
161058 231, /* (367) defer_subclause_opt ::= defer_subclause */
161059 233, /* (368) resolvetype ::= raisetype */
161060 237, /* (369) selectnowith ::= oneselect */
161061 238, /* (370) oneselect ::= values */
161062 252, /* (371) sclp ::= selcollist COMMA */
161063 253, /* (372) as ::= ID|STRING */
161064 270, /* (373) returning ::= */
161065 215, /* (374) expr ::= term */
161066 272, /* (375) likeop ::= LIKE_KW|MATCH */
161067 260, /* (376) exprlist ::= nexprlist */
161068 282, /* (377) nmnum ::= plus_num */
161069 282, /* (378) nmnum ::= nm */
161070 282, /* (379) nmnum ::= ON */
161071 282, /* (380) nmnum ::= DELETE */
161072 282, /* (381) nmnum ::= DEFAULT */
161073 209, /* (382) plus_num ::= INTEGER|FLOAT */
161074 287, /* (383) foreach_clause ::= */
161075 287, /* (384) foreach_clause ::= FOR EACH ROW */
161076 290, /* (385) trnm ::= nm */
161077 291, /* (386) tridxby ::= */
161078 292, /* (387) database_kw_opt ::= DATABASE */
161079 292, /* (388) database_kw_opt ::= */
161080 295, /* (389) kwcolumn_opt ::= */
161081 295, /* (390) kwcolumn_opt ::= COLUMNKW */
161082 297, /* (391) vtabarglist ::= vtabarg */
161083 297, /* (392) vtabarglist ::= vtabarglist COMMA vtabarg */
161084 298, /* (393) vtabarg ::= vtabarg vtabargtoken */
161085 301, /* (394) anylist ::= */
161086 301, /* (395) anylist ::= anylist LP anylist RP */
161087 301, /* (396) anylist ::= anylist ANY */
161088 264, /* (397) with ::= */
161089 };
161090
161091 /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
161092 ** of symbols on the right-hand side of that rule. */
161093 static const signed char yyRuleInfoNRhs[] = {
@@ -160959,20 +161538,20 @@
161538 break;
161539 case 2: /* cmdx ::= cmd */
161540 { sqlite3FinishCoding(pParse); }
161541 break;
161542 case 3: /* cmd ::= BEGIN transtype trans_opt */
161543 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy376);}
161544 break;
161545 case 4: /* transtype ::= */
161546 {yymsp[1].minor.yy376 = TK_DEFERRED;}
161547 break;
161548 case 5: /* transtype ::= DEFERRED */
161549 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
161550 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
161551 case 318: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==318);
161552 {yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-X*/}
161553 break;
161554 case 8: /* cmd ::= COMMIT|END trans_opt */
161555 case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
161556 {sqlite3EndTransaction(pParse,yymsp[-1].major);}
161557 break;
@@ -160991,11 +161570,11 @@
161570 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
161571 }
161572 break;
161573 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
161574 {
161575 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy376,0,0,yymsp[-2].minor.yy376);
161576 }
161577 break;
161578 case 14: /* createkw ::= CREATE */
161579 {disableLookaside(pParse);}
161580 break;
@@ -161006,36 +161585,35 @@
161585 case 60: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==60);
161586 case 70: /* defer_subclause_opt ::= */ yytestcase(yyruleno==70);
161587 case 79: /* ifexists ::= */ yytestcase(yyruleno==79);
161588 case 96: /* distinct ::= */ yytestcase(yyruleno==96);
161589 case 239: /* collate ::= */ yytestcase(yyruleno==239);
161590 {yymsp[1].minor.yy376 = 0;}
161591 break;
161592 case 16: /* ifnotexists ::= IF NOT EXISTS */
161593 {yymsp[-2].minor.yy376 = 1;}
161594 break;
161595 case 17: /* temp ::= TEMP */
161596 {yymsp[0].minor.yy376 = pParse->db->init.busy==0;}
 
161597 break;
161598 case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
161599 {
161600 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy376,0);
161601 }
161602 break;
161603 case 20: /* create_table_args ::= AS select */
161604 {
161605 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy81);
161606 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy81);
161607 }
161608 break;
161609 case 22: /* table_options ::= WITHOUT nm */
161610 {
161611 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
161612 yymsp[-1].minor.yy376 = TF_WithoutRowid | TF_NoVisibleRowid;
161613 }else{
161614 yymsp[-1].minor.yy376 = 0;
161615 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
161616 }
161617 }
161618 break;
161619 case 23: /* columnname ::= nm typetoken */
@@ -161060,11 +161638,11 @@
161638 {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
161639 break;
161640 case 28: /* scanpt ::= */
161641 {
161642 assert( yyLookahead!=YYNOCODE );
161643 yymsp[1].minor.yy504 = yyLookaheadToken.z;
161644 }
161645 break;
161646 case 29: /* scantok ::= */
161647 {
161648 assert( yyLookahead!=YYNOCODE );
@@ -161074,21 +161652,21 @@
161652 case 30: /* ccons ::= CONSTRAINT nm */
161653 case 65: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==65);
161654 {pParse->constraintName = yymsp[0].minor.yy0;}
161655 break;
161656 case 31: /* ccons ::= DEFAULT scantok term */
161657 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy404,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
161658 break;
161659 case 32: /* ccons ::= DEFAULT LP expr RP */
161660 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy404,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
161661 break;
161662 case 33: /* ccons ::= DEFAULT PLUS scantok term */
161663 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy404,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
161664 break;
161665 case 34: /* ccons ::= DEFAULT MINUS scantok term */
161666 {
161667 Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy404, 0);
161668 sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
161669 }
161670 break;
161671 case 35: /* ccons ::= DEFAULT scantok ID|INDEXED */
161672 {
@@ -161099,256 +161677,259 @@
161677 }
161678 sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
161679 }
161680 break;
161681 case 36: /* ccons ::= NOT NULL onconf */
161682 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy376);}
161683 break;
161684 case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
161685 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy376,yymsp[0].minor.yy376,yymsp[-2].minor.yy376);}
161686 break;
161687 case 38: /* ccons ::= UNIQUE onconf */
161688 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy376,0,0,0,0,
161689 SQLITE_IDXTYPE_UNIQUE);}
161690 break;
161691 case 39: /* ccons ::= CHECK LP expr RP */
161692 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy404,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
161693 break;
161694 case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */
161695 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy70,yymsp[0].minor.yy376);}
161696 break;
161697 case 41: /* ccons ::= defer_subclause */
161698 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy376);}
161699 break;
161700 case 42: /* ccons ::= COLLATE ID|STRING */
161701 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
161702 break;
161703 case 43: /* generated ::= LP expr RP */
161704 {sqlite3AddGenerated(pParse,yymsp[-1].minor.yy404,0);}
161705 break;
161706 case 44: /* generated ::= LP expr RP ID */
161707 {sqlite3AddGenerated(pParse,yymsp[-2].minor.yy404,&yymsp[0].minor.yy0);}
161708 break;
161709 case 46: /* autoinc ::= AUTOINCR */
161710 {yymsp[0].minor.yy376 = 1;}
161711 break;
161712 case 47: /* refargs ::= */
161713 { yymsp[1].minor.yy376 = OE_None*0x0101; /* EV: R-19803-45884 */}
161714 break;
161715 case 48: /* refargs ::= refargs refarg */
161716 { yymsp[-1].minor.yy376 = (yymsp[-1].minor.yy376 & ~yymsp[0].minor.yy139.mask) | yymsp[0].minor.yy139.value; }
161717 break;
161718 case 49: /* refarg ::= MATCH nm */
161719 { yymsp[-1].minor.yy139.value = 0; yymsp[-1].minor.yy139.mask = 0x000000; }
161720 break;
161721 case 50: /* refarg ::= ON INSERT refact */
161722 { yymsp[-2].minor.yy139.value = 0; yymsp[-2].minor.yy139.mask = 0x000000; }
161723 break;
161724 case 51: /* refarg ::= ON DELETE refact */
161725 { yymsp[-2].minor.yy139.value = yymsp[0].minor.yy376; yymsp[-2].minor.yy139.mask = 0x0000ff; }
161726 break;
161727 case 52: /* refarg ::= ON UPDATE refact */
161728 { yymsp[-2].minor.yy139.value = yymsp[0].minor.yy376<<8; yymsp[-2].minor.yy139.mask = 0x00ff00; }
161729 break;
161730 case 53: /* refact ::= SET NULL */
161731 { yymsp[-1].minor.yy376 = OE_SetNull; /* EV: R-33326-45252 */}
161732 break;
161733 case 54: /* refact ::= SET DEFAULT */
161734 { yymsp[-1].minor.yy376 = OE_SetDflt; /* EV: R-33326-45252 */}
161735 break;
161736 case 55: /* refact ::= CASCADE */
161737 { yymsp[0].minor.yy376 = OE_Cascade; /* EV: R-33326-45252 */}
161738 break;
161739 case 56: /* refact ::= RESTRICT */
161740 { yymsp[0].minor.yy376 = OE_Restrict; /* EV: R-33326-45252 */}
161741 break;
161742 case 57: /* refact ::= NO ACTION */
161743 { yymsp[-1].minor.yy376 = OE_None; /* EV: R-33326-45252 */}
161744 break;
161745 case 58: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
161746 {yymsp[-2].minor.yy376 = 0;}
161747 break;
161748 case 59: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
161749 case 74: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==74);
161750 case 169: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==169);
161751 {yymsp[-1].minor.yy376 = yymsp[0].minor.yy376;}
161752 break;
161753 case 61: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
161754 case 78: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==78);
161755 case 211: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==211);
161756 case 214: /* in_op ::= NOT IN */ yytestcase(yyruleno==214);
161757 case 240: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==240);
161758 {yymsp[-1].minor.yy376 = 1;}
161759 break;
161760 case 62: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
161761 {yymsp[-1].minor.yy376 = 0;}
161762 break;
161763 case 64: /* tconscomma ::= COMMA */
161764 {pParse->constraintName.n = 0;}
161765 break;
161766 case 66: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
161767 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy70,yymsp[0].minor.yy376,yymsp[-2].minor.yy376,0);}
161768 break;
161769 case 67: /* tcons ::= UNIQUE LP sortlist RP onconf */
161770 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy70,yymsp[0].minor.yy376,0,0,0,0,
161771 SQLITE_IDXTYPE_UNIQUE);}
161772 break;
161773 case 68: /* tcons ::= CHECK LP expr RP onconf */
161774 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy404,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
161775 break;
161776 case 69: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
161777 {
161778 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy70, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy70, yymsp[-1].minor.yy376);
161779 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy376);
161780 }
161781 break;
161782 case 71: /* onconf ::= */
161783 case 73: /* orconf ::= */ yytestcase(yyruleno==73);
161784 {yymsp[1].minor.yy376 = OE_Default;}
161785 break;
161786 case 72: /* onconf ::= ON CONFLICT resolvetype */
161787 {yymsp[-2].minor.yy376 = yymsp[0].minor.yy376;}
161788 break;
161789 case 75: /* resolvetype ::= IGNORE */
161790 {yymsp[0].minor.yy376 = OE_Ignore;}
161791 break;
161792 case 76: /* resolvetype ::= REPLACE */
161793 case 170: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==170);
161794 {yymsp[0].minor.yy376 = OE_Replace;}
161795 break;
161796 case 77: /* cmd ::= DROP TABLE ifexists fullname */
161797 {
161798 sqlite3DropTable(pParse, yymsp[0].minor.yy153, 0, yymsp[-1].minor.yy376);
161799 }
161800 break;
161801 case 80: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
161802 {
161803 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy70, yymsp[0].minor.yy81, yymsp[-7].minor.yy376, yymsp[-5].minor.yy376);
161804 }
161805 break;
161806 case 81: /* cmd ::= DROP VIEW ifexists fullname */
161807 {
161808 sqlite3DropTable(pParse, yymsp[0].minor.yy153, 1, yymsp[-1].minor.yy376);
161809 }
161810 break;
161811 case 82: /* cmd ::= select */
161812 {
161813 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0};
161814 sqlite3Select(pParse, yymsp[0].minor.yy81, &dest);
161815 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy81);
161816 }
161817 break;
161818 case 83: /* select ::= WITH wqlist selectnowith */
161819 {yymsp[-2].minor.yy81 = attachWithToSelect(pParse,yymsp[0].minor.yy81,yymsp[-1].minor.yy103);}
161820 break;
161821 case 84: /* select ::= WITH RECURSIVE wqlist selectnowith */
161822 {yymsp[-3].minor.yy81 = attachWithToSelect(pParse,yymsp[0].minor.yy81,yymsp[-1].minor.yy103);}
161823 break;
161824 case 85: /* select ::= selectnowith */
161825 {
161826 Select *p = yymsp[0].minor.yy81;
161827 if( p ){
161828 parserDoubleLinkSelect(pParse, p);
161829 }
161830 yymsp[0].minor.yy81 = p; /*A-overwrites-X*/
161831 }
161832 break;
161833 case 86: /* selectnowith ::= selectnowith multiselect_op oneselect */
161834 {
161835 Select *pRhs = yymsp[0].minor.yy81;
161836 Select *pLhs = yymsp[-2].minor.yy81;
161837 if( pRhs && pRhs->pPrior ){
161838 SrcList *pFrom;
161839 Token x;
161840 x.n = 0;
161841 parserDoubleLinkSelect(pParse, pRhs);
161842 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
161843 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
161844 }
161845 if( pRhs ){
161846 pRhs->op = (u8)yymsp[-1].minor.yy376;
161847 pRhs->pPrior = pLhs;
161848 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
161849 pRhs->selFlags &= ~SF_MultiValue;
161850 if( yymsp[-1].minor.yy376!=TK_ALL ) pParse->hasCompound = 1;
161851 }else{
161852 sqlite3SelectDelete(pParse->db, pLhs);
161853 }
161854 yymsp[-2].minor.yy81 = pRhs;
161855 }
161856 break;
161857 case 87: /* multiselect_op ::= UNION */
161858 case 89: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==89);
161859 {yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-OP*/}
161860 break;
161861 case 88: /* multiselect_op ::= UNION ALL */
161862 {yymsp[-1].minor.yy376 = TK_ALL;}
161863 break;
161864 case 90: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
161865 {
161866 yymsp[-8].minor.yy81 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy70,yymsp[-5].minor.yy153,yymsp[-4].minor.yy404,yymsp[-3].minor.yy70,yymsp[-2].minor.yy404,yymsp[-1].minor.yy70,yymsp[-7].minor.yy376,yymsp[0].minor.yy404);
161867 }
161868 break;
161869 case 91: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
161870 {
161871 yymsp[-9].minor.yy81 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy70,yymsp[-6].minor.yy153,yymsp[-5].minor.yy404,yymsp[-4].minor.yy70,yymsp[-3].minor.yy404,yymsp[-1].minor.yy70,yymsp[-8].minor.yy376,yymsp[0].minor.yy404);
161872 if( yymsp[-9].minor.yy81 ){
161873 yymsp[-9].minor.yy81->pWinDefn = yymsp[-2].minor.yy49;
161874 }else{
161875 sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy49);
161876 }
161877 }
161878 break;
161879 case 92: /* values ::= VALUES LP nexprlist RP */
161880 {
161881 yymsp[-3].minor.yy81 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy70,0,0,0,0,0,SF_Values,0);
161882 }
161883 break;
161884 case 93: /* values ::= values COMMA LP nexprlist RP */
161885 {
161886 Select *pRight, *pLeft = yymsp[-4].minor.yy81;
161887 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy70,0,0,0,0,0,SF_Values|SF_MultiValue,0);
161888 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
161889 if( pRight ){
161890 pRight->op = TK_ALL;
161891 pRight->pPrior = pLeft;
161892 yymsp[-4].minor.yy81 = pRight;
161893 }else{
161894 yymsp[-4].minor.yy81 = pLeft;
161895 }
161896 }
161897 break;
161898 case 94: /* distinct ::= DISTINCT */
161899 {yymsp[0].minor.yy376 = SF_Distinct;}
161900 break;
161901 case 95: /* distinct ::= ALL */
161902 {yymsp[0].minor.yy376 = SF_All;}
161903 break;
161904 case 97: /* sclp ::= */
161905 case 130: /* orderby_opt ::= */ yytestcase(yyruleno==130);
161906 case 140: /* groupby_opt ::= */ yytestcase(yyruleno==140);
161907 case 227: /* exprlist ::= */ yytestcase(yyruleno==227);
161908 case 230: /* paren_exprlist ::= */ yytestcase(yyruleno==230);
161909 case 235: /* eidlist_opt ::= */ yytestcase(yyruleno==235);
161910 {yymsp[1].minor.yy70 = 0;}
161911 break;
161912 case 98: /* selcollist ::= sclp scanpt expr scanpt as */
161913 {
161914 yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy70, yymsp[-2].minor.yy404);
161915 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy70, &yymsp[0].minor.yy0, 1);
161916 sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy70,yymsp[-3].minor.yy504,yymsp[-1].minor.yy504);
161917 }
161918 break;
161919 case 99: /* selcollist ::= sclp scanpt STAR */
161920 {
161921 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
161922 yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy70, p);
161923 }
161924 break;
161925 case 100: /* selcollist ::= sclp scanpt nm DOT STAR */
161926 {
161927 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
161928 Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
161929 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
161930 yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, pDot);
161931 }
161932 break;
161933 case 101: /* as ::= AS nm */
161934 case 112: /* dbnm ::= DOT nm */ yytestcase(yyruleno==112);
161935 case 251: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==251);
@@ -161355,49 +161936,49 @@
161936 case 252: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==252);
161937 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
161938 break;
161939 case 103: /* from ::= */
161940 case 106: /* stl_prefix ::= */ yytestcase(yyruleno==106);
161941 {yymsp[1].minor.yy153 = 0;}
161942 break;
161943 case 104: /* from ::= FROM seltablist */
161944 {
161945 yymsp[-1].minor.yy153 = yymsp[0].minor.yy153;
161946 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy153);
161947 }
161948 break;
161949 case 105: /* stl_prefix ::= seltablist joinop */
161950 {
161951 if( ALWAYS(yymsp[-1].minor.yy153 && yymsp[-1].minor.yy153->nSrc>0) ) yymsp[-1].minor.yy153->a[yymsp[-1].minor.yy153->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy376;
161952 }
161953 break;
161954 case 107: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
161955 {
161956 yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy404,yymsp[0].minor.yy436);
161957 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy153, &yymsp[-2].minor.yy0);
161958 }
161959 break;
161960 case 108: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
161961 {
161962 yymsp[-8].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy153,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy404,yymsp[0].minor.yy436);
161963 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy153, yymsp[-4].minor.yy70);
161964 }
161965 break;
161966 case 109: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
161967 {
161968 yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy81,yymsp[-1].minor.yy404,yymsp[0].minor.yy436);
161969 }
161970 break;
161971 case 110: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
161972 {
161973 if( yymsp[-6].minor.yy153==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy404==0 && yymsp[0].minor.yy436==0 ){
161974 yymsp[-6].minor.yy153 = yymsp[-4].minor.yy153;
161975 }else if( yymsp[-4].minor.yy153->nSrc==1 ){
161976 yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy404,yymsp[0].minor.yy436);
161977 if( yymsp[-6].minor.yy153 ){
161978 SrcItem *pNew = &yymsp[-6].minor.yy153->a[yymsp[-6].minor.yy153->nSrc-1];
161979 SrcItem *pOld = yymsp[-4].minor.yy153->a;
161980 pNew->zName = pOld->zName;
161981 pNew->zDatabase = pOld->zDatabase;
161982 pNew->pSelect = pOld->pSelect;
161983 if( pOld->fg.isTabFunc ){
161984 pNew->u1.pFuncArg = pOld->u1.pFuncArg;
@@ -161406,240 +161987,240 @@
161987 pNew->fg.isTabFunc = 1;
161988 }
161989 pOld->zName = pOld->zDatabase = 0;
161990 pOld->pSelect = 0;
161991 }
161992 sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy153);
161993 }else{
161994 Select *pSubquery;
161995 sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy153);
161996 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy153,0,0,0,0,SF_NestedFrom,0);
161997 yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy404,yymsp[0].minor.yy436);
161998 }
161999 }
162000 break;
162001 case 111: /* dbnm ::= */
162002 case 125: /* indexed_opt ::= */ yytestcase(yyruleno==125);
162003 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
162004 break;
162005 case 113: /* fullname ::= nm */
162006 {
162007 yylhsminor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
162008 if( IN_RENAME_OBJECT && yylhsminor.yy153 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy153->a[0].zName, &yymsp[0].minor.yy0);
162009 }
162010 yymsp[0].minor.yy153 = yylhsminor.yy153;
162011 break;
162012 case 114: /* fullname ::= nm DOT nm */
162013 {
162014 yylhsminor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
162015 if( IN_RENAME_OBJECT && yylhsminor.yy153 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy153->a[0].zName, &yymsp[0].minor.yy0);
162016 }
162017 yymsp[-2].minor.yy153 = yylhsminor.yy153;
162018 break;
162019 case 115: /* xfullname ::= nm */
162020 {yymsp[0].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
162021 break;
162022 case 116: /* xfullname ::= nm DOT nm */
162023 {yymsp[-2].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
162024 break;
162025 case 117: /* xfullname ::= nm DOT nm AS nm */
162026 {
162027 yymsp[-4].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
162028 if( yymsp[-4].minor.yy153 ) yymsp[-4].minor.yy153->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
162029 }
162030 break;
162031 case 118: /* xfullname ::= nm AS nm */
162032 {
162033 yymsp[-2].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
162034 if( yymsp[-2].minor.yy153 ) yymsp[-2].minor.yy153->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
162035 }
162036 break;
162037 case 119: /* joinop ::= COMMA|JOIN */
162038 { yymsp[0].minor.yy376 = JT_INNER; }
162039 break;
162040 case 120: /* joinop ::= JOIN_KW JOIN */
162041 {yymsp[-1].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
162042 break;
162043 case 121: /* joinop ::= JOIN_KW nm JOIN */
162044 {yymsp[-2].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
162045 break;
162046 case 122: /* joinop ::= JOIN_KW nm nm JOIN */
162047 {yymsp[-3].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
162048 break;
162049 case 123: /* on_opt ::= ON expr */
162050 case 143: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==143);
162051 case 150: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==150);
162052 case 152: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==152);
162053 case 223: /* case_else ::= ELSE expr */ yytestcase(yyruleno==223);
162054 case 244: /* vinto ::= INTO expr */ yytestcase(yyruleno==244);
162055 {yymsp[-1].minor.yy404 = yymsp[0].minor.yy404;}
162056 break;
162057 case 124: /* on_opt ::= */
162058 case 142: /* having_opt ::= */ yytestcase(yyruleno==142);
162059 case 144: /* limit_opt ::= */ yytestcase(yyruleno==144);
162060 case 149: /* where_opt ::= */ yytestcase(yyruleno==149);
162061 case 151: /* where_opt_ret ::= */ yytestcase(yyruleno==151);
162062 case 224: /* case_else ::= */ yytestcase(yyruleno==224);
162063 case 226: /* case_operand ::= */ yytestcase(yyruleno==226);
162064 case 245: /* vinto ::= */ yytestcase(yyruleno==245);
162065 {yymsp[1].minor.yy404 = 0;}
162066 break;
162067 case 126: /* indexed_opt ::= INDEXED BY nm */
162068 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
162069 break;
162070 case 127: /* indexed_opt ::= NOT INDEXED */
162071 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
162072 break;
162073 case 128: /* using_opt ::= USING LP idlist RP */
162074 {yymsp[-3].minor.yy436 = yymsp[-1].minor.yy436;}
162075 break;
162076 case 129: /* using_opt ::= */
162077 case 171: /* idlist_opt ::= */ yytestcase(yyruleno==171);
162078 {yymsp[1].minor.yy436 = 0;}
162079 break;
162080 case 131: /* orderby_opt ::= ORDER BY sortlist */
162081 case 141: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==141);
162082 {yymsp[-2].minor.yy70 = yymsp[0].minor.yy70;}
162083 break;
162084 case 132: /* sortlist ::= sortlist COMMA expr sortorder nulls */
162085 {
162086 yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70,yymsp[-2].minor.yy404);
162087 sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy70,yymsp[-1].minor.yy376,yymsp[0].minor.yy376);
162088 }
162089 break;
162090 case 133: /* sortlist ::= expr sortorder nulls */
162091 {
162092 yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy404); /*A-overwrites-Y*/
162093 sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy70,yymsp[-1].minor.yy376,yymsp[0].minor.yy376);
162094 }
162095 break;
162096 case 134: /* sortorder ::= ASC */
162097 {yymsp[0].minor.yy376 = SQLITE_SO_ASC;}
162098 break;
162099 case 135: /* sortorder ::= DESC */
162100 {yymsp[0].minor.yy376 = SQLITE_SO_DESC;}
162101 break;
162102 case 136: /* sortorder ::= */
162103 case 139: /* nulls ::= */ yytestcase(yyruleno==139);
162104 {yymsp[1].minor.yy376 = SQLITE_SO_UNDEFINED;}
162105 break;
162106 case 137: /* nulls ::= NULLS FIRST */
162107 {yymsp[-1].minor.yy376 = SQLITE_SO_ASC;}
162108 break;
162109 case 138: /* nulls ::= NULLS LAST */
162110 {yymsp[-1].minor.yy376 = SQLITE_SO_DESC;}
162111 break;
162112 case 145: /* limit_opt ::= LIMIT expr */
162113 {yymsp[-1].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy404,0);}
162114 break;
162115 case 146: /* limit_opt ::= LIMIT expr OFFSET expr */
162116 {yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);}
162117 break;
162118 case 147: /* limit_opt ::= LIMIT expr COMMA expr */
162119 {yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy404,yymsp[-2].minor.yy404);}
162120 break;
162121 case 148: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
162122 {
162123 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy153, &yymsp[-1].minor.yy0);
162124 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy153,yymsp[0].minor.yy404,0,0);
162125 }
162126 break;
162127 case 153: /* where_opt_ret ::= RETURNING selcollist */
162128 {sqlite3AddReturning(pParse,yymsp[0].minor.yy70); yymsp[-1].minor.yy404 = 0;}
162129 break;
162130 case 154: /* where_opt_ret ::= WHERE expr RETURNING selcollist */
162131 {sqlite3AddReturning(pParse,yymsp[0].minor.yy70); yymsp[-3].minor.yy404 = yymsp[-2].minor.yy404;}
162132 break;
162133 case 155: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
162134 {
162135 sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy153, &yymsp[-4].minor.yy0);
162136 sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy70,"set list");
162137 yymsp[-5].minor.yy153 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy153, yymsp[-1].minor.yy153);
162138 sqlite3Update(pParse,yymsp[-5].minor.yy153,yymsp[-2].minor.yy70,yymsp[0].minor.yy404,yymsp[-6].minor.yy376,0,0,0);
162139 }
162140 break;
162141 case 156: /* setlist ::= setlist COMMA nm EQ expr */
162142 {
162143 yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy70, yymsp[0].minor.yy404);
162144 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy70, &yymsp[-2].minor.yy0, 1);
162145 }
162146 break;
162147 case 157: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
162148 {
162149 yymsp[-6].minor.yy70 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy70, yymsp[-3].minor.yy436, yymsp[0].minor.yy404);
162150 }
162151 break;
162152 case 158: /* setlist ::= nm EQ expr */
162153 {
162154 yylhsminor.yy70 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy404);
162155 sqlite3ExprListSetName(pParse, yylhsminor.yy70, &yymsp[-2].minor.yy0, 1);
162156 }
162157 yymsp[-2].minor.yy70 = yylhsminor.yy70;
162158 break;
162159 case 159: /* setlist ::= LP idlist RP EQ expr */
162160 {
162161 yymsp[-4].minor.yy70 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy436, yymsp[0].minor.yy404);
162162 }
162163 break;
162164 case 160: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
162165 {
162166 sqlite3Insert(pParse, yymsp[-3].minor.yy153, yymsp[-1].minor.yy81, yymsp[-2].minor.yy436, yymsp[-5].minor.yy376, yymsp[0].minor.yy190);
162167 }
162168 break;
162169 case 161: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
162170 {
162171 sqlite3Insert(pParse, yymsp[-4].minor.yy153, 0, yymsp[-3].minor.yy436, yymsp[-6].minor.yy376, 0);
162172 }
162173 break;
162174 case 162: /* upsert ::= */
162175 { yymsp[1].minor.yy190 = 0; }
162176 break;
162177 case 163: /* upsert ::= RETURNING selcollist */
162178 { yymsp[-1].minor.yy190 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy70); }
162179 break;
162180 case 164: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
162181 { yymsp[-11].minor.yy190 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy70,yymsp[-6].minor.yy404,yymsp[-2].minor.yy70,yymsp[-1].minor.yy404,yymsp[0].minor.yy190);}
162182 break;
162183 case 165: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
162184 { yymsp[-8].minor.yy190 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy70,yymsp[-3].minor.yy404,0,0,yymsp[0].minor.yy190); }
162185 break;
162186 case 166: /* upsert ::= ON CONFLICT DO NOTHING returning */
162187 { yymsp[-4].minor.yy190 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
162188 break;
162189 case 167: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
162190 { yymsp[-7].minor.yy190 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy70,yymsp[-1].minor.yy404,0);}
162191 break;
162192 case 168: /* returning ::= RETURNING selcollist */
162193 {sqlite3AddReturning(pParse,yymsp[0].minor.yy70);}
162194 break;
162195 case 172: /* idlist_opt ::= LP idlist RP */
162196 {yymsp[-2].minor.yy436 = yymsp[-1].minor.yy436;}
162197 break;
162198 case 173: /* idlist ::= idlist COMMA nm */
162199 {yymsp[-2].minor.yy436 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy436,&yymsp[0].minor.yy0);}
162200 break;
162201 case 174: /* idlist ::= nm */
162202 {yymsp[0].minor.yy436 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
162203 break;
162204 case 175: /* expr ::= LP expr RP */
162205 {yymsp[-2].minor.yy404 = yymsp[-1].minor.yy404;}
162206 break;
162207 case 176: /* expr ::= ID|INDEXED */
162208 case 177: /* expr ::= JOIN_KW */ yytestcase(yyruleno==177);
162209 {yymsp[0].minor.yy404=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
162210 break;
162211 case 178: /* expr ::= nm DOT nm */
162212 {
162213 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
162214 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
162215 if( IN_RENAME_OBJECT ){
162216 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
162217 sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
162218 }
162219 yylhsminor.yy404 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
162220 }
162221 yymsp[-2].minor.yy404 = yylhsminor.yy404;
162222 break;
162223 case 179: /* expr ::= nm DOT nm DOT nm */
162224 {
162225 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
162226 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
@@ -161647,322 +162228,322 @@
162228 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
162229 if( IN_RENAME_OBJECT ){
162230 sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
162231 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
162232 }
162233 yylhsminor.yy404 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
162234 }
162235 yymsp[-4].minor.yy404 = yylhsminor.yy404;
162236 break;
162237 case 180: /* term ::= NULL|FLOAT|BLOB */
162238 case 181: /* term ::= STRING */ yytestcase(yyruleno==181);
162239 {yymsp[0].minor.yy404=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
162240 break;
162241 case 182: /* term ::= INTEGER */
162242 {
162243 yylhsminor.yy404 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
162244 }
162245 yymsp[0].minor.yy404 = yylhsminor.yy404;
162246 break;
162247 case 183: /* expr ::= VARIABLE */
162248 {
162249 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
162250 u32 n = yymsp[0].minor.yy0.n;
162251 yymsp[0].minor.yy404 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
162252 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy404, n);
162253 }else{
162254 /* When doing a nested parse, one can include terms in an expression
162255 ** that look like this: #1 #2 ... These terms refer to registers
162256 ** in the virtual machine. #N is the N-th register. */
162257 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
162258 assert( t.n>=2 );
162259 if( pParse->nested==0 ){
162260 sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
162261 yymsp[0].minor.yy404 = 0;
162262 }else{
162263 yymsp[0].minor.yy404 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
162264 if( yymsp[0].minor.yy404 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy404->iTable);
162265 }
162266 }
162267 }
162268 break;
162269 case 184: /* expr ::= expr COLLATE ID|STRING */
162270 {
162271 yymsp[-2].minor.yy404 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy404, &yymsp[0].minor.yy0, 1);
162272 }
162273 break;
162274 case 185: /* expr ::= CAST LP expr AS typetoken RP */
162275 {
162276 yymsp[-5].minor.yy404 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
162277 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy404, yymsp[-3].minor.yy404, 0);
162278 }
162279 break;
162280 case 186: /* expr ::= ID|INDEXED LP distinct exprlist RP */
162281 {
162282 yylhsminor.yy404 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy70, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy376);
162283 }
162284 yymsp[-4].minor.yy404 = yylhsminor.yy404;
162285 break;
162286 case 187: /* expr ::= ID|INDEXED LP STAR RP */
162287 {
162288 yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
162289 }
162290 yymsp[-3].minor.yy404 = yylhsminor.yy404;
162291 break;
162292 case 188: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
162293 {
162294 yylhsminor.yy404 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy70, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy376);
162295 sqlite3WindowAttach(pParse, yylhsminor.yy404, yymsp[0].minor.yy49);
162296 }
162297 yymsp[-5].minor.yy404 = yylhsminor.yy404;
162298 break;
162299 case 189: /* expr ::= ID|INDEXED LP STAR RP filter_over */
162300 {
162301 yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
162302 sqlite3WindowAttach(pParse, yylhsminor.yy404, yymsp[0].minor.yy49);
162303 }
162304 yymsp[-4].minor.yy404 = yylhsminor.yy404;
162305 break;
162306 case 190: /* term ::= CTIME_KW */
162307 {
162308 yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
162309 }
162310 yymsp[0].minor.yy404 = yylhsminor.yy404;
162311 break;
162312 case 191: /* expr ::= LP nexprlist COMMA expr RP */
162313 {
162314 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy70, yymsp[-1].minor.yy404);
162315 yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
162316 if( yymsp[-4].minor.yy404 ){
162317 yymsp[-4].minor.yy404->x.pList = pList;
162318 if( ALWAYS(pList->nExpr) ){
162319 yymsp[-4].minor.yy404->flags |= pList->a[0].pExpr->flags & EP_Propagate;
162320 }
162321 }else{
162322 sqlite3ExprListDelete(pParse->db, pList);
162323 }
162324 }
162325 break;
162326 case 192: /* expr ::= expr AND expr */
162327 {yymsp[-2].minor.yy404=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);}
162328 break;
162329 case 193: /* expr ::= expr OR expr */
162330 case 194: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==194);
162331 case 195: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==195);
162332 case 196: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==196);
162333 case 197: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==197);
162334 case 198: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==198);
162335 case 199: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==199);
162336 {yymsp[-2].minor.yy404=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);}
162337 break;
162338 case 200: /* likeop ::= NOT LIKE_KW|MATCH */
162339 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
162340 break;
162341 case 201: /* expr ::= expr likeop expr */
162342 {
162343 ExprList *pList;
162344 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
162345 yymsp[-1].minor.yy0.n &= 0x7fffffff;
162346 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy404);
162347 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy404);
162348 yymsp[-2].minor.yy404 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
162349 if( bNot ) yymsp[-2].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy404, 0);
162350 if( yymsp[-2].minor.yy404 ) yymsp[-2].minor.yy404->flags |= EP_InfixFunc;
162351 }
162352 break;
162353 case 202: /* expr ::= expr likeop expr ESCAPE expr */
162354 {
162355 ExprList *pList;
162356 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
162357 yymsp[-3].minor.yy0.n &= 0x7fffffff;
162358 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404);
162359 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy404);
162360 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy404);
162361 yymsp[-4].minor.yy404 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
162362 if( bNot ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
162363 if( yymsp[-4].minor.yy404 ) yymsp[-4].minor.yy404->flags |= EP_InfixFunc;
162364 }
162365 break;
162366 case 203: /* expr ::= expr ISNULL|NOTNULL */
162367 {yymsp[-1].minor.yy404 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy404,0);}
162368 break;
162369 case 204: /* expr ::= expr NOT NULL */
162370 {yymsp[-2].minor.yy404 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy404,0);}
162371 break;
162372 case 205: /* expr ::= expr IS expr */
162373 {
162374 yymsp[-2].minor.yy404 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);
162375 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy404, yymsp[-2].minor.yy404, TK_ISNULL);
162376 }
162377 break;
162378 case 206: /* expr ::= expr IS NOT expr */
162379 {
162380 yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy404,yymsp[0].minor.yy404);
162381 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy404, yymsp[-3].minor.yy404, TK_NOTNULL);
162382 }
162383 break;
162384 case 207: /* expr ::= NOT expr */
162385 case 208: /* expr ::= BITNOT expr */ yytestcase(yyruleno==208);
162386 {yymsp[-1].minor.yy404 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy404, 0);/*A-overwrites-B*/}
162387 break;
162388 case 209: /* expr ::= PLUS|MINUS expr */
162389 {
162390 yymsp[-1].minor.yy404 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy404, 0);
162391 /*A-overwrites-B*/
162392 }
162393 break;
162394 case 210: /* between_op ::= BETWEEN */
162395 case 213: /* in_op ::= IN */ yytestcase(yyruleno==213);
162396 {yymsp[0].minor.yy376 = 0;}
162397 break;
162398 case 212: /* expr ::= expr between_op expr AND expr */
162399 {
162400 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404);
162401 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy404);
162402 yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy404, 0);
162403 if( yymsp[-4].minor.yy404 ){
162404 yymsp[-4].minor.yy404->x.pList = pList;
162405 }else{
162406 sqlite3ExprListDelete(pParse->db, pList);
162407 }
162408 if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
162409 }
162410 break;
162411 case 215: /* expr ::= expr in_op LP exprlist RP */
162412 {
162413 if( yymsp[-1].minor.yy70==0 ){
162414 /* Expressions of the form
162415 **
162416 ** expr1 IN ()
162417 ** expr1 NOT IN ()
162418 **
162419 ** simplify to constants 0 (false) and 1 (true), respectively,
162420 ** regardless of the value of expr1.
162421 */
162422 sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy404);
162423 yymsp[-4].minor.yy404 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy376 ? "1" : "0");
162424 }else if( yymsp[-1].minor.yy70->nExpr==1 && sqlite3ExprIsConstant(yymsp[-1].minor.yy70->a[0].pExpr) ){
162425 Expr *pRHS = yymsp[-1].minor.yy70->a[0].pExpr;
162426 yymsp[-1].minor.yy70->a[0].pExpr = 0;
162427 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70);
162428 pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
162429 yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy404, pRHS);
162430 if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
162431 }else{
162432 yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0);
162433 if( yymsp[-4].minor.yy404 ){
162434 yymsp[-4].minor.yy404->x.pList = yymsp[-1].minor.yy70;
162435 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy404);
162436 }else{
162437 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70);
162438 }
162439 if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
162440 }
162441 }
162442 break;
162443 case 216: /* expr ::= LP select RP */
162444 {
162445 yymsp[-2].minor.yy404 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
162446 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy404, yymsp[-1].minor.yy81);
162447 }
162448 break;
162449 case 217: /* expr ::= expr in_op LP select RP */
162450 {
162451 yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0);
162452 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy404, yymsp[-1].minor.yy81);
162453 if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
162454 }
162455 break;
162456 case 218: /* expr ::= expr in_op nm dbnm paren_exprlist */
162457 {
162458 SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
162459 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
162460 if( yymsp[0].minor.yy70 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy70);
162461 yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0);
162462 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy404, pSelect);
162463 if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
162464 }
162465 break;
162466 case 219: /* expr ::= EXISTS LP select RP */
162467 {
162468 Expr *p;
162469 p = yymsp[-3].minor.yy404 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
162470 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy81);
162471 }
162472 break;
162473 case 220: /* expr ::= CASE case_operand case_exprlist case_else END */
162474 {
162475 yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy404, 0);
162476 if( yymsp[-4].minor.yy404 ){
162477 yymsp[-4].minor.yy404->x.pList = yymsp[-1].minor.yy404 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy70,yymsp[-1].minor.yy404) : yymsp[-2].minor.yy70;
162478 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy404);
162479 }else{
162480 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy70);
162481 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy404);
162482 }
162483 }
162484 break;
162485 case 221: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
162486 {
162487 yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, yymsp[-2].minor.yy404);
162488 yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, yymsp[0].minor.yy404);
162489 }
162490 break;
162491 case 222: /* case_exprlist ::= WHEN expr THEN expr */
162492 {
162493 yymsp[-3].minor.yy70 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404);
162494 yymsp[-3].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy70, yymsp[0].minor.yy404);
162495 }
162496 break;
162497 case 225: /* case_operand ::= expr */
162498 {yymsp[0].minor.yy404 = yymsp[0].minor.yy404; /*A-overwrites-X*/}
162499 break;
162500 case 228: /* nexprlist ::= nexprlist COMMA expr */
162501 {yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy70,yymsp[0].minor.yy404);}
162502 break;
162503 case 229: /* nexprlist ::= expr */
162504 {yymsp[0].minor.yy70 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy404); /*A-overwrites-Y*/}
162505 break;
162506 case 231: /* paren_exprlist ::= LP exprlist RP */
162507 case 236: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==236);
162508 {yymsp[-2].minor.yy70 = yymsp[-1].minor.yy70;}
162509 break;
162510 case 232: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
162511 {
162512 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
162513 sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy70, yymsp[-10].minor.yy376,
162514 &yymsp[-11].minor.yy0, yymsp[0].minor.yy404, SQLITE_SO_ASC, yymsp[-8].minor.yy376, SQLITE_IDXTYPE_APPDEF);
162515 if( IN_RENAME_OBJECT && pParse->pNewIndex ){
162516 sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
162517 }
162518 }
162519 break;
162520 case 233: /* uniqueflag ::= UNIQUE */
162521 case 275: /* raisetype ::= ABORT */ yytestcase(yyruleno==275);
162522 {yymsp[0].minor.yy376 = OE_Abort;}
162523 break;
162524 case 234: /* uniqueflag ::= */
162525 {yymsp[1].minor.yy376 = OE_None;}
162526 break;
162527 case 237: /* eidlist ::= eidlist COMMA nm collate sortorder */
162528 {
162529 yymsp[-4].minor.yy70 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy70, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy376, yymsp[0].minor.yy376);
162530 }
162531 break;
162532 case 238: /* eidlist ::= nm collate sortorder */
162533 {
162534 yymsp[-2].minor.yy70 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy376, yymsp[0].minor.yy376); /*A-overwrites-Y*/
162535 }
162536 break;
162537 case 241: /* cmd ::= DROP INDEX ifexists fullname */
162538 {sqlite3DropIndex(pParse, yymsp[0].minor.yy153, yymsp[-1].minor.yy376);}
162539 break;
162540 case 242: /* cmd ::= VACUUM vinto */
162541 {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy404);}
162542 break;
162543 case 243: /* cmd ::= VACUUM nm vinto */
162544 {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy404);}
162545 break;
162546 case 246: /* cmd ::= PRAGMA nm dbnm */
162547 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
162548 break;
162549 case 247: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
@@ -161980,54 +162561,54 @@
162561 case 253: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
162562 {
162563 Token all;
162564 all.z = yymsp[-3].minor.yy0.z;
162565 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
162566 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy157, &all);
162567 }
162568 break;
162569 case 254: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
162570 {
162571 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy376, yymsp[-4].minor.yy262.a, yymsp[-4].minor.yy262.b, yymsp[-2].minor.yy153, yymsp[0].minor.yy404, yymsp[-10].minor.yy376, yymsp[-8].minor.yy376);
162572 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
162573 }
162574 break;
162575 case 255: /* trigger_time ::= BEFORE|AFTER */
162576 { yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-X*/ }
162577 break;
162578 case 256: /* trigger_time ::= INSTEAD OF */
162579 { yymsp[-1].minor.yy376 = TK_INSTEAD;}
162580 break;
162581 case 257: /* trigger_time ::= */
162582 { yymsp[1].minor.yy376 = TK_BEFORE; }
162583 break;
162584 case 258: /* trigger_event ::= DELETE|INSERT */
162585 case 259: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==259);
162586 {yymsp[0].minor.yy262.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy262.b = 0;}
162587 break;
162588 case 260: /* trigger_event ::= UPDATE OF idlist */
162589 {yymsp[-2].minor.yy262.a = TK_UPDATE; yymsp[-2].minor.yy262.b = yymsp[0].minor.yy436;}
162590 break;
162591 case 261: /* when_clause ::= */
162592 case 280: /* key_opt ::= */ yytestcase(yyruleno==280);
162593 { yymsp[1].minor.yy404 = 0; }
162594 break;
162595 case 262: /* when_clause ::= WHEN expr */
162596 case 281: /* key_opt ::= KEY expr */ yytestcase(yyruleno==281);
162597 { yymsp[-1].minor.yy404 = yymsp[0].minor.yy404; }
162598 break;
162599 case 263: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
162600 {
162601 assert( yymsp[-2].minor.yy157!=0 );
162602 yymsp[-2].minor.yy157->pLast->pNext = yymsp[-1].minor.yy157;
162603 yymsp[-2].minor.yy157->pLast = yymsp[-1].minor.yy157;
162604 }
162605 break;
162606 case 264: /* trigger_cmd_list ::= trigger_cmd SEMI */
162607 {
162608 assert( yymsp[-1].minor.yy157!=0 );
162609 yymsp[-1].minor.yy157->pLast = yymsp[-1].minor.yy157;
162610 }
162611 break;
162612 case 265: /* trnm ::= nm DOT nm */
162613 {
162614 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
@@ -162049,62 +162630,62 @@
162630 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
162631 "within triggers");
162632 }
162633 break;
162634 case 268: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
162635 {yylhsminor.yy157 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy153, yymsp[-3].minor.yy70, yymsp[-1].minor.yy404, yymsp[-7].minor.yy376, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy504);}
162636 yymsp[-8].minor.yy157 = yylhsminor.yy157;
162637 break;
162638 case 269: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
162639 {
162640 yylhsminor.yy157 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy436,yymsp[-2].minor.yy81,yymsp[-6].minor.yy376,yymsp[-1].minor.yy190,yymsp[-7].minor.yy504,yymsp[0].minor.yy504);/*yylhsminor.yy157-overwrites-yymsp[-6].minor.yy376*/
162641 }
162642 yymsp[-7].minor.yy157 = yylhsminor.yy157;
162643 break;
162644 case 270: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
162645 {yylhsminor.yy157 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy404, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy504);}
162646 yymsp[-5].minor.yy157 = yylhsminor.yy157;
162647 break;
162648 case 271: /* trigger_cmd ::= scanpt select scanpt */
162649 {yylhsminor.yy157 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy81, yymsp[-2].minor.yy504, yymsp[0].minor.yy504); /*yylhsminor.yy157-overwrites-yymsp[-1].minor.yy81*/}
162650 yymsp[-2].minor.yy157 = yylhsminor.yy157;
162651 break;
162652 case 272: /* expr ::= RAISE LP IGNORE RP */
162653 {
162654 yymsp[-3].minor.yy404 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
162655 if( yymsp[-3].minor.yy404 ){
162656 yymsp[-3].minor.yy404->affExpr = OE_Ignore;
162657 }
162658 }
162659 break;
162660 case 273: /* expr ::= RAISE LP raisetype COMMA nm RP */
162661 {
162662 yymsp[-5].minor.yy404 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
162663 if( yymsp[-5].minor.yy404 ) {
162664 yymsp[-5].minor.yy404->affExpr = (char)yymsp[-3].minor.yy376;
162665 }
162666 }
162667 break;
162668 case 274: /* raisetype ::= ROLLBACK */
162669 {yymsp[0].minor.yy376 = OE_Rollback;}
162670 break;
162671 case 276: /* raisetype ::= FAIL */
162672 {yymsp[0].minor.yy376 = OE_Fail;}
162673 break;
162674 case 277: /* cmd ::= DROP TRIGGER ifexists fullname */
162675 {
162676 sqlite3DropTrigger(pParse,yymsp[0].minor.yy153,yymsp[-1].minor.yy376);
162677 }
162678 break;
162679 case 278: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
162680 {
162681 sqlite3Attach(pParse, yymsp[-3].minor.yy404, yymsp[-1].minor.yy404, yymsp[0].minor.yy404);
162682 }
162683 break;
162684 case 279: /* cmd ::= DETACH database_kw_opt expr */
162685 {
162686 sqlite3Detach(pParse, yymsp[0].minor.yy404);
162687 }
162688 break;
162689 case 282: /* cmd ::= REINDEX */
162690 {sqlite3Reindex(pParse, 0, 0);}
162691 break;
@@ -162117,11 +162698,11 @@
162698 case 285: /* cmd ::= ANALYZE nm dbnm */
162699 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
162700 break;
162701 case 286: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
162702 {
162703 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy153,&yymsp[0].minor.yy0);
162704 }
162705 break;
162706 case 287: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
162707 {
162708 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
@@ -162128,22 +162709,22 @@
162709 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
162710 }
162711 break;
162712 case 288: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
162713 {
162714 sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy153, &yymsp[0].minor.yy0);
162715 }
162716 break;
162717 case 289: /* add_column_fullname ::= fullname */
162718 {
162719 disableLookaside(pParse);
162720 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy153);
162721 }
162722 break;
162723 case 290: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
162724 {
162725 sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy153, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
162726 }
162727 break;
162728 case 291: /* cmd ::= create_vtab */
162729 {sqlite3VtabFinishParse(pParse,0);}
162730 break;
@@ -162150,11 +162731,11 @@
162731 case 292: /* cmd ::= create_vtab LP vtabarglist RP */
162732 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
162733 break;
162734 case 293: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
162735 {
162736 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy376);
162737 }
162738 break;
162739 case 294: /* vtabarg ::= */
162740 {sqlite3VtabArgInit(pParse);}
162741 break;
@@ -162163,176 +162744,180 @@
162744 case 297: /* lp ::= LP */ yytestcase(yyruleno==297);
162745 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
162746 break;
162747 case 298: /* with ::= WITH wqlist */
162748 case 299: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==299);
162749 { sqlite3WithPush(pParse, yymsp[0].minor.yy103, 1); }
162750 break;
162751 case 300: /* wqas ::= AS */
162752 {yymsp[0].minor.yy552 = M10d_Any;}
162753 break;
162754 case 301: /* wqas ::= AS MATERIALIZED */
162755 {yymsp[-1].minor.yy552 = M10d_Yes;}
162756 break;
162757 case 302: /* wqas ::= AS NOT MATERIALIZED */
162758 {yymsp[-2].minor.yy552 = M10d_No;}
162759 break;
162760 case 303: /* wqitem ::= nm eidlist_opt wqas LP select RP */
162761 {
162762 yymsp[-5].minor.yy329 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy70, yymsp[-1].minor.yy81, yymsp[-3].minor.yy552); /*A-overwrites-X*/
162763 }
162764 break;
162765 case 304: /* wqlist ::= wqitem */
162766 {
162767 yymsp[0].minor.yy103 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy329); /*A-overwrites-X*/
162768 }
162769 break;
162770 case 305: /* wqlist ::= wqlist COMMA wqitem */
162771 {
162772 yymsp[-2].minor.yy103 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy103, yymsp[0].minor.yy329);
162773 }
162774 break;
162775 case 306: /* windowdefn_list ::= windowdefn */
162776 { yylhsminor.yy49 = yymsp[0].minor.yy49; }
162777 yymsp[0].minor.yy49 = yylhsminor.yy49;
162778 break;
162779 case 307: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
162780 {
162781 assert( yymsp[0].minor.yy49!=0 );
162782 sqlite3WindowChain(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy49);
162783 yymsp[0].minor.yy49->pNextWin = yymsp[-2].minor.yy49;
162784 yylhsminor.yy49 = yymsp[0].minor.yy49;
162785 }
162786 yymsp[-2].minor.yy49 = yylhsminor.yy49;
162787 break;
162788 case 308: /* windowdefn ::= nm AS LP window RP */
162789 {
162790 if( ALWAYS(yymsp[-1].minor.yy49) ){
162791 yymsp[-1].minor.yy49->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
162792 }
162793 yylhsminor.yy49 = yymsp[-1].minor.yy49;
162794 }
162795 yymsp[-4].minor.yy49 = yylhsminor.yy49;
162796 break;
162797 case 309: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
162798 {
162799 yymsp[-4].minor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy70, yymsp[-1].minor.yy70, 0);
162800 }
162801 break;
162802 case 310: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
162803 {
162804 yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy70, yymsp[-1].minor.yy70, &yymsp[-5].minor.yy0);
162805 }
162806 yymsp[-5].minor.yy49 = yylhsminor.yy49;
162807 break;
162808 case 311: /* window ::= ORDER BY sortlist frame_opt */
162809 {
162810 yymsp[-3].minor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, yymsp[-1].minor.yy70, 0);
162811 }
162812 break;
162813 case 312: /* window ::= nm ORDER BY sortlist frame_opt */
162814 {
162815 yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, yymsp[-1].minor.yy70, &yymsp[-4].minor.yy0);
162816 }
162817 yymsp[-4].minor.yy49 = yylhsminor.yy49;
162818 break;
162819 case 313: /* window ::= frame_opt */
162820 case 332: /* filter_over ::= over_clause */ yytestcase(yyruleno==332);
162821 {
162822 yylhsminor.yy49 = yymsp[0].minor.yy49;
162823 }
162824 yymsp[0].minor.yy49 = yylhsminor.yy49;
162825 break;
162826 case 314: /* window ::= nm frame_opt */
162827 {
162828 yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, 0, &yymsp[-1].minor.yy0);
162829 }
162830 yymsp[-1].minor.yy49 = yylhsminor.yy49;
162831 break;
162832 case 315: /* frame_opt ::= */
162833 {
162834 yymsp[1].minor.yy49 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
162835 }
162836 break;
162837 case 316: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
162838 {
162839 yylhsminor.yy49 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy376, yymsp[-1].minor.yy117.eType, yymsp[-1].minor.yy117.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy552);
162840 }
162841 yymsp[-2].minor.yy49 = yylhsminor.yy49;
162842 break;
162843 case 317: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
162844 {
162845 yylhsminor.yy49 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy376, yymsp[-3].minor.yy117.eType, yymsp[-3].minor.yy117.pExpr, yymsp[-1].minor.yy117.eType, yymsp[-1].minor.yy117.pExpr, yymsp[0].minor.yy552);
162846 }
162847 yymsp[-5].minor.yy49 = yylhsminor.yy49;
162848 break;
162849 case 319: /* frame_bound_s ::= frame_bound */
162850 case 321: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==321);
162851 {yylhsminor.yy117 = yymsp[0].minor.yy117;}
162852 yymsp[0].minor.yy117 = yylhsminor.yy117;
162853 break;
162854 case 320: /* frame_bound_s ::= UNBOUNDED PRECEDING */
162855 case 322: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==322);
162856 case 324: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==324);
162857 {yylhsminor.yy117.eType = yymsp[-1].major; yylhsminor.yy117.pExpr = 0;}
162858 yymsp[-1].minor.yy117 = yylhsminor.yy117;
162859 break;
162860 case 323: /* frame_bound ::= expr PRECEDING|FOLLOWING */
162861 {yylhsminor.yy117.eType = yymsp[0].major; yylhsminor.yy117.pExpr = yymsp[-1].minor.yy404;}
162862 yymsp[-1].minor.yy117 = yylhsminor.yy117;
162863 break;
162864 case 325: /* frame_exclude_opt ::= */
162865 {yymsp[1].minor.yy552 = 0;}
162866 break;
162867 case 326: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
162868 {yymsp[-1].minor.yy552 = yymsp[0].minor.yy552;}
162869 break;
162870 case 327: /* frame_exclude ::= NO OTHERS */
162871 case 328: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==328);
162872 {yymsp[-1].minor.yy552 = yymsp[-1].major; /*A-overwrites-X*/}
162873 break;
162874 case 329: /* frame_exclude ::= GROUP|TIES */
162875 {yymsp[0].minor.yy552 = yymsp[0].major; /*A-overwrites-X*/}
162876 break;
162877 case 330: /* window_clause ::= WINDOW windowdefn_list */
162878 { yymsp[-1].minor.yy49 = yymsp[0].minor.yy49; }
162879 break;
162880 case 331: /* filter_over ::= filter_clause over_clause */
162881 {
162882 if( yymsp[0].minor.yy49 ){
162883 yymsp[0].minor.yy49->pFilter = yymsp[-1].minor.yy404;
162884 }else{
162885 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy404);
162886 }
162887 yylhsminor.yy49 = yymsp[0].minor.yy49;
162888 }
162889 yymsp[-1].minor.yy49 = yylhsminor.yy49;
162890 break;
162891 case 333: /* filter_over ::= filter_clause */
162892 {
162893 yylhsminor.yy49 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
162894 if( yylhsminor.yy49 ){
162895 yylhsminor.yy49->eFrmType = TK_FILTER;
162896 yylhsminor.yy49->pFilter = yymsp[0].minor.yy404;
162897 }else{
162898 sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy404);
162899 }
162900 }
162901 yymsp[0].minor.yy49 = yylhsminor.yy49;
162902 break;
162903 case 334: /* over_clause ::= OVER LP window RP */
162904 {
162905 yymsp[-3].minor.yy49 = yymsp[-1].minor.yy49;
162906 assert( yymsp[-3].minor.yy49!=0 );
162907 }
162908 break;
162909 case 335: /* over_clause ::= OVER nm */
162910 {
162911 yymsp[-1].minor.yy49 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
162912 if( yymsp[-1].minor.yy49 ){
162913 yymsp[-1].minor.yy49->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
162914 }
162915 }
162916 break;
162917 case 336: /* filter_clause ::= FILTER LP WHERE expr RP */
162918 { yymsp[-4].minor.yy404 = yymsp[-1].minor.yy404; }
162919 break;
162920 default:
162921 /* (337) input ::= cmdlist */ yytestcase(yyruleno==337);
162922 /* (338) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==338);
162923 /* (339) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=339);
@@ -162795,10 +163380,11 @@
163380 #define CC_TILDA 25 /* '~' */
163381 #define CC_DOT 26 /* '.' */
163382 #define CC_ID 27 /* unicode characters usable in IDs */
163383 #define CC_ILLEGAL 28 /* Illegal character */
163384 #define CC_NUL 29 /* 0x00 */
163385 #define CC_BOM 30 /* First byte of UTF8 BOM: 0xEF 0xBB 0xBF */
163386
163387 static const unsigned char aiClass[] = {
163388 #ifdef SQLITE_ASCII
163389 /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
163390 /* 0x */ 29, 28, 28, 28, 28, 28, 28, 28, 28, 7, 7, 28, 7, 7, 28, 28,
@@ -162807,18 +163393,18 @@
163393 /* 3x */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 19, 12, 14, 13, 6,
163394 /* 4x */ 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
163395 /* 5x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 9, 28, 28, 28, 2,
163396 /* 6x */ 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
163397 /* 7x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 28, 10, 28, 25, 28,
163398 /* 8x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
163399 /* 9x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
163400 /* Ax */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
163401 /* Bx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
163402 /* Cx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
163403 /* Dx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
163404 /* Ex */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 30,
163405 /* Fx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27
163406 #endif
163407 #ifdef SQLITE_EBCDIC
163408 /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
163409 /* 0x */ 29, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 7, 7, 28, 28,
163410 /* 1x */ 28, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
@@ -163757,10 +164343,18 @@
164343 ** SQL keywords start with the letter 'x'. Fall through */
164344 /* no break */ deliberate_fall_through
164345 }
164346 case CC_KYWD:
164347 case CC_ID: {
164348 i = 1;
164349 break;
164350 }
164351 case CC_BOM: {
164352 if( z[1]==0xbb && z[2]==0xbf ){
164353 *tokenType = TK_SPACE;
164354 return 3;
164355 }
164356 i = 1;
164357 break;
164358 }
164359 case CC_NUL: {
164360 *tokenType = TK_ILLEGAL;
@@ -164776,11 +165370,11 @@
165370 }
165371 if( rc==SQLITE_OK ){
165372 sqlite3GlobalConfig.isPCacheInit = 1;
165373 rc = sqlite3OsInit();
165374 }
165375 #ifndef SQLITE_OMIT_DESERIALIZE
165376 if( rc==SQLITE_OK ){
165377 rc = sqlite3MemdbInit();
165378 }
165379 #endif
165380 if( rc==SQLITE_OK ){
@@ -165191,16 +165785,16 @@
165785 sqlite3GlobalConfig.szSorterRef = (u32)iVal;
165786 break;
165787 }
165788 #endif /* SQLITE_ENABLE_SORTER_REFERENCES */
165789
165790 #ifndef SQLITE_OMIT_DESERIALIZE
165791 case SQLITE_CONFIG_MEMDB_MAXSIZE: {
165792 sqlite3GlobalConfig.mxMemdbSize = va_arg(ap, sqlite3_int64);
165793 break;
165794 }
165795 #endif /* SQLITE_OMIT_DESERIALIZE */
165796
165797 default: {
165798 rc = SQLITE_ERROR;
165799 break;
165800 }
@@ -165745,11 +166339,11 @@
166339 }
166340
166341 /*
166342 ** Two variations on the public interface for closing a database
166343 ** connection. The sqlite3_close() version returns SQLITE_BUSY and
166344 ** leaves the connection open if there are unfinalized prepared
166345 ** statements or unfinished sqlite3_backups. The sqlite3_close_v2()
166346 ** version forces the connection to become a zombie if there are
166347 ** unclosed resources, and arranges for deallocation when the last
166348 ** prepare statement or sqlite3_backup closes.
166349 */
@@ -166355,10 +166949,14 @@
166949 assert( !db->mallocFailed );
166950 return SQLITE_BUSY;
166951 }else{
166952 sqlite3ExpirePreparedStatements(db, 0);
166953 }
166954 }else if( xSFunc==0 && xFinal==0 ){
166955 /* Trying to delete a function that does not exist. This is a no-op.
166956 ** https://sqlite.org/forum/forumpost/726219164b */
166957 return SQLITE_OK;
166958 }
166959
166960 p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1);
166961 assert(p || db->mallocFailed);
166962 if( !p ){
@@ -168750,10 +169348,40 @@
169348 case 2: *ptr = sqlite3WhereTrace; break;
169349 case 3: sqlite3WhereTrace = *ptr; break;
169350 }
169351 break;
169352 }
169353
169354 #ifdef SQLITE_DEBUG
169355 /* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue)
169356 **
169357 ** If "id" is an integer between 1 and SQLITE_NTUNE then set the value
169358 ** of the id-th tuning parameter to *piValue. If "id" is between -1
169359 ** and -SQLITE_NTUNE, then write the current value of the (-id)-th
169360 ** tuning parameter into *piValue.
169361 **
169362 ** Tuning parameters are for use during transient development builds,
169363 ** to help find the best values for constants in the query planner.
169364 ** Access tuning parameters using the Tuning(ID) macro. Set the
169365 ** parameters in the CLI using ".testctrl tune ID VALUE".
169366 **
169367 ** Transient use only. Tuning parameters should not be used in
169368 ** checked-in code.
169369 */
169370 case SQLITE_TESTCTRL_TUNE: {
169371 int id = va_arg(ap, int);
169372 int *piValue = va_arg(ap, int*);
169373 if( id>0 && id<=SQLITE_NTUNE ){
169374 Tuning(id) = *piValue;
169375 }else if( id<0 && id>=-SQLITE_NTUNE ){
169376 *piValue = Tuning(-id);
169377 }else{
169378 rc = SQLITE_NOTFOUND;
169379 }
169380 break;
169381 }
169382 #endif
169383 }
169384 va_end(ap);
169385 #endif /* SQLITE_UNTESTABLE */
169386 return rc;
169387 }
@@ -172321,11 +172949,11 @@
172949 const char *zCsr = zNode; /* Cursor to iterate through node */
172950 const char *zEnd = &zCsr[nNode];/* End of interior node buffer */
172951 char *zBuffer = 0; /* Buffer to load terms into */
172952 i64 nAlloc = 0; /* Size of allocated buffer */
172953 int isFirstTerm = 1; /* True when processing first term on page */
172954 u64 iChild; /* Block id of child node to descend to */
172955 int nBuffer = 0; /* Total term size */
172956
172957 /* Skip over the 'height' varint that occurs at the start of every
172958 ** interior node. Then load the blockid of the left-child of the b-tree
172959 ** node into variable iChild.
@@ -172337,12 +172965,12 @@
172965 ** either more than 20 bytes of allocated space following the nNode bytes of
172966 ** contents, or two zero bytes. Or, if the node is read from the %_segments
172967 ** table, then there are always 20 bytes of zeroed padding following the
172968 ** nNode bytes of content (see sqlite3Fts3ReadBlock() for details).
172969 */
172970 zCsr += sqlite3Fts3GetVarintU(zCsr, &iChild);
172971 zCsr += sqlite3Fts3GetVarintU(zCsr, &iChild);
172972 if( zCsr>zEnd ){
172973 return FTS_CORRUPT_VTAB;
172974 }
172975
172976 while( zCsr<zEnd && (piFirst || piLast) ){
@@ -172391,24 +173019,24 @@
173019 ** If the interior node term is larger than the specified term, then
173020 ** the tree headed by iChild may contain the specified term.
173021 */
173022 cmp = memcmp(zTerm, zBuffer, (nBuffer>nTerm ? nTerm : nBuffer));
173023 if( piFirst && (cmp<0 || (cmp==0 && nBuffer>nTerm)) ){
173024 *piFirst = (i64)iChild;
173025 piFirst = 0;
173026 }
173027
173028 if( piLast && cmp<0 ){
173029 *piLast = (i64)iChild;
173030 piLast = 0;
173031 }
173032
173033 iChild++;
173034 };
173035
173036 if( piFirst ) *piFirst = (i64)iChild;
173037 if( piLast ) *piLast = (i64)iChild;
173038
173039 finish_scan:
173040 sqlite3_free(zBuffer);
173041 return rc;
173042 }
@@ -175552,20 +176180,19 @@
176180
176181 /* Determine which, if any, tokens in the expression should be deferred. */
176182 #ifndef SQLITE_DISABLE_FTS4_DEFERRED
176183 if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){
176184 Fts3TokenAndCost *aTC;
 
176185 aTC = (Fts3TokenAndCost *)sqlite3_malloc64(
176186 sizeof(Fts3TokenAndCost) * nToken
176187 + sizeof(Fts3Expr *) * nOr * 2
176188 );
 
176189
176190 if( !aTC ){
176191 rc = SQLITE_NOMEM;
176192 }else{
176193 Fts3Expr **apOr = (Fts3Expr **)&aTC[nToken];
176194 int ii;
176195 Fts3TokenAndCost *pTC = aTC;
176196 Fts3Expr **ppOr = apOr;
176197
176198 fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);
@@ -176937,10 +177564,11 @@
177564 /* In case this cursor is being reused, close and zero it. */
177565 testcase(pCsr->filter.zTerm);
177566 sqlite3Fts3SegReaderFinish(&pCsr->csr);
177567 sqlite3_free((void *)pCsr->filter.zTerm);
177568 sqlite3_free(pCsr->aStat);
177569 sqlite3_free(pCsr->zStop);
177570 memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr);
177571
177572 pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;
177573 if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN;
177574
@@ -182458,11 +183086,11 @@
183086 rc = (pLhs->aNode==0) - (pRhs->aNode==0);
183087 }
183088 if( rc==0 ){
183089 rc = pRhs->iIdx - pLhs->iIdx;
183090 }
183091 assert_fts3_nc( rc!=0 );
183092 return rc;
183093 }
183094
183095 /*
183096 ** A different comparison function for SegReader structures. In this
@@ -182654,12 +183282,12 @@
183282 int nPrev, /* Size of buffer zPrev in bytes */
183283 const char *zNext, /* Buffer containing next term */
183284 int nNext /* Size of buffer zNext in bytes */
183285 ){
183286 int n;
183287 for(n=0; n<nPrev && n<nNext && zPrev[n]==zNext[n]; n++);
183288 assert_fts3_nc( n<nNext );
183289 return n;
183290 }
183291
183292 /*
183293 ** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger
@@ -183654,11 +184282,11 @@
184282 iDelta = (i64)((u64)iDocid - (u64)iPrev);
184283 }
184284
184285 nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
184286
184287 rc = fts3GrowSegReaderBuffer(pCsr, nByte+nDoclist+FTS3_NODE_PADDING);
184288 if( rc ) return rc;
184289
184290 if( isFirst ){
184291 char *a = &pCsr->aBuffer[nDoclist];
184292 int nWrite;
@@ -186468,10 +187096,14 @@
187096 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
187097
187098 /* #include <string.h> */
187099 /* #include <assert.h> */
187100
187101 #ifndef SQLITE_AMALGAMATION
187102 typedef sqlite3_int64 i64;
187103 #endif
187104
187105 /*
187106 ** Characters that may appear in the second argument to matchinfo().
187107 */
187108 #define FTS3_MATCHINFO_NPHRASE 'p' /* 1 value */
187109 #define FTS3_MATCHINFO_NCOL 'c' /* 1 value */
@@ -186518,13 +187150,13 @@
187150 };
187151
187152 struct SnippetPhrase {
187153 int nToken; /* Number of tokens in phrase */
187154 char *pList; /* Pointer to start of phrase position list */
187155 i64 iHead; /* Next value in position list */
187156 char *pHead; /* Position list data following iHead */
187157 i64 iTail; /* Next value in trailing position list */
187158 char *pTail; /* Position list data following iTail */
187159 };
187160
187161 struct SnippetFragment {
187162 int iCol; /* Column snippet is extracted from */
@@ -186685,11 +187317,11 @@
187317 ** When this function is called, *pp points to the start of an element of
187318 ** the list. *piPos contains the value of the previous entry in the list.
187319 ** After it returns, *piPos contains the value of the next element of the
187320 ** list and *pp is advanced to the following varint.
187321 */
187322 static void fts3GetDeltaPosition(char **pp, i64 *piPos){
187323 int iVal;
187324 *pp += fts3GetVarint32(*pp, &iVal);
187325 *piPos += (iVal-2);
187326 }
187327
@@ -186794,14 +187426,14 @@
187426 /*
187427 ** Advance the position list iterator specified by the first two
187428 ** arguments so that it points to the first element with a value greater
187429 ** than or equal to parameter iNext.
187430 */
187431 static void fts3SnippetAdvance(char **ppIter, i64 *piIter, int iNext){
187432 char *pIter = *ppIter;
187433 if( pIter ){
187434 i64 iIter = *piIter;
187435
187436 while( iIter<iNext ){
187437 if( 0==(*pIter & 0xFE) ){
187438 iIter = -1;
187439 pIter = 0;
@@ -186880,11 +187512,11 @@
187512
187513 for(i=0; i<pIter->nPhrase; i++){
187514 SnippetPhrase *pPhrase = &pIter->aPhrase[i];
187515 if( pPhrase->pTail ){
187516 char *pCsr = pPhrase->pTail;
187517 i64 iCsr = pPhrase->iTail;
187518
187519 while( iCsr<(iStart+pIter->nSnippet) && iCsr>=iStart ){
187520 int j;
187521 u64 mPhrase = (u64)1 << (i%64);
187522 u64 mPos = (u64)1 << (iCsr - iStart);
@@ -186926,11 +187558,11 @@
187558
187559 pPhrase->nToken = pExpr->pPhrase->nToken;
187560 rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr);
187561 assert( rc==SQLITE_OK || pCsr==0 );
187562 if( pCsr ){
187563 i64 iFirst = 0;
187564 pPhrase->pList = pCsr;
187565 fts3GetDeltaPosition(&pCsr, &iFirst);
187566 if( iFirst<0 ){
187567 rc = FTS_CORRUPT_VTAB;
187568 }else{
@@ -187990,12 +188622,12 @@
188622 typedef struct TermOffset TermOffset;
188623 typedef struct TermOffsetCtx TermOffsetCtx;
188624
188625 struct TermOffset {
188626 char *pList; /* Position-list */
188627 i64 iPos; /* Position just read from pList */
188628 i64 iOff; /* Offset of this term from read positions */
188629 };
188630
188631 struct TermOffsetCtx {
188632 Fts3Cursor *pCsr;
188633 int iCol; /* Column of table to populate aTerm for */
@@ -188010,11 +188642,11 @@
188642 static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){
188643 TermOffsetCtx *p = (TermOffsetCtx *)ctx;
188644 int nTerm; /* Number of tokens in phrase */
188645 int iTerm; /* For looping through nTerm phrase terms */
188646 char *pList; /* Pointer to position list for phrase */
188647 i64 iPos = 0; /* First position in position-list */
188648 int rc;
188649
188650 UNUSED_PARAMETER(iPhrase);
188651 rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pList);
188652 nTerm = pExpr->pPhrase->nToken;
@@ -189287,11 +189919,11 @@
189919 ** any double-quotes or backslash characters contained within the
189920 ** string.
189921 */
189922 static void jsonAppendString(JsonString *p, const char *zIn, u32 N){
189923 u32 i;
189924 if( zIn==0 || ((N+p->nUsed+2 >= p->nAlloc) && jsonGrow(p,N+2)!=0) ) return;
189925 p->zBuf[p->nUsed++] = '"';
189926 for(i=0; i<N; i++){
189927 unsigned char c = ((unsigned const char*)zIn)[i];
189928 if( c=='"' || c=='\\' ){
189929 json_simple_escape:
@@ -190886,12 +191518,12 @@
191518 if( pStr->zBuf==0 ){
191519 jsonInit(pStr, ctx);
191520 jsonAppendChar(pStr, '[');
191521 }else if( pStr->nUsed>1 ){
191522 jsonAppendChar(pStr, ',');
 
191523 }
191524 pStr->pCtx = ctx;
191525 jsonAppendValue(pStr, argv[0]);
191526 }
191527 }
191528 static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){
191529 JsonString *pStr;
@@ -190947,26 +191579,27 @@
191579 /* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will
191580 ** always have been called to initalize it */
191581 if( NEVER(!pStr) ) return;
191582 #endif
191583 z = pStr->zBuf;
191584 for(i=1; i<pStr->nUsed && ((c = z[i])!=',' || inStr || nNest); i++){
 
 
 
 
191585 if( c=='"' ){
191586 inStr = !inStr;
191587 }else if( c=='\\' ){
191588 i++;
191589 }else if( !inStr ){
191590 if( c=='{' || c=='[' ) nNest++;
191591 if( c=='}' || c==']' ) nNest--;
191592 }
191593 }
191594 if( i<pStr->nUsed ){
191595 pStr->nUsed -= i;
191596 memmove(&z[1], &z[i+1], (size_t)pStr->nUsed-1);
191597 z[pStr->nUsed] = 0;
191598 }else{
191599 pStr->nUsed = 1;
191600 }
191601 }
191602 #else
191603 # define jsonGroupInverse 0
191604 #endif
191605
@@ -190990,12 +191623,12 @@
191623 if( pStr->zBuf==0 ){
191624 jsonInit(pStr, ctx);
191625 jsonAppendChar(pStr, '{');
191626 }else if( pStr->nUsed>1 ){
191627 jsonAppendChar(pStr, ',');
 
191628 }
191629 pStr->pCtx = ctx;
191630 z = (const char*)sqlite3_value_text(argv[0]);
191631 n = (u32)sqlite3_value_bytes(argv[0]);
191632 jsonAppendString(pStr, z, n);
191633 jsonAppendChar(pStr, ':');
191634 jsonAppendValue(pStr, argv[1]);
@@ -195512,15 +196145,20 @@
196145 */
196146 static void rtreedepth(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){
196147 UNUSED_PARAMETER(nArg);
196148 if( sqlite3_value_type(apArg[0])!=SQLITE_BLOB
196149 || sqlite3_value_bytes(apArg[0])<2
196150
196151 ){
196152 sqlite3_result_error(ctx, "Invalid argument to rtreedepth()", -1);
196153 }else{
196154 u8 *zBlob = (u8 *)sqlite3_value_blob(apArg[0]);
196155 if( zBlob ){
196156 sqlite3_result_int(ctx, readInt16(zBlob));
196157 }else{
196158 sqlite3_result_error_nomem(ctx);
196159 }
196160 }
196161 }
196162
196163 /*
196164 ** Context object passed between the various routines that make up the
@@ -201039,11 +201677,13 @@
201677 );
201678 if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSel) ){
201679 zSep = "";
201680 for(iCol=0; iCol<pIter->nCol; iCol++){
201681 const char *zQuoted = (const char*)sqlite3_column_text(pSel, iCol);
201682 if( zQuoted==0 ){
201683 p->rc = SQLITE_NOMEM;
201684 }else if( zQuoted[0]=='N' ){
201685 bFailed = 1;
201686 break;
201687 }
201688 zVector = rbuMPrintf(p, "%z%s%s", zVector, zSep, zQuoted);
201689 zSep = ", ";
@@ -204411,32 +205051,18 @@
205051 }
205052 else if( flags & SQLITE_OPEN_WAL ){
205053 rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName, 0);
205054 if( pDb ){
205055 if( pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){
205056 /* This call is to open a *-wal file. Intead, open the *-oal. */
205057 size_t nOpen;
 
 
 
 
 
205058 if( rbuIsVacuum(pDb->pRbu) ){
205059 zOpen = sqlite3_db_filename(pDb->pRbu->dbRbu, "main");
205060 zOpen = sqlite3_filename_wal(zOpen);
205061 }
205062 nOpen = strlen(zOpen);
205063 ((char*)zOpen)[nOpen-3] = 'o';
 
 
 
 
 
 
 
 
 
205064 pFd->pRbu = pDb->pRbu;
205065 }
205066 pDb->pWalFd = pFd;
205067 }
205068 }
@@ -206045,17 +206671,19 @@
206671 ** Session handle structure.
206672 */
206673 struct sqlite3_session {
206674 sqlite3 *db; /* Database handle session is attached to */
206675 char *zDb; /* Name of database session is attached to */
206676 int bEnableSize; /* True if changeset_size() enabled */
206677 int bEnable; /* True if currently recording */
206678 int bIndirect; /* True if all changes are indirect */
206679 int bAutoAttach; /* True to auto-attach tables */
206680 int rc; /* Non-zero if an error has occurred */
206681 void *pFilterCtx; /* First argument to pass to xTableFilter */
206682 int (*xTableFilter)(void *pCtx, const char *zTab);
206683 i64 nMalloc; /* Number of bytes of data allocated */
206684 i64 nMaxChangesetSize;
206685 sqlite3_value *pZeroBlob; /* Value containing X'' */
206686 sqlite3_session *pNext; /* Next session object on same db. */
206687 SessionTable *pTable; /* List of attached tables */
206688 SessionHook hook; /* APIs to grab new and old data with */
206689 };
@@ -206294,12 +206922,13 @@
206922 /*
206923 ** For each row modified during a session, there exists a single instance of
206924 ** this structure stored in a SessionTable.aChange[] hash table.
206925 */
206926 struct SessionChange {
206927 u8 op; /* One of UPDATE, DELETE, INSERT */
206928 u8 bIndirect; /* True if this change is "indirect" */
206929 int nMaxSize; /* Max size of eventual changeset record */
206930 int nRecord; /* Number of bytes in buffer aRecord[] */
206931 u8 *aRecord; /* Buffer containing old.* record */
206932 SessionChange *pNext; /* For hash-table collisions */
206933 };
206934
@@ -207124,10 +207753,16 @@
207753 }
207754 }
207755 if( 0==sqlite3_stricmp("sqlite_stat1", pTab->zName) ){
207756 pTab->bStat1 = 1;
207757 }
207758
207759 if( pSession->bEnableSize ){
207760 pSession->nMaxChangesetSize += (
207761 1 + sessionVarintLen(pTab->nCol) + pTab->nCol + strlen(pTab->zName)+1
207762 );
207763 }
207764 }
207765 }
207766 return (pSession->rc || pTab->abPK==0);
207767 }
207768
@@ -207169,10 +207804,107 @@
207804 static int sessionStat1Depth(void *pCtx){
207805 SessionStat1Ctx *p = (SessionStat1Ctx*)pCtx;
207806 return p->hook.xDepth(p->hook.pCtx);
207807 }
207808
207809 static int sessionUpdateMaxSize(
207810 int op,
207811 sqlite3_session *pSession, /* Session object pTab is attached to */
207812 SessionTable *pTab, /* Table that change applies to */
207813 SessionChange *pC /* Update pC->nMaxSize */
207814 ){
207815 i64 nNew = 2;
207816 if( pC->op==SQLITE_INSERT ){
207817 if( op!=SQLITE_DELETE ){
207818 int ii;
207819 for(ii=0; ii<pTab->nCol; ii++){
207820 sqlite3_value *p = 0;
207821 pSession->hook.xNew(pSession->hook.pCtx, ii, &p);
207822 sessionSerializeValue(0, p, &nNew);
207823 }
207824 }
207825 }else if( op==SQLITE_DELETE ){
207826 nNew += pC->nRecord;
207827 if( sqlite3_preupdate_blobwrite(pSession->db)>=0 ){
207828 nNew += pC->nRecord;
207829 }
207830 }else{
207831 int ii;
207832 u8 *pCsr = pC->aRecord;
207833 for(ii=0; ii<pTab->nCol; ii++){
207834 int bChanged = 1;
207835 int nOld = 0;
207836 int eType;
207837 sqlite3_value *p = 0;
207838 pSession->hook.xNew(pSession->hook.pCtx, ii, &p);
207839 if( p==0 ){
207840 return SQLITE_NOMEM;
207841 }
207842
207843 eType = *pCsr++;
207844 switch( eType ){
207845 case SQLITE_NULL:
207846 bChanged = sqlite3_value_type(p)!=SQLITE_NULL;
207847 break;
207848
207849 case SQLITE_FLOAT:
207850 case SQLITE_INTEGER: {
207851 if( eType==sqlite3_value_type(p) ){
207852 sqlite3_int64 iVal = sessionGetI64(pCsr);
207853 if( eType==SQLITE_INTEGER ){
207854 bChanged = (iVal!=sqlite3_value_int64(p));
207855 }else{
207856 double dVal;
207857 memcpy(&dVal, &iVal, 8);
207858 bChanged = (dVal!=sqlite3_value_double(p));
207859 }
207860 }
207861 nOld = 8;
207862 pCsr += 8;
207863 break;
207864 }
207865
207866 default: {
207867 int nByte;
207868 nOld = sessionVarintGet(pCsr, &nByte);
207869 pCsr += nOld;
207870 nOld += nByte;
207871 assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB );
207872 if( eType==sqlite3_value_type(p)
207873 && nByte==sqlite3_value_bytes(p)
207874 && (nByte==0 || 0==memcmp(pCsr, sqlite3_value_blob(p), nByte))
207875 ){
207876 bChanged = 0;
207877 }
207878 pCsr += nByte;
207879 break;
207880 }
207881 }
207882
207883 if( bChanged && pTab->abPK[ii] ){
207884 nNew = pC->nRecord + 2;
207885 break;
207886 }
207887
207888 if( bChanged ){
207889 nNew += 1 + nOld;
207890 sessionSerializeValue(0, p, &nNew);
207891 }else if( pTab->abPK[ii] ){
207892 nNew += 2 + nOld;
207893 }else{
207894 nNew += 2;
207895 }
207896 }
207897 }
207898
207899 if( nNew>pC->nMaxSize ){
207900 int nIncr = nNew - pC->nMaxSize;
207901 pC->nMaxSize = nNew;
207902 pSession->nMaxChangesetSize += nIncr;
207903 }
207904 return SQLITE_OK;
207905 }
207906
207907 /*
207908 ** This function is only called from with a pre-update-hook reporting a
207909 ** change on table pTab (attached to session pSession). The type of change
207910 ** (UPDATE, INSERT, DELETE) is specified by the first argument.
@@ -207242,11 +207974,10 @@
207974
207975 if( pC==0 ){
207976 /* Create a new change object containing all the old values (if
207977 ** this is an SQLITE_UPDATE or SQLITE_DELETE), or just the PK
207978 ** values (if this is an INSERT). */
 
207979 sqlite3_int64 nByte; /* Number of bytes to allocate */
207980 int i; /* Used to iterate through columns */
207981
207982 assert( rc==SQLITE_OK );
207983 pTab->nEntry++;
@@ -207268,17 +207999,17 @@
207999 rc = sessionSerializeValue(0, p, &nByte);
208000 if( rc!=SQLITE_OK ) goto error_out;
208001 }
208002
208003 /* Allocate the change object */
208004 pC = (SessionChange *)sessionMalloc64(pSession, nByte);
208005 if( !pC ){
208006 rc = SQLITE_NOMEM;
208007 goto error_out;
208008 }else{
208009 memset(pC, 0, sizeof(SessionChange));
208010 pC->aRecord = (u8 *)&pC[1];
208011 }
208012
208013 /* Populate the change object. None of the preupdate_old(),
208014 ** preupdate_new() or SerializeValue() calls below may fail as all
208015 ** required values and encodings have already been cached in memory.
@@ -207289,21 +208020,21 @@
208020 if( op!=SQLITE_INSERT ){
208021 pSession->hook.xOld(pSession->hook.pCtx, i, &p);
208022 }else if( pTab->abPK[i] ){
208023 pSession->hook.xNew(pSession->hook.pCtx, i, &p);
208024 }
208025 sessionSerializeValue(&pC->aRecord[nByte], p, &nByte);
208026 }
208027
208028 /* Add the change to the hash-table */
208029 if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){
208030 pC->bIndirect = 1;
208031 }
208032 pC->nRecord = nByte;
208033 pC->op = op;
208034 pC->pNext = pTab->apChange[iHash];
208035 pTab->apChange[iHash] = pC;
208036
208037 }else if( pC->bIndirect ){
208038 /* If the existing change is considered "indirect", but this current
208039 ** change is "direct", mark the change object as direct. */
208040 if( pSession->hook.xDepth(pSession->hook.pCtx)==0
@@ -207310,11 +208041,17 @@
208041 && pSession->bIndirect==0
208042 ){
208043 pC->bIndirect = 0;
208044 }
208045 }
208046
208047 assert( rc==SQLITE_OK );
208048 if( pSession->bEnableSize ){
208049 rc = sessionUpdateMaxSize(op, pSession, pTab, pC);
208050 }
208051 }
208052
208053
208054 /* If an error has occurred, mark the session object as failed. */
208055 error_out:
208056 if( pTab->bStat1 ){
208057 pSession->hook = stat1.hook;
@@ -207866,17 +208603,33 @@
208603 ** If not, use sqlite3_realloc() to grow the buffer so that there is.
208604 **
208605 ** If successful, return zero. Otherwise, if an OOM condition is encountered,
208606 ** set *pRc to SQLITE_NOMEM and return non-zero.
208607 */
208608 static int sessionBufferGrow(SessionBuffer *p, i64 nByte, int *pRc){
208609 #define SESSION_MAX_BUFFER_SZ (0x7FFFFF00 - 1)
208610 i64 nReq = p->nBuf + nByte;
208611 if( *pRc==SQLITE_OK && nReq>p->nAlloc ){
208612 u8 *aNew;
208613 i64 nNew = p->nAlloc ? p->nAlloc : 128;
208614
208615 do {
208616 nNew = nNew*2;
208617 }while( nNew<nReq );
208618
208619 /* The value of SESSION_MAX_BUFFER_SZ is copied from the implementation
208620 ** of sqlite3_realloc64(). Allocations greater than this size in bytes
208621 ** always fail. It is used here to ensure that this routine can always
208622 ** allocate up to this limit - instead of up to the largest power of
208623 ** two smaller than the limit. */
208624 if( nNew>SESSION_MAX_BUFFER_SZ ){
208625 nNew = SESSION_MAX_BUFFER_SZ;
208626 if( nNew<nReq ){
208627 *pRc = SQLITE_NOMEM;
208628 return 1;
208629 }
208630 }
208631
208632 aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew);
208633 if( 0==aNew ){
208634 *pRc = SQLITE_NOMEM;
208635 }else{
@@ -208523,11 +209276,15 @@
209276 SQLITE_API int sqlite3session_changeset(
209277 sqlite3_session *pSession, /* Session object */
209278 int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
209279 void **ppChangeset /* OUT: Buffer containing changeset */
209280 ){
209281 int rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset,ppChangeset);
209282 assert( rc || pnChangeset==0
209283 || pSession->bEnableSize==0 || *pnChangeset<=pSession->nMaxChangesetSize
209284 );
209285 return rc;
209286 }
209287
209288 /*
209289 ** Streaming version of sqlite3session_changeset().
209290 */
@@ -208614,10 +209371,43 @@
209371 ** Return the amount of heap memory in use.
209372 */
209373 SQLITE_API sqlite3_int64 sqlite3session_memory_used(sqlite3_session *pSession){
209374 return pSession->nMalloc;
209375 }
209376
209377 /*
209378 ** Configure the session object passed as the first argument.
209379 */
209380 SQLITE_API int sqlite3session_object_config(sqlite3_session *pSession, int op, void *pArg){
209381 int rc = SQLITE_OK;
209382 switch( op ){
209383 case SQLITE_SESSION_OBJCONFIG_SIZE: {
209384 int iArg = *(int*)pArg;
209385 if( iArg>=0 ){
209386 if( pSession->pTable ){
209387 rc = SQLITE_MISUSE;
209388 }else{
209389 pSession->bEnableSize = (iArg!=0);
209390 }
209391 }
209392 *(int*)pArg = pSession->bEnableSize;
209393 break;
209394 }
209395
209396 default:
209397 rc = SQLITE_MISUSE;
209398 }
209399
209400 return rc;
209401 }
209402
209403 /*
209404 ** Return the maximum size of sqlite3session_changeset() output.
209405 */
209406 SQLITE_API sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession){
209407 return pSession->nMaxChangesetSize;
209408 }
209409
209410 /*
209411 ** Do the work for either sqlite3changeset_start() or start_strm().
209412 */
209413 static int sessionChangesetStart(
@@ -215435,10 +216225,11 @@
216225 return 1;
216226 }else{
216227 i64 iOff = *piOff;
216228 int iVal;
216229 fts5FastGetVarint32(a, i, iVal);
216230 assert( iVal>=0 );
216231 if( iVal<=1 ){
216232 if( iVal==0 ){
216233 *pi = i;
216234 return 0;
216235 }
@@ -215448,13 +216239,16 @@
216239 if( iVal<2 ){
216240 /* This is a corrupt record. So stop parsing it here. */
216241 *piOff = -1;
216242 return 1;
216243 }
216244 *piOff = iOff + ((iVal-2) & 0x7FFFFFFF);
216245 }else{
216246 *piOff = (iOff & (i64)0x7FFFFFFF<<32)+((iOff + (iVal-2)) & 0x7FFFFFFF);
216247 }
 
216248 *pi = i;
216249 assert( *piOff>=iOff );
216250 return 0;
216251 }
216252 }
216253
216254
@@ -215489,18 +216283,20 @@
216283 static void sqlite3Fts5PoslistSafeAppend(
216284 Fts5Buffer *pBuf,
216285 i64 *piPrev,
216286 i64 iPos
216287 ){
216288 if( iPos>=*piPrev ){
216289 static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32;
216290 if( (iPos & colmask) != (*piPrev & colmask) ){
216291 pBuf->p[pBuf->n++] = 1;
216292 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32));
216293 *piPrev = (iPos & colmask);
216294 }
216295 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2);
216296 *piPrev = iPos;
216297 }
216298 }
216299
216300 static int sqlite3Fts5PoslistWriterAppend(
216301 Fts5Buffer *pBuf,
216302 Fts5PoslistWriter *pWriter,
@@ -216198,11 +216994,11 @@
216994 pRet->db = db;
216995 pRet->iCookie = -1;
216996
216997 nByte = nArg * (sizeof(char*) + sizeof(u8));
216998 pRet->azCol = (char**)sqlite3Fts5MallocZero(&rc, nByte);
216999 pRet->abUnindexed = pRet->azCol ? (u8*)&pRet->azCol[nArg] : 0;
217000 pRet->zDb = sqlite3Fts5Strndup(&rc, azArg[1], -1);
217001 pRet->zName = sqlite3Fts5Strndup(&rc, azArg[2], -1);
217002 pRet->bColumnsize = 1;
217003 pRet->eDetail = FTS5_DETAIL_FULL;
217004 #ifdef SQLITE_DEBUG
@@ -219034,10 +219830,11 @@
219830 }
219831
219832 return pRet;
219833 }
219834
219835 #ifdef SQLITE_TEST
219836 static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){
219837 sqlite3_int64 nByte = 0;
219838 Fts5ExprTerm *p;
219839 char *zQuoted;
219840
@@ -219400,16 +220197,18 @@
220197 iCode = sqlite3_value_int(apVal[0]);
220198 if( nArg==2 ) bRemoveDiacritics = sqlite3_value_int(apVal[1]);
220199 sqlite3_result_int(pCtx, sqlite3Fts5UnicodeFold(iCode, bRemoveDiacritics));
220200 }
220201 }
220202 #endif /* ifdef SQLITE_TEST */
220203
220204 /*
220205 ** This is called during initialization to register the fts5_expr() scalar
220206 ** UDF with the SQLite handle passed as the only argument.
220207 */
220208 static int sqlite3Fts5ExprInit(Fts5Global *pGlobal, sqlite3 *db){
220209 #ifdef SQLITE_TEST
220210 struct Fts5ExprFunc {
220211 const char *z;
220212 void (*x)(sqlite3_context*,int,sqlite3_value**);
220213 } aFunc[] = {
220214 { "fts5_expr", fts5ExprFunctionHr },
@@ -219423,10 +220222,14 @@
220222
220223 for(i=0; rc==SQLITE_OK && i<ArraySize(aFunc); i++){
220224 struct Fts5ExprFunc *p = &aFunc[i];
220225 rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0);
220226 }
220227 #else
220228 int rc = SQLITE_OK;
220229 UNUSED_PARAM2(pGlobal,db);
220230 #endif
220231
220232 /* Avoid warnings indicating that sqlite3Fts5ParserTrace() and
220233 ** sqlite3Fts5ParserFallback() are unused */
220234 #ifndef NDEBUG
220235 (void)sqlite3Fts5ParserTrace;
@@ -220669,11 +221472,11 @@
221472 Fts5StructureSegment *pSeg; /* Segment to iterate through */
221473 int flags; /* Mask of configuration flags */
221474 int iLeafPgno; /* Current leaf page number */
221475 Fts5Data *pLeaf; /* Current leaf data */
221476 Fts5Data *pNextLeaf; /* Leaf page (iLeafPgno+1) */
221477 i64 iLeafOffset; /* Byte offset within current leaf */
221478
221479 /* Next method */
221480 void (*xNext)(Fts5Index*, Fts5SegIter*, int*);
221481
221482 /* The page and offset from which the current term was read. The offset
@@ -221849,11 +222652,11 @@
222652 }
222653 }
222654
222655 static void fts5SegIterLoadRowid(Fts5Index *p, Fts5SegIter *pIter){
222656 u8 *a = pIter->pLeaf->p; /* Buffer to read data from */
222657 i64 iOff = pIter->iLeafOffset;
222658
222659 ASSERT_SZLEAF_OK(pIter->pLeaf);
222660 if( iOff>=pIter->pLeaf->szLeaf ){
222661 fts5SegIterNextPage(p, pIter);
222662 if( pIter->pLeaf==0 ){
@@ -221882,11 +222685,11 @@
222685 ** the first position list. The position list belonging to document
222686 ** (Fts5SegIter.iRowid).
222687 */
222688 static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){
222689 u8 *a = pIter->pLeaf->p; /* Buffer to read data from */
222690 i64 iOff = pIter->iLeafOffset; /* Offset to read at */
222691 int nNew; /* Bytes of new data */
222692
222693 iOff += fts5GetVarint32(&a[iOff], nNew);
222694 if( iOff+nNew>pIter->pLeaf->szLeaf || nKeep>pIter->term.n || nNew==0 ){
222695 p->rc = FTS5_CORRUPT;
@@ -222310,11 +223113,10 @@
223113 }else{
223114 /* The following could be done by calling fts5SegIterLoadNPos(). But
223115 ** this block is particularly performance critical, so equivalent
223116 ** code is inlined. */
223117 int nSz;
 
223118 assert_nc( pIter->iLeafOffset<=pIter->pLeaf->nn );
223119 fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz);
223120 pIter->bDel = (nSz & 0x0001);
223121 pIter->nPos = nSz>>1;
223122 assert_nc( pIter->nPos>=0 );
@@ -223422,11 +224224,11 @@
224224 pIter->base.nData = p-aCopy;
224225 return;
224226 }
224227 fts5BufferSafeAppendBlob(&pIter->poslist, aCopy, p-aCopy);
224228 }
224229 if( p>=pEnd ){
224230 pIter->base.pData = pIter->poslist.p;
224231 pIter->base.nData = pIter->poslist.n;
224232 return;
224233 }
224234 aCopy = p++;
@@ -224779,18 +225581,18 @@
225581 if( pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){
225582 /* The entire doclist will fit on the current leaf. */
225583 fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist);
225584 }else{
225585 i64 iRowid = 0;
225586 u64 iDelta = 0;
225587 int iOff = 0;
225588
225589 /* The entire doclist will not fit on this leaf. The following
225590 ** loop iterates through the poslists that make up the current
225591 ** doclist. */
225592 while( p->rc==SQLITE_OK && iOff<nDoclist ){
225593 iOff += fts5GetVarint(&pDoclist[iOff], &iDelta);
225594 iRowid += iDelta;
225595
225596 if( writer.bFirstRowidInPage ){
225597 fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */
225598 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);
@@ -225218,11 +226020,11 @@
226020 Fts5Buffer *p1, /* First list to merge */
226021 int nBuf, /* Number of buffers in array aBuf[] */
226022 Fts5Buffer *aBuf /* Other lists to merge in */
226023 ){
226024 #define fts5PrefixMergerNextPosition(p) \
226025 sqlite3Fts5PoslistNext64((p)->aPos,(p)->iter.nPoslist,&(p)->iOff,&(p)->iPos)
226026 #define FTS5_MERGE_NLIST 16
226027 PrefixMerger aMerger[FTS5_MERGE_NLIST];
226028 PrefixMerger *pHead = 0;
226029 int i;
226030 int nOut = 0;
@@ -225317,11 +226119,12 @@
226119 sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, pHead->iPos);
226120 }
226121 nTail = pHead->iter.nPoslist - pHead->iOff;
226122
226123 /* WRITEPOSLISTSIZE */
226124 assert_nc( tmp.n+nTail<=nTmp );
226125 assert( tmp.n+nTail<=nTmp+nMerge*10 );
226126 if( tmp.n+nTail>nTmp-FTS5_DATA_ZERO_PADDING ){
226127 if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT;
226128 break;
226129 }
226130 fts5BufferSafeAppendVarint(&out, (tmp.n+nTail) * 2);
@@ -226958,10 +227761,11 @@
227761 );
227762 }
227763 return rc;
227764 #else
227765 return SQLITE_OK;
227766 UNUSED_PARAM(db);
227767 #endif
227768 }
227769
227770
227771 static int sqlite3Fts5IndexReset(Fts5Index *p){
@@ -228921,17 +229725,19 @@
229725 }
229726 if( iBest<0 ) break;
229727
229728 nInst++;
229729 if( nInst>=pCsr->nInstAlloc ){
229730 int nNewSize = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32;
229731 aInst = (int*)sqlite3_realloc64(
229732 pCsr->aInst, nNewSize*sizeof(int)*3
229733 );
229734 if( aInst ){
229735 pCsr->aInst = aInst;
229736 pCsr->nInstAlloc = nNewSize;
229737 }else{
229738 nInst--;
229739 rc = SQLITE_NOMEM;
229740 break;
229741 }
229742 }
229743
@@ -229762,11 +230568,11 @@
230568 int nArg, /* Number of args */
230569 sqlite3_value **apUnused /* Function arguments */
230570 ){
230571 assert( nArg==0 );
230572 UNUSED_PARAM2(nArg, apUnused);
230573 sqlite3_result_text(pCtx, "fts5: 2021-06-14 20:41:20 e5a5acd6006133c5da4a7dd79726dbaa41c0d60ebeda890f848a6aafe5f9ef70", -1, SQLITE_TRANSIENT);
230574 }
230575
230576 /*
230577 ** Return true if zName is the extension on one of the shadow tables used
230578 ** by this module.
@@ -234688,12 +235494,12 @@
235494 }
235495 #endif /* SQLITE_CORE */
235496 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
235497
235498 /************** End of stmt.c ************************************************/
235499 #if __LINE__!=235499
235500 #undef SQLITE_SOURCE_ID
235501 #define SQLITE_SOURCE_ID "2021-06-14 20:41:20 e5a5acd6006133c5da4a7dd79726dbaa41c0d60ebeda890f848a6aafe5f9alt2"
235502 #endif
235503 /* Return the source-id for this library */
235504 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
235505 /************************** End of sqlite3.c ******************************/
235506
+95 -21
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126126
#define SQLITE_VERSION "3.36.0"
127127
#define SQLITE_VERSION_NUMBER 3036000
128
-#define SQLITE_SOURCE_ID "2021-04-07 18:17:53 a2ddb89b206c13876d34c5f9e3db41cda72d6eb3fea31ffa8cc6daa1e1580e16"
128
+#define SQLITE_SOURCE_ID "2021-06-14 20:41:20 e5a5acd6006133c5da4a7dd79726dbaa41c0d60ebeda890f848a6aafe5f9ef70"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
@@ -1139,10 +1139,14 @@
11391139
** currently has an SQL transaction open on the database. It is set to 0 if
11401140
** the database is not a wal-mode db, or if there is no such connection in any
11411141
** other process. This opcode cannot be used to detect transactions opened
11421142
** by clients within the current process, only within other processes.
11431143
** </ul>
1144
+**
1145
+** <li>[[SQLITE_FCNTL_CKSM_FILE]]
1146
+** Used by the cksmvfs VFS module only.
1147
+** </ul>
11441148
*/
11451149
#define SQLITE_FCNTL_LOCKSTATE 1
11461150
#define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
11471151
#define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
11481152
#define SQLITE_FCNTL_LAST_ERRNO 4
@@ -1178,12 +1182,12 @@
11781182
#define SQLITE_FCNTL_DATA_VERSION 35
11791183
#define SQLITE_FCNTL_SIZE_LIMIT 36
11801184
#define SQLITE_FCNTL_CKPT_DONE 37
11811185
#define SQLITE_FCNTL_RESERVE_BYTES 38
11821186
#define SQLITE_FCNTL_CKPT_START 39
1183
-
11841187
#define SQLITE_FCNTL_EXTERNAL_READER 40
1188
+#define SQLITE_FCNTL_CKSM_FILE 41
11851189
11861190
/* deprecated names */
11871191
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
11881192
#define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
11891193
#define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -4192,10 +4196,19 @@
41924196
** changes to the content of the database files on disk.
41934197
** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since
41944198
** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and
41954199
** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so
41964200
** sqlite3_stmt_readonly() returns false for those commands.
4201
+**
4202
+** ^This routine returns false if there is any possibility that the
4203
+** statement might change the database file. ^A false return does
4204
+** not guarantee that the statement will change the database file.
4205
+** ^For example, an UPDATE statement might have a WHERE clause that
4206
+** makes it a no-op, but the sqlite3_stmt_readonly() result would still
4207
+** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a
4208
+** read-only no-op if the table already exists, but
4209
+** sqlite3_stmt_readonly() still returns false for such a statement.
41974210
*/
41984211
SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
41994212
42004213
/*
42014214
** CAPI3REF: Query The EXPLAIN Setting For A Prepared Statement
@@ -4361,22 +4374,26 @@
43614374
** terminated. If any NUL characters occurs at byte offsets less than
43624375
** the value of the fourth parameter then the resulting string value will
43634376
** contain embedded NULs. The result of expressions involving strings
43644377
** with embedded NULs is undefined.
43654378
**
4366
-** ^The fifth argument to the BLOB and string binding interfaces
4367
-** is a destructor used to dispose of the BLOB or
4368
-** string after SQLite has finished with it. ^The destructor is called
4369
-** to dispose of the BLOB or string even if the call to the bind API fails,
4370
-** except the destructor is not called if the third parameter is a NULL
4371
-** pointer or the fourth parameter is negative.
4372
-** ^If the fifth argument is
4373
-** the special value [SQLITE_STATIC], then SQLite assumes that the
4374
-** information is in static, unmanaged space and does not need to be freed.
4375
-** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
4376
-** SQLite makes its own private copy of the data immediately, before
4377
-** the sqlite3_bind_*() routine returns.
4379
+** ^The fifth argument to the BLOB and string binding interfaces controls
4380
+** or indicates the lifetime of the object referenced by the third parameter.
4381
+** ^These three options exist:
4382
+** ^(1) A destructor to dispose of the BLOB or string after SQLite has finished
4383
+** with it may be passed. ^It is called to dispose of the BLOB or string even
4384
+** if the call to the bind API fails, except the destructor is not called if
4385
+** the third parameter is a NULL pointer or the fourth parameter is negative.
4386
+** ^(2) The special constant, [SQLITE_STATIC], may be passsed to indicate that
4387
+** the application remains responsible for disposing of the object. ^In this
4388
+** case, the object and the provided pointer to it must remain valid until
4389
+** either the prepared statement is finalized or the same SQL parameter is
4390
+** bound to something else, whichever occurs sooner.
4391
+** ^(3) The constant, [SQLITE_TRANSIENT], may be passed to indicate that the
4392
+** object is to be copied prior to the return from sqlite3_bind_*(). ^The
4393
+** object and pointer to it must remain valid until then. ^SQLite will then
4394
+** manage the lifetime of its private copy.
43784395
**
43794396
** ^The sixth argument to sqlite3_bind_text64() must be one of
43804397
** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]
43814398
** to specify the encoding of the text in the third parameter. If
43824399
** the sixth argument to sqlite3_bind_text64() is not one of the
@@ -5114,21 +5131,19 @@
51145131
** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY]
51155132
** flag, which if present prevents the function from being invoked from
51165133
** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions,
51175134
** index expressions, or the WHERE clause of partial indexes.
51185135
**
5119
-** <span style="background-color:#ffff90;">
51205136
** For best security, the [SQLITE_DIRECTONLY] flag is recommended for
51215137
** all application-defined SQL functions that do not need to be
51225138
** used inside of triggers, view, CHECK constraints, or other elements of
51235139
** the database schema. This flags is especially recommended for SQL
51245140
** functions that have side effects or reveal internal application state.
51255141
** Without this flag, an attacker might be able to modify the schema of
51265142
** a database file to include invocations of the function with parameters
51275143
** chosen by the attacker, which the application will then execute when
51285144
** the database file is opened and read.
5129
-** </span>
51305145
**
51315146
** ^(The fifth parameter is an arbitrary pointer. The implementation of the
51325147
** function can gain access to this pointer using [sqlite3_user_data()].)^
51335148
**
51345149
** ^The sixth, seventh and eighth parameters passed to the three
@@ -7792,11 +7807,12 @@
77927807
#define SQLITE_TESTCTRL_RESULT_INTREAL 27
77937808
#define SQLITE_TESTCTRL_PRNG_SEED 28
77947809
#define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
77957810
#define SQLITE_TESTCTRL_SEEK_COUNT 30
77967811
#define SQLITE_TESTCTRL_TRACEFLAGS 31
7797
-#define SQLITE_TESTCTRL_LAST 31 /* Largest TESTCTRL */
7812
+#define SQLITE_TESTCTRL_TUNE 32
7813
+#define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */
77987814
77997815
/*
78007816
** CAPI3REF: SQL Keyword Checking
78017817
**
78027818
** These routines provide access to the set of SQL language keywords
@@ -9544,10 +9560,19 @@
95449560
** callback was invoked as a result of a direct insert, update, or delete
95459561
** operation; or 1 for inserts, updates, or deletes invoked by top-level
95469562
** triggers; or 2 for changes resulting from triggers called by top-level
95479563
** triggers; and so forth.
95489564
**
9565
+** When the [sqlite3_blob_write()] API is used to update a blob column,
9566
+** the pre-update hook is invoked with SQLITE_DELETE. This is because the
9567
+** in this case the new values are not available. In this case, when a
9568
+** callback made with op==SQLITE_DELETE is actuall a write using the
9569
+** sqlite3_blob_write() API, the [sqlite3_preupdate_blobwrite()] returns
9570
+** the index of the column being written. In other cases, where the
9571
+** pre-update hook is being invoked for some other reason, including a
9572
+** regular DELETE, sqlite3_preupdate_blobwrite() returns -1.
9573
+**
95499574
** See also: [sqlite3_update_hook()]
95509575
*/
95519576
#if defined(SQLITE_ENABLE_PREUPDATE_HOOK)
95529577
SQLITE_API void *sqlite3_preupdate_hook(
95539578
sqlite3 *db,
@@ -9564,10 +9589,11 @@
95649589
);
95659590
SQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);
95669591
SQLITE_API int sqlite3_preupdate_count(sqlite3 *);
95679592
SQLITE_API int sqlite3_preupdate_depth(sqlite3 *);
95689593
SQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);
9594
+SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *);
95699595
#endif
95709596
95719597
/*
95729598
** CAPI3REF: Low-level system error code
95739599
** METHOD: sqlite3
@@ -9802,12 +9828,12 @@
98029828
**
98039829
** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
98049830
** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory
98059831
** allocation error occurs.
98069832
**
9807
-** This interface is only available if SQLite is compiled with the
9808
-** [SQLITE_ENABLE_DESERIALIZE] option.
9833
+** This interface is omitted if SQLite is compiled with the
9834
+** [SQLITE_OMIT_DESERIALIZE] option.
98099835
*/
98109836
SQLITE_API unsigned char *sqlite3_serialize(
98119837
sqlite3 *db, /* The database connection */
98129838
const char *zSchema, /* Which DB to serialize. ex: "main", "temp", ... */
98139839
sqlite3_int64 *piSize, /* Write size of the DB here, if not NULL */
@@ -9854,12 +9880,12 @@
98549880
**
98559881
** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
98569882
** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
98579883
** [sqlite3_free()] is invoked on argument P prior to returning.
98589884
**
9859
-** This interface is only available if SQLite is compiled with the
9860
-** [SQLITE_ENABLE_DESERIALIZE] option.
9885
+** This interface is omitted if SQLite is compiled with the
9886
+** [SQLITE_OMIT_DESERIALIZE] option.
98619887
*/
98629888
SQLITE_API int sqlite3_deserialize(
98639889
sqlite3 *db, /* The database connection */
98649890
const char *zSchema, /* Which DB to reopen with the deserialization */
98659891
unsigned char *pData, /* The serialized database content */
@@ -10104,10 +10130,42 @@
1010410130
** are attached is closed. Refer to the documentation for
1010510131
** [sqlite3session_create()] for details.
1010610132
*/
1010710133
SQLITE_API void sqlite3session_delete(sqlite3_session *pSession);
1010810134
10135
+/*
10136
+** CAPIREF: Conigure a Session Object
10137
+** METHOD: sqlite3_session
10138
+**
10139
+** This method is used to configure a session object after it has been
10140
+** created. At present the only valid value for the second parameter is
10141
+** [SQLITE_SESSION_OBJCONFIG_SIZE].
10142
+**
10143
+** Arguments for sqlite3session_object_config()
10144
+**
10145
+** The following values may passed as the the 4th parameter to
10146
+** sqlite3session_object_config().
10147
+**
10148
+** <dt>SQLITE_SESSION_OBJCONFIG_SIZE <dd>
10149
+** This option is used to set, clear or query the flag that enables
10150
+** the [sqlite3session_changeset_size()] API. Because it imposes some
10151
+** computational overhead, this API is disabled by default. Argument
10152
+** pArg must point to a value of type (int). If the value is initially
10153
+** 0, then the sqlite3session_changeset_size() API is disabled. If it
10154
+** is greater than 0, then the same API is enabled. Or, if the initial
10155
+** value is less than zero, no change is made. In all cases the (int)
10156
+** variable is set to 1 if the sqlite3session_changeset_size() API is
10157
+** enabled following the current call, or 0 otherwise.
10158
+**
10159
+** It is an error (SQLITE_MISUSE) to attempt to modify this setting after
10160
+** the first table has been attached to the session object.
10161
+*/
10162
+SQLITE_API int sqlite3session_object_config(sqlite3_session*, int op, void *pArg);
10163
+
10164
+/*
10165
+*/
10166
+#define SQLITE_SESSION_OBJCONFIG_SIZE 1
1010910167
1011010168
/*
1011110169
** CAPI3REF: Enable Or Disable A Session Object
1011210170
** METHOD: sqlite3_session
1011310171
**
@@ -10348,10 +10406,26 @@
1034810406
sqlite3_session *pSession, /* Session object */
1034910407
int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
1035010408
void **ppChangeset /* OUT: Buffer containing changeset */
1035110409
);
1035210410
10411
+/*
10412
+** CAPI3REF: Return An Upper-limit For The Size Of The Changeset
10413
+** METHOD: sqlite3_session
10414
+**
10415
+** By default, this function always returns 0. For it to return
10416
+** a useful result, the sqlite3_session object must have been configured
10417
+** to enable this API using sqlite3session_object_config() with the
10418
+** SQLITE_SESSION_OBJCONFIG_SIZE verb.
10419
+**
10420
+** When enabled, this function returns an upper limit, in bytes, for the size
10421
+** of the changeset that might be produced if sqlite3session_changeset() were
10422
+** called. The final changeset size might be equal to or smaller than the
10423
+** size in bytes returned by this function.
10424
+*/
10425
+SQLITE_API sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession);
10426
+
1035310427
/*
1035410428
** CAPI3REF: Load The Difference Between Tables Into A Session
1035510429
** METHOD: sqlite3_session
1035610430
**
1035710431
** If it is not already attached to the session object passed as the first
1035810432
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.36.0"
127 #define SQLITE_VERSION_NUMBER 3036000
128 #define SQLITE_SOURCE_ID "2021-04-07 18:17:53 a2ddb89b206c13876d34c5f9e3db41cda72d6eb3fea31ffa8cc6daa1e1580e16"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -1139,10 +1139,14 @@
1139 ** currently has an SQL transaction open on the database. It is set to 0 if
1140 ** the database is not a wal-mode db, or if there is no such connection in any
1141 ** other process. This opcode cannot be used to detect transactions opened
1142 ** by clients within the current process, only within other processes.
1143 ** </ul>
 
 
 
 
1144 */
1145 #define SQLITE_FCNTL_LOCKSTATE 1
1146 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
1147 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
1148 #define SQLITE_FCNTL_LAST_ERRNO 4
@@ -1178,12 +1182,12 @@
1178 #define SQLITE_FCNTL_DATA_VERSION 35
1179 #define SQLITE_FCNTL_SIZE_LIMIT 36
1180 #define SQLITE_FCNTL_CKPT_DONE 37
1181 #define SQLITE_FCNTL_RESERVE_BYTES 38
1182 #define SQLITE_FCNTL_CKPT_START 39
1183
1184 #define SQLITE_FCNTL_EXTERNAL_READER 40
 
1185
1186 /* deprecated names */
1187 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
1188 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1189 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -4192,10 +4196,19 @@
4192 ** changes to the content of the database files on disk.
4193 ** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since
4194 ** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and
4195 ** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so
4196 ** sqlite3_stmt_readonly() returns false for those commands.
 
 
 
 
 
 
 
 
 
4197 */
4198 SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
4199
4200 /*
4201 ** CAPI3REF: Query The EXPLAIN Setting For A Prepared Statement
@@ -4361,22 +4374,26 @@
4361 ** terminated. If any NUL characters occurs at byte offsets less than
4362 ** the value of the fourth parameter then the resulting string value will
4363 ** contain embedded NULs. The result of expressions involving strings
4364 ** with embedded NULs is undefined.
4365 **
4366 ** ^The fifth argument to the BLOB and string binding interfaces
4367 ** is a destructor used to dispose of the BLOB or
4368 ** string after SQLite has finished with it. ^The destructor is called
4369 ** to dispose of the BLOB or string even if the call to the bind API fails,
4370 ** except the destructor is not called if the third parameter is a NULL
4371 ** pointer or the fourth parameter is negative.
4372 ** ^If the fifth argument is
4373 ** the special value [SQLITE_STATIC], then SQLite assumes that the
4374 ** information is in static, unmanaged space and does not need to be freed.
4375 ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
4376 ** SQLite makes its own private copy of the data immediately, before
4377 ** the sqlite3_bind_*() routine returns.
 
 
 
 
4378 **
4379 ** ^The sixth argument to sqlite3_bind_text64() must be one of
4380 ** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]
4381 ** to specify the encoding of the text in the third parameter. If
4382 ** the sixth argument to sqlite3_bind_text64() is not one of the
@@ -5114,21 +5131,19 @@
5114 ** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY]
5115 ** flag, which if present prevents the function from being invoked from
5116 ** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions,
5117 ** index expressions, or the WHERE clause of partial indexes.
5118 **
5119 ** <span style="background-color:#ffff90;">
5120 ** For best security, the [SQLITE_DIRECTONLY] flag is recommended for
5121 ** all application-defined SQL functions that do not need to be
5122 ** used inside of triggers, view, CHECK constraints, or other elements of
5123 ** the database schema. This flags is especially recommended for SQL
5124 ** functions that have side effects or reveal internal application state.
5125 ** Without this flag, an attacker might be able to modify the schema of
5126 ** a database file to include invocations of the function with parameters
5127 ** chosen by the attacker, which the application will then execute when
5128 ** the database file is opened and read.
5129 ** </span>
5130 **
5131 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
5132 ** function can gain access to this pointer using [sqlite3_user_data()].)^
5133 **
5134 ** ^The sixth, seventh and eighth parameters passed to the three
@@ -7792,11 +7807,12 @@
7792 #define SQLITE_TESTCTRL_RESULT_INTREAL 27
7793 #define SQLITE_TESTCTRL_PRNG_SEED 28
7794 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
7795 #define SQLITE_TESTCTRL_SEEK_COUNT 30
7796 #define SQLITE_TESTCTRL_TRACEFLAGS 31
7797 #define SQLITE_TESTCTRL_LAST 31 /* Largest TESTCTRL */
 
7798
7799 /*
7800 ** CAPI3REF: SQL Keyword Checking
7801 **
7802 ** These routines provide access to the set of SQL language keywords
@@ -9544,10 +9560,19 @@
9544 ** callback was invoked as a result of a direct insert, update, or delete
9545 ** operation; or 1 for inserts, updates, or deletes invoked by top-level
9546 ** triggers; or 2 for changes resulting from triggers called by top-level
9547 ** triggers; and so forth.
9548 **
 
 
 
 
 
 
 
 
 
9549 ** See also: [sqlite3_update_hook()]
9550 */
9551 #if defined(SQLITE_ENABLE_PREUPDATE_HOOK)
9552 SQLITE_API void *sqlite3_preupdate_hook(
9553 sqlite3 *db,
@@ -9564,10 +9589,11 @@
9564 );
9565 SQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);
9566 SQLITE_API int sqlite3_preupdate_count(sqlite3 *);
9567 SQLITE_API int sqlite3_preupdate_depth(sqlite3 *);
9568 SQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);
 
9569 #endif
9570
9571 /*
9572 ** CAPI3REF: Low-level system error code
9573 ** METHOD: sqlite3
@@ -9802,12 +9828,12 @@
9802 **
9803 ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
9804 ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory
9805 ** allocation error occurs.
9806 **
9807 ** This interface is only available if SQLite is compiled with the
9808 ** [SQLITE_ENABLE_DESERIALIZE] option.
9809 */
9810 SQLITE_API unsigned char *sqlite3_serialize(
9811 sqlite3 *db, /* The database connection */
9812 const char *zSchema, /* Which DB to serialize. ex: "main", "temp", ... */
9813 sqlite3_int64 *piSize, /* Write size of the DB here, if not NULL */
@@ -9854,12 +9880,12 @@
9854 **
9855 ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
9856 ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
9857 ** [sqlite3_free()] is invoked on argument P prior to returning.
9858 **
9859 ** This interface is only available if SQLite is compiled with the
9860 ** [SQLITE_ENABLE_DESERIALIZE] option.
9861 */
9862 SQLITE_API int sqlite3_deserialize(
9863 sqlite3 *db, /* The database connection */
9864 const char *zSchema, /* Which DB to reopen with the deserialization */
9865 unsigned char *pData, /* The serialized database content */
@@ -10104,10 +10130,42 @@
10104 ** are attached is closed. Refer to the documentation for
10105 ** [sqlite3session_create()] for details.
10106 */
10107 SQLITE_API void sqlite3session_delete(sqlite3_session *pSession);
10108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10109
10110 /*
10111 ** CAPI3REF: Enable Or Disable A Session Object
10112 ** METHOD: sqlite3_session
10113 **
@@ -10348,10 +10406,26 @@
10348 sqlite3_session *pSession, /* Session object */
10349 int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
10350 void **ppChangeset /* OUT: Buffer containing changeset */
10351 );
10352
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10353 /*
10354 ** CAPI3REF: Load The Difference Between Tables Into A Session
10355 ** METHOD: sqlite3_session
10356 **
10357 ** If it is not already attached to the session object passed as the first
10358
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.36.0"
127 #define SQLITE_VERSION_NUMBER 3036000
128 #define SQLITE_SOURCE_ID "2021-06-14 20:41:20 e5a5acd6006133c5da4a7dd79726dbaa41c0d60ebeda890f848a6aafe5f9ef70"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -1139,10 +1139,14 @@
1139 ** currently has an SQL transaction open on the database. It is set to 0 if
1140 ** the database is not a wal-mode db, or if there is no such connection in any
1141 ** other process. This opcode cannot be used to detect transactions opened
1142 ** by clients within the current process, only within other processes.
1143 ** </ul>
1144 **
1145 ** <li>[[SQLITE_FCNTL_CKSM_FILE]]
1146 ** Used by the cksmvfs VFS module only.
1147 ** </ul>
1148 */
1149 #define SQLITE_FCNTL_LOCKSTATE 1
1150 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
1151 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
1152 #define SQLITE_FCNTL_LAST_ERRNO 4
@@ -1178,12 +1182,12 @@
1182 #define SQLITE_FCNTL_DATA_VERSION 35
1183 #define SQLITE_FCNTL_SIZE_LIMIT 36
1184 #define SQLITE_FCNTL_CKPT_DONE 37
1185 #define SQLITE_FCNTL_RESERVE_BYTES 38
1186 #define SQLITE_FCNTL_CKPT_START 39
 
1187 #define SQLITE_FCNTL_EXTERNAL_READER 40
1188 #define SQLITE_FCNTL_CKSM_FILE 41
1189
1190 /* deprecated names */
1191 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
1192 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1193 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -4192,10 +4196,19 @@
4196 ** changes to the content of the database files on disk.
4197 ** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since
4198 ** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and
4199 ** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so
4200 ** sqlite3_stmt_readonly() returns false for those commands.
4201 **
4202 ** ^This routine returns false if there is any possibility that the
4203 ** statement might change the database file. ^A false return does
4204 ** not guarantee that the statement will change the database file.
4205 ** ^For example, an UPDATE statement might have a WHERE clause that
4206 ** makes it a no-op, but the sqlite3_stmt_readonly() result would still
4207 ** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a
4208 ** read-only no-op if the table already exists, but
4209 ** sqlite3_stmt_readonly() still returns false for such a statement.
4210 */
4211 SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
4212
4213 /*
4214 ** CAPI3REF: Query The EXPLAIN Setting For A Prepared Statement
@@ -4361,22 +4374,26 @@
4374 ** terminated. If any NUL characters occurs at byte offsets less than
4375 ** the value of the fourth parameter then the resulting string value will
4376 ** contain embedded NULs. The result of expressions involving strings
4377 ** with embedded NULs is undefined.
4378 **
4379 ** ^The fifth argument to the BLOB and string binding interfaces controls
4380 ** or indicates the lifetime of the object referenced by the third parameter.
4381 ** ^These three options exist:
4382 ** ^(1) A destructor to dispose of the BLOB or string after SQLite has finished
4383 ** with it may be passed. ^It is called to dispose of the BLOB or string even
4384 ** if the call to the bind API fails, except the destructor is not called if
4385 ** the third parameter is a NULL pointer or the fourth parameter is negative.
4386 ** ^(2) The special constant, [SQLITE_STATIC], may be passsed to indicate that
4387 ** the application remains responsible for disposing of the object. ^In this
4388 ** case, the object and the provided pointer to it must remain valid until
4389 ** either the prepared statement is finalized or the same SQL parameter is
4390 ** bound to something else, whichever occurs sooner.
4391 ** ^(3) The constant, [SQLITE_TRANSIENT], may be passed to indicate that the
4392 ** object is to be copied prior to the return from sqlite3_bind_*(). ^The
4393 ** object and pointer to it must remain valid until then. ^SQLite will then
4394 ** manage the lifetime of its private copy.
4395 **
4396 ** ^The sixth argument to sqlite3_bind_text64() must be one of
4397 ** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]
4398 ** to specify the encoding of the text in the third parameter. If
4399 ** the sixth argument to sqlite3_bind_text64() is not one of the
@@ -5114,21 +5131,19 @@
5131 ** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY]
5132 ** flag, which if present prevents the function from being invoked from
5133 ** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions,
5134 ** index expressions, or the WHERE clause of partial indexes.
5135 **
 
5136 ** For best security, the [SQLITE_DIRECTONLY] flag is recommended for
5137 ** all application-defined SQL functions that do not need to be
5138 ** used inside of triggers, view, CHECK constraints, or other elements of
5139 ** the database schema. This flags is especially recommended for SQL
5140 ** functions that have side effects or reveal internal application state.
5141 ** Without this flag, an attacker might be able to modify the schema of
5142 ** a database file to include invocations of the function with parameters
5143 ** chosen by the attacker, which the application will then execute when
5144 ** the database file is opened and read.
 
5145 **
5146 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
5147 ** function can gain access to this pointer using [sqlite3_user_data()].)^
5148 **
5149 ** ^The sixth, seventh and eighth parameters passed to the three
@@ -7792,11 +7807,12 @@
7807 #define SQLITE_TESTCTRL_RESULT_INTREAL 27
7808 #define SQLITE_TESTCTRL_PRNG_SEED 28
7809 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
7810 #define SQLITE_TESTCTRL_SEEK_COUNT 30
7811 #define SQLITE_TESTCTRL_TRACEFLAGS 31
7812 #define SQLITE_TESTCTRL_TUNE 32
7813 #define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */
7814
7815 /*
7816 ** CAPI3REF: SQL Keyword Checking
7817 **
7818 ** These routines provide access to the set of SQL language keywords
@@ -9544,10 +9560,19 @@
9560 ** callback was invoked as a result of a direct insert, update, or delete
9561 ** operation; or 1 for inserts, updates, or deletes invoked by top-level
9562 ** triggers; or 2 for changes resulting from triggers called by top-level
9563 ** triggers; and so forth.
9564 **
9565 ** When the [sqlite3_blob_write()] API is used to update a blob column,
9566 ** the pre-update hook is invoked with SQLITE_DELETE. This is because the
9567 ** in this case the new values are not available. In this case, when a
9568 ** callback made with op==SQLITE_DELETE is actuall a write using the
9569 ** sqlite3_blob_write() API, the [sqlite3_preupdate_blobwrite()] returns
9570 ** the index of the column being written. In other cases, where the
9571 ** pre-update hook is being invoked for some other reason, including a
9572 ** regular DELETE, sqlite3_preupdate_blobwrite() returns -1.
9573 **
9574 ** See also: [sqlite3_update_hook()]
9575 */
9576 #if defined(SQLITE_ENABLE_PREUPDATE_HOOK)
9577 SQLITE_API void *sqlite3_preupdate_hook(
9578 sqlite3 *db,
@@ -9564,10 +9589,11 @@
9589 );
9590 SQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);
9591 SQLITE_API int sqlite3_preupdate_count(sqlite3 *);
9592 SQLITE_API int sqlite3_preupdate_depth(sqlite3 *);
9593 SQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);
9594 SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *);
9595 #endif
9596
9597 /*
9598 ** CAPI3REF: Low-level system error code
9599 ** METHOD: sqlite3
@@ -9802,12 +9828,12 @@
9828 **
9829 ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
9830 ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory
9831 ** allocation error occurs.
9832 **
9833 ** This interface is omitted if SQLite is compiled with the
9834 ** [SQLITE_OMIT_DESERIALIZE] option.
9835 */
9836 SQLITE_API unsigned char *sqlite3_serialize(
9837 sqlite3 *db, /* The database connection */
9838 const char *zSchema, /* Which DB to serialize. ex: "main", "temp", ... */
9839 sqlite3_int64 *piSize, /* Write size of the DB here, if not NULL */
@@ -9854,12 +9880,12 @@
9880 **
9881 ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
9882 ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
9883 ** [sqlite3_free()] is invoked on argument P prior to returning.
9884 **
9885 ** This interface is omitted if SQLite is compiled with the
9886 ** [SQLITE_OMIT_DESERIALIZE] option.
9887 */
9888 SQLITE_API int sqlite3_deserialize(
9889 sqlite3 *db, /* The database connection */
9890 const char *zSchema, /* Which DB to reopen with the deserialization */
9891 unsigned char *pData, /* The serialized database content */
@@ -10104,10 +10130,42 @@
10130 ** are attached is closed. Refer to the documentation for
10131 ** [sqlite3session_create()] for details.
10132 */
10133 SQLITE_API void sqlite3session_delete(sqlite3_session *pSession);
10134
10135 /*
10136 ** CAPIREF: Conigure a Session Object
10137 ** METHOD: sqlite3_session
10138 **
10139 ** This method is used to configure a session object after it has been
10140 ** created. At present the only valid value for the second parameter is
10141 ** [SQLITE_SESSION_OBJCONFIG_SIZE].
10142 **
10143 ** Arguments for sqlite3session_object_config()
10144 **
10145 ** The following values may passed as the the 4th parameter to
10146 ** sqlite3session_object_config().
10147 **
10148 ** <dt>SQLITE_SESSION_OBJCONFIG_SIZE <dd>
10149 ** This option is used to set, clear or query the flag that enables
10150 ** the [sqlite3session_changeset_size()] API. Because it imposes some
10151 ** computational overhead, this API is disabled by default. Argument
10152 ** pArg must point to a value of type (int). If the value is initially
10153 ** 0, then the sqlite3session_changeset_size() API is disabled. If it
10154 ** is greater than 0, then the same API is enabled. Or, if the initial
10155 ** value is less than zero, no change is made. In all cases the (int)
10156 ** variable is set to 1 if the sqlite3session_changeset_size() API is
10157 ** enabled following the current call, or 0 otherwise.
10158 **
10159 ** It is an error (SQLITE_MISUSE) to attempt to modify this setting after
10160 ** the first table has been attached to the session object.
10161 */
10162 SQLITE_API int sqlite3session_object_config(sqlite3_session*, int op, void *pArg);
10163
10164 /*
10165 */
10166 #define SQLITE_SESSION_OBJCONFIG_SIZE 1
10167
10168 /*
10169 ** CAPI3REF: Enable Or Disable A Session Object
10170 ** METHOD: sqlite3_session
10171 **
@@ -10348,10 +10406,26 @@
10406 sqlite3_session *pSession, /* Session object */
10407 int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
10408 void **ppChangeset /* OUT: Buffer containing changeset */
10409 );
10410
10411 /*
10412 ** CAPI3REF: Return An Upper-limit For The Size Of The Changeset
10413 ** METHOD: sqlite3_session
10414 **
10415 ** By default, this function always returns 0. For it to return
10416 ** a useful result, the sqlite3_session object must have been configured
10417 ** to enable this API using sqlite3session_object_config() with the
10418 ** SQLITE_SESSION_OBJCONFIG_SIZE verb.
10419 **
10420 ** When enabled, this function returns an upper limit, in bytes, for the size
10421 ** of the changeset that might be produced if sqlite3session_changeset() were
10422 ** called. The final changeset size might be equal to or smaller than the
10423 ** size in bytes returned by this function.
10424 */
10425 SQLITE_API sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession);
10426
10427 /*
10428 ** CAPI3REF: Load The Difference Between Tables Into A Session
10429 ** METHOD: sqlite3_session
10430 **
10431 ** If it is not already attached to the session object passed as the first
10432
+15 -1
--- src/stat.c
+++ src/stat.c
@@ -59,10 +59,12 @@
5959
*/
6060
void stats_for_email(void){
6161
const char *zDest = db_get("email-send-method",0);
6262
int nSub, nASub, nPend, nDPend;
6363
const char *zDir, *zDb, *zCmd, *zRelay;
64
+ int iCutoff;
65
+ double rDigest;
6466
@ <tr><th>Outgoing&nbsp;Email:</th><td>
6567
if( fossil_strcmp(zDest,"pipe")==0
6668
&& (zCmd = db_get("email-send-command",0))!=0
6769
){
6870
@ Piped to command "%h(zCmd)"
@@ -110,14 +112,26 @@
110112
@ <tr><th><a href="%R/subscribers">Subscribers:</a></th><td>
111113
}else{
112114
@ <tr><th>Subscribers:</th><td>
113115
}
114116
nSub = db_int(0, "SELECT count(*) FROM subscriber");
117
+ iCutoff = db_get_int("email-renew-cutoff",0);
115118
nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified"
116
- " AND NOT sdonotcall AND length(ssub)>1");
119
+ " AND NOT sdonotcall AND length(ssub)>1"
120
+ " AND lastContact>=%d;", iCutoff);
117121
@ %,d(nASub) active, %,d(nSub) total
118122
@ </td></tr>
123
+ rDigest = db_double(-1.0, "SELECT (julianday('now') - value)*24.0"
124
+ " FROM config WHERE name='email-last-digest'");
125
+ if( rDigest>0.0 ){
126
+ @ <tr><th>Last Digest:</th><td>Approximately \
127
+ if( rDigest>48.0 ){
128
+ @ %.1f(rDigest/24.0) days ago</td>
129
+ }else{
130
+ @ %.1f(rDigest) hours ago</td>
131
+ }
132
+ }
119133
}
120134
121135
/*
122136
** WEBPAGE: stat
123137
**
124138
--- src/stat.c
+++ src/stat.c
@@ -59,10 +59,12 @@
59 */
60 void stats_for_email(void){
61 const char *zDest = db_get("email-send-method",0);
62 int nSub, nASub, nPend, nDPend;
63 const char *zDir, *zDb, *zCmd, *zRelay;
 
 
64 @ <tr><th>Outgoing&nbsp;Email:</th><td>
65 if( fossil_strcmp(zDest,"pipe")==0
66 && (zCmd = db_get("email-send-command",0))!=0
67 ){
68 @ Piped to command "%h(zCmd)"
@@ -110,14 +112,26 @@
110 @ <tr><th><a href="%R/subscribers">Subscribers:</a></th><td>
111 }else{
112 @ <tr><th>Subscribers:</th><td>
113 }
114 nSub = db_int(0, "SELECT count(*) FROM subscriber");
 
115 nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified"
116 " AND NOT sdonotcall AND length(ssub)>1");
 
117 @ %,d(nASub) active, %,d(nSub) total
118 @ </td></tr>
 
 
 
 
 
 
 
 
 
 
119 }
120
121 /*
122 ** WEBPAGE: stat
123 **
124
--- src/stat.c
+++ src/stat.c
@@ -59,10 +59,12 @@
59 */
60 void stats_for_email(void){
61 const char *zDest = db_get("email-send-method",0);
62 int nSub, nASub, nPend, nDPend;
63 const char *zDir, *zDb, *zCmd, *zRelay;
64 int iCutoff;
65 double rDigest;
66 @ <tr><th>Outgoing&nbsp;Email:</th><td>
67 if( fossil_strcmp(zDest,"pipe")==0
68 && (zCmd = db_get("email-send-command",0))!=0
69 ){
70 @ Piped to command "%h(zCmd)"
@@ -110,14 +112,26 @@
112 @ <tr><th><a href="%R/subscribers">Subscribers:</a></th><td>
113 }else{
114 @ <tr><th>Subscribers:</th><td>
115 }
116 nSub = db_int(0, "SELECT count(*) FROM subscriber");
117 iCutoff = db_get_int("email-renew-cutoff",0);
118 nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified"
119 " AND NOT sdonotcall AND length(ssub)>1"
120 " AND lastContact>=%d;", iCutoff);
121 @ %,d(nASub) active, %,d(nSub) total
122 @ </td></tr>
123 rDigest = db_double(-1.0, "SELECT (julianday('now') - value)*24.0"
124 " FROM config WHERE name='email-last-digest'");
125 if( rDigest>0.0 ){
126 @ <tr><th>Last Digest:</th><td>Approximately \
127 if( rDigest>48.0 ){
128 @ %.1f(rDigest/24.0) days ago</td>
129 }else{
130 @ %.1f(rDigest) hours ago</td>
131 }
132 }
133 }
134
135 /*
136 ** WEBPAGE: stat
137 **
138
--- src/style.c
+++ src/style.c
@@ -905,10 +905,14 @@
905905
@ <div class="submenu">
906906
if( nSubmenu>0 ){
907907
qsort(aSubmenu, nSubmenu, sizeof(aSubmenu[0]), submenuCompare);
908908
for(i=0; i<nSubmenu; i++){
909909
struct Submenu *p = &aSubmenu[i];
910
+ /* switching away from the %h formatting below might be dangerous
911
+ ** because some places use %s to compose zLabel and zLink;
912
+ ** e.g. /rptview page
913
+ */
910914
if( p->zLink==0 ){
911915
@ <span class="label">%h(p->zLabel)</span>
912916
}else{
913917
@ <a class="label" href="%h(p->zLink)">%h(p->zLabel)</a>
914918
}
915919
--- src/style.c
+++ src/style.c
@@ -905,10 +905,14 @@
905 @ <div class="submenu">
906 if( nSubmenu>0 ){
907 qsort(aSubmenu, nSubmenu, sizeof(aSubmenu[0]), submenuCompare);
908 for(i=0; i<nSubmenu; i++){
909 struct Submenu *p = &aSubmenu[i];
 
 
 
 
910 if( p->zLink==0 ){
911 @ <span class="label">%h(p->zLabel)</span>
912 }else{
913 @ <a class="label" href="%h(p->zLink)">%h(p->zLabel)</a>
914 }
915
--- src/style.c
+++ src/style.c
@@ -905,10 +905,14 @@
905 @ <div class="submenu">
906 if( nSubmenu>0 ){
907 qsort(aSubmenu, nSubmenu, sizeof(aSubmenu[0]), submenuCompare);
908 for(i=0; i<nSubmenu; i++){
909 struct Submenu *p = &aSubmenu[i];
910 /* switching away from the %h formatting below might be dangerous
911 ** because some places use %s to compose zLabel and zLink;
912 ** e.g. /rptview page
913 */
914 if( p->zLink==0 ){
915 @ <span class="label">%h(p->zLabel)</span>
916 }else{
917 @ <a class="label" href="%h(p->zLink)">%h(p->zLabel)</a>
918 }
919
+3 -3
--- src/sync.c
+++ src/sync.c
@@ -192,11 +192,11 @@
192192
**
193193
** Usage: %fossil pull ?URL? ?options?
194194
**
195195
** Pull all sharable changes from a remote repository into the local
196196
** repository. Sharable changes include public check-ins, edits to
197
-** wiki pages, tickets, and tech-notes, as well as forum content. Add
197
+** wiki pages, tickets, tech-notes, and forum posts. Add
198198
** the --private option to pull private branches. Use the
199199
** "configuration pull" command to pull website configuration details.
200200
**
201201
** If URL is not specified, then the URL from the most recent clone, push,
202202
** pull, remote, or sync command is used. See "fossil help clone" for
@@ -243,11 +243,11 @@
243243
**
244244
** Usage: %fossil push ?URL? ?options?
245245
**
246246
** Push all sharable changes from the local repository to a remote
247247
** repository. Sharable changes include public check-ins, edits to
248
-** wiki pages, tickets, and tech-notes, as well as forum content. Use
248
+** wiki pages, tickets, tech-notes, and forum posts. Use
249249
** --private to also push private branches. Use the "configuration
250250
** push" command to push website configuration details.
251251
**
252252
** If URL is not specified, then the URL from the most recent clone, push,
253253
** pull, remote, or sync command is used. See "fossil help clone" for
@@ -290,11 +290,11 @@
290290
**
291291
** Usage: %fossil sync ?URL? ?options?
292292
**
293293
** Synchronize all sharable changes between the local repository and a
294294
** remote repository. Sharable changes include public check-ins and
295
-** edits to wiki pages, tickets, and technical notes.
295
+** edits to wiki pages, tickets, forum posts, and technical notes.
296296
**
297297
** If URL is not specified, then the URL from the most recent clone, push,
298298
** pull, remote, or sync command is used. See "fossil help clone" for
299299
** details on the URL formats.
300300
**
301301
--- src/sync.c
+++ src/sync.c
@@ -192,11 +192,11 @@
192 **
193 ** Usage: %fossil pull ?URL? ?options?
194 **
195 ** Pull all sharable changes from a remote repository into the local
196 ** repository. Sharable changes include public check-ins, edits to
197 ** wiki pages, tickets, and tech-notes, as well as forum content. Add
198 ** the --private option to pull private branches. Use the
199 ** "configuration pull" command to pull website configuration details.
200 **
201 ** If URL is not specified, then the URL from the most recent clone, push,
202 ** pull, remote, or sync command is used. See "fossil help clone" for
@@ -243,11 +243,11 @@
243 **
244 ** Usage: %fossil push ?URL? ?options?
245 **
246 ** Push all sharable changes from the local repository to a remote
247 ** repository. Sharable changes include public check-ins, edits to
248 ** wiki pages, tickets, and tech-notes, as well as forum content. Use
249 ** --private to also push private branches. Use the "configuration
250 ** push" command to push website configuration details.
251 **
252 ** If URL is not specified, then the URL from the most recent clone, push,
253 ** pull, remote, or sync command is used. See "fossil help clone" for
@@ -290,11 +290,11 @@
290 **
291 ** Usage: %fossil sync ?URL? ?options?
292 **
293 ** Synchronize all sharable changes between the local repository and a
294 ** remote repository. Sharable changes include public check-ins and
295 ** edits to wiki pages, tickets, and technical notes.
296 **
297 ** If URL is not specified, then the URL from the most recent clone, push,
298 ** pull, remote, or sync command is used. See "fossil help clone" for
299 ** details on the URL formats.
300 **
301
--- src/sync.c
+++ src/sync.c
@@ -192,11 +192,11 @@
192 **
193 ** Usage: %fossil pull ?URL? ?options?
194 **
195 ** Pull all sharable changes from a remote repository into the local
196 ** repository. Sharable changes include public check-ins, edits to
197 ** wiki pages, tickets, tech-notes, and forum posts. Add
198 ** the --private option to pull private branches. Use the
199 ** "configuration pull" command to pull website configuration details.
200 **
201 ** If URL is not specified, then the URL from the most recent clone, push,
202 ** pull, remote, or sync command is used. See "fossil help clone" for
@@ -243,11 +243,11 @@
243 **
244 ** Usage: %fossil push ?URL? ?options?
245 **
246 ** Push all sharable changes from the local repository to a remote
247 ** repository. Sharable changes include public check-ins, edits to
248 ** wiki pages, tickets, tech-notes, and forum posts. Use
249 ** --private to also push private branches. Use the "configuration
250 ** push" command to push website configuration details.
251 **
252 ** If URL is not specified, then the URL from the most recent clone, push,
253 ** pull, remote, or sync command is used. See "fossil help clone" for
@@ -290,11 +290,11 @@
290 **
291 ** Usage: %fossil sync ?URL? ?options?
292 **
293 ** Synchronize all sharable changes between the local repository and a
294 ** remote repository. Sharable changes include public check-ins and
295 ** edits to wiki pages, tickets, forum posts, and technical notes.
296 **
297 ** If URL is not specified, then the URL from the most recent clone, push,
298 ** pull, remote, or sync command is used. See "fossil help clone" for
299 ** details on the URL formats.
300 **
301
+147 -40
--- src/tag.c
+++ src/tag.c
@@ -363,71 +363,117 @@
363363
assert( blob_is_reset(&ctrl) );
364364
if( g.localOpen ){
365365
manifest_to_disk(rid);
366366
}
367367
}
368
+
369
+/*
370
+** If zTag is NULL or valid for use as a tag for the `tag add` and
371
+** `tag cancel` commands, returns without side effects, else emits a
372
+** fatal error message. We reject certain prefixes to avoid that
373
+** clients cause undue grief by improperly tagging artifacts as being,
374
+** e.g., wiki pages or tickets.
375
+**
376
+** Note that we intentionally allow the "sym-" prefix, partly for
377
+** historical compatibility and partly because it can be applied
378
+** properly, whereas the other reserved name types have special
379
+** meanings for fossil and cannot be sensibly manually manipulated.
380
+*/
381
+static void tag_cmd_tagname_check(const char *zTag){
382
+ if(zTag && *zTag &&
383
+ (strncmp(zTag,"wiki-",5)==0
384
+ || strncmp(zTag,"tkt-",4)==0
385
+ || strncmp(zTag,"event-",6)==0)){
386
+ fossil_fatal("Invalid prefix for tag name: %s", zTag);
387
+ }
388
+}
368389
369390
/*
370391
** COMMAND: tag
371392
**
372393
** Usage: %fossil tag SUBCOMMAND ...
373394
**
374395
** Run various subcommands to control tags and properties.
375396
**
376
-** > fossil tag add ?OPTIONS? TAGNAME CHECK-IN ?VALUE?
397
+** > fossil tag add ?OPTIONS? TAGNAME ARTIFACT-ID ?VALUE?
377398
**
378
-** Add a new tag or property to CHECK-IN. The tag will
379
-** be usable instead of a CHECK-IN in commands such as
380
-** update and merge. If the --propagate flag is present,
381
-** the tag value propagates to all descendants of CHECK-IN
399
+** Add a new tag or property to an artifact referenced by
400
+** ARTIFACT-ID. For checkins, the tag will be usable instead
401
+** of a CHECK-IN in commands such as update and merge. If the
402
+** --propagate flag is present and ARTIFACT-ID refers to a
403
+** wiki page, forum post, technote, or check-in, the tag
404
+** propagates to all descendants of that artifact.
382405
**
383406
** Options:
384
-** --raw Raw tag name.
385
-** --propagate Propagating tag.
386
-** --date-override DATETIME Set date and time added.
387
-** --user-override USER Name USER when adding the tag.
388
-** -n|--dryrun Display the tag text, but do not
389
-** actually insert it into the database.
407
+** --raw Raw tag name. Ignored for
408
+** non-CHECK-IN artifacts.
409
+** --propagate Propagating tag.
410
+** --date-override DATETIME Set date and time added.
411
+** --user-override USER Name USER when adding the tag.
412
+** -n|--dryrun Display the tag text, but do not
413
+** actually insert it into the database.
390414
**
391415
** The --date-override and --user-override options support
392416
** importing history from other SCM systems. DATETIME has
393417
** the form 'YYYY-MMM-DD HH:MM:SS'.
394418
**
395
-** > fossil tag cancel ?--raw? TAGNAME CHECK-IN
419
+** Note that fossil uses some tag prefixes internally and this
420
+** command will reject tags with these prefixes to avoid
421
+** causing problems or confusion: "wiki-", "tkt-", "event-".
422
+**
423
+** > fossil tag cancel ?--raw? TAGNAME ARTIFACT-ID
396424
**
397
-** Remove the tag TAGNAME from CHECK-IN, and also remove
398
-** the propagation of the tag to any descendants. Use the
399
-** the -n|--dryrun option to see what would have happened.
425
+** Remove the tag TAGNAME from the artifact referenced by
426
+** ARTIFACT-ID, and also remove the propagation of the tag to
427
+** any descendants. Use the the -n|--dryrun option to see
428
+** what would have happened. Certain tag name prefixes are
429
+** forbidden, as documented for the 'add' subcommand.
400430
**
401431
** Options:
402
-** --raw Raw tag name.
432
+** --raw Raw tag name. Ignored for
433
+** non-CHECK-IN artifacts.
403434
** --date-override DATETIME Set date and time deleted.
404435
** --user-override USER Name USER when deleting the tag.
405436
** -n|--dryrun Display the control artifact, but do
406437
** not insert it into the database.
407438
**
408439
** > fossil tag find ?OPTIONS? TAGNAME
409440
**
410
-** List all objects that use TAGNAME. TYPE can be "ci" for
411
-** check-ins or "e" for events. The limit option limits the number
412
-** of results to the given value.
441
+** List all objects that use TAGNAME.
413442
**
414443
** Options:
415
-** --raw Raw tag name.
416
-** -t|--type TYPE One of "ci", or "e".
444
+** --raw Interprets tag as a raw name instead of a
445
+** branch name and matches any type of artifact.
446
+** Changes the output to include only the
447
+** hashes of matching objects.
448
+** -t|--type TYPE One of: ci (check-in), w (wiki),
449
+** e (event/technote), f (forum post),
450
+** t (ticket). Default is all types. Ignored
451
+** if --raw is used.
417452
** -n|--limit N Limit to N results.
418453
**
419
-** > fossil tag list|ls ?OPTIONS? ?CHECK-IN?
454
+** > fossil tag list|ls ?OPTIONS? ?ARTIFACT-ID?
420455
**
421
-** List all tags, or if CHECK-IN is supplied, list
422
-** all tags and their values for CHECK-IN. The tagtype option
423
-** takes one of: propagated, singleton, cancel.
456
+** List all tags or, if ARTIFACT-ID is supplied, all tags and
457
+** their values for that artifact. The tagtype option accepts
458
+** one of: propagated, singleton, cancel. For historical
459
+** scripting compatibility, the internal tag types "wiki-",
460
+** "tkt-", and "event-" (technote) are elided by default
461
+** unless the --raw or --prefix options are used.
424462
**
425463
** Options:
426
-** --raw List tags raw names of tags
427
-** --tagtype TYPE List only tags of type TYPE
464
+** --raw List raw names of tags
465
+** --tagtype TYPE List only tags of type TYPE, which must
466
+** be one of: cancel, singleton, propagated
428467
** -v|--inverse Inverse the meaning of --tagtype TYPE.
468
+** --prefix List only tags with the given prefix.
469
+** Fossil-internal prefixes include "sym-"
470
+** (branch name), "wiki-", "event-"
471
+** (technote), and "tkt-" (ticket). The
472
+** prefix is stripped from the resulting
473
+** list unless --raw is provided. Ignored if
474
+** ARTIFACT-ID is provided.
429475
**
430476
** The option --raw allows the manipulation of all types of tags
431477
** used for various internal purposes in fossil. It also shows
432478
** "cancel" tags for the "find" and "list" subcommands. You should
433479
** not use this option to make changes unless you are sure what
@@ -461,21 +507,37 @@
461507
462508
if( strncmp(g.argv[2],"add",n)==0 ){
463509
char *zValue;
464510
int dryRun = 0;
465511
int fRaw = find_option("raw","",0)!=0;
466
- const char *zPrefix = fRaw ? "" : "sym-";
512
+ const char *zPrefix = "";
467513
int fPropagate = find_option("propagate","",0)!=0;
468514
const char *zDateOvrd = find_option("date-override",0,1);
469515
const char *zUserOvrd = find_option("user-override",0,1);
516
+ const char *zTag;
517
+ const char *zObjId;
518
+ int objType;
470519
if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
471520
if( g.argc!=5 && g.argc!=6 ){
472
- usage("add ?options? TAGNAME CHECK-IN ?VALUE?");
521
+ usage("add ?options? TAGNAME ARTIFACT-ID ?VALUE?");
473522
}
523
+ zTag = g.argv[3];
524
+ tag_cmd_tagname_check(zTag);
525
+ zObjId = g.argv[4];
474526
zValue = g.argc==6 ? g.argv[5] : 0;
527
+ objType = whatis_rid_type(symbolic_name_to_rid(zObjId, 0));
528
+ switch(objType){
529
+ case 0:
530
+ fossil_fatal("Cannot resolve artifact ID: %s", zObjId);
531
+ break;
532
+ case CFTYPE_MANIFEST:
533
+ zPrefix = fRaw ? "" : "sym-";
534
+ break;
535
+ default: break;
536
+ }
475537
db_begin_transaction();
476
- tag_add_artifact(zPrefix, g.argv[3], g.argv[4], zValue,
538
+ tag_add_artifact(zPrefix, zTag, zObjId, zValue,
477539
1+fPropagate+dryRun,zDateOvrd,zUserOvrd);
478540
db_end_transaction(0);
479541
}else
480542
481543
if( strncmp(g.argv[2],"branch",n)==0 ){
@@ -484,19 +546,35 @@
484546
}else
485547
486548
if( strncmp(g.argv[2],"cancel",n)==0 ){
487549
int dryRun = 0;
488550
int fRaw = find_option("raw","",0)!=0;
489
- const char *zPrefix = fRaw ? "" : "sym-";
551
+ const char *zPrefix = "";
490552
const char *zDateOvrd = find_option("date-override",0,1);
491553
const char *zUserOvrd = find_option("user-override",0,1);
554
+ const char *zTag;
555
+ const char *zObjId;
556
+ int objType;
492557
if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
493558
if( g.argc!=5 ){
494
- usage("cancel ?options? TAGNAME CHECK-IN");
559
+ usage("cancel ?options? TAGNAME ARTIFACT-ID");
560
+ }
561
+ zTag = g.argv[3];
562
+ tag_cmd_tagname_check(zTag);
563
+ zObjId = g.argv[4];
564
+ objType = whatis_rid_type(symbolic_name_to_rid(zObjId, 0));
565
+ switch(objType){
566
+ case 0:
567
+ fossil_fatal("Cannot resolve artifact ID: %s", zObjId);
568
+ break;
569
+ case CFTYPE_MANIFEST:
570
+ zPrefix = fRaw ? "" : "sym-";
571
+ break;
572
+ default: break;
495573
}
496574
db_begin_transaction();
497
- tag_add_artifact(zPrefix, g.argv[3], g.argv[4], 0, dryRun,
575
+ tag_add_artifact(zPrefix, zTag, zObjId, 0, dryRun,
498576
zDateOvrd, zUserOvrd);
499577
db_end_transaction(0);
500578
}else
501579
502580
if( strncmp(g.argv[2],"find",n)==0 ){
@@ -526,11 +604,14 @@
526604
while( db_step(&q)==SQLITE_ROW ){
527605
fossil_print("%s\n", db_column_text(&q, 0));
528606
}
529607
db_finalize(&q);
530608
}else{
531
- int tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'",
609
+ int tagid = db_int(0, "SELECT tagid FROM tag "
610
+ "WHERE tagname='%s%q'",
611
+ (zType && 'c'==zType[0])
612
+ ? "sym-" : ""/*safe-for-%s*/,
532613
g.argv[3]);
533614
if( tagid>0 ){
534615
blob_append_sql(&sql,
535616
"%s"
536617
" AND event.type GLOB '%q'"
@@ -552,11 +633,13 @@
552633
if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
553634
Stmt q;
554635
const int fRaw = find_option("raw","",0)!=0;
555636
const char *zTagType = find_option("tagtype","t",1);
556637
const int fInverse = find_option("inverse","v",0)!=0;
638
+ const char *zTagPrefix = find_option("prefix","",1);
557639
int nTagType = fRaw ? -1 : 0;
640
+
558641
if( zTagType!=0 ){
559642
int l = strlen(zTagType);
560643
if( strncmp(zTagType,"cancel",l)==0 ){
561644
nTagType = 0;
562645
}else if( strncmp(zTagType,"singleton",l)==0 ){
@@ -566,30 +649,55 @@
566649
}else{
567650
fossil_fatal("unrecognized tag type");
568651
}
569652
}
570653
if( g.argc==3 ){
654
+ const int nTagPrefix = zTagPrefix ? (int)strlen(zTagPrefix) : 0;
571655
db_prepare(&q,
572656
"SELECT tagname FROM tag"
573657
" WHERE EXISTS(SELECT 1 FROM tagxref"
574658
" WHERE tagid=tag.tagid"
575659
" AND tagtype%s%d)"
576
- " ORDER BY tagname",
660
+ " AND CASE WHEN %Q IS NULL THEN 1 ELSE tagname GLOB %Q||'*' "
661
+ " END ORDER BY tagname",
577662
zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/,
578
- nTagType
663
+ nTagType, zTagPrefix, zTagPrefix
579664
);
580665
while( db_step(&q)==SQLITE_ROW ){
581666
const char *zName = db_column_text(&q, 0);
582667
if( fRaw ){
583668
fossil_print("%s\n", zName);
669
+ }else if( nTagPrefix>0 ){
670
+ assert(db_column_bytes(&q,0)>=nTagPrefix);
671
+ fossil_print("%s\n", &zName[nTagPrefix]);
584672
}else if( strncmp(zName, "sym-", 4)==0 ){
585673
fossil_print("%s\n", &zName[4]);
586674
}
587675
}
588676
db_finalize(&q);
589677
}else if( g.argc==4 ){
590
- int rid = name_to_rid(g.argv[3]);
678
+ char const *zObjId = g.argv[3];
679
+ const int rid = name_to_rid(zObjId);
680
+ const int objType = whatis_rid_type(rid);
681
+ int nTagOffset = 0;
682
+
683
+ zTagPrefix = 0;
684
+ if(objType<=0){
685
+ fossil_fatal("Cannot resolve artifact ID: %s", zObjId);
686
+ }else if(fRaw==0){
687
+ /* Figure out the tag prefix to strip */
688
+ switch(objType){
689
+ case CFTYPE_MANIFEST: zTagPrefix = "sym-"; break;
690
+ case CFTYPE_WIKI: zTagPrefix = "wiki-"; break;
691
+ case CFTYPE_TICKET: zTagPrefix = "tkt-"; break;
692
+ case CFTYPE_EVENT: zTagPrefix = "event-"; break;
693
+ default: break;
694
+ }
695
+ if(zTagPrefix!=0){
696
+ nTagOffset = (int)strlen(zTagPrefix);
697
+ }
698
+ }
591699
db_prepare(&q,
592700
"SELECT tagname, value FROM tagxref, tag"
593701
" WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid"
594702
" AND tagtype%s%d"
595703
" ORDER BY tagname",
@@ -598,13 +706,12 @@
598706
nTagType
599707
);
600708
while( db_step(&q)==SQLITE_ROW ){
601709
const char *zName = db_column_text(&q, 0);
602710
const char *zValue = db_column_text(&q, 1);
603
- if( fRaw==0 ){
604
- if( strncmp(zName, "sym-", 4)!=0 ) continue;
605
- zName += 4;
711
+ if( zTagPrefix && strncmp(zName, zTagPrefix, nTagOffset)==0 ){
712
+ zName += nTagOffset;
606713
}
607714
if( zValue && zValue[0] ){
608715
fossil_print("%s=%s\n", zName, zValue);
609716
}else{
610717
fossil_print("%s\n", zName);
611718
--- src/tag.c
+++ src/tag.c
@@ -363,71 +363,117 @@
363 assert( blob_is_reset(&ctrl) );
364 if( g.localOpen ){
365 manifest_to_disk(rid);
366 }
367 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
369 /*
370 ** COMMAND: tag
371 **
372 ** Usage: %fossil tag SUBCOMMAND ...
373 **
374 ** Run various subcommands to control tags and properties.
375 **
376 ** > fossil tag add ?OPTIONS? TAGNAME CHECK-IN ?VALUE?
377 **
378 ** Add a new tag or property to CHECK-IN. The tag will
379 ** be usable instead of a CHECK-IN in commands such as
380 ** update and merge. If the --propagate flag is present,
381 ** the tag value propagates to all descendants of CHECK-IN
 
 
382 **
383 ** Options:
384 ** --raw Raw tag name.
385 ** --propagate Propagating tag.
386 ** --date-override DATETIME Set date and time added.
387 ** --user-override USER Name USER when adding the tag.
388 ** -n|--dryrun Display the tag text, but do not
389 ** actually insert it into the database.
 
390 **
391 ** The --date-override and --user-override options support
392 ** importing history from other SCM systems. DATETIME has
393 ** the form 'YYYY-MMM-DD HH:MM:SS'.
394 **
395 ** > fossil tag cancel ?--raw? TAGNAME CHECK-IN
 
 
 
 
396 **
397 ** Remove the tag TAGNAME from CHECK-IN, and also remove
398 ** the propagation of the tag to any descendants. Use the
399 ** the -n|--dryrun option to see what would have happened.
 
 
400 **
401 ** Options:
402 ** --raw Raw tag name.
 
403 ** --date-override DATETIME Set date and time deleted.
404 ** --user-override USER Name USER when deleting the tag.
405 ** -n|--dryrun Display the control artifact, but do
406 ** not insert it into the database.
407 **
408 ** > fossil tag find ?OPTIONS? TAGNAME
409 **
410 ** List all objects that use TAGNAME. TYPE can be "ci" for
411 ** check-ins or "e" for events. The limit option limits the number
412 ** of results to the given value.
413 **
414 ** Options:
415 ** --raw Raw tag name.
416 ** -t|--type TYPE One of "ci", or "e".
 
 
 
 
 
 
417 ** -n|--limit N Limit to N results.
418 **
419 ** > fossil tag list|ls ?OPTIONS? ?CHECK-IN?
420 **
421 ** List all tags, or if CHECK-IN is supplied, list
422 ** all tags and their values for CHECK-IN. The tagtype option
423 ** takes one of: propagated, singleton, cancel.
 
 
 
424 **
425 ** Options:
426 ** --raw List tags raw names of tags
427 ** --tagtype TYPE List only tags of type TYPE
 
428 ** -v|--inverse Inverse the meaning of --tagtype TYPE.
 
 
 
 
 
 
 
429 **
430 ** The option --raw allows the manipulation of all types of tags
431 ** used for various internal purposes in fossil. It also shows
432 ** "cancel" tags for the "find" and "list" subcommands. You should
433 ** not use this option to make changes unless you are sure what
@@ -461,21 +507,37 @@
461
462 if( strncmp(g.argv[2],"add",n)==0 ){
463 char *zValue;
464 int dryRun = 0;
465 int fRaw = find_option("raw","",0)!=0;
466 const char *zPrefix = fRaw ? "" : "sym-";
467 int fPropagate = find_option("propagate","",0)!=0;
468 const char *zDateOvrd = find_option("date-override",0,1);
469 const char *zUserOvrd = find_option("user-override",0,1);
 
 
 
470 if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
471 if( g.argc!=5 && g.argc!=6 ){
472 usage("add ?options? TAGNAME CHECK-IN ?VALUE?");
473 }
 
 
 
474 zValue = g.argc==6 ? g.argv[5] : 0;
 
 
 
 
 
 
 
 
 
 
475 db_begin_transaction();
476 tag_add_artifact(zPrefix, g.argv[3], g.argv[4], zValue,
477 1+fPropagate+dryRun,zDateOvrd,zUserOvrd);
478 db_end_transaction(0);
479 }else
480
481 if( strncmp(g.argv[2],"branch",n)==0 ){
@@ -484,19 +546,35 @@
484 }else
485
486 if( strncmp(g.argv[2],"cancel",n)==0 ){
487 int dryRun = 0;
488 int fRaw = find_option("raw","",0)!=0;
489 const char *zPrefix = fRaw ? "" : "sym-";
490 const char *zDateOvrd = find_option("date-override",0,1);
491 const char *zUserOvrd = find_option("user-override",0,1);
 
 
 
492 if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
493 if( g.argc!=5 ){
494 usage("cancel ?options? TAGNAME CHECK-IN");
 
 
 
 
 
 
 
 
 
 
 
 
 
495 }
496 db_begin_transaction();
497 tag_add_artifact(zPrefix, g.argv[3], g.argv[4], 0, dryRun,
498 zDateOvrd, zUserOvrd);
499 db_end_transaction(0);
500 }else
501
502 if( strncmp(g.argv[2],"find",n)==0 ){
@@ -526,11 +604,14 @@
526 while( db_step(&q)==SQLITE_ROW ){
527 fossil_print("%s\n", db_column_text(&q, 0));
528 }
529 db_finalize(&q);
530 }else{
531 int tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'",
 
 
 
532 g.argv[3]);
533 if( tagid>0 ){
534 blob_append_sql(&sql,
535 "%s"
536 " AND event.type GLOB '%q'"
@@ -552,11 +633,13 @@
552 if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
553 Stmt q;
554 const int fRaw = find_option("raw","",0)!=0;
555 const char *zTagType = find_option("tagtype","t",1);
556 const int fInverse = find_option("inverse","v",0)!=0;
 
557 int nTagType = fRaw ? -1 : 0;
 
558 if( zTagType!=0 ){
559 int l = strlen(zTagType);
560 if( strncmp(zTagType,"cancel",l)==0 ){
561 nTagType = 0;
562 }else if( strncmp(zTagType,"singleton",l)==0 ){
@@ -566,30 +649,55 @@
566 }else{
567 fossil_fatal("unrecognized tag type");
568 }
569 }
570 if( g.argc==3 ){
 
571 db_prepare(&q,
572 "SELECT tagname FROM tag"
573 " WHERE EXISTS(SELECT 1 FROM tagxref"
574 " WHERE tagid=tag.tagid"
575 " AND tagtype%s%d)"
576 " ORDER BY tagname",
 
577 zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/,
578 nTagType
579 );
580 while( db_step(&q)==SQLITE_ROW ){
581 const char *zName = db_column_text(&q, 0);
582 if( fRaw ){
583 fossil_print("%s\n", zName);
 
 
 
584 }else if( strncmp(zName, "sym-", 4)==0 ){
585 fossil_print("%s\n", &zName[4]);
586 }
587 }
588 db_finalize(&q);
589 }else if( g.argc==4 ){
590 int rid = name_to_rid(g.argv[3]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
591 db_prepare(&q,
592 "SELECT tagname, value FROM tagxref, tag"
593 " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid"
594 " AND tagtype%s%d"
595 " ORDER BY tagname",
@@ -598,13 +706,12 @@
598 nTagType
599 );
600 while( db_step(&q)==SQLITE_ROW ){
601 const char *zName = db_column_text(&q, 0);
602 const char *zValue = db_column_text(&q, 1);
603 if( fRaw==0 ){
604 if( strncmp(zName, "sym-", 4)!=0 ) continue;
605 zName += 4;
606 }
607 if( zValue && zValue[0] ){
608 fossil_print("%s=%s\n", zName, zValue);
609 }else{
610 fossil_print("%s\n", zName);
611
--- src/tag.c
+++ src/tag.c
@@ -363,71 +363,117 @@
363 assert( blob_is_reset(&ctrl) );
364 if( g.localOpen ){
365 manifest_to_disk(rid);
366 }
367 }
368
369 /*
370 ** If zTag is NULL or valid for use as a tag for the `tag add` and
371 ** `tag cancel` commands, returns without side effects, else emits a
372 ** fatal error message. We reject certain prefixes to avoid that
373 ** clients cause undue grief by improperly tagging artifacts as being,
374 ** e.g., wiki pages or tickets.
375 **
376 ** Note that we intentionally allow the "sym-" prefix, partly for
377 ** historical compatibility and partly because it can be applied
378 ** properly, whereas the other reserved name types have special
379 ** meanings for fossil and cannot be sensibly manually manipulated.
380 */
381 static void tag_cmd_tagname_check(const char *zTag){
382 if(zTag && *zTag &&
383 (strncmp(zTag,"wiki-",5)==0
384 || strncmp(zTag,"tkt-",4)==0
385 || strncmp(zTag,"event-",6)==0)){
386 fossil_fatal("Invalid prefix for tag name: %s", zTag);
387 }
388 }
389
390 /*
391 ** COMMAND: tag
392 **
393 ** Usage: %fossil tag SUBCOMMAND ...
394 **
395 ** Run various subcommands to control tags and properties.
396 **
397 ** > fossil tag add ?OPTIONS? TAGNAME ARTIFACT-ID ?VALUE?
398 **
399 ** Add a new tag or property to an artifact referenced by
400 ** ARTIFACT-ID. For checkins, the tag will be usable instead
401 ** of a CHECK-IN in commands such as update and merge. If the
402 ** --propagate flag is present and ARTIFACT-ID refers to a
403 ** wiki page, forum post, technote, or check-in, the tag
404 ** propagates to all descendants of that artifact.
405 **
406 ** Options:
407 ** --raw Raw tag name. Ignored for
408 ** non-CHECK-IN artifacts.
409 ** --propagate Propagating tag.
410 ** --date-override DATETIME Set date and time added.
411 ** --user-override USER Name USER when adding the tag.
412 ** -n|--dryrun Display the tag text, but do not
413 ** actually insert it into the database.
414 **
415 ** The --date-override and --user-override options support
416 ** importing history from other SCM systems. DATETIME has
417 ** the form 'YYYY-MMM-DD HH:MM:SS'.
418 **
419 ** Note that fossil uses some tag prefixes internally and this
420 ** command will reject tags with these prefixes to avoid
421 ** causing problems or confusion: "wiki-", "tkt-", "event-".
422 **
423 ** > fossil tag cancel ?--raw? TAGNAME ARTIFACT-ID
424 **
425 ** Remove the tag TAGNAME from the artifact referenced by
426 ** ARTIFACT-ID, and also remove the propagation of the tag to
427 ** any descendants. Use the the -n|--dryrun option to see
428 ** what would have happened. Certain tag name prefixes are
429 ** forbidden, as documented for the 'add' subcommand.
430 **
431 ** Options:
432 ** --raw Raw tag name. Ignored for
433 ** non-CHECK-IN artifacts.
434 ** --date-override DATETIME Set date and time deleted.
435 ** --user-override USER Name USER when deleting the tag.
436 ** -n|--dryrun Display the control artifact, but do
437 ** not insert it into the database.
438 **
439 ** > fossil tag find ?OPTIONS? TAGNAME
440 **
441 ** List all objects that use TAGNAME.
 
 
442 **
443 ** Options:
444 ** --raw Interprets tag as a raw name instead of a
445 ** branch name and matches any type of artifact.
446 ** Changes the output to include only the
447 ** hashes of matching objects.
448 ** -t|--type TYPE One of: ci (check-in), w (wiki),
449 ** e (event/technote), f (forum post),
450 ** t (ticket). Default is all types. Ignored
451 ** if --raw is used.
452 ** -n|--limit N Limit to N results.
453 **
454 ** > fossil tag list|ls ?OPTIONS? ?ARTIFACT-ID?
455 **
456 ** List all tags or, if ARTIFACT-ID is supplied, all tags and
457 ** their values for that artifact. The tagtype option accepts
458 ** one of: propagated, singleton, cancel. For historical
459 ** scripting compatibility, the internal tag types "wiki-",
460 ** "tkt-", and "event-" (technote) are elided by default
461 ** unless the --raw or --prefix options are used.
462 **
463 ** Options:
464 ** --raw List raw names of tags
465 ** --tagtype TYPE List only tags of type TYPE, which must
466 ** be one of: cancel, singleton, propagated
467 ** -v|--inverse Inverse the meaning of --tagtype TYPE.
468 ** --prefix List only tags with the given prefix.
469 ** Fossil-internal prefixes include "sym-"
470 ** (branch name), "wiki-", "event-"
471 ** (technote), and "tkt-" (ticket). The
472 ** prefix is stripped from the resulting
473 ** list unless --raw is provided. Ignored if
474 ** ARTIFACT-ID is provided.
475 **
476 ** The option --raw allows the manipulation of all types of tags
477 ** used for various internal purposes in fossil. It also shows
478 ** "cancel" tags for the "find" and "list" subcommands. You should
479 ** not use this option to make changes unless you are sure what
@@ -461,21 +507,37 @@
507
508 if( strncmp(g.argv[2],"add",n)==0 ){
509 char *zValue;
510 int dryRun = 0;
511 int fRaw = find_option("raw","",0)!=0;
512 const char *zPrefix = "";
513 int fPropagate = find_option("propagate","",0)!=0;
514 const char *zDateOvrd = find_option("date-override",0,1);
515 const char *zUserOvrd = find_option("user-override",0,1);
516 const char *zTag;
517 const char *zObjId;
518 int objType;
519 if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
520 if( g.argc!=5 && g.argc!=6 ){
521 usage("add ?options? TAGNAME ARTIFACT-ID ?VALUE?");
522 }
523 zTag = g.argv[3];
524 tag_cmd_tagname_check(zTag);
525 zObjId = g.argv[4];
526 zValue = g.argc==6 ? g.argv[5] : 0;
527 objType = whatis_rid_type(symbolic_name_to_rid(zObjId, 0));
528 switch(objType){
529 case 0:
530 fossil_fatal("Cannot resolve artifact ID: %s", zObjId);
531 break;
532 case CFTYPE_MANIFEST:
533 zPrefix = fRaw ? "" : "sym-";
534 break;
535 default: break;
536 }
537 db_begin_transaction();
538 tag_add_artifact(zPrefix, zTag, zObjId, zValue,
539 1+fPropagate+dryRun,zDateOvrd,zUserOvrd);
540 db_end_transaction(0);
541 }else
542
543 if( strncmp(g.argv[2],"branch",n)==0 ){
@@ -484,19 +546,35 @@
546 }else
547
548 if( strncmp(g.argv[2],"cancel",n)==0 ){
549 int dryRun = 0;
550 int fRaw = find_option("raw","",0)!=0;
551 const char *zPrefix = "";
552 const char *zDateOvrd = find_option("date-override",0,1);
553 const char *zUserOvrd = find_option("user-override",0,1);
554 const char *zTag;
555 const char *zObjId;
556 int objType;
557 if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
558 if( g.argc!=5 ){
559 usage("cancel ?options? TAGNAME ARTIFACT-ID");
560 }
561 zTag = g.argv[3];
562 tag_cmd_tagname_check(zTag);
563 zObjId = g.argv[4];
564 objType = whatis_rid_type(symbolic_name_to_rid(zObjId, 0));
565 switch(objType){
566 case 0:
567 fossil_fatal("Cannot resolve artifact ID: %s", zObjId);
568 break;
569 case CFTYPE_MANIFEST:
570 zPrefix = fRaw ? "" : "sym-";
571 break;
572 default: break;
573 }
574 db_begin_transaction();
575 tag_add_artifact(zPrefix, zTag, zObjId, 0, dryRun,
576 zDateOvrd, zUserOvrd);
577 db_end_transaction(0);
578 }else
579
580 if( strncmp(g.argv[2],"find",n)==0 ){
@@ -526,11 +604,14 @@
604 while( db_step(&q)==SQLITE_ROW ){
605 fossil_print("%s\n", db_column_text(&q, 0));
606 }
607 db_finalize(&q);
608 }else{
609 int tagid = db_int(0, "SELECT tagid FROM tag "
610 "WHERE tagname='%s%q'",
611 (zType && 'c'==zType[0])
612 ? "sym-" : ""/*safe-for-%s*/,
613 g.argv[3]);
614 if( tagid>0 ){
615 blob_append_sql(&sql,
616 "%s"
617 " AND event.type GLOB '%q'"
@@ -552,11 +633,13 @@
633 if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
634 Stmt q;
635 const int fRaw = find_option("raw","",0)!=0;
636 const char *zTagType = find_option("tagtype","t",1);
637 const int fInverse = find_option("inverse","v",0)!=0;
638 const char *zTagPrefix = find_option("prefix","",1);
639 int nTagType = fRaw ? -1 : 0;
640
641 if( zTagType!=0 ){
642 int l = strlen(zTagType);
643 if( strncmp(zTagType,"cancel",l)==0 ){
644 nTagType = 0;
645 }else if( strncmp(zTagType,"singleton",l)==0 ){
@@ -566,30 +649,55 @@
649 }else{
650 fossil_fatal("unrecognized tag type");
651 }
652 }
653 if( g.argc==3 ){
654 const int nTagPrefix = zTagPrefix ? (int)strlen(zTagPrefix) : 0;
655 db_prepare(&q,
656 "SELECT tagname FROM tag"
657 " WHERE EXISTS(SELECT 1 FROM tagxref"
658 " WHERE tagid=tag.tagid"
659 " AND tagtype%s%d)"
660 " AND CASE WHEN %Q IS NULL THEN 1 ELSE tagname GLOB %Q||'*' "
661 " END ORDER BY tagname",
662 zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/,
663 nTagType, zTagPrefix, zTagPrefix
664 );
665 while( db_step(&q)==SQLITE_ROW ){
666 const char *zName = db_column_text(&q, 0);
667 if( fRaw ){
668 fossil_print("%s\n", zName);
669 }else if( nTagPrefix>0 ){
670 assert(db_column_bytes(&q,0)>=nTagPrefix);
671 fossil_print("%s\n", &zName[nTagPrefix]);
672 }else if( strncmp(zName, "sym-", 4)==0 ){
673 fossil_print("%s\n", &zName[4]);
674 }
675 }
676 db_finalize(&q);
677 }else if( g.argc==4 ){
678 char const *zObjId = g.argv[3];
679 const int rid = name_to_rid(zObjId);
680 const int objType = whatis_rid_type(rid);
681 int nTagOffset = 0;
682
683 zTagPrefix = 0;
684 if(objType<=0){
685 fossil_fatal("Cannot resolve artifact ID: %s", zObjId);
686 }else if(fRaw==0){
687 /* Figure out the tag prefix to strip */
688 switch(objType){
689 case CFTYPE_MANIFEST: zTagPrefix = "sym-"; break;
690 case CFTYPE_WIKI: zTagPrefix = "wiki-"; break;
691 case CFTYPE_TICKET: zTagPrefix = "tkt-"; break;
692 case CFTYPE_EVENT: zTagPrefix = "event-"; break;
693 default: break;
694 }
695 if(zTagPrefix!=0){
696 nTagOffset = (int)strlen(zTagPrefix);
697 }
698 }
699 db_prepare(&q,
700 "SELECT tagname, value FROM tagxref, tag"
701 " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid"
702 " AND tagtype%s%d"
703 " ORDER BY tagname",
@@ -598,13 +706,12 @@
706 nTagType
707 );
708 while( db_step(&q)==SQLITE_ROW ){
709 const char *zName = db_column_text(&q, 0);
710 const char *zValue = db_column_text(&q, 1);
711 if( zTagPrefix && strncmp(zName, zTagPrefix, nTagOffset)==0 ){
712 zName += nTagOffset;
 
713 }
714 if( zValue && zValue[0] ){
715 fossil_print("%s=%s\n", zName, zValue);
716 }else{
717 fossil_print("%s\n", zName);
718
+12 -2
--- src/th_main.c
+++ src/th_main.c
@@ -2976,11 +2976,12 @@
29762976
** COMMAND: test-th-eval
29772977
**
29782978
** Usage: %fossil test-th-eval SCRIPT
29792979
**
29802980
** Evaluate SCRIPT as if it were a header or footer or ticket rendering
2981
-** script and show the results on standard output.
2981
+** script and show the results on standard output. SCRIPT may be either
2982
+** a filename or a string of th1 script code.
29822983
**
29832984
** Options:
29842985
**
29852986
** --cgi Include a CGI response header in the output
29862987
** --http Include an HTTP response header in the output
@@ -2990,11 +2991,13 @@
29902991
** --th-trace Trace TH1 execution (for debugging purposes)
29912992
*/
29922993
void test_th_eval(void){
29932994
int rc;
29942995
const char *zRc;
2996
+ const char *zCode = 0;
29952997
int forceCgi, fullHttpReply;
2998
+ Blob code = empty_blob;
29962999
Th_InitTraceLog();
29973000
forceCgi = find_option("cgi", 0, 0)!=0;
29983001
fullHttpReply = find_option("http", 0, 0)!=0;
29993002
if( fullHttpReply ) forceCgi = 1;
30003003
if( forceCgi ) Th_ForceCgi(fullHttpReply);
@@ -3012,16 +3015,23 @@
30123015
g.useLocalauth = 1;
30133016
}
30143017
verify_all_options();
30153018
if( g.argc!=3 ){
30163019
usage("script");
3020
+ }
3021
+ if(file_isfile(g.argv[2], ExtFILE)){
3022
+ blob_read_from_file(&code, g.argv[2], ExtFILE);
3023
+ zCode = blob_str(&code);
3024
+ }else{
3025
+ zCode = g.argv[2];
30173026
}
30183027
Th_FossilInit(TH_INIT_DEFAULT);
3019
- rc = Th_Eval(g.interp, 0, g.argv[2], -1);
3028
+ rc = Th_Eval(g.interp, 0, zCode, -1);
30203029
zRc = Th_ReturnCodeName(rc, 1);
30213030
fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
30223031
Th_PrintTraceLog();
3032
+ blob_reset(&code);
30233033
if( forceCgi ) cgi_reply();
30243034
}
30253035
30263036
/*
30273037
** COMMAND: test-th-source
30283038
--- src/th_main.c
+++ src/th_main.c
@@ -2976,11 +2976,12 @@
2976 ** COMMAND: test-th-eval
2977 **
2978 ** Usage: %fossil test-th-eval SCRIPT
2979 **
2980 ** Evaluate SCRIPT as if it were a header or footer or ticket rendering
2981 ** script and show the results on standard output.
 
2982 **
2983 ** Options:
2984 **
2985 ** --cgi Include a CGI response header in the output
2986 ** --http Include an HTTP response header in the output
@@ -2990,11 +2991,13 @@
2990 ** --th-trace Trace TH1 execution (for debugging purposes)
2991 */
2992 void test_th_eval(void){
2993 int rc;
2994 const char *zRc;
 
2995 int forceCgi, fullHttpReply;
 
2996 Th_InitTraceLog();
2997 forceCgi = find_option("cgi", 0, 0)!=0;
2998 fullHttpReply = find_option("http", 0, 0)!=0;
2999 if( fullHttpReply ) forceCgi = 1;
3000 if( forceCgi ) Th_ForceCgi(fullHttpReply);
@@ -3012,16 +3015,23 @@
3012 g.useLocalauth = 1;
3013 }
3014 verify_all_options();
3015 if( g.argc!=3 ){
3016 usage("script");
 
 
 
 
 
 
3017 }
3018 Th_FossilInit(TH_INIT_DEFAULT);
3019 rc = Th_Eval(g.interp, 0, g.argv[2], -1);
3020 zRc = Th_ReturnCodeName(rc, 1);
3021 fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
3022 Th_PrintTraceLog();
 
3023 if( forceCgi ) cgi_reply();
3024 }
3025
3026 /*
3027 ** COMMAND: test-th-source
3028
--- src/th_main.c
+++ src/th_main.c
@@ -2976,11 +2976,12 @@
2976 ** COMMAND: test-th-eval
2977 **
2978 ** Usage: %fossil test-th-eval SCRIPT
2979 **
2980 ** Evaluate SCRIPT as if it were a header or footer or ticket rendering
2981 ** script and show the results on standard output. SCRIPT may be either
2982 ** a filename or a string of th1 script code.
2983 **
2984 ** Options:
2985 **
2986 ** --cgi Include a CGI response header in the output
2987 ** --http Include an HTTP response header in the output
@@ -2990,11 +2991,13 @@
2991 ** --th-trace Trace TH1 execution (for debugging purposes)
2992 */
2993 void test_th_eval(void){
2994 int rc;
2995 const char *zRc;
2996 const char *zCode = 0;
2997 int forceCgi, fullHttpReply;
2998 Blob code = empty_blob;
2999 Th_InitTraceLog();
3000 forceCgi = find_option("cgi", 0, 0)!=0;
3001 fullHttpReply = find_option("http", 0, 0)!=0;
3002 if( fullHttpReply ) forceCgi = 1;
3003 if( forceCgi ) Th_ForceCgi(fullHttpReply);
@@ -3012,16 +3015,23 @@
3015 g.useLocalauth = 1;
3016 }
3017 verify_all_options();
3018 if( g.argc!=3 ){
3019 usage("script");
3020 }
3021 if(file_isfile(g.argv[2], ExtFILE)){
3022 blob_read_from_file(&code, g.argv[2], ExtFILE);
3023 zCode = blob_str(&code);
3024 }else{
3025 zCode = g.argv[2];
3026 }
3027 Th_FossilInit(TH_INIT_DEFAULT);
3028 rc = Th_Eval(g.interp, 0, zCode, -1);
3029 zRc = Th_ReturnCodeName(rc, 1);
3030 fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
3031 Th_PrintTraceLog();
3032 blob_reset(&code);
3033 if( forceCgi ) cgi_reply();
3034 }
3035
3036 /*
3037 ** COMMAND: test-th-source
3038
+19 -8
--- src/timeline.c
+++ src/timeline.c
@@ -1275,11 +1275,13 @@
12751275
*/
12761276
typedef enum {
12771277
MS_EXACT, /* Matches a single tag by exact string comparison. */
12781278
MS_GLOB, /* Matches tags against a list of GLOB patterns. */
12791279
MS_LIKE, /* Matches tags against a list of LIKE patterns. */
1280
- MS_REGEXP /* Matches tags against a list of regular expressions. */
1280
+ MS_REGEXP, /* Matches tags against a list of regular expressions. */
1281
+ MS_BRLIST, /* Same as REGEXP, except the regular expression is a list
1282
+ ** of branch names */
12811283
} MatchStyle;
12821284
12831285
/*
12841286
** Quote a tag string by surrounding it with double quotes and preceding
12851287
** internal double quotes and backslashes with backslashes.
@@ -1310,11 +1312,13 @@
13101312
13111313
/*
13121314
** Construct the tag match SQL expression.
13131315
**
13141316
** This function is adapted from glob_expr() to support the MS_EXACT, MS_GLOB,
1315
-** MS_LIKE, and MS_REGEXP match styles. For MS_EXACT, the returned expression
1317
+** MS_LIKE, MS_REGEXP, and MS_BRLIST match styles.
1318
+**
1319
+** For MS_EXACT, the returned expression
13161320
** checks for integer match against the tag ID which is looked up directly by
13171321
** this function. For the other modes, the returned SQL expression performs
13181322
** string comparisons against the tag names, so it is necessary to join against
13191323
** the tag table to access the "tagname" column.
13201324
**
@@ -1372,17 +1376,24 @@
13721376
zDelimiter = " OR ";
13731377
zEnd = ")";
13741378
zPrefix = "tagname LIKE 'sym-";
13751379
zSuffix = "'";
13761380
zIntro = "SQL LIKE pattern ";
1377
- }else/* if( matchStyle==MS_REGEXP )*/{
1381
+ }else if( matchStyle==MS_REGEXP ){
13781382
zStart = "(tagname REGEXP '^sym-(";
13791383
zDelimiter = "|";
13801384
zEnd = ")$')";
13811385
zPrefix = "";
13821386
zSuffix = "";
13831387
zIntro = "regular expression ";
1388
+ }else/* if( matchStyle==MS_BRLIST )*/{
1389
+ zStart = "tagname IN ('sym-";
1390
+ zDelimiter = "','sym-";
1391
+ zEnd = "')";
1392
+ zPrefix = "";
1393
+ zSuffix = "";
1394
+ zIntro = "any of ";
13841395
}
13851396
13861397
/* Convert the list of matches into an SQL expression and text description. */
13871398
blob_zero(&expr);
13881399
blob_zero(&desc);
@@ -1792,10 +1803,12 @@
17921803
matchStyle = MS_GLOB;
17931804
}else if( fossil_stricmp(zMatchStyle, "like")==0 ){
17941805
matchStyle = MS_LIKE;
17951806
}else if( fossil_stricmp(zMatchStyle, "regexp")==0 ){
17961807
matchStyle = MS_REGEXP;
1808
+ }else if( fossil_stricmp(zMatchStyle, "brlist")==0 ){
1809
+ matchStyle = MS_BRLIST;
17971810
}else{
17981811
/* For exact maching, inhibit links to the selected tag. */
17991812
zThisTag = zTagName;
18001813
Th_Store("current_checkin", zTagName);
18011814
}
@@ -1903,14 +1916,11 @@
19031916
);
19041917
tmFlags |= TIMELINE_UNHIDE;
19051918
zType = "ci";
19061919
disableY = 1;
19071920
}
1908
- if( bisectLocal
1909
- && fossil_strcmp(g.zIpAddr,"127.0.0.1")==0
1910
- && db_open_local(0)
1911
- ){
1921
+ if( bisectLocal && cgi_is_loopback(g.zIpAddr) && db_open_local(0) ){
19121922
int iCurrent = db_lget_int("checkout",0);
19131923
char *zPerm = bisect_permalink();
19141924
bisect_create_bilog_table(iCurrent, 0, 1);
19151925
tmFlags |= TIMELINE_UNHIDE | TIMELINE_BISECT | TIMELINE_FILLGAPS;
19161926
zType = "ci";
@@ -2557,11 +2567,12 @@
25572567
if( zSearch ){
25582568
blob_appendf(&desc, " matching \"%h\"", zSearch);
25592569
}
25602570
if( g.perm.Hyperlink ){
25612571
static const char *const azMatchStyles[] = {
2562
- "exact", "Exact", "glob", "Glob", "like", "Like", "regexp", "Regexp"
2572
+ "exact", "Exact", "glob", "Glob", "like", "Like", "regexp", "Regexp",
2573
+ "brlist", "List"
25632574
};
25642575
double rDate;
25652576
zDate = db_text(0, "SELECT min(timestamp) FROM timeline /*scan*/");
25662577
if( (!zDate || !zDate[0]) && ( zAfter || zBefore ) ){
25672578
zDate = mprintf("%s", (zAfter ? zAfter : zBefore));
25682579
--- src/timeline.c
+++ src/timeline.c
@@ -1275,11 +1275,13 @@
1275 */
1276 typedef enum {
1277 MS_EXACT, /* Matches a single tag by exact string comparison. */
1278 MS_GLOB, /* Matches tags against a list of GLOB patterns. */
1279 MS_LIKE, /* Matches tags against a list of LIKE patterns. */
1280 MS_REGEXP /* Matches tags against a list of regular expressions. */
 
 
1281 } MatchStyle;
1282
1283 /*
1284 ** Quote a tag string by surrounding it with double quotes and preceding
1285 ** internal double quotes and backslashes with backslashes.
@@ -1310,11 +1312,13 @@
1310
1311 /*
1312 ** Construct the tag match SQL expression.
1313 **
1314 ** This function is adapted from glob_expr() to support the MS_EXACT, MS_GLOB,
1315 ** MS_LIKE, and MS_REGEXP match styles. For MS_EXACT, the returned expression
 
 
1316 ** checks for integer match against the tag ID which is looked up directly by
1317 ** this function. For the other modes, the returned SQL expression performs
1318 ** string comparisons against the tag names, so it is necessary to join against
1319 ** the tag table to access the "tagname" column.
1320 **
@@ -1372,17 +1376,24 @@
1372 zDelimiter = " OR ";
1373 zEnd = ")";
1374 zPrefix = "tagname LIKE 'sym-";
1375 zSuffix = "'";
1376 zIntro = "SQL LIKE pattern ";
1377 }else/* if( matchStyle==MS_REGEXP )*/{
1378 zStart = "(tagname REGEXP '^sym-(";
1379 zDelimiter = "|";
1380 zEnd = ")$')";
1381 zPrefix = "";
1382 zSuffix = "";
1383 zIntro = "regular expression ";
 
 
 
 
 
 
 
1384 }
1385
1386 /* Convert the list of matches into an SQL expression and text description. */
1387 blob_zero(&expr);
1388 blob_zero(&desc);
@@ -1792,10 +1803,12 @@
1792 matchStyle = MS_GLOB;
1793 }else if( fossil_stricmp(zMatchStyle, "like")==0 ){
1794 matchStyle = MS_LIKE;
1795 }else if( fossil_stricmp(zMatchStyle, "regexp")==0 ){
1796 matchStyle = MS_REGEXP;
 
 
1797 }else{
1798 /* For exact maching, inhibit links to the selected tag. */
1799 zThisTag = zTagName;
1800 Th_Store("current_checkin", zTagName);
1801 }
@@ -1903,14 +1916,11 @@
1903 );
1904 tmFlags |= TIMELINE_UNHIDE;
1905 zType = "ci";
1906 disableY = 1;
1907 }
1908 if( bisectLocal
1909 && fossil_strcmp(g.zIpAddr,"127.0.0.1")==0
1910 && db_open_local(0)
1911 ){
1912 int iCurrent = db_lget_int("checkout",0);
1913 char *zPerm = bisect_permalink();
1914 bisect_create_bilog_table(iCurrent, 0, 1);
1915 tmFlags |= TIMELINE_UNHIDE | TIMELINE_BISECT | TIMELINE_FILLGAPS;
1916 zType = "ci";
@@ -2557,11 +2567,12 @@
2557 if( zSearch ){
2558 blob_appendf(&desc, " matching \"%h\"", zSearch);
2559 }
2560 if( g.perm.Hyperlink ){
2561 static const char *const azMatchStyles[] = {
2562 "exact", "Exact", "glob", "Glob", "like", "Like", "regexp", "Regexp"
 
2563 };
2564 double rDate;
2565 zDate = db_text(0, "SELECT min(timestamp) FROM timeline /*scan*/");
2566 if( (!zDate || !zDate[0]) && ( zAfter || zBefore ) ){
2567 zDate = mprintf("%s", (zAfter ? zAfter : zBefore));
2568
--- src/timeline.c
+++ src/timeline.c
@@ -1275,11 +1275,13 @@
1275 */
1276 typedef enum {
1277 MS_EXACT, /* Matches a single tag by exact string comparison. */
1278 MS_GLOB, /* Matches tags against a list of GLOB patterns. */
1279 MS_LIKE, /* Matches tags against a list of LIKE patterns. */
1280 MS_REGEXP, /* Matches tags against a list of regular expressions. */
1281 MS_BRLIST, /* Same as REGEXP, except the regular expression is a list
1282 ** of branch names */
1283 } MatchStyle;
1284
1285 /*
1286 ** Quote a tag string by surrounding it with double quotes and preceding
1287 ** internal double quotes and backslashes with backslashes.
@@ -1310,11 +1312,13 @@
1312
1313 /*
1314 ** Construct the tag match SQL expression.
1315 **
1316 ** This function is adapted from glob_expr() to support the MS_EXACT, MS_GLOB,
1317 ** MS_LIKE, MS_REGEXP, and MS_BRLIST match styles.
1318 **
1319 ** For MS_EXACT, the returned expression
1320 ** checks for integer match against the tag ID which is looked up directly by
1321 ** this function. For the other modes, the returned SQL expression performs
1322 ** string comparisons against the tag names, so it is necessary to join against
1323 ** the tag table to access the "tagname" column.
1324 **
@@ -1372,17 +1376,24 @@
1376 zDelimiter = " OR ";
1377 zEnd = ")";
1378 zPrefix = "tagname LIKE 'sym-";
1379 zSuffix = "'";
1380 zIntro = "SQL LIKE pattern ";
1381 }else if( matchStyle==MS_REGEXP ){
1382 zStart = "(tagname REGEXP '^sym-(";
1383 zDelimiter = "|";
1384 zEnd = ")$')";
1385 zPrefix = "";
1386 zSuffix = "";
1387 zIntro = "regular expression ";
1388 }else/* if( matchStyle==MS_BRLIST )*/{
1389 zStart = "tagname IN ('sym-";
1390 zDelimiter = "','sym-";
1391 zEnd = "')";
1392 zPrefix = "";
1393 zSuffix = "";
1394 zIntro = "any of ";
1395 }
1396
1397 /* Convert the list of matches into an SQL expression and text description. */
1398 blob_zero(&expr);
1399 blob_zero(&desc);
@@ -1792,10 +1803,12 @@
1803 matchStyle = MS_GLOB;
1804 }else if( fossil_stricmp(zMatchStyle, "like")==0 ){
1805 matchStyle = MS_LIKE;
1806 }else if( fossil_stricmp(zMatchStyle, "regexp")==0 ){
1807 matchStyle = MS_REGEXP;
1808 }else if( fossil_stricmp(zMatchStyle, "brlist")==0 ){
1809 matchStyle = MS_BRLIST;
1810 }else{
1811 /* For exact maching, inhibit links to the selected tag. */
1812 zThisTag = zTagName;
1813 Th_Store("current_checkin", zTagName);
1814 }
@@ -1903,14 +1916,11 @@
1916 );
1917 tmFlags |= TIMELINE_UNHIDE;
1918 zType = "ci";
1919 disableY = 1;
1920 }
1921 if( bisectLocal && cgi_is_loopback(g.zIpAddr) && db_open_local(0) ){
 
 
 
1922 int iCurrent = db_lget_int("checkout",0);
1923 char *zPerm = bisect_permalink();
1924 bisect_create_bilog_table(iCurrent, 0, 1);
1925 tmFlags |= TIMELINE_UNHIDE | TIMELINE_BISECT | TIMELINE_FILLGAPS;
1926 zType = "ci";
@@ -2557,11 +2567,12 @@
2567 if( zSearch ){
2568 blob_appendf(&desc, " matching \"%h\"", zSearch);
2569 }
2570 if( g.perm.Hyperlink ){
2571 static const char *const azMatchStyles[] = {
2572 "exact", "Exact", "glob", "Glob", "like", "Like", "regexp", "Regexp",
2573 "brlist", "List"
2574 };
2575 double rDate;
2576 zDate = db_text(0, "SELECT min(timestamp) FROM timeline /*scan*/");
2577 if( (!zDate || !zDate[0]) && ( zAfter || zBefore ) ){
2578 zDate = mprintf("%s", (zAfter ? zAfter : zBefore));
2579
+23 -2
--- src/tkt.c
+++ src/tkt.c
@@ -378,10 +378,12 @@
378378
** schema for the ticketing system. Only allow
379379
**
380380
** CREATE TABLE
381381
** CREATE INDEX
382382
** CREATE VIEW
383
+** DROP INDEX
384
+** DROP VIEW
383385
**
384386
** And for objects in "main" or "repository" whose names
385387
** begin with "ticket" or "fx_". Also allow
386388
**
387389
** INSERT
@@ -393,10 +395,13 @@
393395
**
394396
** Of particular importance for security is that this routine
395397
** disallows data changes on the "config" table, as that could
396398
** allow a malicious server to modify settings in such a way as
397399
** to cause a remote code execution.
400
+**
401
+** Use the "fossil test-db-prepare --auth-ticket SQL" command to perform
402
+** manual testing of this authorizer.
398403
*/
399404
static int ticket_schema_auth(
400405
void *pNErr,
401406
int eCode,
402407
const char *z0,
@@ -403,10 +408,11 @@
403408
const char *z1,
404409
const char *z2,
405410
const char *z3
406411
){
407412
switch( eCode ){
413
+ case SQLITE_DROP_VIEW:
408414
case SQLITE_CREATE_VIEW:
409415
case SQLITE_CREATE_TABLE: {
410416
if( sqlite3_stricmp(z2,"main")!=0
411417
&& sqlite3_stricmp(z2,"repository")!=0
412418
){
@@ -417,10 +423,11 @@
417423
){
418424
goto ticket_schema_error;
419425
}
420426
break;
421427
}
428
+ case SQLITE_DROP_INDEX:
422429
case SQLITE_CREATE_INDEX: {
423430
if( sqlite3_stricmp(z2,"main")!=0
424431
&& sqlite3_stricmp(z2,"repository")!=0
425432
){
426433
goto ticket_schema_error;
@@ -463,10 +470,24 @@
463470
ticket_schema_error:
464471
if( pNErr ) *(int*)pNErr = 1;
465472
return SQLITE_DENY;
466473
}
467474
475
+/*
476
+** Activate the ticket schema authorizer. Must be followed by
477
+** an eventual call to ticket_unrestrict_sql().
478
+*/
479
+void ticket_restrict_sql(int * pNErr){
480
+ db_set_authorizer(ticket_schema_auth,(void*)pNErr,"Ticket-Schema");
481
+}
482
+/*
483
+** Deactivate the ticket schema authorizer.
484
+*/
485
+void ticket_unrestrict_sql(void){
486
+ db_clear_authorizer();
487
+}
488
+
468489
469490
/*
470491
** Recreate the TICKET and TICKETCHNG tables.
471492
*/
472493
void ticket_create_table(int separateConnection){
@@ -475,18 +496,18 @@
475496
db_multi_exec(
476497
"DROP TABLE IF EXISTS ticket;"
477498
"DROP TABLE IF EXISTS ticketchng;"
478499
);
479500
zSql = ticket_table_schema();
480
- db_set_authorizer(ticket_schema_auth,0,"Ticket-Schema");
501
+ ticket_restrict_sql(0);
481502
if( separateConnection ){
482503
if( db_transaction_nesting_depth() ) db_end_transaction(0);
483504
db_init_database(g.zRepositoryName, zSql, 0);
484505
}else{
485506
db_multi_exec("%s", zSql/*safe-for-%s*/);
486507
}
487
- db_clear_authorizer();
508
+ ticket_unrestrict_sql();
488509
fossil_free(zSql);
489510
}
490511
491512
/*
492513
** Repopulate the TICKET and TICKETCHNG tables from scratch using all
493514
--- src/tkt.c
+++ src/tkt.c
@@ -378,10 +378,12 @@
378 ** schema for the ticketing system. Only allow
379 **
380 ** CREATE TABLE
381 ** CREATE INDEX
382 ** CREATE VIEW
 
 
383 **
384 ** And for objects in "main" or "repository" whose names
385 ** begin with "ticket" or "fx_". Also allow
386 **
387 ** INSERT
@@ -393,10 +395,13 @@
393 **
394 ** Of particular importance for security is that this routine
395 ** disallows data changes on the "config" table, as that could
396 ** allow a malicious server to modify settings in such a way as
397 ** to cause a remote code execution.
 
 
 
398 */
399 static int ticket_schema_auth(
400 void *pNErr,
401 int eCode,
402 const char *z0,
@@ -403,10 +408,11 @@
403 const char *z1,
404 const char *z2,
405 const char *z3
406 ){
407 switch( eCode ){
 
408 case SQLITE_CREATE_VIEW:
409 case SQLITE_CREATE_TABLE: {
410 if( sqlite3_stricmp(z2,"main")!=0
411 && sqlite3_stricmp(z2,"repository")!=0
412 ){
@@ -417,10 +423,11 @@
417 ){
418 goto ticket_schema_error;
419 }
420 break;
421 }
 
422 case SQLITE_CREATE_INDEX: {
423 if( sqlite3_stricmp(z2,"main")!=0
424 && sqlite3_stricmp(z2,"repository")!=0
425 ){
426 goto ticket_schema_error;
@@ -463,10 +470,24 @@
463 ticket_schema_error:
464 if( pNErr ) *(int*)pNErr = 1;
465 return SQLITE_DENY;
466 }
467
 
 
 
 
 
 
 
 
 
 
 
 
 
 
468
469 /*
470 ** Recreate the TICKET and TICKETCHNG tables.
471 */
472 void ticket_create_table(int separateConnection){
@@ -475,18 +496,18 @@
475 db_multi_exec(
476 "DROP TABLE IF EXISTS ticket;"
477 "DROP TABLE IF EXISTS ticketchng;"
478 );
479 zSql = ticket_table_schema();
480 db_set_authorizer(ticket_schema_auth,0,"Ticket-Schema");
481 if( separateConnection ){
482 if( db_transaction_nesting_depth() ) db_end_transaction(0);
483 db_init_database(g.zRepositoryName, zSql, 0);
484 }else{
485 db_multi_exec("%s", zSql/*safe-for-%s*/);
486 }
487 db_clear_authorizer();
488 fossil_free(zSql);
489 }
490
491 /*
492 ** Repopulate the TICKET and TICKETCHNG tables from scratch using all
493
--- src/tkt.c
+++ src/tkt.c
@@ -378,10 +378,12 @@
378 ** schema for the ticketing system. Only allow
379 **
380 ** CREATE TABLE
381 ** CREATE INDEX
382 ** CREATE VIEW
383 ** DROP INDEX
384 ** DROP VIEW
385 **
386 ** And for objects in "main" or "repository" whose names
387 ** begin with "ticket" or "fx_". Also allow
388 **
389 ** INSERT
@@ -393,10 +395,13 @@
395 **
396 ** Of particular importance for security is that this routine
397 ** disallows data changes on the "config" table, as that could
398 ** allow a malicious server to modify settings in such a way as
399 ** to cause a remote code execution.
400 **
401 ** Use the "fossil test-db-prepare --auth-ticket SQL" command to perform
402 ** manual testing of this authorizer.
403 */
404 static int ticket_schema_auth(
405 void *pNErr,
406 int eCode,
407 const char *z0,
@@ -403,10 +408,11 @@
408 const char *z1,
409 const char *z2,
410 const char *z3
411 ){
412 switch( eCode ){
413 case SQLITE_DROP_VIEW:
414 case SQLITE_CREATE_VIEW:
415 case SQLITE_CREATE_TABLE: {
416 if( sqlite3_stricmp(z2,"main")!=0
417 && sqlite3_stricmp(z2,"repository")!=0
418 ){
@@ -417,10 +423,11 @@
423 ){
424 goto ticket_schema_error;
425 }
426 break;
427 }
428 case SQLITE_DROP_INDEX:
429 case SQLITE_CREATE_INDEX: {
430 if( sqlite3_stricmp(z2,"main")!=0
431 && sqlite3_stricmp(z2,"repository")!=0
432 ){
433 goto ticket_schema_error;
@@ -463,10 +470,24 @@
470 ticket_schema_error:
471 if( pNErr ) *(int*)pNErr = 1;
472 return SQLITE_DENY;
473 }
474
475 /*
476 ** Activate the ticket schema authorizer. Must be followed by
477 ** an eventual call to ticket_unrestrict_sql().
478 */
479 void ticket_restrict_sql(int * pNErr){
480 db_set_authorizer(ticket_schema_auth,(void*)pNErr,"Ticket-Schema");
481 }
482 /*
483 ** Deactivate the ticket schema authorizer.
484 */
485 void ticket_unrestrict_sql(void){
486 db_clear_authorizer();
487 }
488
489
490 /*
491 ** Recreate the TICKET and TICKETCHNG tables.
492 */
493 void ticket_create_table(int separateConnection){
@@ -475,18 +496,18 @@
496 db_multi_exec(
497 "DROP TABLE IF EXISTS ticket;"
498 "DROP TABLE IF EXISTS ticketchng;"
499 );
500 zSql = ticket_table_schema();
501 ticket_restrict_sql(0);
502 if( separateConnection ){
503 if( db_transaction_nesting_depth() ) db_end_transaction(0);
504 db_init_database(g.zRepositoryName, zSql, 0);
505 }else{
506 db_multi_exec("%s", zSql/*safe-for-%s*/);
507 }
508 ticket_unrestrict_sql();
509 fossil_free(zSql);
510 }
511
512 /*
513 ** Repopulate the TICKET and TICKETCHNG tables from scratch using all
514
+7 -2
--- src/url.c
+++ src/url.c
@@ -638,11 +638,11 @@
638638
** * If the URL has a path, use the tail of the path, with any suffix
639639
** elided.
640640
**
641641
** * If the URL is just a domain name, without a path, then use the
642642
** first element of the domain name, except skip over "www." if
643
-** present.
643
+** present and if there is a ".com" or ".org" or similar suffix.
644644
**
645645
** The string returned is obtained from fossil_malloc(). NULL might be
646646
** returned if there is an error.
647647
*/
648648
char *url_to_repo_basename(const char *zUrl){
@@ -652,11 +652,16 @@
652652
for(i=0; zUrl[i]; i++){
653653
if( zUrl[i]=='?' ) break;
654654
if( (zUrl[i]=='/' || zUrl[i]=='@') && zUrl[i+1]!=0 ) zTail = &zUrl[i+1];
655655
}
656656
if( zTail==0 ) return 0;
657
- if( sqlite3_strnicmp(zTail, "www.", 4)==0 ) zTail += 4;
657
+ if( sqlite3_strnicmp(zTail, "www.", 4)==0 && strchr(zTail+4,'.')!=0 ){
658
+ /* Remove the "www." prefix if there are more "." characters later.
659
+ ** But don't remove the "www." prefix if what follows is the suffix.
660
+ ** forum:/forumpost/74e111a2ee */
661
+ zTail += 4;
662
+ }
658663
if( zTail[0]==0 ) return 0;
659664
for(i=0; zTail[i] && zTail[i]!='.' && zTail[i]!='?'; i++){}
660665
if( i==0 ) return 0;
661666
return mprintf("%.*s", i, zTail);
662667
}
663668
--- src/url.c
+++ src/url.c
@@ -638,11 +638,11 @@
638 ** * If the URL has a path, use the tail of the path, with any suffix
639 ** elided.
640 **
641 ** * If the URL is just a domain name, without a path, then use the
642 ** first element of the domain name, except skip over "www." if
643 ** present.
644 **
645 ** The string returned is obtained from fossil_malloc(). NULL might be
646 ** returned if there is an error.
647 */
648 char *url_to_repo_basename(const char *zUrl){
@@ -652,11 +652,16 @@
652 for(i=0; zUrl[i]; i++){
653 if( zUrl[i]=='?' ) break;
654 if( (zUrl[i]=='/' || zUrl[i]=='@') && zUrl[i+1]!=0 ) zTail = &zUrl[i+1];
655 }
656 if( zTail==0 ) return 0;
657 if( sqlite3_strnicmp(zTail, "www.", 4)==0 ) zTail += 4;
 
 
 
 
 
658 if( zTail[0]==0 ) return 0;
659 for(i=0; zTail[i] && zTail[i]!='.' && zTail[i]!='?'; i++){}
660 if( i==0 ) return 0;
661 return mprintf("%.*s", i, zTail);
662 }
663
--- src/url.c
+++ src/url.c
@@ -638,11 +638,11 @@
638 ** * If the URL has a path, use the tail of the path, with any suffix
639 ** elided.
640 **
641 ** * If the URL is just a domain name, without a path, then use the
642 ** first element of the domain name, except skip over "www." if
643 ** present and if there is a ".com" or ".org" or similar suffix.
644 **
645 ** The string returned is obtained from fossil_malloc(). NULL might be
646 ** returned if there is an error.
647 */
648 char *url_to_repo_basename(const char *zUrl){
@@ -652,11 +652,16 @@
652 for(i=0; zUrl[i]; i++){
653 if( zUrl[i]=='?' ) break;
654 if( (zUrl[i]=='/' || zUrl[i]=='@') && zUrl[i+1]!=0 ) zTail = &zUrl[i+1];
655 }
656 if( zTail==0 ) return 0;
657 if( sqlite3_strnicmp(zTail, "www.", 4)==0 && strchr(zTail+4,'.')!=0 ){
658 /* Remove the "www." prefix if there are more "." characters later.
659 ** But don't remove the "www." prefix if what follows is the suffix.
660 ** forum:/forumpost/74e111a2ee */
661 zTail += 4;
662 }
663 if( zTail[0]==0 ) return 0;
664 for(i=0; zTail[i] && zTail[i]!='.' && zTail[i]!='?'; i++){}
665 if( i==0 ) return 0;
666 return mprintf("%.*s", i, zTail);
667 }
668
+8 -2
--- src/wiki.c
+++ src/wiki.c
@@ -768,10 +768,13 @@
768768
db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)", nrid);
769769
}
770770
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
771771
db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", nrid);
772772
manifest_crosslink(nrid, pWiki, MC_NONE);
773
+ if( login_is_individual() ){
774
+ alert_user_contact(login_name());
775
+ }
773776
return nrid;
774777
}
775778
776779
/*
777780
** Output a selection box from which the user can select the
@@ -1147,10 +1150,12 @@
11471150
db_begin_transaction();
11481151
db_prepare(&q, "SELECT"
11491152
" substr(tagname,6) AS name"
11501153
" FROM tag JOIN tagxref USING('tagid')"
11511154
" WHERE tagname GLOB 'wiki-*'"
1155
+ " AND TYPEOF(tagxref.value+0)='integer'"
1156
+ /* ^^^ elide wiki- tags which are not wiki pages */
11521157
" UNION SELECT 'Sandbox' AS name"
11531158
" ORDER BY name COLLATE NOCASE");
11541159
CX("[");
11551160
while( SQLITE_ROW==db_step(&q) ){
11561161
char const * zName = db_column_text(&q,0);
@@ -1332,11 +1337,11 @@
13321337
">");
13331338
CX("<div class='"
13341339
"wikiedit-options flex-container flex-row child-gap-small'>");
13351340
CX("<div class='input-with-label'>"
13361341
"<label>Mime type</label>");
1337
- mimetype_option_menu(0);
1342
+ mimetype_option_menu("text/x-markdown");
13381343
CX("</div>");
13391344
style_select_list_int("select-font-size",
13401345
"editor_font_size", "Editor font size",
13411346
NULL/*tooltip*/,
13421347
100,
@@ -1529,11 +1534,11 @@
15291534
well_formed_wiki_name_rules();
15301535
form_begin(0, "%R/wikinew");
15311536
@ <p>Name of new wiki page:
15321537
@ <input style="width: 35;" type="text" name="name" value="%h(zName)" /><br />
15331538
@ %z(href("%R/markup_help"))Markup style</a>:
1534
- mimetype_option_menu("text/x-fossil-wiki");
1539
+ mimetype_option_menu("text/x-markdown");
15351540
@ <br /><input type="submit" value="Create" />
15361541
@ </p></form>
15371542
if( zName[0] ){
15381543
@ <p><span class="wikiError">
15391544
@ "%h(zName)" is not a valid wiki page name!</span></p>
@@ -1890,10 +1895,11 @@
18901895
@ tag,
18911896
@ tagxref
18921897
@ WHERE
18931898
@ tag.tagname GLOB 'wiki-*'
18941899
@ AND tagxref.tagid=tag.tagid
1900
+@ AND TYPEOF(wrid)='integer' -- only wiki- tags which are wiki pages
18951901
@ GROUP BY 1
18961902
@ ORDER BY 2;
18971903
;
18981904
18991905
/*
19001906
--- src/wiki.c
+++ src/wiki.c
@@ -768,10 +768,13 @@
768 db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)", nrid);
769 }
770 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
771 db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", nrid);
772 manifest_crosslink(nrid, pWiki, MC_NONE);
 
 
 
773 return nrid;
774 }
775
776 /*
777 ** Output a selection box from which the user can select the
@@ -1147,10 +1150,12 @@
1147 db_begin_transaction();
1148 db_prepare(&q, "SELECT"
1149 " substr(tagname,6) AS name"
1150 " FROM tag JOIN tagxref USING('tagid')"
1151 " WHERE tagname GLOB 'wiki-*'"
 
 
1152 " UNION SELECT 'Sandbox' AS name"
1153 " ORDER BY name COLLATE NOCASE");
1154 CX("[");
1155 while( SQLITE_ROW==db_step(&q) ){
1156 char const * zName = db_column_text(&q,0);
@@ -1332,11 +1337,11 @@
1332 ">");
1333 CX("<div class='"
1334 "wikiedit-options flex-container flex-row child-gap-small'>");
1335 CX("<div class='input-with-label'>"
1336 "<label>Mime type</label>");
1337 mimetype_option_menu(0);
1338 CX("</div>");
1339 style_select_list_int("select-font-size",
1340 "editor_font_size", "Editor font size",
1341 NULL/*tooltip*/,
1342 100,
@@ -1529,11 +1534,11 @@
1529 well_formed_wiki_name_rules();
1530 form_begin(0, "%R/wikinew");
1531 @ <p>Name of new wiki page:
1532 @ <input style="width: 35;" type="text" name="name" value="%h(zName)" /><br />
1533 @ %z(href("%R/markup_help"))Markup style</a>:
1534 mimetype_option_menu("text/x-fossil-wiki");
1535 @ <br /><input type="submit" value="Create" />
1536 @ </p></form>
1537 if( zName[0] ){
1538 @ <p><span class="wikiError">
1539 @ "%h(zName)" is not a valid wiki page name!</span></p>
@@ -1890,10 +1895,11 @@
1890 @ tag,
1891 @ tagxref
1892 @ WHERE
1893 @ tag.tagname GLOB 'wiki-*'
1894 @ AND tagxref.tagid=tag.tagid
 
1895 @ GROUP BY 1
1896 @ ORDER BY 2;
1897 ;
1898
1899 /*
1900
--- src/wiki.c
+++ src/wiki.c
@@ -768,10 +768,13 @@
768 db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)", nrid);
769 }
770 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
771 db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", nrid);
772 manifest_crosslink(nrid, pWiki, MC_NONE);
773 if( login_is_individual() ){
774 alert_user_contact(login_name());
775 }
776 return nrid;
777 }
778
779 /*
780 ** Output a selection box from which the user can select the
@@ -1147,10 +1150,12 @@
1150 db_begin_transaction();
1151 db_prepare(&q, "SELECT"
1152 " substr(tagname,6) AS name"
1153 " FROM tag JOIN tagxref USING('tagid')"
1154 " WHERE tagname GLOB 'wiki-*'"
1155 " AND TYPEOF(tagxref.value+0)='integer'"
1156 /* ^^^ elide wiki- tags which are not wiki pages */
1157 " UNION SELECT 'Sandbox' AS name"
1158 " ORDER BY name COLLATE NOCASE");
1159 CX("[");
1160 while( SQLITE_ROW==db_step(&q) ){
1161 char const * zName = db_column_text(&q,0);
@@ -1332,11 +1337,11 @@
1337 ">");
1338 CX("<div class='"
1339 "wikiedit-options flex-container flex-row child-gap-small'>");
1340 CX("<div class='input-with-label'>"
1341 "<label>Mime type</label>");
1342 mimetype_option_menu("text/x-markdown");
1343 CX("</div>");
1344 style_select_list_int("select-font-size",
1345 "editor_font_size", "Editor font size",
1346 NULL/*tooltip*/,
1347 100,
@@ -1529,11 +1534,11 @@
1534 well_formed_wiki_name_rules();
1535 form_begin(0, "%R/wikinew");
1536 @ <p>Name of new wiki page:
1537 @ <input style="width: 35;" type="text" name="name" value="%h(zName)" /><br />
1538 @ %z(href("%R/markup_help"))Markup style</a>:
1539 mimetype_option_menu("text/x-markdown");
1540 @ <br /><input type="submit" value="Create" />
1541 @ </p></form>
1542 if( zName[0] ){
1543 @ <p><span class="wikiError">
1544 @ "%h(zName)" is not a valid wiki page name!</span></p>
@@ -1890,10 +1895,11 @@
1895 @ tag,
1896 @ tagxref
1897 @ WHERE
1898 @ tag.tagname GLOB 'wiki-*'
1899 @ AND tagxref.tagid=tag.tagid
1900 @ AND TYPEOF(wrid)='integer' -- only wiki- tags which are wiki pages
1901 @ GROUP BY 1
1902 @ ORDER BY 2;
1903 ;
1904
1905 /*
1906
+8 -2
--- src/wiki.c
+++ src/wiki.c
@@ -768,10 +768,13 @@
768768
db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)", nrid);
769769
}
770770
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
771771
db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", nrid);
772772
manifest_crosslink(nrid, pWiki, MC_NONE);
773
+ if( login_is_individual() ){
774
+ alert_user_contact(login_name());
775
+ }
773776
return nrid;
774777
}
775778
776779
/*
777780
** Output a selection box from which the user can select the
@@ -1147,10 +1150,12 @@
11471150
db_begin_transaction();
11481151
db_prepare(&q, "SELECT"
11491152
" substr(tagname,6) AS name"
11501153
" FROM tag JOIN tagxref USING('tagid')"
11511154
" WHERE tagname GLOB 'wiki-*'"
1155
+ " AND TYPEOF(tagxref.value+0)='integer'"
1156
+ /* ^^^ elide wiki- tags which are not wiki pages */
11521157
" UNION SELECT 'Sandbox' AS name"
11531158
" ORDER BY name COLLATE NOCASE");
11541159
CX("[");
11551160
while( SQLITE_ROW==db_step(&q) ){
11561161
char const * zName = db_column_text(&q,0);
@@ -1332,11 +1337,11 @@
13321337
">");
13331338
CX("<div class='"
13341339
"wikiedit-options flex-container flex-row child-gap-small'>");
13351340
CX("<div class='input-with-label'>"
13361341
"<label>Mime type</label>");
1337
- mimetype_option_menu(0);
1342
+ mimetype_option_menu("text/x-markdown");
13381343
CX("</div>");
13391344
style_select_list_int("select-font-size",
13401345
"editor_font_size", "Editor font size",
13411346
NULL/*tooltip*/,
13421347
100,
@@ -1529,11 +1534,11 @@
15291534
well_formed_wiki_name_rules();
15301535
form_begin(0, "%R/wikinew");
15311536
@ <p>Name of new wiki page:
15321537
@ <input style="width: 35;" type="text" name="name" value="%h(zName)" /><br />
15331538
@ %z(href("%R/markup_help"))Markup style</a>:
1534
- mimetype_option_menu("text/x-fossil-wiki");
1539
+ mimetype_option_menu("text/x-markdown");
15351540
@ <br /><input type="submit" value="Create" />
15361541
@ </p></form>
15371542
if( zName[0] ){
15381543
@ <p><span class="wikiError">
15391544
@ "%h(zName)" is not a valid wiki page name!</span></p>
@@ -1890,10 +1895,11 @@
18901895
@ tag,
18911896
@ tagxref
18921897
@ WHERE
18931898
@ tag.tagname GLOB 'wiki-*'
18941899
@ AND tagxref.tagid=tag.tagid
1900
+@ AND TYPEOF(wrid)='integer' -- only wiki- tags which are wiki pages
18951901
@ GROUP BY 1
18961902
@ ORDER BY 2;
18971903
;
18981904
18991905
/*
19001906
--- src/wiki.c
+++ src/wiki.c
@@ -768,10 +768,13 @@
768 db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)", nrid);
769 }
770 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
771 db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", nrid);
772 manifest_crosslink(nrid, pWiki, MC_NONE);
 
 
 
773 return nrid;
774 }
775
776 /*
777 ** Output a selection box from which the user can select the
@@ -1147,10 +1150,12 @@
1147 db_begin_transaction();
1148 db_prepare(&q, "SELECT"
1149 " substr(tagname,6) AS name"
1150 " FROM tag JOIN tagxref USING('tagid')"
1151 " WHERE tagname GLOB 'wiki-*'"
 
 
1152 " UNION SELECT 'Sandbox' AS name"
1153 " ORDER BY name COLLATE NOCASE");
1154 CX("[");
1155 while( SQLITE_ROW==db_step(&q) ){
1156 char const * zName = db_column_text(&q,0);
@@ -1332,11 +1337,11 @@
1332 ">");
1333 CX("<div class='"
1334 "wikiedit-options flex-container flex-row child-gap-small'>");
1335 CX("<div class='input-with-label'>"
1336 "<label>Mime type</label>");
1337 mimetype_option_menu(0);
1338 CX("</div>");
1339 style_select_list_int("select-font-size",
1340 "editor_font_size", "Editor font size",
1341 NULL/*tooltip*/,
1342 100,
@@ -1529,11 +1534,11 @@
1529 well_formed_wiki_name_rules();
1530 form_begin(0, "%R/wikinew");
1531 @ <p>Name of new wiki page:
1532 @ <input style="width: 35;" type="text" name="name" value="%h(zName)" /><br />
1533 @ %z(href("%R/markup_help"))Markup style</a>:
1534 mimetype_option_menu("text/x-fossil-wiki");
1535 @ <br /><input type="submit" value="Create" />
1536 @ </p></form>
1537 if( zName[0] ){
1538 @ <p><span class="wikiError">
1539 @ "%h(zName)" is not a valid wiki page name!</span></p>
@@ -1890,10 +1895,11 @@
1890 @ tag,
1891 @ tagxref
1892 @ WHERE
1893 @ tag.tagname GLOB 'wiki-*'
1894 @ AND tagxref.tagid=tag.tagid
 
1895 @ GROUP BY 1
1896 @ ORDER BY 2;
1897 ;
1898
1899 /*
1900
--- src/wiki.c
+++ src/wiki.c
@@ -768,10 +768,13 @@
768 db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)", nrid);
769 }
770 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
771 db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", nrid);
772 manifest_crosslink(nrid, pWiki, MC_NONE);
773 if( login_is_individual() ){
774 alert_user_contact(login_name());
775 }
776 return nrid;
777 }
778
779 /*
780 ** Output a selection box from which the user can select the
@@ -1147,10 +1150,12 @@
1150 db_begin_transaction();
1151 db_prepare(&q, "SELECT"
1152 " substr(tagname,6) AS name"
1153 " FROM tag JOIN tagxref USING('tagid')"
1154 " WHERE tagname GLOB 'wiki-*'"
1155 " AND TYPEOF(tagxref.value+0)='integer'"
1156 /* ^^^ elide wiki- tags which are not wiki pages */
1157 " UNION SELECT 'Sandbox' AS name"
1158 " ORDER BY name COLLATE NOCASE");
1159 CX("[");
1160 while( SQLITE_ROW==db_step(&q) ){
1161 char const * zName = db_column_text(&q,0);
@@ -1332,11 +1337,11 @@
1337 ">");
1338 CX("<div class='"
1339 "wikiedit-options flex-container flex-row child-gap-small'>");
1340 CX("<div class='input-with-label'>"
1341 "<label>Mime type</label>");
1342 mimetype_option_menu("text/x-markdown");
1343 CX("</div>");
1344 style_select_list_int("select-font-size",
1345 "editor_font_size", "Editor font size",
1346 NULL/*tooltip*/,
1347 100,
@@ -1529,11 +1534,11 @@
1534 well_formed_wiki_name_rules();
1535 form_begin(0, "%R/wikinew");
1536 @ <p>Name of new wiki page:
1537 @ <input style="width: 35;" type="text" name="name" value="%h(zName)" /><br />
1538 @ %z(href("%R/markup_help"))Markup style</a>:
1539 mimetype_option_menu("text/x-markdown");
1540 @ <br /><input type="submit" value="Create" />
1541 @ </p></form>
1542 if( zName[0] ){
1543 @ <p><span class="wikiError">
1544 @ "%h(zName)" is not a valid wiki page name!</span></p>
@@ -1890,10 +1895,11 @@
1895 @ tag,
1896 @ tagxref
1897 @ WHERE
1898 @ tag.tagname GLOB 'wiki-*'
1899 @ AND tagxref.tagid=tag.tagid
1900 @ AND TYPEOF(wrid)='integer' -- only wiki- tags which are wiki pages
1901 @ GROUP BY 1
1902 @ ORDER BY 2;
1903 ;
1904
1905 /*
1906
--- test/merge_renames.test
+++ test/merge_renames.test
@@ -523,33 +523,27 @@
523523
524524
fossil update m1
525525
fossil merge b
526526
test_status_list merge_renames-13-6 $RESULT {
527527
UPDATE f1
528
- DELETE f2n
529
- ADDED f2n
530528
}
531529
test_file_contents merge_renames-13-7 f2n "line1"
532530
533531
fossil revert
534532
test_status_list merge_renames-13-8 $RESULT {
535533
REVERT f1
536
- REVERT f2n
537534
}
538535
fossil update trunk
539536
fossil merge --integrate b
540537
test_status_list merge_renames-13-9 $RESULT {
541538
UPDATE f1
542
- DELETE f2n
543
- ADDED f2n
544539
}
545540
test_file_contents merge_renames-13-10 f2n "line1"
546541
547542
fossil revert
548543
test_status_list merge_renames-13-11 $RESULT {
549544
REVERT f1
550
- REVERT f2n
551545
}
552546
553547
######################################
554548
#
555549
# Tests for troubles not specifically linked with renames but that I'd like to
556550
557551
ADDED test/merge_renames_2.test
--- test/merge_renames.test
+++ test/merge_renames.test
@@ -523,33 +523,27 @@
523
524 fossil update m1
525 fossil merge b
526 test_status_list merge_renames-13-6 $RESULT {
527 UPDATE f1
528 DELETE f2n
529 ADDED f2n
530 }
531 test_file_contents merge_renames-13-7 f2n "line1"
532
533 fossil revert
534 test_status_list merge_renames-13-8 $RESULT {
535 REVERT f1
536 REVERT f2n
537 }
538 fossil update trunk
539 fossil merge --integrate b
540 test_status_list merge_renames-13-9 $RESULT {
541 UPDATE f1
542 DELETE f2n
543 ADDED f2n
544 }
545 test_file_contents merge_renames-13-10 f2n "line1"
546
547 fossil revert
548 test_status_list merge_renames-13-11 $RESULT {
549 REVERT f1
550 REVERT f2n
551 }
552
553 ######################################
554 #
555 # Tests for troubles not specifically linked with renames but that I'd like to
556
557 DDED test/merge_renames_2.test
--- test/merge_renames.test
+++ test/merge_renames.test
@@ -523,33 +523,27 @@
523
524 fossil update m1
525 fossil merge b
526 test_status_list merge_renames-13-6 $RESULT {
527 UPDATE f1
 
 
528 }
529 test_file_contents merge_renames-13-7 f2n "line1"
530
531 fossil revert
532 test_status_list merge_renames-13-8 $RESULT {
533 REVERT f1
 
534 }
535 fossil update trunk
536 fossil merge --integrate b
537 test_status_list merge_renames-13-9 $RESULT {
538 UPDATE f1
 
 
539 }
540 test_file_contents merge_renames-13-10 f2n "line1"
541
542 fossil revert
543 test_status_list merge_renames-13-11 $RESULT {
544 REVERT f1
 
545 }
546
547 ######################################
548 #
549 # Tests for troubles not specifically linked with renames but that I'd like to
550
551 DDED test/merge_renames_2.test
--- a/test/merge_renames_2.test
+++ b/test/merge_renames_2.test
@@ -0,0 +1,59 @@
1
+#
2
+# Tests for merging with renames
3
+#
4
+#
5
+
6
+proc commit_id {version} {
7
+ regexp -line {^artifact:\s+(\S+)} [fossil whatis $version] - id
8
+ return $id
9
+}
10
+
11
+require_no_open_checkout
12
+
13
+#################################################################
14
+# Test 1 #
15
+# https://fossil-scm.org/forum/forumpost/549700437b #
16
+#################################################################
17
+
18
+test_setup
19
+
20
+write_file file1 "file1\n"
21
+fossil add file1
22
+fossil commit -m "added file1"
23
+
24
+write_file file2 "file2\n"
25
+fossil add file2
26
+fossil commit -m "added file2" --branch added
27
+
28
+write_file file2 "edit file2 on added\n"
29
+fossil commit -m "edited file2"
30
+
31
+fossil mv --hard file2 file2.renamed
32
+fossil commit -m "renamed file2" --branch renamed
33
+
34
+fossil branch new branched current
35
+
36
+write_file file2.renamed "edit file2.renamed on renamed\n"
37
+fossil commit -m "edited file2.renamed"
38
+
39
+fossil update trunk
40
+fossil merge renamed
41
+fossil commit -m "merged from renamed"
42
+
43
+write_file file2.renamed "edit file2.renamed on trunk (1)\n"
44
+fossil commit -m "edited file2.renamed on trunk (1)"
45
+
46
+fossil update branched
47
+fossil merge trunk
48
+test_status_list merge_renames_2-1.1 $RESULT {UPDATE file2.renamed}
49
+fossil commit -m "merged edit from trunk (1:this merge succeeded)"
50
+
51
+fossil update trunk
52
+write_file file2.renamed "edit2 file2.renamed on trunk (2)\n"
53
+fossil commit -m "edited file2.renamed on trunk (2)"
54
+
55
+fossil update branched
56
+fossil merge trunk
57
+test_status_list merge_renames_2-1.2 $RESULT {UPDATE file2.renamed}
58
+
59
+test_cleanup
--- a/test/merge_renames_2.test
+++ b/test/merge_renames_2.test
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/test/merge_renames_2.test
+++ b/test/merge_renames_2.test
@@ -0,0 +1,59 @@
1 #
2 # Tests for merging with renames
3 #
4 #
5
6 proc commit_id {version} {
7 regexp -line {^artifact:\s+(\S+)} [fossil whatis $version] - id
8 return $id
9 }
10
11 require_no_open_checkout
12
13 #################################################################
14 # Test 1 #
15 # https://fossil-scm.org/forum/forumpost/549700437b #
16 #################################################################
17
18 test_setup
19
20 write_file file1 "file1\n"
21 fossil add file1
22 fossil commit -m "added file1"
23
24 write_file file2 "file2\n"
25 fossil add file2
26 fossil commit -m "added file2" --branch added
27
28 write_file file2 "edit file2 on added\n"
29 fossil commit -m "edited file2"
30
31 fossil mv --hard file2 file2.renamed
32 fossil commit -m "renamed file2" --branch renamed
33
34 fossil branch new branched current
35
36 write_file file2.renamed "edit file2.renamed on renamed\n"
37 fossil commit -m "edited file2.renamed"
38
39 fossil update trunk
40 fossil merge renamed
41 fossil commit -m "merged from renamed"
42
43 write_file file2.renamed "edit file2.renamed on trunk (1)\n"
44 fossil commit -m "edited file2.renamed on trunk (1)"
45
46 fossil update branched
47 fossil merge trunk
48 test_status_list merge_renames_2-1.1 $RESULT {UPDATE file2.renamed}
49 fossil commit -m "merged edit from trunk (1:this merge succeeded)"
50
51 fossil update trunk
52 write_file file2.renamed "edit2 file2.renamed on trunk (2)\n"
53 fossil commit -m "edited file2.renamed on trunk (2)"
54
55 fossil update branched
56 fossil merge trunk
57 test_status_list merge_renames_2-1.2 $RESULT {UPDATE file2.renamed}
58
59 test_cleanup
--- test/release-checklist.wiki
+++ test/release-checklist.wiki
@@ -75,15 +75,19 @@
7575
</ol>
7676
7777
<li><p>
7878
Run the following commands on Linux and verify no major memory leaks
7979
and no run-time errors or warnings (except for the well-known jump on an
80
-uninitialized value that occurs within zlib).
80
+uninitialized value that occurs within zlib).</p>
8181
<ol type="a">
8282
<li> <b>valgrind fossil rebuild</b>
8383
<li> <b>valgrind fossil sync</b>
8484
</ol>
85
+
86
+<p>Achtung: make sure to point valgrind to the proper fossil binary
87
+so that it does not pick up another from the PATH.</p>
88
+
8589
8690
<li><p>
8791
8892
Inspect [http://fossil-scm.org/home/vdiff?from=release&to=trunk&sbs=1|all code changes since the previous release], paying particular
8993
attention to the following details:
9094
--- test/release-checklist.wiki
+++ test/release-checklist.wiki
@@ -75,15 +75,19 @@
75 </ol>
76
77 <li><p>
78 Run the following commands on Linux and verify no major memory leaks
79 and no run-time errors or warnings (except for the well-known jump on an
80 uninitialized value that occurs within zlib).
81 <ol type="a">
82 <li> <b>valgrind fossil rebuild</b>
83 <li> <b>valgrind fossil sync</b>
84 </ol>
 
 
 
 
85
86 <li><p>
87
88 Inspect [http://fossil-scm.org/home/vdiff?from=release&to=trunk&sbs=1|all code changes since the previous release], paying particular
89 attention to the following details:
90
--- test/release-checklist.wiki
+++ test/release-checklist.wiki
@@ -75,15 +75,19 @@
75 </ol>
76
77 <li><p>
78 Run the following commands on Linux and verify no major memory leaks
79 and no run-time errors or warnings (except for the well-known jump on an
80 uninitialized value that occurs within zlib).</p>
81 <ol type="a">
82 <li> <b>valgrind fossil rebuild</b>
83 <li> <b>valgrind fossil sync</b>
84 </ol>
85
86 <p>Achtung: make sure to point valgrind to the proper fossil binary
87 so that it does not pick up another from the PATH.</p>
88
89
90 <li><p>
91
92 Inspect [http://fossil-scm.org/home/vdiff?from=release&to=trunk&sbs=1|all code changes since the previous release], paying particular
93 attention to the following details:
94
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -635,13 +635,15 @@
635635
$(SRCDIR)/fossil.copybutton.js \
636636
$(SRCDIR)/fossil.dom.js \
637637
$(SRCDIR)/fossil.fetch.js \
638638
$(SRCDIR)/fossil.info-diff.js \
639639
$(SRCDIR)/fossil.numbered-lines.js \
640
+ $(SRCDIR)/fossil.page.brlist.js \
640641
$(SRCDIR)/fossil.page.fileedit.js \
641642
$(SRCDIR)/fossil.page.forumpost.js \
642643
$(SRCDIR)/fossil.page.pikchrshow.js \
644
+ $(SRCDIR)/fossil.page.whistory.js \
643645
$(SRCDIR)/fossil.page.wikiedit.js \
644646
$(SRCDIR)/fossil.pikchr.js \
645647
$(SRCDIR)/fossil.popupwidget.js \
646648
$(SRCDIR)/fossil.storage.js \
647649
$(SRCDIR)/fossil.tabs.js \
648650
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -635,13 +635,15 @@
635 $(SRCDIR)/fossil.copybutton.js \
636 $(SRCDIR)/fossil.dom.js \
637 $(SRCDIR)/fossil.fetch.js \
638 $(SRCDIR)/fossil.info-diff.js \
639 $(SRCDIR)/fossil.numbered-lines.js \
 
640 $(SRCDIR)/fossil.page.fileedit.js \
641 $(SRCDIR)/fossil.page.forumpost.js \
642 $(SRCDIR)/fossil.page.pikchrshow.js \
 
643 $(SRCDIR)/fossil.page.wikiedit.js \
644 $(SRCDIR)/fossil.pikchr.js \
645 $(SRCDIR)/fossil.popupwidget.js \
646 $(SRCDIR)/fossil.storage.js \
647 $(SRCDIR)/fossil.tabs.js \
648
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -635,13 +635,15 @@
635 $(SRCDIR)/fossil.copybutton.js \
636 $(SRCDIR)/fossil.dom.js \
637 $(SRCDIR)/fossil.fetch.js \
638 $(SRCDIR)/fossil.info-diff.js \
639 $(SRCDIR)/fossil.numbered-lines.js \
640 $(SRCDIR)/fossil.page.brlist.js \
641 $(SRCDIR)/fossil.page.fileedit.js \
642 $(SRCDIR)/fossil.page.forumpost.js \
643 $(SRCDIR)/fossil.page.pikchrshow.js \
644 $(SRCDIR)/fossil.page.whistory.js \
645 $(SRCDIR)/fossil.page.wikiedit.js \
646 $(SRCDIR)/fossil.pikchr.js \
647 $(SRCDIR)/fossil.popupwidget.js \
648 $(SRCDIR)/fossil.storage.js \
649 $(SRCDIR)/fossil.tabs.js \
650
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -635,13 +635,15 @@
635635
$(SRCDIR)/fossil.copybutton.js \
636636
$(SRCDIR)/fossil.dom.js \
637637
$(SRCDIR)/fossil.fetch.js \
638638
$(SRCDIR)/fossil.info-diff.js \
639639
$(SRCDIR)/fossil.numbered-lines.js \
640
+ $(SRCDIR)/fossil.page.brlist.js \
640641
$(SRCDIR)/fossil.page.fileedit.js \
641642
$(SRCDIR)/fossil.page.forumpost.js \
642643
$(SRCDIR)/fossil.page.pikchrshow.js \
644
+ $(SRCDIR)/fossil.page.whistory.js \
643645
$(SRCDIR)/fossil.page.wikiedit.js \
644646
$(SRCDIR)/fossil.pikchr.js \
645647
$(SRCDIR)/fossil.popupwidget.js \
646648
$(SRCDIR)/fossil.storage.js \
647649
$(SRCDIR)/fossil.tabs.js \
648650
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -635,13 +635,15 @@
635 $(SRCDIR)/fossil.copybutton.js \
636 $(SRCDIR)/fossil.dom.js \
637 $(SRCDIR)/fossil.fetch.js \
638 $(SRCDIR)/fossil.info-diff.js \
639 $(SRCDIR)/fossil.numbered-lines.js \
 
640 $(SRCDIR)/fossil.page.fileedit.js \
641 $(SRCDIR)/fossil.page.forumpost.js \
642 $(SRCDIR)/fossil.page.pikchrshow.js \
 
643 $(SRCDIR)/fossil.page.wikiedit.js \
644 $(SRCDIR)/fossil.pikchr.js \
645 $(SRCDIR)/fossil.popupwidget.js \
646 $(SRCDIR)/fossil.storage.js \
647 $(SRCDIR)/fossil.tabs.js \
648
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -635,13 +635,15 @@
635 $(SRCDIR)/fossil.copybutton.js \
636 $(SRCDIR)/fossil.dom.js \
637 $(SRCDIR)/fossil.fetch.js \
638 $(SRCDIR)/fossil.info-diff.js \
639 $(SRCDIR)/fossil.numbered-lines.js \
640 $(SRCDIR)/fossil.page.brlist.js \
641 $(SRCDIR)/fossil.page.fileedit.js \
642 $(SRCDIR)/fossil.page.forumpost.js \
643 $(SRCDIR)/fossil.page.pikchrshow.js \
644 $(SRCDIR)/fossil.page.whistory.js \
645 $(SRCDIR)/fossil.page.wikiedit.js \
646 $(SRCDIR)/fossil.pikchr.js \
647 $(SRCDIR)/fossil.popupwidget.js \
648 $(SRCDIR)/fossil.storage.js \
649 $(SRCDIR)/fossil.tabs.js \
650
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -577,13 +577,15 @@
577577
"$(SRCDIR)\fossil.copybutton.js" \
578578
"$(SRCDIR)\fossil.dom.js" \
579579
"$(SRCDIR)\fossil.fetch.js" \
580580
"$(SRCDIR)\fossil.info-diff.js" \
581581
"$(SRCDIR)\fossil.numbered-lines.js" \
582
+ "$(SRCDIR)\fossil.page.brlist.js" \
582583
"$(SRCDIR)\fossil.page.fileedit.js" \
583584
"$(SRCDIR)\fossil.page.forumpost.js" \
584585
"$(SRCDIR)\fossil.page.pikchrshow.js" \
586
+ "$(SRCDIR)\fossil.page.whistory.js" \
585587
"$(SRCDIR)\fossil.page.wikiedit.js" \
586588
"$(SRCDIR)\fossil.pikchr.js" \
587589
"$(SRCDIR)\fossil.popupwidget.js" \
588590
"$(SRCDIR)\fossil.storage.js" \
589591
"$(SRCDIR)\fossil.tabs.js" \
@@ -1181,13 +1183,15 @@
11811183
echo "$(SRCDIR)\fossil.copybutton.js" >> $@
11821184
echo "$(SRCDIR)\fossil.dom.js" >> $@
11831185
echo "$(SRCDIR)\fossil.fetch.js" >> $@
11841186
echo "$(SRCDIR)\fossil.info-diff.js" >> $@
11851187
echo "$(SRCDIR)\fossil.numbered-lines.js" >> $@
1188
+ echo "$(SRCDIR)\fossil.page.brlist.js" >> $@
11861189
echo "$(SRCDIR)\fossil.page.fileedit.js" >> $@
11871190
echo "$(SRCDIR)\fossil.page.forumpost.js" >> $@
11881191
echo "$(SRCDIR)\fossil.page.pikchrshow.js" >> $@
1192
+ echo "$(SRCDIR)\fossil.page.whistory.js" >> $@
11891193
echo "$(SRCDIR)\fossil.page.wikiedit.js" >> $@
11901194
echo "$(SRCDIR)\fossil.pikchr.js" >> $@
11911195
echo "$(SRCDIR)\fossil.popupwidget.js" >> $@
11921196
echo "$(SRCDIR)\fossil.storage.js" >> $@
11931197
echo "$(SRCDIR)\fossil.tabs.js" >> $@
11941198
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -577,13 +577,15 @@
577 "$(SRCDIR)\fossil.copybutton.js" \
578 "$(SRCDIR)\fossil.dom.js" \
579 "$(SRCDIR)\fossil.fetch.js" \
580 "$(SRCDIR)\fossil.info-diff.js" \
581 "$(SRCDIR)\fossil.numbered-lines.js" \
 
582 "$(SRCDIR)\fossil.page.fileedit.js" \
583 "$(SRCDIR)\fossil.page.forumpost.js" \
584 "$(SRCDIR)\fossil.page.pikchrshow.js" \
 
585 "$(SRCDIR)\fossil.page.wikiedit.js" \
586 "$(SRCDIR)\fossil.pikchr.js" \
587 "$(SRCDIR)\fossil.popupwidget.js" \
588 "$(SRCDIR)\fossil.storage.js" \
589 "$(SRCDIR)\fossil.tabs.js" \
@@ -1181,13 +1183,15 @@
1181 echo "$(SRCDIR)\fossil.copybutton.js" >> $@
1182 echo "$(SRCDIR)\fossil.dom.js" >> $@
1183 echo "$(SRCDIR)\fossil.fetch.js" >> $@
1184 echo "$(SRCDIR)\fossil.info-diff.js" >> $@
1185 echo "$(SRCDIR)\fossil.numbered-lines.js" >> $@
 
1186 echo "$(SRCDIR)\fossil.page.fileedit.js" >> $@
1187 echo "$(SRCDIR)\fossil.page.forumpost.js" >> $@
1188 echo "$(SRCDIR)\fossil.page.pikchrshow.js" >> $@
 
1189 echo "$(SRCDIR)\fossil.page.wikiedit.js" >> $@
1190 echo "$(SRCDIR)\fossil.pikchr.js" >> $@
1191 echo "$(SRCDIR)\fossil.popupwidget.js" >> $@
1192 echo "$(SRCDIR)\fossil.storage.js" >> $@
1193 echo "$(SRCDIR)\fossil.tabs.js" >> $@
1194
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -577,13 +577,15 @@
577 "$(SRCDIR)\fossil.copybutton.js" \
578 "$(SRCDIR)\fossil.dom.js" \
579 "$(SRCDIR)\fossil.fetch.js" \
580 "$(SRCDIR)\fossil.info-diff.js" \
581 "$(SRCDIR)\fossil.numbered-lines.js" \
582 "$(SRCDIR)\fossil.page.brlist.js" \
583 "$(SRCDIR)\fossil.page.fileedit.js" \
584 "$(SRCDIR)\fossil.page.forumpost.js" \
585 "$(SRCDIR)\fossil.page.pikchrshow.js" \
586 "$(SRCDIR)\fossil.page.whistory.js" \
587 "$(SRCDIR)\fossil.page.wikiedit.js" \
588 "$(SRCDIR)\fossil.pikchr.js" \
589 "$(SRCDIR)\fossil.popupwidget.js" \
590 "$(SRCDIR)\fossil.storage.js" \
591 "$(SRCDIR)\fossil.tabs.js" \
@@ -1181,13 +1183,15 @@
1183 echo "$(SRCDIR)\fossil.copybutton.js" >> $@
1184 echo "$(SRCDIR)\fossil.dom.js" >> $@
1185 echo "$(SRCDIR)\fossil.fetch.js" >> $@
1186 echo "$(SRCDIR)\fossil.info-diff.js" >> $@
1187 echo "$(SRCDIR)\fossil.numbered-lines.js" >> $@
1188 echo "$(SRCDIR)\fossil.page.brlist.js" >> $@
1189 echo "$(SRCDIR)\fossil.page.fileedit.js" >> $@
1190 echo "$(SRCDIR)\fossil.page.forumpost.js" >> $@
1191 echo "$(SRCDIR)\fossil.page.pikchrshow.js" >> $@
1192 echo "$(SRCDIR)\fossil.page.whistory.js" >> $@
1193 echo "$(SRCDIR)\fossil.page.wikiedit.js" >> $@
1194 echo "$(SRCDIR)\fossil.pikchr.js" >> $@
1195 echo "$(SRCDIR)\fossil.popupwidget.js" >> $@
1196 echo "$(SRCDIR)\fossil.storage.js" >> $@
1197 echo "$(SRCDIR)\fossil.tabs.js" >> $@
1198
+6 -6
--- www/alerts.md
+++ www/alerts.md
@@ -551,10 +551,11 @@
551551
Web pages available to users and subscribers:
552552
553553
* The [`/subscribe`](/help?cmd=/subscribe) page
554554
* The [`/alerts`](/help?cmd=/alerts) page
555555
* The [`/unsubscribe`](/help?cmd=/unsubscribe) page
556
+ * The [`/renew`](/help?cmd=/renew) page
556557
* The [`/contact_admin`](/help?cmd=/contact_admin) page
557558
558559
Administrator-only web pages:
559560
560561
* The [`/setup_notification`](/help?cmd=/setup_notification) page
@@ -574,11 +575,11 @@
574575
575576
576577
<a id="datades"></a>
577578
### Data Design
578579
579
-There are three new tables in the repository database, starting with
580
+There are two new tables in the repository database, starting with
580581
Fossil 2.7. These tables are not created in new repositories by
581582
default. The tables only come into existence as needed when email
582583
alerts are configured and used.
583584
584585
@@ -599,15 +600,14 @@
599600
and records timeline entries. In other words, there is one
600601
row in the EVENT table for each possible timeline entry. The
601602
PENDING\_ALERT table refers to EVENT table entries for which
602603
we might need to send alert emails.
603604
604
- * <b>EMAIL\_BOUNCE</b> →
605
- This table is intended to record email bounce history so that
606
- subscribers with excessive bounces can be turned off. That
607
- logic has not yet been implemented so the EMAIL\_BOUNCE table
608
- is currently unused.
605
+There was a third table "EMAIL_BOUNCE" in Fossil versions 2.7 through 2.14.
606
+That table was intended to record email bounce history so that
607
+subscribers with excessive bounces can be turned off. But that feature
608
+was never implemented and the table was removed in Fossil 2.15.
609609
610610
As pointed out above, ["subscribers" are distinct from "users"](#uvs).
611611
The SUBSCRIBER.SUNAME field is the optional linkage between users and
612612
subscribers.
613613
614614
--- www/alerts.md
+++ www/alerts.md
@@ -551,10 +551,11 @@
551 Web pages available to users and subscribers:
552
553 * The [`/subscribe`](/help?cmd=/subscribe) page
554 * The [`/alerts`](/help?cmd=/alerts) page
555 * The [`/unsubscribe`](/help?cmd=/unsubscribe) page
 
556 * The [`/contact_admin`](/help?cmd=/contact_admin) page
557
558 Administrator-only web pages:
559
560 * The [`/setup_notification`](/help?cmd=/setup_notification) page
@@ -574,11 +575,11 @@
574
575
576 <a id="datades"></a>
577 ### Data Design
578
579 There are three new tables in the repository database, starting with
580 Fossil 2.7. These tables are not created in new repositories by
581 default. The tables only come into existence as needed when email
582 alerts are configured and used.
583
584
@@ -599,15 +600,14 @@
599 and records timeline entries. In other words, there is one
600 row in the EVENT table for each possible timeline entry. The
601 PENDING\_ALERT table refers to EVENT table entries for which
602 we might need to send alert emails.
603
604 * <b>EMAIL\_BOUNCE</b> →
605 This table is intended to record email bounce history so that
606 subscribers with excessive bounces can be turned off. That
607 logic has not yet been implemented so the EMAIL\_BOUNCE table
608 is currently unused.
609
610 As pointed out above, ["subscribers" are distinct from "users"](#uvs).
611 The SUBSCRIBER.SUNAME field is the optional linkage between users and
612 subscribers.
613
614
--- www/alerts.md
+++ www/alerts.md
@@ -551,10 +551,11 @@
551 Web pages available to users and subscribers:
552
553 * The [`/subscribe`](/help?cmd=/subscribe) page
554 * The [`/alerts`](/help?cmd=/alerts) page
555 * The [`/unsubscribe`](/help?cmd=/unsubscribe) page
556 * The [`/renew`](/help?cmd=/renew) page
557 * The [`/contact_admin`](/help?cmd=/contact_admin) page
558
559 Administrator-only web pages:
560
561 * The [`/setup_notification`](/help?cmd=/setup_notification) page
@@ -574,11 +575,11 @@
575
576
577 <a id="datades"></a>
578 ### Data Design
579
580 There are two new tables in the repository database, starting with
581 Fossil 2.7. These tables are not created in new repositories by
582 default. The tables only come into existence as needed when email
583 alerts are configured and used.
584
585
@@ -599,15 +600,14 @@
600 and records timeline entries. In other words, there is one
601 row in the EVENT table for each possible timeline entry. The
602 PENDING\_ALERT table refers to EVENT table entries for which
603 we might need to send alert emails.
604
605 There was a third table "EMAIL_BOUNCE" in Fossil versions 2.7 through 2.14.
606 That table was intended to record email bounce history so that
607 subscribers with excessive bounces can be turned off. But that feature
608 was never implemented and the table was removed in Fossil 2.15.
 
609
610 As pointed out above, ["subscribers" are distinct from "users"](#uvs).
611 The SUBSCRIBER.SUNAME field is the optional linkage between users and
612 subscribers.
613
614
+37 -4
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,20 +1,49 @@
11
<title>Change Log</title>
22
33
<a name='v2_16'></a>
44
<h2>Changes for Version 2.16 (pending)</h2>
5
+ * <b>Security:</b> Fix the client-side TLS so that it verifies that the
6
+ server hostname matches its certificate. <b>Upgrading to
7
+ the patch is recommended.</b>
8
+ * The [/brlist|/brlist web page] allows the user to
9
+ select multiple branches to be displayed together in a single
10
+ timeline.
11
+ * The [./forum.wiki|Forum] provides a hyperlink on the author of each
12
+ post that goes to a timeline of recent posts by that same author.
13
+ * The [/help?cmd=merge|fossil merge] command now does a better job merging
14
+ branches where files have been renamed between the current branch and the
15
+ branch being merged.
16
+ * The [/help?cmd=open|fossil open] command allows the repository file
17
+ to be inside the working directory without requiring the --force flag.
18
+ * The [/help?cmd=/wikiedit|/wikiedit] and [/help?cmd=/wikinew|/wikinew]
19
+ pages now default to markdown format.
20
+ * The [/help?cmd=/login|/login] page now links to a user's forum post
21
+ timeline if the repository has forum posts.
22
+ * Tags may now be propagated for forum posts, wiki pages, and technotes.
23
+ The [/help?cmd=tag|tag command] can now manipulate and list such tags.
24
+ * [./caps/login-groups.md|Login-Groups] are now show on the repository
25
+ list of the "[/help?cmd=all|fossil all ui]" command.
26
+ * Administrators can configure [./alerts|email alerts] to expire
27
+ a specific number of days (ex: 365) after the last user contact with
28
+ the Fossil server. This can prevents alert emails being sent to
29
+ abandoned email accounts forever.
530
* [/wcontent|Listing] of the available wiki pages
631
[/timeline?r=wcontent-subsets|gained] the ability to
732
[./javascript.md#wcontent|interactively] adjust a subset of
833
wiki pages that are shown; this is based on the
934
classification of wiki page names according to the
1035
[/help?cmd=wiki-classes|configurable] glob patterns.
1136
1237
<a name='v2_15'></a>
13
-<h2>Changes for Version 2.15 (2021-03-26) and Patch 2.15.1 on (2021-04-07)</h2>
38
+<h2>Changes for Version 2.15 (2021-03-26) and Patch 2.15.1 on (2021-04-07)
39
+ and 2.15.2 on (2021-06-15)</h2>
40
+ * <b>Patch 2.15.2:</b> Fix the client-side TLS so that it verifies that the
41
+ server hostname matches its certificate. <b>Upgrading to
42
+ the patch is recommended.</b>
1443
* <b>Patch 2.15.1:</b> Fix a data exfiltration bug in the server. <b>Upgrading to
15
- the patch is recommended.</b><p>
44
+ the patch is recommended.</b>
1645
* The [./defcsp.md|default CSP] has been relaxed slightly to allow
1746
images to be loaded from any URL. All other resources are still
1847
locked down by default.
1948
* The built-in skins all use the "[/help?cmd=mainmenu|mainmenu]"
2049
setting to determine the content of the main menu.
@@ -89,13 +118,17 @@
89118
versions of a wiki (by the means of anchoring a "baseline" version)
90119
and the ability to squeeze several sequential edits made by the same
91120
user into a single "recycled" row (the latest edit in that sequence).
92121
93122
<a name='v2_14'></a>
94
-<h2>Changes for Version 2.14 (2021-01-20) and Patch 2.14.1 on (2021-04-07)</h2>
123
+<h2>Changes for Version 2.14 (2021-01-20) and Patch 2.14.1 on (2021-04-07)
124
+ and 2.14.2 on (2021-06-15)</h2>
125
+ * <b>Patch 2.14.2:</b> Fix the client-side TLS so that it verifies that the
126
+ server hostname matches its certificate. <b>Upgrading to
127
+ the patch is recommended.</b><
95128
* <b>Patch 2.14.1:</b> Fix a data exfiltration bug in the server.
96
- <b>Upgrading to the patch is recommended.</b><p>
129
+ <b>Upgrading to the patch is recommended.</b>
97130
* <b>Schema Update Notice #1:</b>
98131
This release drops a trigger from the database schema (replacing
99132
it with a TEMP trigger that is created as needed). This
100133
change happens automatically the first time you
101134
add content to a repository using Fossil 2.14 or later. No
102135
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,20 +1,49 @@
1 <title>Change Log</title>
2
3 <a name='v2_16'></a>
4 <h2>Changes for Version 2.16 (pending)</h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5 * [/wcontent|Listing] of the available wiki pages
6 [/timeline?r=wcontent-subsets|gained] the ability to
7 [./javascript.md#wcontent|interactively] adjust a subset of
8 wiki pages that are shown; this is based on the
9 classification of wiki page names according to the
10 [/help?cmd=wiki-classes|configurable] glob patterns.
11
12 <a name='v2_15'></a>
13 <h2>Changes for Version 2.15 (2021-03-26) and Patch 2.15.1 on (2021-04-07)</h2>
 
 
 
 
14 * <b>Patch 2.15.1:</b> Fix a data exfiltration bug in the server. <b>Upgrading to
15 the patch is recommended.</b><p>
16 * The [./defcsp.md|default CSP] has been relaxed slightly to allow
17 images to be loaded from any URL. All other resources are still
18 locked down by default.
19 * The built-in skins all use the "[/help?cmd=mainmenu|mainmenu]"
20 setting to determine the content of the main menu.
@@ -89,13 +118,17 @@
89 versions of a wiki (by the means of anchoring a "baseline" version)
90 and the ability to squeeze several sequential edits made by the same
91 user into a single "recycled" row (the latest edit in that sequence).
92
93 <a name='v2_14'></a>
94 <h2>Changes for Version 2.14 (2021-01-20) and Patch 2.14.1 on (2021-04-07)</h2>
 
 
 
 
95 * <b>Patch 2.14.1:</b> Fix a data exfiltration bug in the server.
96 <b>Upgrading to the patch is recommended.</b><p>
97 * <b>Schema Update Notice #1:</b>
98 This release drops a trigger from the database schema (replacing
99 it with a TEMP trigger that is created as needed). This
100 change happens automatically the first time you
101 add content to a repository using Fossil 2.14 or later. No
102
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,20 +1,49 @@
1 <title>Change Log</title>
2
3 <a name='v2_16'></a>
4 <h2>Changes for Version 2.16 (pending)</h2>
5 * <b>Security:</b> Fix the client-side TLS so that it verifies that the
6 server hostname matches its certificate. <b>Upgrading to
7 the patch is recommended.</b>
8 * The [/brlist|/brlist web page] allows the user to
9 select multiple branches to be displayed together in a single
10 timeline.
11 * The [./forum.wiki|Forum] provides a hyperlink on the author of each
12 post that goes to a timeline of recent posts by that same author.
13 * The [/help?cmd=merge|fossil merge] command now does a better job merging
14 branches where files have been renamed between the current branch and the
15 branch being merged.
16 * The [/help?cmd=open|fossil open] command allows the repository file
17 to be inside the working directory without requiring the --force flag.
18 * The [/help?cmd=/wikiedit|/wikiedit] and [/help?cmd=/wikinew|/wikinew]
19 pages now default to markdown format.
20 * The [/help?cmd=/login|/login] page now links to a user's forum post
21 timeline if the repository has forum posts.
22 * Tags may now be propagated for forum posts, wiki pages, and technotes.
23 The [/help?cmd=tag|tag command] can now manipulate and list such tags.
24 * [./caps/login-groups.md|Login-Groups] are now show on the repository
25 list of the "[/help?cmd=all|fossil all ui]" command.
26 * Administrators can configure [./alerts|email alerts] to expire
27 a specific number of days (ex: 365) after the last user contact with
28 the Fossil server. This can prevents alert emails being sent to
29 abandoned email accounts forever.
30 * [/wcontent|Listing] of the available wiki pages
31 [/timeline?r=wcontent-subsets|gained] the ability to
32 [./javascript.md#wcontent|interactively] adjust a subset of
33 wiki pages that are shown; this is based on the
34 classification of wiki page names according to the
35 [/help?cmd=wiki-classes|configurable] glob patterns.
36
37 <a name='v2_15'></a>
38 <h2>Changes for Version 2.15 (2021-03-26) and Patch 2.15.1 on (2021-04-07)
39 and 2.15.2 on (2021-06-15)</h2>
40 * <b>Patch 2.15.2:</b> Fix the client-side TLS so that it verifies that the
41 server hostname matches its certificate. <b>Upgrading to
42 the patch is recommended.</b>
43 * <b>Patch 2.15.1:</b> Fix a data exfiltration bug in the server. <b>Upgrading to
44 the patch is recommended.</b>
45 * The [./defcsp.md|default CSP] has been relaxed slightly to allow
46 images to be loaded from any URL. All other resources are still
47 locked down by default.
48 * The built-in skins all use the "[/help?cmd=mainmenu|mainmenu]"
49 setting to determine the content of the main menu.
@@ -89,13 +118,17 @@
118 versions of a wiki (by the means of anchoring a "baseline" version)
119 and the ability to squeeze several sequential edits made by the same
120 user into a single "recycled" row (the latest edit in that sequence).
121
122 <a name='v2_14'></a>
123 <h2>Changes for Version 2.14 (2021-01-20) and Patch 2.14.1 on (2021-04-07)
124 and 2.14.2 on (2021-06-15)</h2>
125 * <b>Patch 2.14.2:</b> Fix the client-side TLS so that it verifies that the
126 server hostname matches its certificate. <b>Upgrading to
127 the patch is recommended.</b><
128 * <b>Patch 2.14.1:</b> Fix a data exfiltration bug in the server.
129 <b>Upgrading to the patch is recommended.</b>
130 * <b>Schema Update Notice #1:</b>
131 This release drops a trigger from the database schema (replacing
132 it with a TEMP trigger that is created as needed). This
133 change happens automatically the first time you
134 add content to a repository using Fossil 2.14 or later. No
135
+37 -4
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,20 +1,49 @@
11
<title>Change Log</title>
22
33
<a name='v2_16'></a>
44
<h2>Changes for Version 2.16 (pending)</h2>
5
+ * <b>Security:</b> Fix the client-side TLS so that it verifies that the
6
+ server hostname matches its certificate. <b>Upgrading to
7
+ the patch is recommended.</b>
8
+ * The [/brlist|/brlist web page] allows the user to
9
+ select multiple branches to be displayed together in a single
10
+ timeline.
11
+ * The [./forum.wiki|Forum] provides a hyperlink on the author of each
12
+ post that goes to a timeline of recent posts by that same author.
13
+ * The [/help?cmd=merge|fossil merge] command now does a better job merging
14
+ branches where files have been renamed between the current branch and the
15
+ branch being merged.
16
+ * The [/help?cmd=open|fossil open] command allows the repository file
17
+ to be inside the working directory without requiring the --force flag.
18
+ * The [/help?cmd=/wikiedit|/wikiedit] and [/help?cmd=/wikinew|/wikinew]
19
+ pages now default to markdown format.
20
+ * The [/help?cmd=/login|/login] page now links to a user's forum post
21
+ timeline if the repository has forum posts.
22
+ * Tags may now be propagated for forum posts, wiki pages, and technotes.
23
+ The [/help?cmd=tag|tag command] can now manipulate and list such tags.
24
+ * [./caps/login-groups.md|Login-Groups] are now show on the repository
25
+ list of the "[/help?cmd=all|fossil all ui]" command.
26
+ * Administrators can configure [./alerts|email alerts] to expire
27
+ a specific number of days (ex: 365) after the last user contact with
28
+ the Fossil server. This can prevents alert emails being sent to
29
+ abandoned email accounts forever.
530
* [/wcontent|Listing] of the available wiki pages
631
[/timeline?r=wcontent-subsets|gained] the ability to
732
[./javascript.md#wcontent|interactively] adjust a subset of
833
wiki pages that are shown; this is based on the
934
classification of wiki page names according to the
1035
[/help?cmd=wiki-classes|configurable] glob patterns.
1136
1237
<a name='v2_15'></a>
13
-<h2>Changes for Version 2.15 (2021-03-26) and Patch 2.15.1 on (2021-04-07)</h2>
38
+<h2>Changes for Version 2.15 (2021-03-26) and Patch 2.15.1 on (2021-04-07)
39
+ and 2.15.2 on (2021-06-15)</h2>
40
+ * <b>Patch 2.15.2:</b> Fix the client-side TLS so that it verifies that the
41
+ server hostname matches its certificate. <b>Upgrading to
42
+ the patch is recommended.</b>
1443
* <b>Patch 2.15.1:</b> Fix a data exfiltration bug in the server. <b>Upgrading to
15
- the patch is recommended.</b><p>
44
+ the patch is recommended.</b>
1645
* The [./defcsp.md|default CSP] has been relaxed slightly to allow
1746
images to be loaded from any URL. All other resources are still
1847
locked down by default.
1948
* The built-in skins all use the "[/help?cmd=mainmenu|mainmenu]"
2049
setting to determine the content of the main menu.
@@ -89,13 +118,17 @@
89118
versions of a wiki (by the means of anchoring a "baseline" version)
90119
and the ability to squeeze several sequential edits made by the same
91120
user into a single "recycled" row (the latest edit in that sequence).
92121
93122
<a name='v2_14'></a>
94
-<h2>Changes for Version 2.14 (2021-01-20) and Patch 2.14.1 on (2021-04-07)</h2>
123
+<h2>Changes for Version 2.14 (2021-01-20) and Patch 2.14.1 on (2021-04-07)
124
+ and 2.14.2 on (2021-06-15)</h2>
125
+ * <b>Patch 2.14.2:</b> Fix the client-side TLS so that it verifies that the
126
+ server hostname matches its certificate. <b>Upgrading to
127
+ the patch is recommended.</b><
95128
* <b>Patch 2.14.1:</b> Fix a data exfiltration bug in the server.
96
- <b>Upgrading to the patch is recommended.</b><p>
129
+ <b>Upgrading to the patch is recommended.</b>
97130
* <b>Schema Update Notice #1:</b>
98131
This release drops a trigger from the database schema (replacing
99132
it with a TEMP trigger that is created as needed). This
100133
change happens automatically the first time you
101134
add content to a repository using Fossil 2.14 or later. No
102135
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,20 +1,49 @@
1 <title>Change Log</title>
2
3 <a name='v2_16'></a>
4 <h2>Changes for Version 2.16 (pending)</h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5 * [/wcontent|Listing] of the available wiki pages
6 [/timeline?r=wcontent-subsets|gained] the ability to
7 [./javascript.md#wcontent|interactively] adjust a subset of
8 wiki pages that are shown; this is based on the
9 classification of wiki page names according to the
10 [/help?cmd=wiki-classes|configurable] glob patterns.
11
12 <a name='v2_15'></a>
13 <h2>Changes for Version 2.15 (2021-03-26) and Patch 2.15.1 on (2021-04-07)</h2>
 
 
 
 
14 * <b>Patch 2.15.1:</b> Fix a data exfiltration bug in the server. <b>Upgrading to
15 the patch is recommended.</b><p>
16 * The [./defcsp.md|default CSP] has been relaxed slightly to allow
17 images to be loaded from any URL. All other resources are still
18 locked down by default.
19 * The built-in skins all use the "[/help?cmd=mainmenu|mainmenu]"
20 setting to determine the content of the main menu.
@@ -89,13 +118,17 @@
89 versions of a wiki (by the means of anchoring a "baseline" version)
90 and the ability to squeeze several sequential edits made by the same
91 user into a single "recycled" row (the latest edit in that sequence).
92
93 <a name='v2_14'></a>
94 <h2>Changes for Version 2.14 (2021-01-20) and Patch 2.14.1 on (2021-04-07)</h2>
 
 
 
 
95 * <b>Patch 2.14.1:</b> Fix a data exfiltration bug in the server.
96 <b>Upgrading to the patch is recommended.</b><p>
97 * <b>Schema Update Notice #1:</b>
98 This release drops a trigger from the database schema (replacing
99 it with a TEMP trigger that is created as needed). This
100 change happens automatically the first time you
101 add content to a repository using Fossil 2.14 or later. No
102
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,20 +1,49 @@
1 <title>Change Log</title>
2
3 <a name='v2_16'></a>
4 <h2>Changes for Version 2.16 (pending)</h2>
5 * <b>Security:</b> Fix the client-side TLS so that it verifies that the
6 server hostname matches its certificate. <b>Upgrading to
7 the patch is recommended.</b>
8 * The [/brlist|/brlist web page] allows the user to
9 select multiple branches to be displayed together in a single
10 timeline.
11 * The [./forum.wiki|Forum] provides a hyperlink on the author of each
12 post that goes to a timeline of recent posts by that same author.
13 * The [/help?cmd=merge|fossil merge] command now does a better job merging
14 branches where files have been renamed between the current branch and the
15 branch being merged.
16 * The [/help?cmd=open|fossil open] command allows the repository file
17 to be inside the working directory without requiring the --force flag.
18 * The [/help?cmd=/wikiedit|/wikiedit] and [/help?cmd=/wikinew|/wikinew]
19 pages now default to markdown format.
20 * The [/help?cmd=/login|/login] page now links to a user's forum post
21 timeline if the repository has forum posts.
22 * Tags may now be propagated for forum posts, wiki pages, and technotes.
23 The [/help?cmd=tag|tag command] can now manipulate and list such tags.
24 * [./caps/login-groups.md|Login-Groups] are now show on the repository
25 list of the "[/help?cmd=all|fossil all ui]" command.
26 * Administrators can configure [./alerts|email alerts] to expire
27 a specific number of days (ex: 365) after the last user contact with
28 the Fossil server. This can prevents alert emails being sent to
29 abandoned email accounts forever.
30 * [/wcontent|Listing] of the available wiki pages
31 [/timeline?r=wcontent-subsets|gained] the ability to
32 [./javascript.md#wcontent|interactively] adjust a subset of
33 wiki pages that are shown; this is based on the
34 classification of wiki page names according to the
35 [/help?cmd=wiki-classes|configurable] glob patterns.
36
37 <a name='v2_15'></a>
38 <h2>Changes for Version 2.15 (2021-03-26) and Patch 2.15.1 on (2021-04-07)
39 and 2.15.2 on (2021-06-15)</h2>
40 * <b>Patch 2.15.2:</b> Fix the client-side TLS so that it verifies that the
41 server hostname matches its certificate. <b>Upgrading to
42 the patch is recommended.</b>
43 * <b>Patch 2.15.1:</b> Fix a data exfiltration bug in the server. <b>Upgrading to
44 the patch is recommended.</b>
45 * The [./defcsp.md|default CSP] has been relaxed slightly to allow
46 images to be loaded from any URL. All other resources are still
47 locked down by default.
48 * The built-in skins all use the "[/help?cmd=mainmenu|mainmenu]"
49 setting to determine the content of the main menu.
@@ -89,13 +118,17 @@
118 versions of a wiki (by the means of anchoring a "baseline" version)
119 and the ability to squeeze several sequential edits made by the same
120 user into a single "recycled" row (the latest edit in that sequence).
121
122 <a name='v2_14'></a>
123 <h2>Changes for Version 2.14 (2021-01-20) and Patch 2.14.1 on (2021-04-07)
124 and 2.14.2 on (2021-06-15)</h2>
125 * <b>Patch 2.14.2:</b> Fix the client-side TLS so that it verifies that the
126 server hostname matches its certificate. <b>Upgrading to
127 the patch is recommended.</b><
128 * <b>Patch 2.14.1:</b> Fix a data exfiltration bug in the server.
129 <b>Upgrading to the patch is recommended.</b>
130 * <b>Schema Update Notice #1:</b>
131 This release drops a trigger from the database schema (replacing
132 it with a TEMP trigger that is created as needed). This
133 change happens automatically the first time you
134 add content to a repository using Fossil 2.14 or later. No
135
--- www/fossil-v-git.wiki
+++ www/fossil-v-git.wiki
@@ -543,80 +543,11 @@
543543
[https://en.wikipedia.org/wiki/Impact_wrench|automotive air impact
544544
wrench] running at 8000 RPM driving an M8 socket-cap bolt at 16 cm/s is
545545
not the best way to hang a picture on the living room wall.
546546
547547
548
-<h4 id="contrib">2.5.3 Accepting Contributions</h4>
549
-
550
-As of this writing, Git has received about 4.5 times as many commits as
551
-Fossil resulting in about 2.5 times as many lines of source code. The line
552
-count excludes tests and in-tree third-party dependencies. It does not
553
-exclude the default GUI for each, since it's integral for Fossil, so we
554
-count the size of <tt>gitk</tt> in this.
555
-
556
-It is obvious that Git is bigger in part because of its first-mover
557
-advantage, which resulted in a larger user community, which results in
558
-more contributions. But is that the <i>only</i> reason? We believe there
559
-are other relevant differences that also play into this which fall out
560
-of the "Linux vs. SQLite" framing: licensing, community structure, and
561
-how we react to
562
-[https://www.jonobacon.com/2012/07/25/building-strong-community-structural-integrity/|drive-by
563
-contributions]. In brief, it's harder to get a new feature into Fossil
564
-than into Git.
565
-
566
-A larger feature set is not necessarily a good thing. Git's command line
567
-interface is famously arcane. Masters of the arcane are able to do
568
-wizardly things, but only by studying their art deeply for years. This
569
-strikes us as a good thing only in cases where use of the tool itself is
570
-the primary point of that user's work.
571
-
572
-Almost no one uses a DVCS for its own sake; very few people get paid
573
-specifically in order to drive a DVCS. We use DVCSes as a tool to
574
-support some other effort, so we do not necessarily want the DVCS with
575
-the most features. We want a DVCS with easily internalized behavior so
576
-we can thoroughly master it despite spending only a small fraction of
577
-our working time thinking about the DVCS. We want to pick the tool up,
578
-use it quickly, and then set it aside in order to get back to our actual
579
-job as quickly as possible.
580
-
581
-Professional software developers in particular are prone to focusing on
582
-feature set sizes when choosing tools because this is sometimes a highly
583
-important consideration. They spend all day, every day, in their
584
-favorite text editors, and time they spend learning all of the arcana of
585
-their favorite programming languages is well-spent. Skills with these
586
-tools are direct productivity drivers, which in turn directly drives how
587
-much money a developer can make. (Or how much idle time they can afford
588
-to take, which amounts to the same thing.) But if you are a professional
589
-software developer, we want you to ask yourself a question: "How do I
590
-get paid more by mastering arcane features of my DVCS?" Unless you have
591
-a good answer to that, you probably do not want to be choosing a DVCS
592
-based on how many arcane features it has.
593
-
594
-The argument is similar for other types of users: if you are a hobbyist,
595
-how much time do you want to spend mastering your DVCS instead of on
596
-the hobby supported by use of that DVCS?
597
-
598
-There is some minimal set of features required to achieve the purposes
599
-that drive our selection of a DVCS, but there is a level beyond which
600
-more features only slow us down while we're learning the tool, since we
601
-must plow through documentation on features we're not likely to ever
602
-use. When the number of features grows to the point where people of
603
-normal motivation cannot spend the time to master them all, the tool
604
-becomes <i>less</i> productive to use.
605
-
606
-The core developers of the Fossil project achieve a balance between feature
607
-set size and ease of use by
608
-carefully choosing which users to give commit bits to, then in being
609
-choosy about which of the contributed feature branches to merge down to
610
-trunk. We say "no" to a lot of feature proposals.
611
-
612
-The end result is that Fossil more closely adheres to
613
-[https://en.wikipedia.org/wiki/Principle_of_least_astonishment|the
614
-principle of least astonishment] than Git does.
615
-
616
-
617
-<h4 id="branches">2.5.4 Individual Branches vs. The Entire Change History</h4>
548
+<h4 id="branches">2.5.3 Individual Branches vs. The Entire Change History</h4>
618549
619550
Both Fossil and Git store history as a directed acyclic graph (DAG)
620551
of changes, but Git tends to focus more on individual branches of
621552
the DAG, whereas Fossil puts more emphasis on the entire DAG.
622553
623554
--- www/fossil-v-git.wiki
+++ www/fossil-v-git.wiki
@@ -543,80 +543,11 @@
543 [https://en.wikipedia.org/wiki/Impact_wrench|automotive air impact
544 wrench] running at 8000 RPM driving an M8 socket-cap bolt at 16 cm/s is
545 not the best way to hang a picture on the living room wall.
546
547
548 <h4 id="contrib">2.5.3 Accepting Contributions</h4>
549
550 As of this writing, Git has received about 4.5 times as many commits as
551 Fossil resulting in about 2.5 times as many lines of source code. The line
552 count excludes tests and in-tree third-party dependencies. It does not
553 exclude the default GUI for each, since it's integral for Fossil, so we
554 count the size of <tt>gitk</tt> in this.
555
556 It is obvious that Git is bigger in part because of its first-mover
557 advantage, which resulted in a larger user community, which results in
558 more contributions. But is that the <i>only</i> reason? We believe there
559 are other relevant differences that also play into this which fall out
560 of the "Linux vs. SQLite" framing: licensing, community structure, and
561 how we react to
562 [https://www.jonobacon.com/2012/07/25/building-strong-community-structural-integrity/|drive-by
563 contributions]. In brief, it's harder to get a new feature into Fossil
564 than into Git.
565
566 A larger feature set is not necessarily a good thing. Git's command line
567 interface is famously arcane. Masters of the arcane are able to do
568 wizardly things, but only by studying their art deeply for years. This
569 strikes us as a good thing only in cases where use of the tool itself is
570 the primary point of that user's work.
571
572 Almost no one uses a DVCS for its own sake; very few people get paid
573 specifically in order to drive a DVCS. We use DVCSes as a tool to
574 support some other effort, so we do not necessarily want the DVCS with
575 the most features. We want a DVCS with easily internalized behavior so
576 we can thoroughly master it despite spending only a small fraction of
577 our working time thinking about the DVCS. We want to pick the tool up,
578 use it quickly, and then set it aside in order to get back to our actual
579 job as quickly as possible.
580
581 Professional software developers in particular are prone to focusing on
582 feature set sizes when choosing tools because this is sometimes a highly
583 important consideration. They spend all day, every day, in their
584 favorite text editors, and time they spend learning all of the arcana of
585 their favorite programming languages is well-spent. Skills with these
586 tools are direct productivity drivers, which in turn directly drives how
587 much money a developer can make. (Or how much idle time they can afford
588 to take, which amounts to the same thing.) But if you are a professional
589 software developer, we want you to ask yourself a question: "How do I
590 get paid more by mastering arcane features of my DVCS?" Unless you have
591 a good answer to that, you probably do not want to be choosing a DVCS
592 based on how many arcane features it has.
593
594 The argument is similar for other types of users: if you are a hobbyist,
595 how much time do you want to spend mastering your DVCS instead of on
596 the hobby supported by use of that DVCS?
597
598 There is some minimal set of features required to achieve the purposes
599 that drive our selection of a DVCS, but there is a level beyond which
600 more features only slow us down while we're learning the tool, since we
601 must plow through documentation on features we're not likely to ever
602 use. When the number of features grows to the point where people of
603 normal motivation cannot spend the time to master them all, the tool
604 becomes <i>less</i> productive to use.
605
606 The core developers of the Fossil project achieve a balance between feature
607 set size and ease of use by
608 carefully choosing which users to give commit bits to, then in being
609 choosy about which of the contributed feature branches to merge down to
610 trunk. We say "no" to a lot of feature proposals.
611
612 The end result is that Fossil more closely adheres to
613 [https://en.wikipedia.org/wiki/Principle_of_least_astonishment|the
614 principle of least astonishment] than Git does.
615
616
617 <h4 id="branches">2.5.4 Individual Branches vs. The Entire Change History</h4>
618
619 Both Fossil and Git store history as a directed acyclic graph (DAG)
620 of changes, but Git tends to focus more on individual branches of
621 the DAG, whereas Fossil puts more emphasis on the entire DAG.
622
623
--- www/fossil-v-git.wiki
+++ www/fossil-v-git.wiki
@@ -543,80 +543,11 @@
543 [https://en.wikipedia.org/wiki/Impact_wrench|automotive air impact
544 wrench] running at 8000 RPM driving an M8 socket-cap bolt at 16 cm/s is
545 not the best way to hang a picture on the living room wall.
546
547
548 <h4 id="branches">2.5.3 Individual Branches vs. The Entire Change History</h4>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
549
550 Both Fossil and Git store history as a directed acyclic graph (DAG)
551 of changes, but Git tends to focus more on individual branches of
552 the DAG, whereas Fossil puts more emphasis on the entire DAG.
553
554
+2 -2
--- www/index.wiki
+++ www/index.wiki
@@ -82,15 +82,15 @@
8282
the repository are consistent prior to each commit.
8383
8484
8. <b>Free and Open-Source</b> - [../COPYRIGHT-BSD2.txt|2-clause BSD license].
8585
8686
<hr>
87
-<h3>Latest Release: 2.15 ([/timeline?c=version-2.15|2021-03-26])</h3>
87
+<h3>Latest Release: 2.15.2 ([/timeline?c=version-2.15.2|2021-06-15])</h3>
8888
8989
* [/uv/download.html|Download]
9090
* [./changes.wiki#v2_15|Change Summary]
91
- * [/timeline?p=version-2.15&bt=version-2.14&y=ci|Check-ins in version 2.15]
91
+ * [/timeline?p=version-2.15.2&bt=version-2.14&y=ci|Check-ins in version 2.15.2]
9292
* [/timeline?df=version-2.15&y=ci|Check-ins derived from the 2.15 release]
9393
* [/timeline?t=release|Timeline of all past releases]
9494
9595
<hr>
9696
<h3>Quick Start</h3>
9797
--- www/index.wiki
+++ www/index.wiki
@@ -82,15 +82,15 @@
82 the repository are consistent prior to each commit.
83
84 8. <b>Free and Open-Source</b> - [../COPYRIGHT-BSD2.txt|2-clause BSD license].
85
86 <hr>
87 <h3>Latest Release: 2.15 ([/timeline?c=version-2.15|2021-03-26])</h3>
88
89 * [/uv/download.html|Download]
90 * [./changes.wiki#v2_15|Change Summary]
91 * [/timeline?p=version-2.15&bt=version-2.14&y=ci|Check-ins in version 2.15]
92 * [/timeline?df=version-2.15&y=ci|Check-ins derived from the 2.15 release]
93 * [/timeline?t=release|Timeline of all past releases]
94
95 <hr>
96 <h3>Quick Start</h3>
97
--- www/index.wiki
+++ www/index.wiki
@@ -82,15 +82,15 @@
82 the repository are consistent prior to each commit.
83
84 8. <b>Free and Open-Source</b> - [../COPYRIGHT-BSD2.txt|2-clause BSD license].
85
86 <hr>
87 <h3>Latest Release: 2.15.2 ([/timeline?c=version-2.15.2|2021-06-15])</h3>
88
89 * [/uv/download.html|Download]
90 * [./changes.wiki#v2_15|Change Summary]
91 * [/timeline?p=version-2.15.2&bt=version-2.14&y=ci|Check-ins in version 2.15.2]
92 * [/timeline?df=version-2.15&y=ci|Check-ins derived from the 2.15 release]
93 * [/timeline?t=release|Timeline of all past releases]
94
95 <hr>
96 <h3>Quick Start</h3>
97
--- www/javascript.md
+++ www/javascript.md
@@ -570,10 +570,23 @@
570570
571571
…would pull the messages submitted since the last poll. Making the
572572
gateway bidirectional should be possible as well, as long as it properly
573573
uses SQLite transactions.
574574
575
+### <a id="brlist"></a>List of branches
576
+
577
+Since Fossil 2.16 the [`/brlist`](/brlist) page uses JavaScript to enable
578
+selection of several branches for further study via `/timeline`.
579
+Client-side script interactively responds to checkboxes' events
580
+and constructs a special hyperlink in the submenu.
581
+Clicking this hyperlink loads a `/timeline` page that shows
582
+only these selected branches (and the related check-ins).
583
+
584
+_Potential Workaround:_ A user can manually construct an appropriate
585
+regular expession and put it into the "Tag Filter" entry of the
586
+`/timeline` page (in its advanced mode).
587
+
575588
### <a id="wcontent"></a>Wiki content listing
576589
577590
[Since](/timeline?r=wcontent-subsets) version 2.16 it is possible to
578591
add [configurable](/help?cmd=wiki-classes) checkbox controls to the
579592
submenu of [available wiki pages](/wcontent) for the interactive
@@ -615,12 +628,12 @@
615628
2) Features end users request which catch the interest of one or more
616629
developers, provided the developer(s) in question are in a position to
617630
expend the effort.
618631
619632
3) Features end users and co-contributors can convince a developer into
620
-coding even when they really don't want to. 𘘉
633
+coding even when they really don't want to.
621634
622635
In all of this, Fossil's project lead understandably has the final
623636
say-so in whether any given feature indeed gets merged into the mainline
624637
trunk. Development of any given feature, no matter how much effort was
625638
involved, does not guarantee its eventual inclusion into the public
626639
releases.
627640
--- www/javascript.md
+++ www/javascript.md
@@ -570,10 +570,23 @@
570
571 …would pull the messages submitted since the last poll. Making the
572 gateway bidirectional should be possible as well, as long as it properly
573 uses SQLite transactions.
574
 
 
 
 
 
 
 
 
 
 
 
 
 
575 ### <a id="wcontent"></a>Wiki content listing
576
577 [Since](/timeline?r=wcontent-subsets) version 2.16 it is possible to
578 add [configurable](/help?cmd=wiki-classes) checkbox controls to the
579 submenu of [available wiki pages](/wcontent) for the interactive
@@ -615,12 +628,12 @@
615 2) Features end users request which catch the interest of one or more
616 developers, provided the developer(s) in question are in a position to
617 expend the effort.
618
619 3) Features end users and co-contributors can convince a developer into
620 coding even when they really don't want to. 𘘉
621
622 In all of this, Fossil's project lead understandably has the final
623 say-so in whether any given feature indeed gets merged into the mainline
624 trunk. Development of any given feature, no matter how much effort was
625 involved, does not guarantee its eventual inclusion into the public
626 releases.
627
--- www/javascript.md
+++ www/javascript.md
@@ -570,10 +570,23 @@
570
571 …would pull the messages submitted since the last poll. Making the
572 gateway bidirectional should be possible as well, as long as it properly
573 uses SQLite transactions.
574
575 ### <a id="brlist"></a>List of branches
576
577 Since Fossil 2.16 the [`/brlist`](/brlist) page uses JavaScript to enable
578 selection of several branches for further study via `/timeline`.
579 Client-side script interactively responds to checkboxes' events
580 and constructs a special hyperlink in the submenu.
581 Clicking this hyperlink loads a `/timeline` page that shows
582 only these selected branches (and the related check-ins).
583
584 _Potential Workaround:_ A user can manually construct an appropriate
585 regular expession and put it into the "Tag Filter" entry of the
586 `/timeline` page (in its advanced mode).
587
588 ### <a id="wcontent"></a>Wiki content listing
589
590 [Since](/timeline?r=wcontent-subsets) version 2.16 it is possible to
591 add [configurable](/help?cmd=wiki-classes) checkbox controls to the
592 submenu of [available wiki pages](/wcontent) for the interactive
@@ -615,12 +628,12 @@
628 2) Features end users request which catch the interest of one or more
629 developers, provided the developer(s) in question are in a position to
630 expend the effort.
631
632 3) Features end users and co-contributors can convince a developer into
633 coding even when they really don't want to.
634
635 In all of this, Fossil's project lead understandably has the final
636 say-so in whether any given feature indeed gets merged into the mainline
637 trunk. Development of any given feature, no matter how much effort was
638 involved, does not guarantee its eventual inclusion into the public
639 releases.
640
--- www/javascript.md
+++ www/javascript.md
@@ -570,10 +570,23 @@
570570
571571
…would pull the messages submitted since the last poll. Making the
572572
gateway bidirectional should be possible as well, as long as it properly
573573
uses SQLite transactions.
574574
575
+### <a id="brlist"></a>List of branches
576
+
577
+Since Fossil 2.16 the [`/brlist`](/brlist) page uses JavaScript to enable
578
+selection of several branches for further study via `/timeline`.
579
+Client-side script interactively responds to checkboxes' events
580
+and constructs a special hyperlink in the submenu.
581
+Clicking this hyperlink loads a `/timeline` page that shows
582
+only these selected branches (and the related check-ins).
583
+
584
+_Potential Workaround:_ A user can manually construct an appropriate
585
+regular expession and put it into the "Tag Filter" entry of the
586
+`/timeline` page (in its advanced mode).
587
+
575588
### <a id="wcontent"></a>Wiki content listing
576589
577590
[Since](/timeline?r=wcontent-subsets) version 2.16 it is possible to
578591
add [configurable](/help?cmd=wiki-classes) checkbox controls to the
579592
submenu of [available wiki pages](/wcontent) for the interactive
@@ -615,12 +628,12 @@
615628
2) Features end users request which catch the interest of one or more
616629
developers, provided the developer(s) in question are in a position to
617630
expend the effort.
618631
619632
3) Features end users and co-contributors can convince a developer into
620
-coding even when they really don't want to. 𘘉
633
+coding even when they really don't want to.
621634
622635
In all of this, Fossil's project lead understandably has the final
623636
say-so in whether any given feature indeed gets merged into the mainline
624637
trunk. Development of any given feature, no matter how much effort was
625638
involved, does not guarantee its eventual inclusion into the public
626639
releases.
627640
--- www/javascript.md
+++ www/javascript.md
@@ -570,10 +570,23 @@
570
571 …would pull the messages submitted since the last poll. Making the
572 gateway bidirectional should be possible as well, as long as it properly
573 uses SQLite transactions.
574
 
 
 
 
 
 
 
 
 
 
 
 
 
575 ### <a id="wcontent"></a>Wiki content listing
576
577 [Since](/timeline?r=wcontent-subsets) version 2.16 it is possible to
578 add [configurable](/help?cmd=wiki-classes) checkbox controls to the
579 submenu of [available wiki pages](/wcontent) for the interactive
@@ -615,12 +628,12 @@
615 2) Features end users request which catch the interest of one or more
616 developers, provided the developer(s) in question are in a position to
617 expend the effort.
618
619 3) Features end users and co-contributors can convince a developer into
620 coding even when they really don't want to. 𘘉
621
622 In all of this, Fossil's project lead understandably has the final
623 say-so in whether any given feature indeed gets merged into the mainline
624 trunk. Development of any given feature, no matter how much effort was
625 involved, does not guarantee its eventual inclusion into the public
626 releases.
627
--- www/javascript.md
+++ www/javascript.md
@@ -570,10 +570,23 @@
570
571 …would pull the messages submitted since the last poll. Making the
572 gateway bidirectional should be possible as well, as long as it properly
573 uses SQLite transactions.
574
575 ### <a id="brlist"></a>List of branches
576
577 Since Fossil 2.16 the [`/brlist`](/brlist) page uses JavaScript to enable
578 selection of several branches for further study via `/timeline`.
579 Client-side script interactively responds to checkboxes' events
580 and constructs a special hyperlink in the submenu.
581 Clicking this hyperlink loads a `/timeline` page that shows
582 only these selected branches (and the related check-ins).
583
584 _Potential Workaround:_ A user can manually construct an appropriate
585 regular expession and put it into the "Tag Filter" entry of the
586 `/timeline` page (in its advanced mode).
587
588 ### <a id="wcontent"></a>Wiki content listing
589
590 [Since](/timeline?r=wcontent-subsets) version 2.16 it is possible to
591 add [configurable](/help?cmd=wiki-classes) checkbox controls to the
592 submenu of [available wiki pages](/wcontent) for the interactive
@@ -615,12 +628,12 @@
628 2) Features end users request which catch the interest of one or more
629 developers, provided the developer(s) in question are in a position to
630 expend the effort.
631
632 3) Features end users and co-contributors can convince a developer into
633 coding even when they really don't want to.
634
635 In all of this, Fossil's project lead understandably has the final
636 say-so in whether any given feature indeed gets merged into the mainline
637 trunk. Development of any given feature, no matter how much effort was
638 involved, does not guarantee its eventual inclusion into the public
639 releases.
640
--- www/mkindex.tcl
+++ www/mkindex.tcl
@@ -115,10 +115,11 @@
115115
theory1.wiki {Thoughts On The Design Of The Fossil DVCS}
116116
tickets.wiki {The Fossil Ticket System}
117117
unvers.wiki {Unversioned Files}
118118
webpage-ex.md {Webpage Examples}
119119
webui.wiki {The Fossil Web Interface}
120
+ whyallinone.md {Why Bundle Forum, Wiki, and other Web Software With Your DVCS?}
120121
whyusefossil.wiki {Why You Should Use Fossil}
121122
whyusefossil.wiki {Benefits Of Version Control}
122123
wikitheory.wiki {Wiki In Fossil}
123124
/wiki_rules {Wiki Formatting Rules}
124125
}
125126
--- www/mkindex.tcl
+++ www/mkindex.tcl
@@ -115,10 +115,11 @@
115 theory1.wiki {Thoughts On The Design Of The Fossil DVCS}
116 tickets.wiki {The Fossil Ticket System}
117 unvers.wiki {Unversioned Files}
118 webpage-ex.md {Webpage Examples}
119 webui.wiki {The Fossil Web Interface}
 
120 whyusefossil.wiki {Why You Should Use Fossil}
121 whyusefossil.wiki {Benefits Of Version Control}
122 wikitheory.wiki {Wiki In Fossil}
123 /wiki_rules {Wiki Formatting Rules}
124 }
125
--- www/mkindex.tcl
+++ www/mkindex.tcl
@@ -115,10 +115,11 @@
115 theory1.wiki {Thoughts On The Design Of The Fossil DVCS}
116 tickets.wiki {The Fossil Ticket System}
117 unvers.wiki {Unversioned Files}
118 webpage-ex.md {Webpage Examples}
119 webui.wiki {The Fossil Web Interface}
120 whyallinone.md {Why Bundle Forum, Wiki, and other Web Software With Your DVCS?}
121 whyusefossil.wiki {Why You Should Use Fossil}
122 whyusefossil.wiki {Benefits Of Version Control}
123 wikitheory.wiki {Wiki In Fossil}
124 /wiki_rules {Wiki Formatting Rules}
125 }
126
--- www/permutedindex.html
+++ www/permutedindex.html
@@ -125,9 +125,10 @@
125125
<li><a href="fiveminutes.wiki">Up and Running in 5 Minutes as a Single User</a></li>
126126
<li><a href="javascript.md">Use of JavaScript in Fossil</a></li>
127127
<li><a href="caps/ref.html">User Capability Reference</a></li>
128128
<li><a href="ssl.wiki">Using SSL with Fossil</a></li>
129129
<li><a href="webpage-ex.md">Webpage Examples</a></li>
130
+<li><a href="whyallinone.md">Why Bundle Forum, Wiki, and other Web Software With Your DVCS?</a></li>
130131
<li><a href="whyusefossil.wiki">Why You Should Use Fossil</a></li>
131132
<li><a href="../../../wiki_rules">Wiki Formatting Rules</a></li>
132133
<li><a href="wikitheory.wiki">Wiki In Fossil</a></li>
133134
</ul></div>
134135
--- www/permutedindex.html
+++ www/permutedindex.html
@@ -125,9 +125,10 @@
125 <li><a href="fiveminutes.wiki">Up and Running in 5 Minutes as a Single User</a></li>
126 <li><a href="javascript.md">Use of JavaScript in Fossil</a></li>
127 <li><a href="caps/ref.html">User Capability Reference</a></li>
128 <li><a href="ssl.wiki">Using SSL with Fossil</a></li>
129 <li><a href="webpage-ex.md">Webpage Examples</a></li>
 
130 <li><a href="whyusefossil.wiki">Why You Should Use Fossil</a></li>
131 <li><a href="../../../wiki_rules">Wiki Formatting Rules</a></li>
132 <li><a href="wikitheory.wiki">Wiki In Fossil</a></li>
133 </ul></div>
134
--- www/permutedindex.html
+++ www/permutedindex.html
@@ -125,9 +125,10 @@
125 <li><a href="fiveminutes.wiki">Up and Running in 5 Minutes as a Single User</a></li>
126 <li><a href="javascript.md">Use of JavaScript in Fossil</a></li>
127 <li><a href="caps/ref.html">User Capability Reference</a></li>
128 <li><a href="ssl.wiki">Using SSL with Fossil</a></li>
129 <li><a href="webpage-ex.md">Webpage Examples</a></li>
130 <li><a href="whyallinone.md">Why Bundle Forum, Wiki, and other Web Software With Your DVCS?</a></li>
131 <li><a href="whyusefossil.wiki">Why You Should Use Fossil</a></li>
132 <li><a href="../../../wiki_rules">Wiki Formatting Rules</a></li>
133 <li><a href="wikitheory.wiki">Wiki In Fossil</a></li>
134 </ul></div>
135
--- www/server/index.html
+++ www/server/index.html
@@ -256,11 +256,11 @@
256256
<td class="doc"><a href="any/cgi.md">✅</a></td>
257257
<td class="doc"><a href="any/scgi.md">✅</a></td>
258258
<td class="doc"><a href="openbsd/fastcgi.md">✅</a></td>
259259
<td class="doc"><a href="any/althttpd.md">✅</a></td>
260260
<td class="doc">❌</td>
261
- <td class="doc">❌</td>
261
+ <td class="doc"><a href="openbsd/service.wiki">✅</a></td>
262262
</tr>
263263
264264
<tr>
265265
<th class="host"><a href="windows/">Windows</a></th>
266266
<td class="doc"><a href="windows/none.md">✅</a></td>
267267
--- www/server/index.html
+++ www/server/index.html
@@ -256,11 +256,11 @@
256 <td class="doc"><a href="any/cgi.md">✅</a></td>
257 <td class="doc"><a href="any/scgi.md">✅</a></td>
258 <td class="doc"><a href="openbsd/fastcgi.md">✅</a></td>
259 <td class="doc"><a href="any/althttpd.md">✅</a></td>
260 <td class="doc">❌</td>
261 <td class="doc">❌</td>
262 </tr>
263
264 <tr>
265 <th class="host"><a href="windows/">Windows</a></th>
266 <td class="doc"><a href="windows/none.md">✅</a></td>
267
--- www/server/index.html
+++ www/server/index.html
@@ -256,11 +256,11 @@
256 <td class="doc"><a href="any/cgi.md">✅</a></td>
257 <td class="doc"><a href="any/scgi.md">✅</a></td>
258 <td class="doc"><a href="openbsd/fastcgi.md">✅</a></td>
259 <td class="doc"><a href="any/althttpd.md">✅</a></td>
260 <td class="doc">❌</td>
261 <td class="doc"><a href="openbsd/service.wiki">✅</a></td>
262 </tr>
263
264 <tr>
265 <th class="host"><a href="windows/">Windows</a></th>
266 <td class="doc"><a href="windows/none.md">✅</a></td>
267
--- www/server/openbsd/fastcgi.md
+++ www/server/openbsd/fastcgi.md
@@ -58,10 +58,11 @@
5858
5959
```console
6060
$ doas mkdir /var/www/htdocs/fsl.domain.tld
6161
$ doas touch /var/www/logs/fossil.log
6262
$ doas chown www /var/www/logs/fossil.log
63
+ $ doas chmod 660 /var/www/logs/fossil.log
6364
$ doas chmod 755 /var/www/cgi-bin/scm
6465
```
6566
6667
## <a name="chroot"></a>Setup chroot
6768
@@ -104,11 +105,11 @@
104105
this is `www`. In addition, grant repository directory ownership to the
105106
user who will push to, pull from, and create repositories.
106107
107108
```console
108109
$ doas chown -R user:www /var/www/htdocs/fsl.domain.tld
109
- $ doas chmod 775 /var/www/htdocs/fsl.domain.tld
110
+ $ doas chmod 770 /var/www/htdocs/fsl.domain.tld
110111
```
111112
112113
## <a name="httpdconfig"></a>Configure httpd
113114
114115
On OpenBSD, [httpd.conf(5)][httpd] is the configuration file for
115116
--- www/server/openbsd/fastcgi.md
+++ www/server/openbsd/fastcgi.md
@@ -58,10 +58,11 @@
58
59 ```console
60 $ doas mkdir /var/www/htdocs/fsl.domain.tld
61 $ doas touch /var/www/logs/fossil.log
62 $ doas chown www /var/www/logs/fossil.log
 
63 $ doas chmod 755 /var/www/cgi-bin/scm
64 ```
65
66 ## <a name="chroot"></a>Setup chroot
67
@@ -104,11 +105,11 @@
104 this is `www`. In addition, grant repository directory ownership to the
105 user who will push to, pull from, and create repositories.
106
107 ```console
108 $ doas chown -R user:www /var/www/htdocs/fsl.domain.tld
109 $ doas chmod 775 /var/www/htdocs/fsl.domain.tld
110 ```
111
112 ## <a name="httpdconfig"></a>Configure httpd
113
114 On OpenBSD, [httpd.conf(5)][httpd] is the configuration file for
115
--- www/server/openbsd/fastcgi.md
+++ www/server/openbsd/fastcgi.md
@@ -58,10 +58,11 @@
58
59 ```console
60 $ doas mkdir /var/www/htdocs/fsl.domain.tld
61 $ doas touch /var/www/logs/fossil.log
62 $ doas chown www /var/www/logs/fossil.log
63 $ doas chmod 660 /var/www/logs/fossil.log
64 $ doas chmod 755 /var/www/cgi-bin/scm
65 ```
66
67 ## <a name="chroot"></a>Setup chroot
68
@@ -104,11 +105,11 @@
105 this is `www`. In addition, grant repository directory ownership to the
106 user who will push to, pull from, and create repositories.
107
108 ```console
109 $ doas chown -R user:www /var/www/htdocs/fsl.domain.tld
110 $ doas chmod 770 /var/www/htdocs/fsl.domain.tld
111 ```
112
113 ## <a name="httpdconfig"></a>Configure httpd
114
115 On OpenBSD, [httpd.conf(5)][httpd] is the configuration file for
116
--- www/server/openbsd/index.md
+++ www/server/openbsd/index.md
@@ -1,5 +1,6 @@
11
# Debian/Ubuntu Specific Fossil Service Options
22
33
- [Serving Fossil under OpenBSD’s `httpd` via FastCGI](./fastcgi.md)
4
+- [Running Fossil as a service on OpenBSD](./service.wiki)
45
56
*[Return to the top-level Fossil server article.](../)*
67
78
ADDED www/server/openbsd/service.wiki
89
ADDED www/whyallinone.md
--- www/server/openbsd/index.md
+++ www/server/openbsd/index.md
@@ -1,5 +1,6 @@
1 # Debian/Ubuntu Specific Fossil Service Options
2
3 - [Serving Fossil under OpenBSD’s `httpd` via FastCGI](./fastcgi.md)
 
4
5 *[Return to the top-level Fossil server article.](../)*
6
7 DDED www/server/openbsd/service.wiki
8 DDED www/whyallinone.md
--- www/server/openbsd/index.md
+++ www/server/openbsd/index.md
@@ -1,5 +1,6 @@
1 # Debian/Ubuntu Specific Fossil Service Options
2
3 - [Serving Fossil under OpenBSD’s `httpd` via FastCGI](./fastcgi.md)
4 - [Running Fossil as a service on OpenBSD](./service.wiki)
5
6 *[Return to the top-level Fossil server article.](../)*
7
8 DDED www/server/openbsd/service.wiki
9 DDED www/whyallinone.md
--- a/www/server/openbsd/service.wiki
+++ b/www/server/openbsd/service.wiki
@@ -0,0 +1,60 @@
1
+<title>Serving via rc on OpenBSD</title>
2
+
3
+OpenBSD provides [https://man.openbsd.org/rc.subr.8|rc.subr(8)],
4
+a framework for writing [https://man.openbsd.org/rc.8|rc(8)] scripts.
5
+
6
+<h2>Creating the daemon</h2>
7
+Create the file /etc/rc.d/fossil with contents like the following.
8
+
9
+<blockquote><pre>
10
+#!/bin/ksh
11
+daemon="/usr/local/bin/fossil" # fossil executable
12
+daemon_user="_fossil" # user to run fossil as
13
+daemon_flags="server /home/_fossil/example --repolist --port 8888" # fossil command
14
+
15
+. /etc/rc.d/rc.subr
16
+# pexp="$daemon sil' kills the process.
17
+rc_bg=YES # Run in the background, since fossil serve does not daemon</blockquote>
18
+
19
+<h3>pexp</h3>
20
+You may need to uncomment the "pexp=". rc.subr typically
21
+finds the daemon process based by matching the process name and argument list.
22
+Without the "pexp=" line, rc.subr would look for this exact command:
23
+
24
+<blockquote><pre>
25
+/usr/local/bin/fossil se--repolist --port 8888
26
+</pre></blockquot--repolist --port 8888
27
+</pre>
28
+
29
+Depending on the arguments and their order, fossil may rewrite the arguments
30
+for display in the process listing ([https://man.openbsd.org/ps.1|ps(1)]),
31
+so rc.subr may fail to find the process through the default match. The example
32
+above does not get rewritten, but the same commands in a different order can
33
+be rewritten.
34
+For example, when I switch the order of the argublockquote><pre>
35
+/usr/local/bin/fossil server --repolist --port 8888 /home/_fossil/example
36
+</pre></blockquote>
37
+
38
+the process comblockquote><pre>
39
+/usr/local/bin/fossil server /home/_fossil/example /home/_fossil/example 8888 /</blockquot /home/_fossil/example
40
+</pre>
41
+
42
+The commented "pexp=" line instructs rc.subr to choose the processblockquote><pre>
43
+/usr/local/bin/fossil server
44
+</pre></blockquote>
45
+
46
+<h2>Enabling the daemon</h2>
47
+>Enabling the daemon</h2>
48
+
49
+Once youblockquote>ssil, run these commands.
50
+
51
+<pre>
52
+rcctl enable fossil # add fossil to pkg_scripts in /etc/rc.conf.</blockquot# start the daemon now
53
+</pre>
54
+
55
+The daemon should now be running and set to start at boot.
56
+You may want to serve multiple fossil instances with different options.
57
+For example,
58
+
59
+ * If different users own different repositories, you may want different users
60
+ to serve different repositori
--- a/www/server/openbsd/service.wiki
+++ b/www/server/openbsd/service.wiki
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/www/server/openbsd/service.wiki
+++ b/www/server/openbsd/service.wiki
@@ -0,0 +1,60 @@
1 <title>Serving via rc on OpenBSD</title>
2
3 OpenBSD provides [https://man.openbsd.org/rc.subr.8|rc.subr(8)],
4 a framework for writing [https://man.openbsd.org/rc.8|rc(8)] scripts.
5
6 <h2>Creating the daemon</h2>
7 Create the file /etc/rc.d/fossil with contents like the following.
8
9 <blockquote><pre>
10 #!/bin/ksh
11 daemon="/usr/local/bin/fossil" # fossil executable
12 daemon_user="_fossil" # user to run fossil as
13 daemon_flags="server /home/_fossil/example --repolist --port 8888" # fossil command
14
15 . /etc/rc.d/rc.subr
16 # pexp="$daemon sil' kills the process.
17 rc_bg=YES # Run in the background, since fossil serve does not daemon</blockquote>
18
19 <h3>pexp</h3>
20 You may need to uncomment the "pexp=". rc.subr typically
21 finds the daemon process based by matching the process name and argument list.
22 Without the "pexp=" line, rc.subr would look for this exact command:
23
24 <blockquote><pre>
25 /usr/local/bin/fossil se--repolist --port 8888
26 </pre></blockquot--repolist --port 8888
27 </pre>
28
29 Depending on the arguments and their order, fossil may rewrite the arguments
30 for display in the process listing ([https://man.openbsd.org/ps.1|ps(1)]),
31 so rc.subr may fail to find the process through the default match. The example
32 above does not get rewritten, but the same commands in a different order can
33 be rewritten.
34 For example, when I switch the order of the argublockquote><pre>
35 /usr/local/bin/fossil server --repolist --port 8888 /home/_fossil/example
36 </pre></blockquote>
37
38 the process comblockquote><pre>
39 /usr/local/bin/fossil server /home/_fossil/example /home/_fossil/example 8888 /</blockquot /home/_fossil/example
40 </pre>
41
42 The commented "pexp=" line instructs rc.subr to choose the processblockquote><pre>
43 /usr/local/bin/fossil server
44 </pre></blockquote>
45
46 <h2>Enabling the daemon</h2>
47 >Enabling the daemon</h2>
48
49 Once youblockquote>ssil, run these commands.
50
51 <pre>
52 rcctl enable fossil # add fossil to pkg_scripts in /etc/rc.conf.</blockquot# start the daemon now
53 </pre>
54
55 The daemon should now be running and set to start at boot.
56 You may want to serve multiple fossil instances with different options.
57 For example,
58
59 * If different users own different repositories, you may want different users
60 to serve different repositori
--- a/www/whyallinone.md
+++ b/www/whyallinone.md
@@ -0,0 +1,231 @@
1
+# Why Add Forum, Wiki, and Web Software To Your DVCS?
2
+
3
+One notable feature of Fossil is that it bundles
4
+[bug tracking](./bugtheory.wiki),
5
+[wiki](./wikitheory.wiki),
6
+[forum](./forum.wiki),
7
+[chat](./chat.md), and
8
+[technotes](./event.wiki)
9
+with distributed version control to give you an
10
+all-in-one software project management system.
11
+
12
+A commenter on [Hacker News](https://news.ycombinator.com/item?id=27437895)
13
+takes exception to this idea, writing:
14
+
15
+> *I don't want forum/web software built into my dvcs.*
16
+> *I don't see how this improves over git.*
17
+
18
+This commenter may hold whatever opinions he wishes, of course.
19
+However, there are many good reasons why bundling other project management
20
+features with the DVCS might be useful for a given project:
21
+
22
+ 1. There is a single software package to install and manage for the
23
+ project website.
24
+ The alternative is to select, install, configure, learn about,
25
+ manage, and maintain separate DVCS, wiki,
26
+ ticketing, forum,
27
+ chat, documentation, and whatever other software packages your project needs.
28
+ Less time spent on project administration details means more
29
+ time available to spend on the project itself.
30
+
31
+ 2. Fossil’s autosync feature gives you an implicit backup of the
32
+ wiki, tickets, forum, and so forth simply by cloning the
33
+ repository to another machine and using that clone regularly.
34
+ Since the typical Fossil usage pattern is to stand the repo up on a
35
+ central server and have the developers clone that repository down
36
+ to their personal machines, if the server falls over, the last
37
+ developer to do anything that resulted in an autosync has a
38
+ functional and up-to-date backup.
39
+
40
+ There are [limitations to relying on Fossil’s autosync feature for
41
+ backup purposes](./backup.md), but that document gives two methods
42
+ for more complete backups, both of which are easily automated. The
43
+ Fossil project itself is distributed across three data centers in
44
+ this manner via cron.
45
+
46
+ 3. Remote workers get more than just the source code:
47
+ they get the entire website including versioned documentation,
48
+ wiki articles, tickets, forum posts, and so forth. This supports
49
+ off-network development when traveling, when riding out Internet
50
+ service failures, and when workers must sync with multiple remote
51
+ servers, as when working alternately from home and in some central
52
+ office.
53
+
54
+ Feature-competitive Fossil alternatives typically solve this same
55
+ problem with centralization, which generally means that only the
56
+ DVCS piece still works in these situations where the developer is
57
+ unable to contact the central server. Why accept the limitation of
58
+ having a distributed clone of the code repo alone?
59
+
60
+ Centralization doesn’t work for every project. If you enjoy the
61
+ benefits of truly distributed (read: non-centralized) version
62
+ control, you may also benefit from distributed forums, distributed
63
+ ticket tracking, distributed wiki article publishing, and so
64
+ forth.
65
+
66
+ 4. Integration of all of these features allows easy hyperlinks between
67
+ check-in comments, wiki pages, forum posts, and tickets. More,
68
+ because the software sees both sides of the link, referrer and
69
+ referent, it can provide automatic back-references.
70
+
71
+ A common situation in a Fossil project is that:
72
+
73
+ * a forum post refers to a versioned project document that shows
74
+ that the software isn’t behaving as documented;
75
+ * a developer triages that forum report as a verified bug, filing
76
+ a ticket to prioritize and track the resolution;
77
+ * developers chat about the problem, referring to the ticket and
78
+ thereby indirectly referring to the forum post, plus perhaps to
79
+ other Fossil-managed resources such as a wiki document giving
80
+ design principles that guide the proper fix; and finally
81
+ * the commit message resolving the ticket includes a reference to
82
+ the ticket it resolves.
83
+
84
+ Since Fossil sees that the commit refers to a ticket, the ticket
85
+ page automatically also refers back to the commit, closing the
86
+ loop. A latecomer may arrive at the ticket via a web search, and
87
+ from that see that it was closed following a commit. They can
88
+ follow the link from the initial ticket message to the forum
89
+ thread to catch up on the discussion leading to the fix and likely
90
+ find a follow-up post from the initial reporting user saying
91
+ whether the fix worked for them. If further work was needed, the
92
+ latecomer can likely find it from that forum thread.
93
+
94
+ This works even in a remote off-network clone: the developer can
95
+ pull up the project web site via an `http://localhost` link and
96
+ follow these links around the loop.
97
+
98
+ Fossil allows breaking some of these project facilities out into
99
+ separate repositories, as when the public forum is kept separate
100
+ from the actual software development repository for administration
101
+ reasons. By using Fossil’s [interwiki link
102
+ feature](./interwiki.md), you can get this same internal linking
103
+ from ticket to commit to forum to wiki even across these
104
+ administrative boundaries, even with remote off-network clones,
105
+ simply by adjusting the interwiki map to match the remote clone’s
106
+ network configuration.
107
+
108
+ 5. Bundling all of these services gives [single sign-on][SSO] (SSO) for all
109
+ aspects of the project. The same username/password works for code,
110
+ wiki, forum, tickets, and chat.
111
+
112
+ If you choose to administratively separate some of these features
113
+ by setting up multiple cooperating Fossil repositories, its skinning groups feature](./caps/login-groups.md) allows asymmetric SSO
114
+ across these administrative boundaries so that, for example, users
115
+ allowed to commit to the code repository also get a forum
116
+ repository login, but self-registered forum users don’t
117
+ automatically get the ability to commit to the code repo.
118
+
119
+ 6. Bundling all of these features reduces the number of external
120
+ dependencies for the project.
121
+
122
+ Take the first two points above: standing up a Fossil repo backup
123
+ on a new server may be as simple as copying the backup to the new
124
+ server and [configuring its stock HTTP server to point at the
125
+ backup repository via CGI](./server/any/cgi.md).
126
+
127
+ Consider: If you had good backups for all of the elements in a
128
+ Git + [Jira] + [Discord] + [MediaWiki] + [Sphinx] lash-up, how long
129
+ would it take you to stand up a replacement? That lash-up
130
+ certainly has more features combined than Fossil alone, but are
131
+ they worth the administration and hosting costs they impose?
132
+ Fossil’s feature set suffices for the SQLite project it was
133
+ created to serve, as well as for many others; is your project
134
+ sufficiently more complex, such that it *needs* all of those extra
135
+ features and their concomitant complexity?
136
+
137
+ Considerations such as these push many into centralized hosting
138
+ services such as GitHub, GitLab, Bitbucket, and so forth, but that
139
+ just takes you back to point 3 above.
140
+
141
+ 7. Hosting all of these elements within a single service gives a
142
+ consistent look-and-feel across all aspects of the project.
143
+
144
+ Skinning independent software packages’ web interfaces to make
145
+ them appear unified is more work than [skinning] everything once, as
146
+ in Fossil, and even then, you can’t make independently-developed
147
+ software look like it was produced by a single entity without
148
+ resorting to heroic levels of customization. If you use a separate
149
+ DVCS web front end, chat system, forum manager, documentation
150
+ system, ticket tracker, and so on, you are likely to be relegated
151
+ to simply matching colors and fonts; you *might* also get the
152
+ ability to add a common logo to the header of all of these
153
+ independent pieces. The pieces won’t look unified, because they
154
+ weren’t developed that way.
155
+
156
+ The Fossil project’s
157
+ skinning system lets you affect all of its elements globally from the
158
+ single skin editor.
159
+
160
+ Or not: there’s a feature in Fossil that lets skin customizations
161
+ apply to only *some* Fossil features. The initial impetus behind
162
+ this feature was that one of our users wanted Markdown to be
163
+ rendered with different indentation in forum posts than in
164
+ [embedded documentation][edoc] owing to the inherent differences between
165
+ the two presentation modalities.
166
+
167
+ A user taking advantage of this per-feature CSS capability who
168
+ wishes to change a UI element common to all Fossil features — say,
169
+ to change the font for literal code blocks — may still make such a
170
+ change globally. Opting into this per-feature CSS doesn’t fork all
171
+ skinning efforts: UI elements not explicitly reskinned on a
172
+ per-feature basis inherit the global skinning.
173
+
174
+ But it goes futher. Fossil has a feature for [project-specific
175
+ extensions](./serverext.wiki), which backs the [SQLite Release
176
+ Checklist][srckl], for instance. You wouldn’t know by looking at
177
+ that page that it’s produced by software that isn’t actually part
178
+ of Fossil: the extension only delivers the core of the page,
179
+ and Fossil’s skining wraps it in a way that lets it inherit all of
180
+ the project-level skinning customizations.
181
+
182
+ 8. Unifying all of these features within Fossil
183
+ means we have a single Markdown interpreter common to all
184
+ elements. If you lash multiple software systems together, even if
185
+ they can all agree on Markdown as a common document markup
186
+ language — hardly a given, as shown by the MediaWiki and Sphinx
187
+ elements in point 6’s example above — they’re likely to render your text
188
+ using different — possibly even incompatibly-different — Markdown
189
+ dialects.
190
+
191
+ This costs you Fossil
192
+can link out to these systems, and they back into Fossil, letting you
193
+use Fossiln-controlled
194
+ project document. A developer on a Fossil-backed project may simply copy-paste the forum post
195
+ text into the new document and save it, not needing to carefully
196
+ check that it still renders properly under the second Markdown
197
+ rendering engine. Similarly, if a user reports a potential bug via
198
+ the forum, the developer can copy interesting pieces of the
199
+ Markdown from the post into a ticket comment, again without
200
+ needing to fiddle with dialect incompatibilities.
201
+
202
+ 9. Fossil is [free, open-source software](../COPYRIGHT-BSD2.txt),
203
+ through and through. Git-backed lash-ups tend to incorporate
204
+ either proprietary add-ons or proprietary hosting systems that
205
+ produce vendor lock-in. Fossil gives you the freedom to take your
206
+ complete backup (point 2) of the project including its
207
+ idiosyncratic customizations and stand it up elsewhere on
208
+ commodity hardware and software stacks.
209
+
210
+All of this having been said, the non-DVCS features of Fossil are
211
+optional. Its forum and chat features are disabled by default, and you
212
+can disable the ticket-tracking and wiki features with a quick
213
+configuration change to its [role-based access control system](./caps/).
214
+When you’re ready to turn these additional features on, you can do so
215
+with a few mouse clicks.
216
+
217
+Because Fossil is web-native out of the box, if you’ve delegated these
218
+features to outside systems to flesh out Git’s DVCS-only nature, you are
219
+free to do the same with Fossil. One of the many things the [skinning]
220
+facility allows is replacing the built-in links to the wiki, forum,
221
+ticket system, etc. with links to external systems. How easy those
222
+systems make it to link back into Fossil is up to their developers.
223
+
224
+[Discord]: https://discord.com/
225
+[edoc]: ./embeddeddoc.wiki
226
+[Jira]: https://www.atlassian.com/software/jira
227
+[MediaWiki]: https://www.mediawiki.org/
228
+[skinning]: ./customskin.md
229
+[Sphinx]: https://www.sphinx-doc.org/en/master/
230
+[SSO]: https://en.wikipedia.org/wiki/Single_sign-on
231
+[srckl]: https://www.sqlite.org/src/ext/checklist/top/inde
--- a/www/whyallinone.md
+++ b/www/whyallinone.md
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/www/whyallinone.md
+++ b/www/whyallinone.md
@@ -0,0 +1,231 @@
1 # Why Add Forum, Wiki, and Web Software To Your DVCS?
2
3 One notable feature of Fossil is that it bundles
4 [bug tracking](./bugtheory.wiki),
5 [wiki](./wikitheory.wiki),
6 [forum](./forum.wiki),
7 [chat](./chat.md), and
8 [technotes](./event.wiki)
9 with distributed version control to give you an
10 all-in-one software project management system.
11
12 A commenter on [Hacker News](https://news.ycombinator.com/item?id=27437895)
13 takes exception to this idea, writing:
14
15 > *I don't want forum/web software built into my dvcs.*
16 > *I don't see how this improves over git.*
17
18 This commenter may hold whatever opinions he wishes, of course.
19 However, there are many good reasons why bundling other project management
20 features with the DVCS might be useful for a given project:
21
22 1. There is a single software package to install and manage for the
23 project website.
24 The alternative is to select, install, configure, learn about,
25 manage, and maintain separate DVCS, wiki,
26 ticketing, forum,
27 chat, documentation, and whatever other software packages your project needs.
28 Less time spent on project administration details means more
29 time available to spend on the project itself.
30
31 2. Fossil’s autosync feature gives you an implicit backup of the
32 wiki, tickets, forum, and so forth simply by cloning the
33 repository to another machine and using that clone regularly.
34 Since the typical Fossil usage pattern is to stand the repo up on a
35 central server and have the developers clone that repository down
36 to their personal machines, if the server falls over, the last
37 developer to do anything that resulted in an autosync has a
38 functional and up-to-date backup.
39
40 There are [limitations to relying on Fossil’s autosync feature for
41 backup purposes](./backup.md), but that document gives two methods
42 for more complete backups, both of which are easily automated. The
43 Fossil project itself is distributed across three data centers in
44 this manner via cron.
45
46 3. Remote workers get more than just the source code:
47 they get the entire website including versioned documentation,
48 wiki articles, tickets, forum posts, and so forth. This supports
49 off-network development when traveling, when riding out Internet
50 service failures, and when workers must sync with multiple remote
51 servers, as when working alternately from home and in some central
52 office.
53
54 Feature-competitive Fossil alternatives typically solve this same
55 problem with centralization, which generally means that only the
56 DVCS piece still works in these situations where the developer is
57 unable to contact the central server. Why accept the limitation of
58 having a distributed clone of the code repo alone?
59
60 Centralization doesn’t work for every project. If you enjoy the
61 benefits of truly distributed (read: non-centralized) version
62 control, you may also benefit from distributed forums, distributed
63 ticket tracking, distributed wiki article publishing, and so
64 forth.
65
66 4. Integration of all of these features allows easy hyperlinks between
67 check-in comments, wiki pages, forum posts, and tickets. More,
68 because the software sees both sides of the link, referrer and
69 referent, it can provide automatic back-references.
70
71 A common situation in a Fossil project is that:
72
73 * a forum post refers to a versioned project document that shows
74 that the software isn’t behaving as documented;
75 * a developer triages that forum report as a verified bug, filing
76 a ticket to prioritize and track the resolution;
77 * developers chat about the problem, referring to the ticket and
78 thereby indirectly referring to the forum post, plus perhaps to
79 other Fossil-managed resources such as a wiki document giving
80 design principles that guide the proper fix; and finally
81 * the commit message resolving the ticket includes a reference to
82 the ticket it resolves.
83
84 Since Fossil sees that the commit refers to a ticket, the ticket
85 page automatically also refers back to the commit, closing the
86 loop. A latecomer may arrive at the ticket via a web search, and
87 from that see that it was closed following a commit. They can
88 follow the link from the initial ticket message to the forum
89 thread to catch up on the discussion leading to the fix and likely
90 find a follow-up post from the initial reporting user saying
91 whether the fix worked for them. If further work was needed, the
92 latecomer can likely find it from that forum thread.
93
94 This works even in a remote off-network clone: the developer can
95 pull up the project web site via an `http://localhost` link and
96 follow these links around the loop.
97
98 Fossil allows breaking some of these project facilities out into
99 separate repositories, as when the public forum is kept separate
100 from the actual software development repository for administration
101 reasons. By using Fossil’s [interwiki link
102 feature](./interwiki.md), you can get this same internal linking
103 from ticket to commit to forum to wiki even across these
104 administrative boundaries, even with remote off-network clones,
105 simply by adjusting the interwiki map to match the remote clone’s
106 network configuration.
107
108 5. Bundling all of these services gives [single sign-on][SSO] (SSO) for all
109 aspects of the project. The same username/password works for code,
110 wiki, forum, tickets, and chat.
111
112 If you choose to administratively separate some of these features
113 by setting up multiple cooperating Fossil repositories, its skinning groups feature](./caps/login-groups.md) allows asymmetric SSO
114 across these administrative boundaries so that, for example, users
115 allowed to commit to the code repository also get a forum
116 repository login, but self-registered forum users don’t
117 automatically get the ability to commit to the code repo.
118
119 6. Bundling all of these features reduces the number of external
120 dependencies for the project.
121
122 Take the first two points above: standing up a Fossil repo backup
123 on a new server may be as simple as copying the backup to the new
124 server and [configuring its stock HTTP server to point at the
125 backup repository via CGI](./server/any/cgi.md).
126
127 Consider: If you had good backups for all of the elements in a
128 Git + [Jira] + [Discord] + [MediaWiki] + [Sphinx] lash-up, how long
129 would it take you to stand up a replacement? That lash-up
130 certainly has more features combined than Fossil alone, but are
131 they worth the administration and hosting costs they impose?
132 Fossil’s feature set suffices for the SQLite project it was
133 created to serve, as well as for many others; is your project
134 sufficiently more complex, such that it *needs* all of those extra
135 features and their concomitant complexity?
136
137 Considerations such as these push many into centralized hosting
138 services such as GitHub, GitLab, Bitbucket, and so forth, but that
139 just takes you back to point 3 above.
140
141 7. Hosting all of these elements within a single service gives a
142 consistent look-and-feel across all aspects of the project.
143
144 Skinning independent software packages’ web interfaces to make
145 them appear unified is more work than [skinning] everything once, as
146 in Fossil, and even then, you can’t make independently-developed
147 software look like it was produced by a single entity without
148 resorting to heroic levels of customization. If you use a separate
149 DVCS web front end, chat system, forum manager, documentation
150 system, ticket tracker, and so on, you are likely to be relegated
151 to simply matching colors and fonts; you *might* also get the
152 ability to add a common logo to the header of all of these
153 independent pieces. The pieces won’t look unified, because they
154 weren’t developed that way.
155
156 The Fossil project’s
157 skinning system lets you affect all of its elements globally from the
158 single skin editor.
159
160 Or not: there’s a feature in Fossil that lets skin customizations
161 apply to only *some* Fossil features. The initial impetus behind
162 this feature was that one of our users wanted Markdown to be
163 rendered with different indentation in forum posts than in
164 [embedded documentation][edoc] owing to the inherent differences between
165 the two presentation modalities.
166
167 A user taking advantage of this per-feature CSS capability who
168 wishes to change a UI element common to all Fossil features — say,
169 to change the font for literal code blocks — may still make such a
170 change globally. Opting into this per-feature CSS doesn’t fork all
171 skinning efforts: UI elements not explicitly reskinned on a
172 per-feature basis inherit the global skinning.
173
174 But it goes futher. Fossil has a feature for [project-specific
175 extensions](./serverext.wiki), which backs the [SQLite Release
176 Checklist][srckl], for instance. You wouldn’t know by looking at
177 that page that it’s produced by software that isn’t actually part
178 of Fossil: the extension only delivers the core of the page,
179 and Fossil’s skining wraps it in a way that lets it inherit all of
180 the project-level skinning customizations.
181
182 8. Unifying all of these features within Fossil
183 means we have a single Markdown interpreter common to all
184 elements. If you lash multiple software systems together, even if
185 they can all agree on Markdown as a common document markup
186 language — hardly a given, as shown by the MediaWiki and Sphinx
187 elements in point 6’s example above — they’re likely to render your text
188 using different — possibly even incompatibly-different — Markdown
189 dialects.
190
191 This costs you Fossil
192 can link out to these systems, and they back into Fossil, letting you
193 use Fossiln-controlled
194 project document. A developer on a Fossil-backed project may simply copy-paste the forum post
195 text into the new document and save it, not needing to carefully
196 check that it still renders properly under the second Markdown
197 rendering engine. Similarly, if a user reports a potential bug via
198 the forum, the developer can copy interesting pieces of the
199 Markdown from the post into a ticket comment, again without
200 needing to fiddle with dialect incompatibilities.
201
202 9. Fossil is [free, open-source software](../COPYRIGHT-BSD2.txt),
203 through and through. Git-backed lash-ups tend to incorporate
204 either proprietary add-ons or proprietary hosting systems that
205 produce vendor lock-in. Fossil gives you the freedom to take your
206 complete backup (point 2) of the project including its
207 idiosyncratic customizations and stand it up elsewhere on
208 commodity hardware and software stacks.
209
210 All of this having been said, the non-DVCS features of Fossil are
211 optional. Its forum and chat features are disabled by default, and you
212 can disable the ticket-tracking and wiki features with a quick
213 configuration change to its [role-based access control system](./caps/).
214 When you’re ready to turn these additional features on, you can do so
215 with a few mouse clicks.
216
217 Because Fossil is web-native out of the box, if you’ve delegated these
218 features to outside systems to flesh out Git’s DVCS-only nature, you are
219 free to do the same with Fossil. One of the many things the [skinning]
220 facility allows is replacing the built-in links to the wiki, forum,
221 ticket system, etc. with links to external systems. How easy those
222 systems make it to link back into Fossil is up to their developers.
223
224 [Discord]: https://discord.com/
225 [edoc]: ./embeddeddoc.wiki
226 [Jira]: https://www.atlassian.com/software/jira
227 [MediaWiki]: https://www.mediawiki.org/
228 [skinning]: ./customskin.md
229 [Sphinx]: https://www.sphinx-doc.org/en/master/
230 [SSO]: https://en.wikipedia.org/wiki/Single_sign-on
231 [srckl]: https://www.sqlite.org/src/ext/checklist/top/inde

Keyboard Shortcuts

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