Fossil SCM

Merge updates from trunk.

mistachkin 2015-04-03 03:13 mvAndRmFiles merge
Commit bc31308652f722c00ae2baf5343ffa975799ade9
--- setup/fossil.iss
+++ setup/fossil.iss
@@ -19,17 +19,17 @@
1919
AlwaysShowComponentsList=false
2020
AppCopyright=Copyright (c) D. Richard Hipp. All rights reserved.
2121
AppID={{f1c25a1f-3954-4e1a-ac36-4314c52f057c}
2222
AppName=Fossil
2323
AppPublisher=Fossil Development Team
24
-AppPublisherURL=http://www.fossil-scm.org/
25
-AppSupportURL=http://www.fossil-scm.org/
26
-AppUpdatesURL=http://www.fossil-scm.org/
24
+AppPublisherURL=https://www.fossil-scm.org/
25
+AppSupportURL=https://www.fossil-scm.org/
26
+AppUpdatesURL=https://www.fossil-scm.org/
2727
AppVerName=Fossil v{#AppVersion}
2828
AppVersion={#AppVersion}
2929
AppComments=Simple, high-reliability, distributed software configuration management system.
30
-AppReadmeFile=http://www.fossil-scm.org/index.html/doc/tip/www/quickstart.wiki
30
+AppReadmeFile=https://www.fossil-scm.org/index.html/doc/tip/www/quickstart.wiki
3131
DefaultDirName={pf}\Fossil
3232
DefaultGroupName=Fossil
3333
OutputBaseFilename=fossil-win32-{#AppVersion}
3434
OutputManifestFile=fossil-win32-{#AppVersion}-manifest.txt
3535
SetupLogging=true
3636
--- setup/fossil.iss
+++ setup/fossil.iss
@@ -19,17 +19,17 @@
19 AlwaysShowComponentsList=false
20 AppCopyright=Copyright (c) D. Richard Hipp. All rights reserved.
21 AppID={{f1c25a1f-3954-4e1a-ac36-4314c52f057c}
22 AppName=Fossil
23 AppPublisher=Fossil Development Team
24 AppPublisherURL=http://www.fossil-scm.org/
25 AppSupportURL=http://www.fossil-scm.org/
26 AppUpdatesURL=http://www.fossil-scm.org/
27 AppVerName=Fossil v{#AppVersion}
28 AppVersion={#AppVersion}
29 AppComments=Simple, high-reliability, distributed software configuration management system.
30 AppReadmeFile=http://www.fossil-scm.org/index.html/doc/tip/www/quickstart.wiki
31 DefaultDirName={pf}\Fossil
32 DefaultGroupName=Fossil
33 OutputBaseFilename=fossil-win32-{#AppVersion}
34 OutputManifestFile=fossil-win32-{#AppVersion}-manifest.txt
35 SetupLogging=true
36
--- setup/fossil.iss
+++ setup/fossil.iss
@@ -19,17 +19,17 @@
19 AlwaysShowComponentsList=false
20 AppCopyright=Copyright (c) D. Richard Hipp. All rights reserved.
21 AppID={{f1c25a1f-3954-4e1a-ac36-4314c52f057c}
22 AppName=Fossil
23 AppPublisher=Fossil Development Team
24 AppPublisherURL=https://www.fossil-scm.org/
25 AppSupportURL=https://www.fossil-scm.org/
26 AppUpdatesURL=https://www.fossil-scm.org/
27 AppVerName=Fossil v{#AppVersion}
28 AppVersion={#AppVersion}
29 AppComments=Simple, high-reliability, distributed software configuration management system.
30 AppReadmeFile=https://www.fossil-scm.org/index.html/doc/tip/www/quickstart.wiki
31 DefaultDirName={pf}\Fossil
32 DefaultGroupName=Fossil
33 OutputBaseFilename=fossil-win32-{#AppVersion}
34 OutputManifestFile=fossil-win32-{#AppVersion}-manifest.txt
35 SetupLogging=true
36
+10 -8
--- skins/README.md
+++ skins/README.md
@@ -1,11 +1,11 @@
11
Built-in Skins
22
==============
33
44
Each subdirectory under this folder describes a built-in "skin".
5
-There are three files in each subdirectory for the CSS, the header,
6
-and the footer for that skin.
5
+There are four files in each subdirectory for the CSS, the "details"
6
+file, the footer, and the header for that skin.
77
88
To improve an existing built-in skin, simply edit the appropriate
99
files and recompile.
1010
1111
To add a new skin:
@@ -12,12 +12,13 @@
1212
1313
1. Create a new subdirectory under skins/. (The new directory is
1414
called "skins/newskin" below but you should use a new original
1515
name, of course.)
1616
17
- 2. Add files skins/newskin/css.txt, skins/newskin/header.txt,
18
- and skins/newskin/footer.txt. Be sure to "fossil add" these files.
17
+ 2. Add files skins/newskin/css.txt, skins/newskin/details.txt,
18
+ skins/newskin/footer.txt and skins/newskin/header.txt.
19
+ Be sure to "fossil add" these files.
1920
2021
3. Go to the src/ directory and rerun "tclsh makemake.tcl". This
2122
step rebuilds the various makefiles so that they have dependencies
2223
on the skin files you just installed.
2324
@@ -28,16 +29,17 @@
2829
2930
Development Hints
3031
-----------------
3132
3233
One way to develop a new skin is to copy the baseline files (css.txt,
33
-footer.txt, and header.txt) into a working directory $WORKDIR then
34
-launch Fossil with a command-line option "--skin $WORKDIR". Example:
34
+details.txt, footer.txt, and header.txt) into a working directory $WORKDIR
35
+then launch Fossil with a command-line option "--skin $WORKDIR". Example:
3536
3637
cp -r skins/default newskin
3738
fossil ui --skin ./newskin
3839
3940
When the argument to --skin contains one or more '/' characters, the
4041
appropriate skin files are read from disk from the directory specified.
4142
So after launching fossil as shown above, you can edit the newskin/css.txt,
42
-newskin/header.txt, and newskin/footer.txt files using your favorite
43
-text editor, then press Reload on your browser to see immediate results.
43
+newskin/details.txt, newskin/footer.txt, and newskin/header.txt files using
44
+your favorite text editor, then press Reload on your browser to see
45
+immediate results.
4446
4547
ADDED skins/aht/details.txt
4648
ADDED skins/black_and_white/details.txt
4749
ADDED skins/blitz/details.txt
4850
ADDED skins/blitz_no_logo/details.txt
4951
ADDED skins/default/details.txt
5052
ADDED skins/eagle/details.txt
5153
ADDED skins/enhanced1/details.txt
5254
ADDED skins/khaki/details.txt
5355
ADDED skins/original/details.txt
5456
ADDED skins/plain_gray/details.txt
5557
ADDED skins/rounded1/details.txt
--- skins/README.md
+++ skins/README.md
@@ -1,11 +1,11 @@
1 Built-in Skins
2 ==============
3
4 Each subdirectory under this folder describes a built-in "skin".
5 There are three files in each subdirectory for the CSS, the header,
6 and the footer for that skin.
7
8 To improve an existing built-in skin, simply edit the appropriate
9 files and recompile.
10
11 To add a new skin:
@@ -12,12 +12,13 @@
12
13 1. Create a new subdirectory under skins/. (The new directory is
14 called "skins/newskin" below but you should use a new original
15 name, of course.)
16
17 2. Add files skins/newskin/css.txt, skins/newskin/header.txt,
18 and skins/newskin/footer.txt. Be sure to "fossil add" these files.
 
19
20 3. Go to the src/ directory and rerun "tclsh makemake.tcl". This
21 step rebuilds the various makefiles so that they have dependencies
22 on the skin files you just installed.
23
@@ -28,16 +29,17 @@
28
29 Development Hints
30 -----------------
31
32 One way to develop a new skin is to copy the baseline files (css.txt,
33 footer.txt, and header.txt) into a working directory $WORKDIR then
34 launch Fossil with a command-line option "--skin $WORKDIR". Example:
35
36 cp -r skins/default newskin
37 fossil ui --skin ./newskin
38
39 When the argument to --skin contains one or more '/' characters, the
40 appropriate skin files are read from disk from the directory specified.
41 So after launching fossil as shown above, you can edit the newskin/css.txt,
42 newskin/header.txt, and newskin/footer.txt files using your favorite
43 text editor, then press Reload on your browser to see immediate results.
 
44
45 DDED skins/aht/details.txt
46 DDED skins/black_and_white/details.txt
47 DDED skins/blitz/details.txt
48 DDED skins/blitz_no_logo/details.txt
49 DDED skins/default/details.txt
50 DDED skins/eagle/details.txt
51 DDED skins/enhanced1/details.txt
52 DDED skins/khaki/details.txt
53 DDED skins/original/details.txt
54 DDED skins/plain_gray/details.txt
55 DDED skins/rounded1/details.txt
--- skins/README.md
+++ skins/README.md
@@ -1,11 +1,11 @@
1 Built-in Skins
2 ==============
3
4 Each subdirectory under this folder describes a built-in "skin".
5 There are four files in each subdirectory for the CSS, the "details"
6 file, the footer, and the header for that skin.
7
8 To improve an existing built-in skin, simply edit the appropriate
9 files and recompile.
10
11 To add a new skin:
@@ -12,12 +12,13 @@
12
13 1. Create a new subdirectory under skins/. (The new directory is
14 called "skins/newskin" below but you should use a new original
15 name, of course.)
16
17 2. Add files skins/newskin/css.txt, skins/newskin/details.txt,
18 skins/newskin/footer.txt and skins/newskin/header.txt.
19 Be sure to "fossil add" these files.
20
21 3. Go to the src/ directory and rerun "tclsh makemake.tcl". This
22 step rebuilds the various makefiles so that they have dependencies
23 on the skin files you just installed.
24
@@ -28,16 +29,17 @@
29
30 Development Hints
31 -----------------
32
33 One way to develop a new skin is to copy the baseline files (css.txt,
34 details.txt, footer.txt, and header.txt) into a working directory $WORKDIR
35 then launch Fossil with a command-line option "--skin $WORKDIR". Example:
36
37 cp -r skins/default newskin
38 fossil ui --skin ./newskin
39
40 When the argument to --skin contains one or more '/' characters, the
41 appropriate skin files are read from disk from the directory specified.
42 So after launching fossil as shown above, you can edit the newskin/css.txt,
43 newskin/details.txt, newskin/footer.txt, and newskin/header.txt files using
44 your favorite text editor, then press Reload on your browser to see
45 immediate results.
46
47 DDED skins/aht/details.txt
48 DDED skins/black_and_white/details.txt
49 DDED skins/blitz/details.txt
50 DDED skins/blitz_no_logo/details.txt
51 DDED skins/default/details.txt
52 DDED skins/eagle/details.txt
53 DDED skins/enhanced1/details.txt
54 DDED skins/khaki/details.txt
55 DDED skins/original/details.txt
56 DDED skins/plain_gray/details.txt
57 DDED skins/rounded1/details.txt
--- a/skins/aht/details.txt
+++ b/skins/aht/details.txt
@@ -0,0 +1,3 @@
1
+timeline-arrowheads: 1
2
+timeline-circle-nodes: 0
3
+timeline-color-graph-lines: 0
--- a/skins/aht/details.txt
+++ b/skins/aht/details.txt
@@ -0,0 +1,3 @@
 
 
 
--- a/skins/aht/details.txt
+++ b/skins/aht/details.txt
@@ -0,0 +1,3 @@
1 timeline-arrowheads: 1
2 timeline-circle-nodes: 0
3 timeline-color-graph-lines: 0
--- a/skins/black_and_white/details.txt
+++ b/skins/black_and_white/details.txt
@@ -0,0 +1,3 @@
1
+timeline-arrowheads: 1
2
+timeline-circle-nodes: 0
3
+timeline-color-graph-lines: 0
--- a/skins/black_and_white/details.txt
+++ b/skins/black_and_white/details.txt
@@ -0,0 +1,3 @@
 
 
 
--- a/skins/black_and_white/details.txt
+++ b/skins/black_and_white/details.txt
@@ -0,0 +1,3 @@
1 timeline-arrowheads: 1
2 timeline-circle-nodes: 0
3 timeline-color-graph-lines: 0
--- a/skins/blitz/details.txt
+++ b/skins/blitz/details.txt
@@ -0,0 +1,3 @@
1
+timeline-arrowheads: 0
2
+tim 1
3
+x@0,1OUWFw;
--- a/skins/blitz/details.txt
+++ b/skins/blitz/details.txt
@@ -0,0 +1,3 @@
 
 
 
--- a/skins/blitz/details.txt
+++ b/skins/blitz/details.txt
@@ -0,0 +1,3 @@
1 timeline-arrowheads: 0
2 tim 1
3 x@0,1OUWFw;
--- a/skins/blitz_no_logo/details.txt
+++ b/skins/blitz_no_logo/details.txt
@@ -0,0 +1,3 @@
1
+timeline-arrowheads: 0
2
+tim 1
3
+x@0,1OUWFw;
--- a/skins/blitz_no_logo/details.txt
+++ b/skins/blitz_no_logo/details.txt
@@ -0,0 +1,3 @@
 
 
 
--- a/skins/blitz_no_logo/details.txt
+++ b/skins/blitz_no_logo/details.txt
@@ -0,0 +1,3 @@
1 timeline-arrowheads: 0
2 tim 1
3 x@0,1OUWFw;
--- a/skins/default/details.txt
+++ b/skins/default/details.txt
@@ -0,0 +1,3 @@
1
+timeline-arrowheads: 1
2
+timeline-circle-nodes: 0
3
+timeline-color-graph-lines: 0
--- a/skins/default/details.txt
+++ b/skins/default/details.txt
@@ -0,0 +1,3 @@
 
 
 
--- a/skins/default/details.txt
+++ b/skins/default/details.txt
@@ -0,0 +1,3 @@
1 timeline-arrowheads: 1
2 timeline-circle-nodes: 0
3 timeline-color-graph-lines: 0
--- a/skins/eagle/details.txt
+++ b/skins/eagle/details.txt
@@ -0,0 +1,4 @@
1
+timeline-arrowheads: 1
2
+timeline-circle-nodes: 0
3
+timeline-color-graph-lines: 0
4
+whi
--- a/skins/eagle/details.txt
+++ b/skins/eagle/details.txt
@@ -0,0 +1,4 @@
 
 
 
 
--- a/skins/eagle/details.txt
+++ b/skins/eagle/details.txt
@@ -0,0 +1,4 @@
1 timeline-arrowheads: 1
2 timeline-circle-nodes: 0
3 timeline-color-graph-lines: 0
4 whi
--- a/skins/enhanced1/details.txt
+++ b/skins/enhanced1/details.txt
@@ -0,0 +1,3 @@
1
+timeline-arrowheads: 1
2
+timeline-circle-nodes: 0
3
+timeline-color-graph-lines: 0
--- a/skins/enhanced1/details.txt
+++ b/skins/enhanced1/details.txt
@@ -0,0 +1,3 @@
 
 
 
--- a/skins/enhanced1/details.txt
+++ b/skins/enhanced1/details.txt
@@ -0,0 +1,3 @@
1 timeline-arrowheads: 1
2 timeline-circle-nodes: 0
3 timeline-color-graph-lines: 0
--- a/skins/khaki/details.txt
+++ b/skins/khaki/details.txt
@@ -0,0 +1,3 @@
1
+timeline-arrowheads: 1
2
+timeline-circle-nodes: 0
3
+timeline-color-graph-lines: 0
--- a/skins/khaki/details.txt
+++ b/skins/khaki/details.txt
@@ -0,0 +1,3 @@
 
 
 
--- a/skins/khaki/details.txt
+++ b/skins/khaki/details.txt
@@ -0,0 +1,3 @@
1 timeline-arrowheads: 1
2 timeline-circle-nodes: 0
3 timeline-color-graph-lines: 0
--- a/skins/original/details.txt
+++ b/skins/original/details.txt
@@ -0,0 +1,3 @@
1
+timeline-arrowheads: 1
2
+timeline-circle-nodes: 0
3
+timeline-color-graph-lines: 0
--- a/skins/original/details.txt
+++ b/skins/original/details.txt
@@ -0,0 +1,3 @@
 
 
 
--- a/skins/original/details.txt
+++ b/skins/original/details.txt
@@ -0,0 +1,3 @@
1 timeline-arrowheads: 1
2 timeline-circle-nodes: 0
3 timeline-color-graph-lines: 0
--- a/skins/plain_gray/details.txt
+++ b/skins/plain_gray/details.txt
@@ -0,0 +1,3 @@
1
+timeline-arrowheads: 1
2
+timeline-circle-nodes: 0
3
+timeline-color-graph-lines: 0
--- a/skins/plain_gray/details.txt
+++ b/skins/plain_gray/details.txt
@@ -0,0 +1,3 @@
 
 
 
--- a/skins/plain_gray/details.txt
+++ b/skins/plain_gray/details.txt
@@ -0,0 +1,3 @@
1 timeline-arrowheads: 1
2 timeline-circle-nodes: 0
3 timeline-color-graph-lines: 0
--- a/skins/rounded1/details.txt
+++ b/skins/rounded1/details.txt
@@ -0,0 +1,3 @@
1
+timeline-arrowheads: 1
2
+timeline-circle-nodes: 0
3
+timeline-color-graph-lines: 0
--- a/skins/rounded1/details.txt
+++ b/skins/rounded1/details.txt
@@ -0,0 +1,3 @@
 
 
 
--- a/skins/rounded1/details.txt
+++ b/skins/rounded1/details.txt
@@ -0,0 +1,3 @@
1 timeline-arrowheads: 1
2 timeline-circle-nodes: 0
3 timeline-color-graph-lines: 0
--- skins/xekri/css.txt
+++ skins/xekri/css.txt
@@ -1,7 +1,13 @@
1
-/**************************************
1
+/******************************************************************************
22
* Xekri
3
+ *
4
+ * To adjust the width of the contents for this skin, look for the "max-width"
5
+ * property and change its value. (It's in the "Main Area" section) The value
6
+ * determines how much of the browser window to use. Some like 100%, so that
7
+ * the entire window is used. Others prefer 80%, which makes the contents
8
+ * easier to read for them.
39
*/
410
511
612
/**************************************
713
* General HTML
@@ -16,10 +22,13 @@
1622
}
1723
1824
body {
1925
margin: 0;
2026
padding: 0;
27
+ -moz-text-size-adjust: none;
28
+ -ms-text-size-adjust: none;
29
+ -webkit-text-size-adjust: none;
2130
}
2231
2332
a {
2433
color: #07e;
2534
}
@@ -58,19 +67,24 @@
5867
}
5968
6069
span[style^=background-color] {
6170
color: #000;
6271
}
72
+
73
+td[style^=background-color] {
74
+ color: #000;
75
+}
76
+
6377
6478
/**************************************
6579
* Main Area
6680
*/
6781
6882
div.header, div.mainmenu, div.submenu, div.content, div.footer {
6983
clear: both;
7084
margin: 0 auto;
71
- max-width: 80%;
85
+ max-width: 90%;
7286
padding: 0.25rem 1rem;
7387
}
7488
7589
7690
/**************************************
@@ -134,34 +148,46 @@
134148
font-size: 1.1rem;
135149
text-align: center;
136150
}
137151
138152
div.mainmenu {
153
+ padding-top: 0.33rem;
139154
padding-bottom: 0.25rem;
140155
}
141156
142157
div.submenu {
143158
border-top: 1px solid #0a0;
144159
border-radius: 0;
145
- display: flex;
146
- justify-content: space-around;
160
+ display: block;
147161
}
148162
149163
div.mainmenu a, div.submenu a {
150164
color: #000;
151165
padding: 0 0.75rem;
152166
text-decoration: none;
153
- vertical-align: middle;
154167
}
155168
156169
div.mainmenu a:hover, div.submenu a:hover {
157170
color: #fff;
158171
text-shadow: 0px 0px 6px #0f0;
159172
}
173
+
174
+div.submenu * {
175
+ margin: 0 0.5rem;
176
+ vertical-align: middle;
177
+}
178
+
179
+div.submenu select, div.submenu input {
180
+ background-color: #222;
181
+ border: 1px inset #080;
182
+ color: #eee;
183
+ cursor: pointer;
184
+ font-size: 0.9rem;
185
+}
160186
161187
div.submenu select {
162
- background-color: #090;
188
+ height: 1.75rem;
163189
}
164190
165191
/**************************************
166192
* Main Area: Content
167193
*/
@@ -338,10 +364,19 @@
338364
339365
ul.browser li.dir {
340366
font-style: italic
341367
}
342368
369
+
370
+/**************************************
371
+ * File List : Age
372
+ */
373
+
374
+.fileage tr:hover td {
375
+ background-color: #225;
376
+}
377
+
343378
344379
/**************************************
345380
* File List : Tree
346381
*/
347382
@@ -416,10 +451,18 @@
416451
.filetree .dir > a {
417452
background-image: url(data:image/gif;base64,R0lGODlhEAAQAJEAAP/WVCIiIv\/\/\/wAAACH5BAEHAAIALAAAAAAQABAAAAInlI9pwa3XYniCgQtkrAFfLXkiFo1jaXpo+jUs6b5Z/K4siDu5RPUFADs=);
418453
font-style: italic
419454
}
420455
456
+.filetreeline:hover {
457
+ color: #000;
458
+ font-weight: bold;
459
+}
460
+
461
+.filetreeline .filetreeage {
462
+ padding-right: 0.5rem;
463
+}
421464
422465
/**************************************
423466
* Logout
424467
*/
425468
@@ -483,10 +526,19 @@
483526
484527
.statistics-report-week-of-year-list {
485528
font-size: 0.8rem;
486529
}
487530
531
+
532
+/**************************************
533
+ * Search
534
+ */
535
+
536
+.searchResult .snippet mark {
537
+ color: #ee0;
538
+}
539
+
488540
489541
/**************************************
490542
* Sections
491543
*/
492544
493545
494546
ADDED skins/xekri/details.txt
--- skins/xekri/css.txt
+++ skins/xekri/css.txt
@@ -1,7 +1,13 @@
1 /**************************************
2 * Xekri
 
 
 
 
 
 
3 */
4
5
6 /**************************************
7 * General HTML
@@ -16,10 +22,13 @@
16 }
17
18 body {
19 margin: 0;
20 padding: 0;
 
 
 
21 }
22
23 a {
24 color: #07e;
25 }
@@ -58,19 +67,24 @@
58 }
59
60 span[style^=background-color] {
61 color: #000;
62 }
 
 
 
 
 
63
64 /**************************************
65 * Main Area
66 */
67
68 div.header, div.mainmenu, div.submenu, div.content, div.footer {
69 clear: both;
70 margin: 0 auto;
71 max-width: 80%;
72 padding: 0.25rem 1rem;
73 }
74
75
76 /**************************************
@@ -134,34 +148,46 @@
134 font-size: 1.1rem;
135 text-align: center;
136 }
137
138 div.mainmenu {
 
139 padding-bottom: 0.25rem;
140 }
141
142 div.submenu {
143 border-top: 1px solid #0a0;
144 border-radius: 0;
145 display: flex;
146 justify-content: space-around;
147 }
148
149 div.mainmenu a, div.submenu a {
150 color: #000;
151 padding: 0 0.75rem;
152 text-decoration: none;
153 vertical-align: middle;
154 }
155
156 div.mainmenu a:hover, div.submenu a:hover {
157 color: #fff;
158 text-shadow: 0px 0px 6px #0f0;
159 }
 
 
 
 
 
 
 
 
 
 
 
 
 
160
161 div.submenu select {
162 background-color: #090;
163 }
164
165 /**************************************
166 * Main Area: Content
167 */
@@ -338,10 +364,19 @@
338
339 ul.browser li.dir {
340 font-style: italic
341 }
342
 
 
 
 
 
 
 
 
 
343
344 /**************************************
345 * File List : Tree
346 */
347
@@ -416,10 +451,18 @@
416 .filetree .dir > a {
417 background-image: url(data:image/gif;base64,R0lGODlhEAAQAJEAAP/WVCIiIv\/\/\/wAAACH5BAEHAAIALAAAAAAQABAAAAInlI9pwa3XYniCgQtkrAFfLXkiFo1jaXpo+jUs6b5Z/K4siDu5RPUFADs=);
418 font-style: italic
419 }
420
 
 
 
 
 
 
 
 
421
422 /**************************************
423 * Logout
424 */
425
@@ -483,10 +526,19 @@
483
484 .statistics-report-week-of-year-list {
485 font-size: 0.8rem;
486 }
487
 
 
 
 
 
 
 
 
 
488
489 /**************************************
490 * Sections
491 */
492
493
494 DDED skins/xekri/details.txt
--- skins/xekri/css.txt
+++ skins/xekri/css.txt
@@ -1,7 +1,13 @@
1 /******************************************************************************
2 * Xekri
3 *
4 * To adjust the width of the contents for this skin, look for the "max-width"
5 * property and change its value. (It's in the "Main Area" section) The value
6 * determines how much of the browser window to use. Some like 100%, so that
7 * the entire window is used. Others prefer 80%, which makes the contents
8 * easier to read for them.
9 */
10
11
12 /**************************************
13 * General HTML
@@ -16,10 +22,13 @@
22 }
23
24 body {
25 margin: 0;
26 padding: 0;
27 -moz-text-size-adjust: none;
28 -ms-text-size-adjust: none;
29 -webkit-text-size-adjust: none;
30 }
31
32 a {
33 color: #07e;
34 }
@@ -58,19 +67,24 @@
67 }
68
69 span[style^=background-color] {
70 color: #000;
71 }
72
73 td[style^=background-color] {
74 color: #000;
75 }
76
77
78 /**************************************
79 * Main Area
80 */
81
82 div.header, div.mainmenu, div.submenu, div.content, div.footer {
83 clear: both;
84 margin: 0 auto;
85 max-width: 90%;
86 padding: 0.25rem 1rem;
87 }
88
89
90 /**************************************
@@ -134,34 +148,46 @@
148 font-size: 1.1rem;
149 text-align: center;
150 }
151
152 div.mainmenu {
153 padding-top: 0.33rem;
154 padding-bottom: 0.25rem;
155 }
156
157 div.submenu {
158 border-top: 1px solid #0a0;
159 border-radius: 0;
160 display: block;
 
161 }
162
163 div.mainmenu a, div.submenu a {
164 color: #000;
165 padding: 0 0.75rem;
166 text-decoration: none;
 
167 }
168
169 div.mainmenu a:hover, div.submenu a:hover {
170 color: #fff;
171 text-shadow: 0px 0px 6px #0f0;
172 }
173
174 div.submenu * {
175 margin: 0 0.5rem;
176 vertical-align: middle;
177 }
178
179 div.submenu select, div.submenu input {
180 background-color: #222;
181 border: 1px inset #080;
182 color: #eee;
183 cursor: pointer;
184 font-size: 0.9rem;
185 }
186
187 div.submenu select {
188 height: 1.75rem;
189 }
190
191 /**************************************
192 * Main Area: Content
193 */
@@ -338,10 +364,19 @@
364
365 ul.browser li.dir {
366 font-style: italic
367 }
368
369
370 /**************************************
371 * File List : Age
372 */
373
374 .fileage tr:hover td {
375 background-color: #225;
376 }
377
378
379 /**************************************
380 * File List : Tree
381 */
382
@@ -416,10 +451,18 @@
451 .filetree .dir > a {
452 background-image: url(data:image/gif;base64,R0lGODlhEAAQAJEAAP/WVCIiIv\/\/\/wAAACH5BAEHAAIALAAAAAAQABAAAAInlI9pwa3XYniCgQtkrAFfLXkiFo1jaXpo+jUs6b5Z/K4siDu5RPUFADs=);
453 font-style: italic
454 }
455
456 .filetreeline:hover {
457 color: #000;
458 font-weight: bold;
459 }
460
461 .filetreeline .filetreeage {
462 padding-right: 0.5rem;
463 }
464
465 /**************************************
466 * Logout
467 */
468
@@ -483,10 +526,19 @@
526
527 .statistics-report-week-of-year-list {
528 font-size: 0.8rem;
529 }
530
531
532 /**************************************
533 * Search
534 */
535
536 .searchResult .snippet mark {
537 color: #ee0;
538 }
539
540
541 /**************************************
542 * Sections
543 */
544
545
546 DDED skins/xekri/details.txt
--- a/skins/xekri/details.txt
+++ b/skins/xekri/details.txt
@@ -0,0 +1,3 @@
1
+timeline-arrowheads: 1
2
+timeline-circle-nodes: 0
3
+timeline-color-graph-lines: 0
--- a/skins/xekri/details.txt
+++ b/skins/xekri/details.txt
@@ -0,0 +1,3 @@
 
 
 
--- a/skins/xekri/details.txt
+++ b/skins/xekri/details.txt
@@ -0,0 +1,3 @@
1 timeline-arrowheads: 1
2 timeline-circle-nodes: 0
3 timeline-color-graph-lines: 0
--- skins/xekri/header.txt
+++ skins/xekri/header.txt
@@ -114,21 +114,21 @@
114114
}
115115
menulink $index_page Home
116116
if {[anycap jor]} {
117117
menulink /timeline Timeline
118118
}
119
-if {[hascap oh]} {
119
+if {[anoncap oh]} {
120120
menulink /dir?ci=tip Files
121121
}
122
-if {[hascap o]} {
122
+if {[anoncap o]} {
123123
menulink /brlist Branches
124124
menulink /taglist Tags
125125
}
126
-if {[hascap r]} {
126
+if {[anoncap r]} {
127127
menulink /ticket Tickets
128128
}
129
-if {[hascap j]} {
129
+if {[anoncap j]} {
130130
menulink /wiki Wiki
131131
}
132132
if {[hascap s]} {
133133
menulink /setup Admin
134134
} elseif {[hascap a]} {
135135
--- skins/xekri/header.txt
+++ skins/xekri/header.txt
@@ -114,21 +114,21 @@
114 }
115 menulink $index_page Home
116 if {[anycap jor]} {
117 menulink /timeline Timeline
118 }
119 if {[hascap oh]} {
120 menulink /dir?ci=tip Files
121 }
122 if {[hascap o]} {
123 menulink /brlist Branches
124 menulink /taglist Tags
125 }
126 if {[hascap r]} {
127 menulink /ticket Tickets
128 }
129 if {[hascap j]} {
130 menulink /wiki Wiki
131 }
132 if {[hascap s]} {
133 menulink /setup Admin
134 } elseif {[hascap a]} {
135
--- skins/xekri/header.txt
+++ skins/xekri/header.txt
@@ -114,21 +114,21 @@
114 }
115 menulink $index_page Home
116 if {[anycap jor]} {
117 menulink /timeline Timeline
118 }
119 if {[anoncap oh]} {
120 menulink /dir?ci=tip Files
121 }
122 if {[anoncap o]} {
123 menulink /brlist Branches
124 menulink /taglist Tags
125 }
126 if {[anoncap r]} {
127 menulink /ticket Tickets
128 }
129 if {[anoncap j]} {
130 menulink /wiki Wiki
131 }
132 if {[hascap s]} {
133 menulink /setup Admin
134 } elseif {[hascap a]} {
135
+4 -4
--- src/captcha.c
+++ src/captcha.c
@@ -28,11 +28,11 @@
2828
#endif
2929
3030
/*
3131
** Convert a hex digit into a value between 0 and 15
3232
*/
33
-static int hexValue(char c){
33
+int hex_digit_value(char c){
3434
if( c>='0' && c<='9' ){
3535
return c - '0';
3636
}else if( c>='a' && c<='f' ){
3737
return c - 'a' + 10;
3838
}else if( c>='A' && c<='F' ){
@@ -75,11 +75,11 @@
7575
int i, j, k, m;
7676
7777
k = 0;
7878
for(i=0; i<6; i++){
7979
for(j=0; zPw[j]; j++){
80
- unsigned char v = hexValue(zPw[j]);
80
+ unsigned char v = hex_digit_value(zPw[j]);
8181
v = (aFont1[v] >> ((5-i)*4)) & 0xf;
8282
for(m=8; m>=1; m = m>>1){
8383
if( v & m ){
8484
z[k++] = 'X';
8585
z[k++] = 'X';
@@ -209,11 +209,11 @@
209209
const char *zChar;
210210
211211
k = 0;
212212
for(i=0; i<4; i++){
213213
for(j=0; zPw[j]; j++){
214
- unsigned char v = hexValue(zPw[j]);
214
+ unsigned char v = hex_digit_value(zPw[j]);
215215
zChar = azFont2[4*v + i];
216216
for(m=0; zChar[m]; m++){
217217
z[k++] = zChar[m];
218218
}
219219
}
@@ -369,11 +369,11 @@
369369
370370
k = 0;
371371
for(i=0; i<6; i++){
372372
x = 0;
373373
for(j=0; zPw[j]; j++){
374
- unsigned char v = hexValue(zPw[j]);
374
+ unsigned char v = hex_digit_value(zPw[j]);
375375
x = (x<<4) + v;
376376
switch( x ){
377377
case 0x7a:
378378
case 0xfa:
379379
y = 3;
380380
--- src/captcha.c
+++ src/captcha.c
@@ -28,11 +28,11 @@
28 #endif
29
30 /*
31 ** Convert a hex digit into a value between 0 and 15
32 */
33 static int hexValue(char c){
34 if( c>='0' && c<='9' ){
35 return c - '0';
36 }else if( c>='a' && c<='f' ){
37 return c - 'a' + 10;
38 }else if( c>='A' && c<='F' ){
@@ -75,11 +75,11 @@
75 int i, j, k, m;
76
77 k = 0;
78 for(i=0; i<6; i++){
79 for(j=0; zPw[j]; j++){
80 unsigned char v = hexValue(zPw[j]);
81 v = (aFont1[v] >> ((5-i)*4)) & 0xf;
82 for(m=8; m>=1; m = m>>1){
83 if( v & m ){
84 z[k++] = 'X';
85 z[k++] = 'X';
@@ -209,11 +209,11 @@
209 const char *zChar;
210
211 k = 0;
212 for(i=0; i<4; i++){
213 for(j=0; zPw[j]; j++){
214 unsigned char v = hexValue(zPw[j]);
215 zChar = azFont2[4*v + i];
216 for(m=0; zChar[m]; m++){
217 z[k++] = zChar[m];
218 }
219 }
@@ -369,11 +369,11 @@
369
370 k = 0;
371 for(i=0; i<6; i++){
372 x = 0;
373 for(j=0; zPw[j]; j++){
374 unsigned char v = hexValue(zPw[j]);
375 x = (x<<4) + v;
376 switch( x ){
377 case 0x7a:
378 case 0xfa:
379 y = 3;
380
--- src/captcha.c
+++ src/captcha.c
@@ -28,11 +28,11 @@
28 #endif
29
30 /*
31 ** Convert a hex digit into a value between 0 and 15
32 */
33 int hex_digit_value(char c){
34 if( c>='0' && c<='9' ){
35 return c - '0';
36 }else if( c>='a' && c<='f' ){
37 return c - 'a' + 10;
38 }else if( c>='A' && c<='F' ){
@@ -75,11 +75,11 @@
75 int i, j, k, m;
76
77 k = 0;
78 for(i=0; i<6; i++){
79 for(j=0; zPw[j]; j++){
80 unsigned char v = hex_digit_value(zPw[j]);
81 v = (aFont1[v] >> ((5-i)*4)) & 0xf;
82 for(m=8; m>=1; m = m>>1){
83 if( v & m ){
84 z[k++] = 'X';
85 z[k++] = 'X';
@@ -209,11 +209,11 @@
209 const char *zChar;
210
211 k = 0;
212 for(i=0; i<4; i++){
213 for(j=0; zPw[j]; j++){
214 unsigned char v = hex_digit_value(zPw[j]);
215 zChar = azFont2[4*v + i];
216 for(m=0; zChar[m]; m++){
217 z[k++] = zChar[m];
218 }
219 }
@@ -369,11 +369,11 @@
369
370 k = 0;
371 for(i=0; i<6; i++){
372 x = 0;
373 for(j=0; zPw[j]; j++){
374 unsigned char v = hex_digit_value(zPw[j]);
375 x = (x<<4) + v;
376 switch( x ){
377 case 0x7a:
378 case 0xfa:
379 y = 3;
380
--- src/checkin.c
+++ src/checkin.c
@@ -1809,10 +1809,14 @@
18091809
** or --force flags is used, or unless this is a private check-in.
18101810
** The initial commit MUST have tags "trunk" and "sym-trunk".
18111811
*/
18121812
if( !vid ){
18131813
if( sCiInfo.zBranch==0 ){
1814
+ if( allowFork==0 && forceFlag==0 && g.markPrivate==0
1815
+ && db_exists("SELECT 1 from event where type='ci'") ){
1816
+ fossil_fatal("would fork. \"update\" first or use --allow-fork.");
1817
+ }
18141818
sCiInfo.zBranch = db_get("main-branch", "trunk");
18151819
}
18161820
}else if( sCiInfo.zBranch==0 && allowFork==0 && forceFlag==0
18171821
&& g.markPrivate==0 && !is_a_leaf(vid)
18181822
){
18191823
--- src/checkin.c
+++ src/checkin.c
@@ -1809,10 +1809,14 @@
1809 ** or --force flags is used, or unless this is a private check-in.
1810 ** The initial commit MUST have tags "trunk" and "sym-trunk".
1811 */
1812 if( !vid ){
1813 if( sCiInfo.zBranch==0 ){
 
 
 
 
1814 sCiInfo.zBranch = db_get("main-branch", "trunk");
1815 }
1816 }else if( sCiInfo.zBranch==0 && allowFork==0 && forceFlag==0
1817 && g.markPrivate==0 && !is_a_leaf(vid)
1818 ){
1819
--- src/checkin.c
+++ src/checkin.c
@@ -1809,10 +1809,14 @@
1809 ** or --force flags is used, or unless this is a private check-in.
1810 ** The initial commit MUST have tags "trunk" and "sym-trunk".
1811 */
1812 if( !vid ){
1813 if( sCiInfo.zBranch==0 ){
1814 if( allowFork==0 && forceFlag==0 && g.markPrivate==0
1815 && db_exists("SELECT 1 from event where type='ci'") ){
1816 fossil_fatal("would fork. \"update\" first or use --allow-fork.");
1817 }
1818 sCiInfo.zBranch = db_get("main-branch", "trunk");
1819 }
1820 }else if( sCiInfo.zBranch==0 && allowFork==0 && forceFlag==0
1821 && g.markPrivate==0 && !is_a_leaf(vid)
1822 ){
1823
+1 -1
--- src/configure.c
+++ src/configure.c
@@ -86,10 +86,11 @@
8686
int groupMask; /* Which config groups is it part of */
8787
} aConfig[] = {
8888
{ "css", CONFIGSET_CSS },
8989
{ "header", CONFIGSET_SKIN },
9090
{ "footer", CONFIGSET_SKIN },
91
+ { "details", CONFIGSET_SKIN },
9192
{ "logo-mimetype", CONFIGSET_SKIN },
9293
{ "logo-image", CONFIGSET_SKIN },
9394
{ "background-mimetype", CONFIGSET_SKIN },
9495
{ "background-image", CONFIGSET_SKIN },
9596
{ "timeline-block-markup", CONFIGSET_SKIN },
@@ -96,11 +97,10 @@
9697
{ "timeline-max-comment", CONFIGSET_SKIN },
9798
{ "timeline-plaintext", CONFIGSET_SKIN },
9899
{ "adunit", CONFIGSET_SKIN },
99100
{ "adunit-omit-if-admin", CONFIGSET_SKIN },
100101
{ "adunit-omit-if-user", CONFIGSET_SKIN },
101
- { "white-foreground", CONFIGSET_SKIN },
102102
103103
#ifdef FOSSIL_ENABLE_TH1_DOCS
104104
{ "th1-docs", CONFIGSET_TH1 },
105105
#endif
106106
#ifdef FOSSIL_ENABLE_TH1_HOOKS
107107
--- src/configure.c
+++ src/configure.c
@@ -86,10 +86,11 @@
86 int groupMask; /* Which config groups is it part of */
87 } aConfig[] = {
88 { "css", CONFIGSET_CSS },
89 { "header", CONFIGSET_SKIN },
90 { "footer", CONFIGSET_SKIN },
 
91 { "logo-mimetype", CONFIGSET_SKIN },
92 { "logo-image", CONFIGSET_SKIN },
93 { "background-mimetype", CONFIGSET_SKIN },
94 { "background-image", CONFIGSET_SKIN },
95 { "timeline-block-markup", CONFIGSET_SKIN },
@@ -96,11 +97,10 @@
96 { "timeline-max-comment", CONFIGSET_SKIN },
97 { "timeline-plaintext", CONFIGSET_SKIN },
98 { "adunit", CONFIGSET_SKIN },
99 { "adunit-omit-if-admin", CONFIGSET_SKIN },
100 { "adunit-omit-if-user", CONFIGSET_SKIN },
101 { "white-foreground", CONFIGSET_SKIN },
102
103 #ifdef FOSSIL_ENABLE_TH1_DOCS
104 { "th1-docs", CONFIGSET_TH1 },
105 #endif
106 #ifdef FOSSIL_ENABLE_TH1_HOOKS
107
--- src/configure.c
+++ src/configure.c
@@ -86,10 +86,11 @@
86 int groupMask; /* Which config groups is it part of */
87 } aConfig[] = {
88 { "css", CONFIGSET_CSS },
89 { "header", CONFIGSET_SKIN },
90 { "footer", CONFIGSET_SKIN },
91 { "details", CONFIGSET_SKIN },
92 { "logo-mimetype", CONFIGSET_SKIN },
93 { "logo-image", CONFIGSET_SKIN },
94 { "background-mimetype", CONFIGSET_SKIN },
95 { "background-image", CONFIGSET_SKIN },
96 { "timeline-block-markup", CONFIGSET_SKIN },
@@ -96,11 +97,10 @@
97 { "timeline-max-comment", CONFIGSET_SKIN },
98 { "timeline-plaintext", CONFIGSET_SKIN },
99 { "adunit", CONFIGSET_SKIN },
100 { "adunit-omit-if-admin", CONFIGSET_SKIN },
101 { "adunit-omit-if-user", CONFIGSET_SKIN },
 
102
103 #ifdef FOSSIL_ENABLE_TH1_DOCS
104 { "th1-docs", CONFIGSET_TH1 },
105 #endif
106 #ifdef FOSSIL_ENABLE_TH1_HOOKS
107
+1 -1
--- src/configure.c
+++ src/configure.c
@@ -86,10 +86,11 @@
8686
int groupMask; /* Which config groups is it part of */
8787
} aConfig[] = {
8888
{ "css", CONFIGSET_CSS },
8989
{ "header", CONFIGSET_SKIN },
9090
{ "footer", CONFIGSET_SKIN },
91
+ { "details", CONFIGSET_SKIN },
9192
{ "logo-mimetype", CONFIGSET_SKIN },
9293
{ "logo-image", CONFIGSET_SKIN },
9394
{ "background-mimetype", CONFIGSET_SKIN },
9495
{ "background-image", CONFIGSET_SKIN },
9596
{ "timeline-block-markup", CONFIGSET_SKIN },
@@ -96,11 +97,10 @@
9697
{ "timeline-max-comment", CONFIGSET_SKIN },
9798
{ "timeline-plaintext", CONFIGSET_SKIN },
9899
{ "adunit", CONFIGSET_SKIN },
99100
{ "adunit-omit-if-admin", CONFIGSET_SKIN },
100101
{ "adunit-omit-if-user", CONFIGSET_SKIN },
101
- { "white-foreground", CONFIGSET_SKIN },
102102
103103
#ifdef FOSSIL_ENABLE_TH1_DOCS
104104
{ "th1-docs", CONFIGSET_TH1 },
105105
#endif
106106
#ifdef FOSSIL_ENABLE_TH1_HOOKS
107107
--- src/configure.c
+++ src/configure.c
@@ -86,10 +86,11 @@
86 int groupMask; /* Which config groups is it part of */
87 } aConfig[] = {
88 { "css", CONFIGSET_CSS },
89 { "header", CONFIGSET_SKIN },
90 { "footer", CONFIGSET_SKIN },
 
91 { "logo-mimetype", CONFIGSET_SKIN },
92 { "logo-image", CONFIGSET_SKIN },
93 { "background-mimetype", CONFIGSET_SKIN },
94 { "background-image", CONFIGSET_SKIN },
95 { "timeline-block-markup", CONFIGSET_SKIN },
@@ -96,11 +97,10 @@
96 { "timeline-max-comment", CONFIGSET_SKIN },
97 { "timeline-plaintext", CONFIGSET_SKIN },
98 { "adunit", CONFIGSET_SKIN },
99 { "adunit-omit-if-admin", CONFIGSET_SKIN },
100 { "adunit-omit-if-user", CONFIGSET_SKIN },
101 { "white-foreground", CONFIGSET_SKIN },
102
103 #ifdef FOSSIL_ENABLE_TH1_DOCS
104 { "th1-docs", CONFIGSET_TH1 },
105 #endif
106 #ifdef FOSSIL_ENABLE_TH1_HOOKS
107
--- src/configure.c
+++ src/configure.c
@@ -86,10 +86,11 @@
86 int groupMask; /* Which config groups is it part of */
87 } aConfig[] = {
88 { "css", CONFIGSET_CSS },
89 { "header", CONFIGSET_SKIN },
90 { "footer", CONFIGSET_SKIN },
91 { "details", CONFIGSET_SKIN },
92 { "logo-mimetype", CONFIGSET_SKIN },
93 { "logo-image", CONFIGSET_SKIN },
94 { "background-mimetype", CONFIGSET_SKIN },
95 { "background-image", CONFIGSET_SKIN },
96 { "timeline-block-markup", CONFIGSET_SKIN },
@@ -96,11 +97,10 @@
97 { "timeline-max-comment", CONFIGSET_SKIN },
98 { "timeline-plaintext", CONFIGSET_SKIN },
99 { "adunit", CONFIGSET_SKIN },
100 { "adunit-omit-if-admin", CONFIGSET_SKIN },
101 { "adunit-omit-if-user", CONFIGSET_SKIN },
 
102
103 #ifdef FOSSIL_ENABLE_TH1_DOCS
104 { "th1-docs", CONFIGSET_TH1 },
105 #endif
106 #ifdef FOSSIL_ENABLE_TH1_HOOKS
107
+2 -2
--- src/db.c
+++ src/db.c
@@ -2345,11 +2345,11 @@
23452345
{ "crnl-glob", 0, 40, 1, 0, "" },
23462346
{ "default-perms", 0, 16, 0, 0, "u" },
23472347
{ "diff-binary", 0, 0, 0, 0, "on" },
23482348
{ "diff-command", 0, 40, 0, 0, "" },
23492349
{ "dont-push", 0, 0, 0, 0, "off" },
2350
- { "dotfiles", 0, 0, 0, 0, "off" },
2350
+ { "dotfiles", 0, 0, 1, 0, "off" },
23512351
{ "editor", 0, 32, 0, 0, "" },
23522352
{ "empty-dirs", 0, 40, 1, 0, "" },
23532353
{ "encoding-glob", 0, 40, 1, 0, "" },
23542354
{ "gdiff-command", 0, 40, 0, 0, "gdiff" },
23552355
{ "gmerge-command", 0, 40, 0, 0, "" },
@@ -2389,11 +2389,10 @@
23892389
{ "th1-hooks", 0, 0, 0, 0, "off" },
23902390
#endif
23912391
{ "th1-setup", 0, 40, 1, 1, "" },
23922392
{ "th1-uri-regexp", 0, 40, 1, 0, "" },
23932393
{ "web-browser", 0, 32, 0, 0, "" },
2394
- { "white-foreground", 0, 0, 0, 0, "off" },
23952394
{ 0,0,0,0,0,0 }
23962395
};
23972396
23982397
/*
23992398
** Look up a control setting by its name. Return a pointer to the Setting
@@ -2514,10 +2513,11 @@
25142513
**
25152514
** dont-push Prevent this repository from pushing from client to
25162515
** server. Useful when setting up a private branch.
25172516
**
25182517
** dotfiles Include --dotfiles option for all compatible commands.
2518
+** (versionable)
25192519
**
25202520
** editor Text editor command used for check-in comments.
25212521
**
25222522
** empty-dirs A comma or newline-separated list of pathnames. On
25232523
** (versionable) update and checkout commands, if no file or directory
25242524
--- src/db.c
+++ src/db.c
@@ -2345,11 +2345,11 @@
2345 { "crnl-glob", 0, 40, 1, 0, "" },
2346 { "default-perms", 0, 16, 0, 0, "u" },
2347 { "diff-binary", 0, 0, 0, 0, "on" },
2348 { "diff-command", 0, 40, 0, 0, "" },
2349 { "dont-push", 0, 0, 0, 0, "off" },
2350 { "dotfiles", 0, 0, 0, 0, "off" },
2351 { "editor", 0, 32, 0, 0, "" },
2352 { "empty-dirs", 0, 40, 1, 0, "" },
2353 { "encoding-glob", 0, 40, 1, 0, "" },
2354 { "gdiff-command", 0, 40, 0, 0, "gdiff" },
2355 { "gmerge-command", 0, 40, 0, 0, "" },
@@ -2389,11 +2389,10 @@
2389 { "th1-hooks", 0, 0, 0, 0, "off" },
2390 #endif
2391 { "th1-setup", 0, 40, 1, 1, "" },
2392 { "th1-uri-regexp", 0, 40, 1, 0, "" },
2393 { "web-browser", 0, 32, 0, 0, "" },
2394 { "white-foreground", 0, 0, 0, 0, "off" },
2395 { 0,0,0,0,0,0 }
2396 };
2397
2398 /*
2399 ** Look up a control setting by its name. Return a pointer to the Setting
@@ -2514,10 +2513,11 @@
2514 **
2515 ** dont-push Prevent this repository from pushing from client to
2516 ** server. Useful when setting up a private branch.
2517 **
2518 ** dotfiles Include --dotfiles option for all compatible commands.
 
2519 **
2520 ** editor Text editor command used for check-in comments.
2521 **
2522 ** empty-dirs A comma or newline-separated list of pathnames. On
2523 ** (versionable) update and checkout commands, if no file or directory
2524
--- src/db.c
+++ src/db.c
@@ -2345,11 +2345,11 @@
2345 { "crnl-glob", 0, 40, 1, 0, "" },
2346 { "default-perms", 0, 16, 0, 0, "u" },
2347 { "diff-binary", 0, 0, 0, 0, "on" },
2348 { "diff-command", 0, 40, 0, 0, "" },
2349 { "dont-push", 0, 0, 0, 0, "off" },
2350 { "dotfiles", 0, 0, 1, 0, "off" },
2351 { "editor", 0, 32, 0, 0, "" },
2352 { "empty-dirs", 0, 40, 1, 0, "" },
2353 { "encoding-glob", 0, 40, 1, 0, "" },
2354 { "gdiff-command", 0, 40, 0, 0, "gdiff" },
2355 { "gmerge-command", 0, 40, 0, 0, "" },
@@ -2389,11 +2389,10 @@
2389 { "th1-hooks", 0, 0, 0, 0, "off" },
2390 #endif
2391 { "th1-setup", 0, 40, 1, 1, "" },
2392 { "th1-uri-regexp", 0, 40, 1, 0, "" },
2393 { "web-browser", 0, 32, 0, 0, "" },
 
2394 { 0,0,0,0,0,0 }
2395 };
2396
2397 /*
2398 ** Look up a control setting by its name. Return a pointer to the Setting
@@ -2514,10 +2513,11 @@
2513 **
2514 ** dont-push Prevent this repository from pushing from client to
2515 ** server. Useful when setting up a private branch.
2516 **
2517 ** dotfiles Include --dotfiles option for all compatible commands.
2518 ** (versionable)
2519 **
2520 ** editor Text editor command used for check-in comments.
2521 **
2522 ** empty-dirs A comma or newline-separated list of pathnames. On
2523 ** (versionable) update and checkout commands, if no file or directory
2524
+2 -2
--- src/db.c
+++ src/db.c
@@ -2345,11 +2345,11 @@
23452345
{ "crnl-glob", 0, 40, 1, 0, "" },
23462346
{ "default-perms", 0, 16, 0, 0, "u" },
23472347
{ "diff-binary", 0, 0, 0, 0, "on" },
23482348
{ "diff-command", 0, 40, 0, 0, "" },
23492349
{ "dont-push", 0, 0, 0, 0, "off" },
2350
- { "dotfiles", 0, 0, 0, 0, "off" },
2350
+ { "dotfiles", 0, 0, 1, 0, "off" },
23512351
{ "editor", 0, 32, 0, 0, "" },
23522352
{ "empty-dirs", 0, 40, 1, 0, "" },
23532353
{ "encoding-glob", 0, 40, 1, 0, "" },
23542354
{ "gdiff-command", 0, 40, 0, 0, "gdiff" },
23552355
{ "gmerge-command", 0, 40, 0, 0, "" },
@@ -2389,11 +2389,10 @@
23892389
{ "th1-hooks", 0, 0, 0, 0, "off" },
23902390
#endif
23912391
{ "th1-setup", 0, 40, 1, 1, "" },
23922392
{ "th1-uri-regexp", 0, 40, 1, 0, "" },
23932393
{ "web-browser", 0, 32, 0, 0, "" },
2394
- { "white-foreground", 0, 0, 0, 0, "off" },
23952394
{ 0,0,0,0,0,0 }
23962395
};
23972396
23982397
/*
23992398
** Look up a control setting by its name. Return a pointer to the Setting
@@ -2514,10 +2513,11 @@
25142513
**
25152514
** dont-push Prevent this repository from pushing from client to
25162515
** server. Useful when setting up a private branch.
25172516
**
25182517
** dotfiles Include --dotfiles option for all compatible commands.
2518
+** (versionable)
25192519
**
25202520
** editor Text editor command used for check-in comments.
25212521
**
25222522
** empty-dirs A comma or newline-separated list of pathnames. On
25232523
** (versionable) update and checkout commands, if no file or directory
25242524
--- src/db.c
+++ src/db.c
@@ -2345,11 +2345,11 @@
2345 { "crnl-glob", 0, 40, 1, 0, "" },
2346 { "default-perms", 0, 16, 0, 0, "u" },
2347 { "diff-binary", 0, 0, 0, 0, "on" },
2348 { "diff-command", 0, 40, 0, 0, "" },
2349 { "dont-push", 0, 0, 0, 0, "off" },
2350 { "dotfiles", 0, 0, 0, 0, "off" },
2351 { "editor", 0, 32, 0, 0, "" },
2352 { "empty-dirs", 0, 40, 1, 0, "" },
2353 { "encoding-glob", 0, 40, 1, 0, "" },
2354 { "gdiff-command", 0, 40, 0, 0, "gdiff" },
2355 { "gmerge-command", 0, 40, 0, 0, "" },
@@ -2389,11 +2389,10 @@
2389 { "th1-hooks", 0, 0, 0, 0, "off" },
2390 #endif
2391 { "th1-setup", 0, 40, 1, 1, "" },
2392 { "th1-uri-regexp", 0, 40, 1, 0, "" },
2393 { "web-browser", 0, 32, 0, 0, "" },
2394 { "white-foreground", 0, 0, 0, 0, "off" },
2395 { 0,0,0,0,0,0 }
2396 };
2397
2398 /*
2399 ** Look up a control setting by its name. Return a pointer to the Setting
@@ -2514,10 +2513,11 @@
2514 **
2515 ** dont-push Prevent this repository from pushing from client to
2516 ** server. Useful when setting up a private branch.
2517 **
2518 ** dotfiles Include --dotfiles option for all compatible commands.
 
2519 **
2520 ** editor Text editor command used for check-in comments.
2521 **
2522 ** empty-dirs A comma or newline-separated list of pathnames. On
2523 ** (versionable) update and checkout commands, if no file or directory
2524
--- src/db.c
+++ src/db.c
@@ -2345,11 +2345,11 @@
2345 { "crnl-glob", 0, 40, 1, 0, "" },
2346 { "default-perms", 0, 16, 0, 0, "u" },
2347 { "diff-binary", 0, 0, 0, 0, "on" },
2348 { "diff-command", 0, 40, 0, 0, "" },
2349 { "dont-push", 0, 0, 0, 0, "off" },
2350 { "dotfiles", 0, 0, 1, 0, "off" },
2351 { "editor", 0, 32, 0, 0, "" },
2352 { "empty-dirs", 0, 40, 1, 0, "" },
2353 { "encoding-glob", 0, 40, 1, 0, "" },
2354 { "gdiff-command", 0, 40, 0, 0, "gdiff" },
2355 { "gmerge-command", 0, 40, 0, 0, "" },
@@ -2389,11 +2389,10 @@
2389 { "th1-hooks", 0, 0, 0, 0, "off" },
2390 #endif
2391 { "th1-setup", 0, 40, 1, 1, "" },
2392 { "th1-uri-regexp", 0, 40, 1, 0, "" },
2393 { "web-browser", 0, 32, 0, 0, "" },
 
2394 { 0,0,0,0,0,0 }
2395 };
2396
2397 /*
2398 ** Look up a control setting by its name. Return a pointer to the Setting
@@ -2514,10 +2513,11 @@
2513 **
2514 ** dont-push Prevent this repository from pushing from client to
2515 ** server. Useful when setting up a private branch.
2516 **
2517 ** dotfiles Include --dotfiles option for all compatible commands.
2518 ** (versionable)
2519 **
2520 ** editor Text editor command used for check-in comments.
2521 **
2522 ** empty-dirs A comma or newline-separated list of pathnames. On
2523 ** (versionable) update and checkout commands, if no file or directory
2524
+1 -1
--- src/diff.c
+++ src/diff.c
@@ -2294,11 +2294,11 @@
22942294
}
22952295
if( iLimit>20 ){
22962296
style_submenu_element("20 Ancestors", "20 Ancestors",
22972297
"%s", url_render(&url, "limit", "20", 0, 0));
22982298
}
2299
- if( skin_white_foreground() ){
2299
+ if( skin_detail_boolean("white-foreground") ){
23002300
clr1 = 0xa04040;
23012301
clr2 = 0x4059a0;
23022302
}else{
23032303
clr1 = 0xffb5b5; /* Recent changes: red (hot) */
23042304
clr2 = 0xb5e0ff; /* Older changes: blue (cold) */
23052305
--- src/diff.c
+++ src/diff.c
@@ -2294,11 +2294,11 @@
2294 }
2295 if( iLimit>20 ){
2296 style_submenu_element("20 Ancestors", "20 Ancestors",
2297 "%s", url_render(&url, "limit", "20", 0, 0));
2298 }
2299 if( skin_white_foreground() ){
2300 clr1 = 0xa04040;
2301 clr2 = 0x4059a0;
2302 }else{
2303 clr1 = 0xffb5b5; /* Recent changes: red (hot) */
2304 clr2 = 0xb5e0ff; /* Older changes: blue (cold) */
2305
--- src/diff.c
+++ src/diff.c
@@ -2294,11 +2294,11 @@
2294 }
2295 if( iLimit>20 ){
2296 style_submenu_element("20 Ancestors", "20 Ancestors",
2297 "%s", url_render(&url, "limit", "20", 0, 0));
2298 }
2299 if( skin_detail_boolean("white-foreground") ){
2300 clr1 = 0xa04040;
2301 clr2 = 0x4059a0;
2302 }else{
2303 clr1 = 0xffb5b5; /* Recent changes: red (hot) */
2304 clr2 = 0xb5e0ff; /* Older changes: blue (cold) */
2305
--- src/http_socket.c
+++ src/http_socket.c
@@ -24,10 +24,13 @@
2424
**
2525
** Low-level sockets are abstracted out into this module because they
2626
** are handled different on Unix and windows.
2727
*/
2828
29
+#ifndef __EXTENSIONS__
30
+# define __EXTENSIONS__ 1 /* IPv6 won't compile on Solaris without this */
31
+#endif
2932
#include "config.h"
3033
#include "http_socket.h"
3134
#if defined(_WIN32)
3235
# if !defined(_WIN32_WINNT)
3336
# define _WIN32_WINNT 0x0501
3437
--- src/http_socket.c
+++ src/http_socket.c
@@ -24,10 +24,13 @@
24 **
25 ** Low-level sockets are abstracted out into this module because they
26 ** are handled different on Unix and windows.
27 */
28
 
 
 
29 #include "config.h"
30 #include "http_socket.h"
31 #if defined(_WIN32)
32 # if !defined(_WIN32_WINNT)
33 # define _WIN32_WINNT 0x0501
34
--- src/http_socket.c
+++ src/http_socket.c
@@ -24,10 +24,13 @@
24 **
25 ** Low-level sockets are abstracted out into this module because they
26 ** are handled different on Unix and windows.
27 */
28
29 #ifndef __EXTENSIONS__
30 # define __EXTENSIONS__ 1 /* IPv6 won't compile on Solaris without this */
31 #endif
32 #include "config.h"
33 #include "http_socket.h"
34 #if defined(_WIN32)
35 # if !defined(_WIN32_WINNT)
36 # define _WIN32_WINNT 0x0501
37
--- src/json_config.c
+++ src/json_config.c
@@ -56,10 +56,11 @@
5656
int groupMask;
5757
} JsonConfigProperties[] = {
5858
{ "css", CONFIGSET_CSS },
5959
{ "header", CONFIGSET_SKIN },
6060
{ "footer", CONFIGSET_SKIN },
61
+{ "details", CONFIGSET_SKIN },
6162
{ "logo-mimetype", CONFIGSET_SKIN },
6263
{ "logo-image", CONFIGSET_SKIN },
6364
{ "background-mimetype", CONFIGSET_SKIN },
6465
{ "background-image", CONFIGSET_SKIN },
6566
{ "timeline-block-markup", CONFIGSET_SKIN },
@@ -66,11 +67,10 @@
6667
{ "timeline-max-comment", CONFIGSET_SKIN },
6768
{ "timeline-plaintext", CONFIGSET_SKIN },
6869
{ "adunit", CONFIGSET_SKIN },
6970
{ "adunit-omit-if-admin", CONFIGSET_SKIN },
7071
{ "adunit-omit-if-user", CONFIGSET_SKIN },
71
-{ "white-foreground", CONFIGSET_SKIN },
7272
7373
{ "project-name", CONFIGSET_PROJ },
7474
{ "short-project-name", CONFIGSET_PROJ },
7575
{ "project-description", CONFIGSET_PROJ },
7676
{ "index-page", CONFIGSET_PROJ },
7777
--- src/json_config.c
+++ src/json_config.c
@@ -56,10 +56,11 @@
56 int groupMask;
57 } JsonConfigProperties[] = {
58 { "css", CONFIGSET_CSS },
59 { "header", CONFIGSET_SKIN },
60 { "footer", CONFIGSET_SKIN },
 
61 { "logo-mimetype", CONFIGSET_SKIN },
62 { "logo-image", CONFIGSET_SKIN },
63 { "background-mimetype", CONFIGSET_SKIN },
64 { "background-image", CONFIGSET_SKIN },
65 { "timeline-block-markup", CONFIGSET_SKIN },
@@ -66,11 +67,10 @@
66 { "timeline-max-comment", CONFIGSET_SKIN },
67 { "timeline-plaintext", CONFIGSET_SKIN },
68 { "adunit", CONFIGSET_SKIN },
69 { "adunit-omit-if-admin", CONFIGSET_SKIN },
70 { "adunit-omit-if-user", CONFIGSET_SKIN },
71 { "white-foreground", CONFIGSET_SKIN },
72
73 { "project-name", CONFIGSET_PROJ },
74 { "short-project-name", CONFIGSET_PROJ },
75 { "project-description", CONFIGSET_PROJ },
76 { "index-page", CONFIGSET_PROJ },
77
--- src/json_config.c
+++ src/json_config.c
@@ -56,10 +56,11 @@
56 int groupMask;
57 } JsonConfigProperties[] = {
58 { "css", CONFIGSET_CSS },
59 { "header", CONFIGSET_SKIN },
60 { "footer", CONFIGSET_SKIN },
61 { "details", CONFIGSET_SKIN },
62 { "logo-mimetype", CONFIGSET_SKIN },
63 { "logo-image", CONFIGSET_SKIN },
64 { "background-mimetype", CONFIGSET_SKIN },
65 { "background-image", CONFIGSET_SKIN },
66 { "timeline-block-markup", CONFIGSET_SKIN },
@@ -66,11 +67,10 @@
67 { "timeline-max-comment", CONFIGSET_SKIN },
68 { "timeline-plaintext", CONFIGSET_SKIN },
69 { "adunit", CONFIGSET_SKIN },
70 { "adunit-omit-if-admin", CONFIGSET_SKIN },
71 { "adunit-omit-if-user", CONFIGSET_SKIN },
 
72
73 { "project-name", CONFIGSET_PROJ },
74 { "short-project-name", CONFIGSET_PROJ },
75 { "project-description", CONFIGSET_PROJ },
76 { "index-page", CONFIGSET_PROJ },
77
+6
--- src/main.c
+++ src/main.c
@@ -1525,10 +1525,16 @@
15251525
break;
15261526
}
15271527
if( szFile==0 ){
15281528
if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
15291529
szFile = file_size(zRepo);
1530
+ /* this should only be set from the --baseurl option, not CGI */
1531
+ if( g.zBaseURL && g.zBaseURL[0]!=0 && g.zTop && g.zTop[0]!=0 &&
1532
+ file_isdir(g.zRepositoryName)==1 ){
1533
+ g.zBaseURL = mprintf("%s%.*s", g.zBaseURL, i, zPathInfo);
1534
+ g.zTop = mprintf("%s%.*s", g.zTop, i, zPathInfo);
1535
+ }
15301536
}
15311537
if( szFile<0 && i>0 ){
15321538
const char *zMimetype;
15331539
assert( fossil_strcmp(&zRepo[j], ".fossil")==0 );
15341540
zRepo[j] = 0;
15351541
--- src/main.c
+++ src/main.c
@@ -1525,10 +1525,16 @@
1525 break;
1526 }
1527 if( szFile==0 ){
1528 if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
1529 szFile = file_size(zRepo);
 
 
 
 
 
 
1530 }
1531 if( szFile<0 && i>0 ){
1532 const char *zMimetype;
1533 assert( fossil_strcmp(&zRepo[j], ".fossil")==0 );
1534 zRepo[j] = 0;
1535
--- src/main.c
+++ src/main.c
@@ -1525,10 +1525,16 @@
1525 break;
1526 }
1527 if( szFile==0 ){
1528 if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
1529 szFile = file_size(zRepo);
1530 /* this should only be set from the --baseurl option, not CGI */
1531 if( g.zBaseURL && g.zBaseURL[0]!=0 && g.zTop && g.zTop[0]!=0 &&
1532 file_isdir(g.zRepositoryName)==1 ){
1533 g.zBaseURL = mprintf("%s%.*s", g.zBaseURL, i, zPathInfo);
1534 g.zTop = mprintf("%s%.*s", g.zTop, i, zPathInfo);
1535 }
1536 }
1537 if( szFile<0 && i>0 ){
1538 const char *zMimetype;
1539 assert( fossil_strcmp(&zRepo[j], ".fossil")==0 );
1540 zRepo[j] = 0;
1541
+6
--- src/main.c
+++ src/main.c
@@ -1525,10 +1525,16 @@
15251525
break;
15261526
}
15271527
if( szFile==0 ){
15281528
if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
15291529
szFile = file_size(zRepo);
1530
+ /* this should only be set from the --baseurl option, not CGI */
1531
+ if( g.zBaseURL && g.zBaseURL[0]!=0 && g.zTop && g.zTop[0]!=0 &&
1532
+ file_isdir(g.zRepositoryName)==1 ){
1533
+ g.zBaseURL = mprintf("%s%.*s", g.zBaseURL, i, zPathInfo);
1534
+ g.zTop = mprintf("%s%.*s", g.zTop, i, zPathInfo);
1535
+ }
15301536
}
15311537
if( szFile<0 && i>0 ){
15321538
const char *zMimetype;
15331539
assert( fossil_strcmp(&zRepo[j], ".fossil")==0 );
15341540
zRepo[j] = 0;
15351541
--- src/main.c
+++ src/main.c
@@ -1525,10 +1525,16 @@
1525 break;
1526 }
1527 if( szFile==0 ){
1528 if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
1529 szFile = file_size(zRepo);
 
 
 
 
 
 
1530 }
1531 if( szFile<0 && i>0 ){
1532 const char *zMimetype;
1533 assert( fossil_strcmp(&zRepo[j], ".fossil")==0 );
1534 zRepo[j] = 0;
1535
--- src/main.c
+++ src/main.c
@@ -1525,10 +1525,16 @@
1525 break;
1526 }
1527 if( szFile==0 ){
1528 if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
1529 szFile = file_size(zRepo);
1530 /* this should only be set from the --baseurl option, not CGI */
1531 if( g.zBaseURL && g.zBaseURL[0]!=0 && g.zTop && g.zTop[0]!=0 &&
1532 file_isdir(g.zRepositoryName)==1 ){
1533 g.zBaseURL = mprintf("%s%.*s", g.zBaseURL, i, zPathInfo);
1534 g.zTop = mprintf("%s%.*s", g.zTop, i, zPathInfo);
1535 }
1536 }
1537 if( szFile<0 && i>0 ){
1538 const char *zMimetype;
1539 assert( fossil_strcmp(&zRepo[j], ".fossil")==0 );
1540 zRepo[j] = 0;
1541
+12
--- src/main.mk
+++ src/main.mk
@@ -132,43 +132,55 @@
132132
$(SRCDIR)/xfer.c \
133133
$(SRCDIR)/xfersetup.c \
134134
$(SRCDIR)/zip.c
135135
136136
EXTRA_FILES = \
137
+ $(SRCDIR)/../skins/aht/details.txt \
137138
$(SRCDIR)/../skins/black_and_white/css.txt \
139
+ $(SRCDIR)/../skins/black_and_white/details.txt \
138140
$(SRCDIR)/../skins/black_and_white/footer.txt \
139141
$(SRCDIR)/../skins/black_and_white/header.txt \
140142
$(SRCDIR)/../skins/blitz/css.txt \
143
+ $(SRCDIR)/../skins/blitz/details.txt \
141144
$(SRCDIR)/../skins/blitz/footer.txt \
142145
$(SRCDIR)/../skins/blitz/header.txt \
143146
$(SRCDIR)/../skins/blitz/ticket.txt \
144147
$(SRCDIR)/../skins/blitz_no_logo/css.txt \
148
+ $(SRCDIR)/../skins/blitz_no_logo/details.txt \
145149
$(SRCDIR)/../skins/blitz_no_logo/footer.txt \
146150
$(SRCDIR)/../skins/blitz_no_logo/header.txt \
147151
$(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
148152
$(SRCDIR)/../skins/default/css.txt \
153
+ $(SRCDIR)/../skins/default/details.txt \
149154
$(SRCDIR)/../skins/default/footer.txt \
150155
$(SRCDIR)/../skins/default/header.txt \
151156
$(SRCDIR)/../skins/eagle/css.txt \
157
+ $(SRCDIR)/../skins/eagle/details.txt \
152158
$(SRCDIR)/../skins/eagle/footer.txt \
153159
$(SRCDIR)/../skins/eagle/header.txt \
154160
$(SRCDIR)/../skins/enhanced1/css.txt \
161
+ $(SRCDIR)/../skins/enhanced1/details.txt \
155162
$(SRCDIR)/../skins/enhanced1/footer.txt \
156163
$(SRCDIR)/../skins/enhanced1/header.txt \
157164
$(SRCDIR)/../skins/khaki/css.txt \
165
+ $(SRCDIR)/../skins/khaki/details.txt \
158166
$(SRCDIR)/../skins/khaki/footer.txt \
159167
$(SRCDIR)/../skins/khaki/header.txt \
160168
$(SRCDIR)/../skins/original/css.txt \
169
+ $(SRCDIR)/../skins/original/details.txt \
161170
$(SRCDIR)/../skins/original/footer.txt \
162171
$(SRCDIR)/../skins/original/header.txt \
163172
$(SRCDIR)/../skins/plain_gray/css.txt \
173
+ $(SRCDIR)/../skins/plain_gray/details.txt \
164174
$(SRCDIR)/../skins/plain_gray/footer.txt \
165175
$(SRCDIR)/../skins/plain_gray/header.txt \
166176
$(SRCDIR)/../skins/rounded1/css.txt \
177
+ $(SRCDIR)/../skins/rounded1/details.txt \
167178
$(SRCDIR)/../skins/rounded1/footer.txt \
168179
$(SRCDIR)/../skins/rounded1/header.txt \
169180
$(SRCDIR)/../skins/xekri/css.txt \
181
+ $(SRCDIR)/../skins/xekri/details.txt \
170182
$(SRCDIR)/../skins/xekri/footer.txt \
171183
$(SRCDIR)/../skins/xekri/header.txt \
172184
$(SRCDIR)/diff.tcl \
173185
$(SRCDIR)/markdown.md
174186
175187
--- src/main.mk
+++ src/main.mk
@@ -132,43 +132,55 @@
132 $(SRCDIR)/xfer.c \
133 $(SRCDIR)/xfersetup.c \
134 $(SRCDIR)/zip.c
135
136 EXTRA_FILES = \
 
137 $(SRCDIR)/../skins/black_and_white/css.txt \
 
138 $(SRCDIR)/../skins/black_and_white/footer.txt \
139 $(SRCDIR)/../skins/black_and_white/header.txt \
140 $(SRCDIR)/../skins/blitz/css.txt \
 
141 $(SRCDIR)/../skins/blitz/footer.txt \
142 $(SRCDIR)/../skins/blitz/header.txt \
143 $(SRCDIR)/../skins/blitz/ticket.txt \
144 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
 
145 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
146 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
147 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
148 $(SRCDIR)/../skins/default/css.txt \
 
149 $(SRCDIR)/../skins/default/footer.txt \
150 $(SRCDIR)/../skins/default/header.txt \
151 $(SRCDIR)/../skins/eagle/css.txt \
 
152 $(SRCDIR)/../skins/eagle/footer.txt \
153 $(SRCDIR)/../skins/eagle/header.txt \
154 $(SRCDIR)/../skins/enhanced1/css.txt \
 
155 $(SRCDIR)/../skins/enhanced1/footer.txt \
156 $(SRCDIR)/../skins/enhanced1/header.txt \
157 $(SRCDIR)/../skins/khaki/css.txt \
 
158 $(SRCDIR)/../skins/khaki/footer.txt \
159 $(SRCDIR)/../skins/khaki/header.txt \
160 $(SRCDIR)/../skins/original/css.txt \
 
161 $(SRCDIR)/../skins/original/footer.txt \
162 $(SRCDIR)/../skins/original/header.txt \
163 $(SRCDIR)/../skins/plain_gray/css.txt \
 
164 $(SRCDIR)/../skins/plain_gray/footer.txt \
165 $(SRCDIR)/../skins/plain_gray/header.txt \
166 $(SRCDIR)/../skins/rounded1/css.txt \
 
167 $(SRCDIR)/../skins/rounded1/footer.txt \
168 $(SRCDIR)/../skins/rounded1/header.txt \
169 $(SRCDIR)/../skins/xekri/css.txt \
 
170 $(SRCDIR)/../skins/xekri/footer.txt \
171 $(SRCDIR)/../skins/xekri/header.txt \
172 $(SRCDIR)/diff.tcl \
173 $(SRCDIR)/markdown.md
174
175
--- src/main.mk
+++ src/main.mk
@@ -132,43 +132,55 @@
132 $(SRCDIR)/xfer.c \
133 $(SRCDIR)/xfersetup.c \
134 $(SRCDIR)/zip.c
135
136 EXTRA_FILES = \
137 $(SRCDIR)/../skins/aht/details.txt \
138 $(SRCDIR)/../skins/black_and_white/css.txt \
139 $(SRCDIR)/../skins/black_and_white/details.txt \
140 $(SRCDIR)/../skins/black_and_white/footer.txt \
141 $(SRCDIR)/../skins/black_and_white/header.txt \
142 $(SRCDIR)/../skins/blitz/css.txt \
143 $(SRCDIR)/../skins/blitz/details.txt \
144 $(SRCDIR)/../skins/blitz/footer.txt \
145 $(SRCDIR)/../skins/blitz/header.txt \
146 $(SRCDIR)/../skins/blitz/ticket.txt \
147 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
148 $(SRCDIR)/../skins/blitz_no_logo/details.txt \
149 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
150 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
151 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
152 $(SRCDIR)/../skins/default/css.txt \
153 $(SRCDIR)/../skins/default/details.txt \
154 $(SRCDIR)/../skins/default/footer.txt \
155 $(SRCDIR)/../skins/default/header.txt \
156 $(SRCDIR)/../skins/eagle/css.txt \
157 $(SRCDIR)/../skins/eagle/details.txt \
158 $(SRCDIR)/../skins/eagle/footer.txt \
159 $(SRCDIR)/../skins/eagle/header.txt \
160 $(SRCDIR)/../skins/enhanced1/css.txt \
161 $(SRCDIR)/../skins/enhanced1/details.txt \
162 $(SRCDIR)/../skins/enhanced1/footer.txt \
163 $(SRCDIR)/../skins/enhanced1/header.txt \
164 $(SRCDIR)/../skins/khaki/css.txt \
165 $(SRCDIR)/../skins/khaki/details.txt \
166 $(SRCDIR)/../skins/khaki/footer.txt \
167 $(SRCDIR)/../skins/khaki/header.txt \
168 $(SRCDIR)/../skins/original/css.txt \
169 $(SRCDIR)/../skins/original/details.txt \
170 $(SRCDIR)/../skins/original/footer.txt \
171 $(SRCDIR)/../skins/original/header.txt \
172 $(SRCDIR)/../skins/plain_gray/css.txt \
173 $(SRCDIR)/../skins/plain_gray/details.txt \
174 $(SRCDIR)/../skins/plain_gray/footer.txt \
175 $(SRCDIR)/../skins/plain_gray/header.txt \
176 $(SRCDIR)/../skins/rounded1/css.txt \
177 $(SRCDIR)/../skins/rounded1/details.txt \
178 $(SRCDIR)/../skins/rounded1/footer.txt \
179 $(SRCDIR)/../skins/rounded1/header.txt \
180 $(SRCDIR)/../skins/xekri/css.txt \
181 $(SRCDIR)/../skins/xekri/details.txt \
182 $(SRCDIR)/../skins/xekri/footer.txt \
183 $(SRCDIR)/../skins/xekri/header.txt \
184 $(SRCDIR)/diff.tcl \
185 $(SRCDIR)/markdown.md
186
187
--- src/search.c
+++ src/search.c
@@ -1103,10 +1103,11 @@
11031103
if( doc_is_embedded_html(pIn, &title) ){
11041104
blob_appendf(pOut, "%s\n", blob_str(&title));
11051105
}
11061106
html_to_plaintext(blob_str(pIn), pOut);
11071107
}else{
1108
+ blob_append(pOut, "\n", 1);
11081109
blob_append(pOut, blob_buffer(pIn), blob_size(pIn));
11091110
}
11101111
blob_reset(&html);
11111112
blob_reset(&title);
11121113
}
11131114
--- src/search.c
+++ src/search.c
@@ -1103,10 +1103,11 @@
1103 if( doc_is_embedded_html(pIn, &title) ){
1104 blob_appendf(pOut, "%s\n", blob_str(&title));
1105 }
1106 html_to_plaintext(blob_str(pIn), pOut);
1107 }else{
 
1108 blob_append(pOut, blob_buffer(pIn), blob_size(pIn));
1109 }
1110 blob_reset(&html);
1111 blob_reset(&title);
1112 }
1113
--- src/search.c
+++ src/search.c
@@ -1103,10 +1103,11 @@
1103 if( doc_is_embedded_html(pIn, &title) ){
1104 blob_appendf(pOut, "%s\n", blob_str(&title));
1105 }
1106 html_to_plaintext(blob_str(pIn), pOut);
1107 }else{
1108 blob_append(pOut, "\n", 1);
1109 blob_append(pOut, blob_buffer(pIn), blob_size(pIn));
1110 }
1111 blob_reset(&html);
1112 blob_reset(&title);
1113 }
1114
+9 -163
--- src/setup.c
+++ src/setup.c
@@ -69,11 +69,11 @@
6969
/* Make sure the header contains <base href="...">. Issue a warning
7070
** if it does not. */
7171
if( !cgi_header_contains("<base href=") ){
7272
@ <p class="generalError"><b>Configuration Error:</b> Please add
7373
@ <tt>&lt;base href="$secureurl/$current_page"&gt;</tt> after
74
- @ <tt>&lt;head&gt;</tt> in the <a href="setup_header">HTML header</a>!</p>
74
+ @ <tt>&lt;head&gt;</tt> in the <a href="setup_skinedit?w=2">HTML header</a>!</p>
7575
}
7676
7777
#if !defined(_WIN32)
7878
/* Check for /dev/null and /dev/urandom. We want both devices to be present,
7979
** but they are sometimes omitted (by mistake) from chroot jails. */
@@ -107,17 +107,11 @@
107107
setup_menu_entry("Search","srchsetup",
108108
"Configure the built-in search engine");
109109
setup_menu_entry("Transfers", "xfersetup",
110110
"Configure the transfer system for this repository");
111111
setup_menu_entry("Skins", "setup_skin",
112
- "Select from a menu of prepackaged \"skins\" for the web interface");
113
- setup_menu_entry("CSS", "setup_editcss",
114
- "Edit the Cascading Style Sheet used by all pages of this repository");
115
- setup_menu_entry("Header", "setup_header",
116
- "Edit HTML text inserted at the top of every page");
117
- setup_menu_entry("Footer", "setup_footer",
118
- "Edit HTML text inserted at the bottom of every page");
112
+ "Select and/or modify the web interface \"skins\"");
119113
setup_menu_entry("Moderation", "setup_modreq",
120114
"Enable/Disable requiring moderator approval of Wiki and/or Ticket"
121115
" changes and attachments.");
122116
setup_menu_entry("Ad-Unit", "setup_adunit",
123117
"Edit HTML text for an ad unit inserted after the menu bar");
@@ -930,11 +924,11 @@
930924
}
931925
932926
/*
933927
** Generate a text box for an attribute.
934928
*/
935
-static void textarea_attribute(
929
+const char *textarea_attribute(
936930
const char *zLabel, /* The text label on the textarea */
937931
int rows, /* Rows in the textarea */
938932
int cols, /* Columns in the textarea */
939933
const char *zVar, /* The corresponding row in the VAR table */
940934
const char *zQP, /* The query parameter */
@@ -959,10 +953,11 @@
959953
@ cols="%d(cols)">%h(z)</textarea>
960954
if( zLabel && *zLabel ){
961955
@ <span class="textareaLabel">%s(zLabel)</span>
962956
}
963957
}
958
+ return z;
964959
}
965960
966961
/*
967962
** Generate a text box for an attribute.
968963
*/
@@ -1550,159 +1545,10 @@
15501545
@ </div></form>
15511546
db_end_transaction(0);
15521547
style_footer();
15531548
}
15541549
1555
-/*
1556
-** WEBPAGE: setup_editcss
1557
-*/
1558
-void setup_editcss(void){
1559
- login_check_credentials();
1560
- if( !g.perm.Setup ){
1561
- login_needed(0);
1562
- return;
1563
- }
1564
- db_begin_transaction();
1565
- if( P("clear")!=0 ){
1566
- db_multi_exec("DELETE FROM config WHERE name='css'");
1567
- cgi_replace_parameter("css", builtin_text("skins/default/css.txt"));
1568
- db_end_transaction(0);
1569
- cgi_redirect("setup_editcss");
1570
- }
1571
- if( P("submit")!=0 ){
1572
- textarea_attribute(0, 0, 0, "css", "css",
1573
- builtin_text("skins/default/css.txt"), 0);
1574
- db_end_transaction(0);
1575
- cgi_redirect("setup_editcss");
1576
- }
1577
- style_header("Edit CSS");
1578
- @ <form action="%s(g.zTop)/setup_editcss" method="post"><div>
1579
- login_insert_csrf_secret();
1580
- @ Edit the CSS below:<br />
1581
- textarea_attribute("", 35, 80, "css", "css",
1582
- builtin_text("skins/default/css.txt"), 0);
1583
- @ <br />
1584
- @ <input type="submit" name="submit" value="Apply Changes" />
1585
- @ <input type="submit" name="clear" value="Revert To Default" />
1586
- @ </div></form>
1587
- @ <p><span class="note">Note:</span> Press your browser Reload button after
1588
- @ modifying the CSS in order to pull in the modified CSS file.</p>
1589
- @ <hr />
1590
- @ The default CSS is shown below for reference. Other examples
1591
- @ of CSS files can be seen on the <a href="setup_skin">skins page</a>.
1592
- @ See also the <a href="setup_header">header</a> and
1593
- @ <a href="setup_footer">footer</a> editing screens.
1594
- @ <blockquote><pre>
1595
- cgi_append_default_css();
1596
- @ </pre></blockquote>
1597
- style_footer();
1598
- db_end_transaction(0);
1599
-}
1600
-
1601
-/*
1602
-** WEBPAGE: setup_header
1603
-*/
1604
-void setup_header(void){
1605
- login_check_credentials();
1606
- if( !g.perm.Setup ){
1607
- login_needed(0);
1608
- return;
1609
- }
1610
- db_begin_transaction();
1611
- if( P("clear")!=0 ){
1612
- db_multi_exec("DELETE FROM config WHERE name='header'");
1613
- cgi_replace_parameter("header", builtin_text("skins/default/header.txt"));
1614
- }else if( P("submit")!=0 ){
1615
- textarea_attribute(0, 0, 0, "header", "header",
1616
- builtin_text("skins/default/header.txt"), 0);
1617
- }else if( P("fixbase")!=0 ){
1618
- const char *z = db_get("header",
1619
- (char*)builtin_text("skins/default/header.txt"));
1620
- char *zHead = strstr(z, "<head>");
1621
- if( strstr(z, "<base href=")==0 && zHead!=0 ){
1622
- char *zNew;
1623
- char *zTail = &zHead[6];
1624
- while( fossil_isspace(zTail[0]) ) zTail++;
1625
- zNew = mprintf("%.*s\n<base href=\"$secureurl/$current_page\" />\n%s",
1626
- zHead+6-z, z, zTail);
1627
- cgi_replace_parameter("header", zNew);
1628
- db_set("header", zNew, 0);
1629
- }
1630
- }
1631
-
1632
- style_header("Edit Page Header");
1633
- @ <form action="%R/setup_header" method="post"><div>
1634
-
1635
- /* Make sure the header contains <base href="...">. Issue a warning
1636
- ** if it does not. */
1637
- if( !cgi_header_contains("<base href=") ){
1638
- @ <p class="generalError">Please add
1639
- @ <tt>&lt;base href="$secureurl/$current_page"&gt;</tt> after
1640
- @ <tt>&lt;head&gt;</tt> in the header!
1641
- @ <input type="submit" name="fixbase" value="Add &lt;base&gt; Now"></p>
1642
- }
1643
-
1644
- login_insert_csrf_secret();
1645
- @ <p>Edit HTML text with embedded TH1 (a Tcl dialect) that will be used to
1646
- @ generate the beginning of every page through start of the main
1647
- @ menu.</p>
1648
- textarea_attribute("", 35, 80, "header", "header",
1649
- builtin_text("skins/default/header.txt"), 0);
1650
- @ <br />
1651
- @ <input type="submit" name="submit" value="Apply Changes" />
1652
- @ <input type="submit" name="clear" value="Revert To Default" />
1653
- @ </div></form>
1654
- @ <hr />
1655
- @ The default header is shown below for reference. Other examples
1656
- @ of headers can be seen on the <a href="setup_skin">skins page</a>.
1657
- @ See also the <a href="setup_editcss">CSS</a> and
1658
- @ <a href="setup_footer">footer</a> editing screens.
1659
- @ <blockquote><pre>
1660
- @ %h(builtin_text("skins/default/header.txt"))
1661
- @ </pre></blockquote>
1662
- style_footer();
1663
- db_end_transaction(0);
1664
-}
1665
-
1666
-/*
1667
-** WEBPAGE: setup_footer
1668
-*/
1669
-void setup_footer(void){
1670
- login_check_credentials();
1671
- if( !g.perm.Setup ){
1672
- login_needed(0);
1673
- return;
1674
- }
1675
- db_begin_transaction();
1676
- if( P("clear")!=0 ){
1677
- db_multi_exec("DELETE FROM config WHERE name='footer'");
1678
- cgi_replace_parameter("footer", builtin_text("skins/default/footer.txt"));
1679
- }
1680
-
1681
- style_header("Edit Page Footer");
1682
- @ <form action="%s(g.zTop)/setup_footer" method="post"><div>
1683
- login_insert_csrf_secret();
1684
- @ <p>Edit HTML text with embedded TH1 (a Tcl dialect) that will be used to
1685
- @ generate the end of every page.</p>
1686
- textarea_attribute("", 20, 80, "footer", "footer",
1687
- builtin_text("skins/default/footer.txt"), 0);
1688
- @ <br />
1689
- @ <input type="submit" name="submit" value="Apply Changes" />
1690
- @ <input type="submit" name="clear" value="Revert To Default" />
1691
- @ </div></form>
1692
- @ <hr />
1693
- @ The default footer is shown below for reference. Other examples
1694
- @ of footers can be seen on the <a href="setup_skin">skins page</a>.
1695
- @ See also the <a href="setup_editcss">CSS</a> and
1696
- @ <a href="setup_header">header</a> editing screens.
1697
- @ <blockquote><pre>
1698
- @ %h(builtin_text("skins/default/footer.txt"))
1699
- @ </pre></blockquote>
1700
- style_footer();
1701
- db_end_transaction(0);
1702
-}
1703
-
17041550
/*
17051551
** WEBPAGE: setup_modreq
17061552
*/
17071553
void setup_modreq(void){
17081554
login_check_credentials();
@@ -1783,11 +1629,11 @@
17831629
@ <b>Ad-Unit Notes:</b><ul>
17841630
@ <li>Leave both Ad-Units blank to disable all advertising.
17851631
@ <li>The "Banner Ad-Unit" is used for wide pages.
17861632
@ <li>The "Right-Column Ad-Unit" is used on pages with tall, narrow content.
17871633
@ <li>If the "Right-Column Ad-Unit" is blank, the "Banner Ad-Unit" is used on all pages.
1788
- @ <li>Suggested <a href="setup_editcss">CSS</a> changes:
1634
+ @ <li>Suggested <a href="setup_skinedit?w=0">CSS</a> changes:
17891635
@ <blockquote><pre>
17901636
@ div.adunit_banner {
17911637
@ margin: auto;
17921638
@ width: 100%;
17931639
@ }
@@ -1897,12 +1743,12 @@
18971743
@ <form action="%s(g.zTop)/setup_logo" method="post"
18981744
@ enctype="multipart/form-data"><div>
18991745
@ <p>The logo is accessible to all users at this URL:
19001746
@ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
19011747
@ The logo may or may not appear on each
1902
- @ page depending on the <a href="setup_editcss">CSS</a> and
1903
- @ <a href="setup_header">header setup</a>.
1748
+ @ page depending on the <a href="setup_skinedit?w=0">CSS</a> and
1749
+ @ <a href="setup_skinedit?w=2">header setup</a>.
19041750
@ To change the logo image, use the following form:</p>
19051751
login_insert_csrf_secret();
19061752
@ Logo Image file:
19071753
@ <input type="file" name="logoim" size="60" accept="image/*" />
19081754
@ <p align="center">
@@ -1919,12 +1765,12 @@
19191765
@ <form action="%s(g.zTop)/setup_logo" method="post"
19201766
@ enctype="multipart/form-data"><div>
19211767
@ <p>The background image is accessible to all users at this URL:
19221768
@ <a href="%s(g.zBaseURL)/background">%s(g.zBaseURL)/background</a>.
19231769
@ The background image may or may not appear on each
1924
- @ page depending on the <a href="setup_editcss">CSS</a> and
1925
- @ <a href="setup_header">header setup</a>.
1770
+ @ page depending on the <a href="setup_skinedit?w=0">CSS</a> and
1771
+ @ <a href="setup_skinedit?w=2">header setup</a>.
19261772
@ To change the background image, use the following form:</p>
19271773
login_insert_csrf_secret();
19281774
@ Background image file:
19291775
@ <input type="file" name="bgim" size="60" accept="image/*" />
19301776
@ <p align="center">
19311777
--- src/setup.c
+++ src/setup.c
@@ -69,11 +69,11 @@
69 /* Make sure the header contains <base href="...">. Issue a warning
70 ** if it does not. */
71 if( !cgi_header_contains("<base href=") ){
72 @ <p class="generalError"><b>Configuration Error:</b> Please add
73 @ <tt>&lt;base href="$secureurl/$current_page"&gt;</tt> after
74 @ <tt>&lt;head&gt;</tt> in the <a href="setup_header">HTML header</a>!</p>
75 }
76
77 #if !defined(_WIN32)
78 /* Check for /dev/null and /dev/urandom. We want both devices to be present,
79 ** but they are sometimes omitted (by mistake) from chroot jails. */
@@ -107,17 +107,11 @@
107 setup_menu_entry("Search","srchsetup",
108 "Configure the built-in search engine");
109 setup_menu_entry("Transfers", "xfersetup",
110 "Configure the transfer system for this repository");
111 setup_menu_entry("Skins", "setup_skin",
112 "Select from a menu of prepackaged \"skins\" for the web interface");
113 setup_menu_entry("CSS", "setup_editcss",
114 "Edit the Cascading Style Sheet used by all pages of this repository");
115 setup_menu_entry("Header", "setup_header",
116 "Edit HTML text inserted at the top of every page");
117 setup_menu_entry("Footer", "setup_footer",
118 "Edit HTML text inserted at the bottom of every page");
119 setup_menu_entry("Moderation", "setup_modreq",
120 "Enable/Disable requiring moderator approval of Wiki and/or Ticket"
121 " changes and attachments.");
122 setup_menu_entry("Ad-Unit", "setup_adunit",
123 "Edit HTML text for an ad unit inserted after the menu bar");
@@ -930,11 +924,11 @@
930 }
931
932 /*
933 ** Generate a text box for an attribute.
934 */
935 static void textarea_attribute(
936 const char *zLabel, /* The text label on the textarea */
937 int rows, /* Rows in the textarea */
938 int cols, /* Columns in the textarea */
939 const char *zVar, /* The corresponding row in the VAR table */
940 const char *zQP, /* The query parameter */
@@ -959,10 +953,11 @@
959 @ cols="%d(cols)">%h(z)</textarea>
960 if( zLabel && *zLabel ){
961 @ <span class="textareaLabel">%s(zLabel)</span>
962 }
963 }
 
964 }
965
966 /*
967 ** Generate a text box for an attribute.
968 */
@@ -1550,159 +1545,10 @@
1550 @ </div></form>
1551 db_end_transaction(0);
1552 style_footer();
1553 }
1554
1555 /*
1556 ** WEBPAGE: setup_editcss
1557 */
1558 void setup_editcss(void){
1559 login_check_credentials();
1560 if( !g.perm.Setup ){
1561 login_needed(0);
1562 return;
1563 }
1564 db_begin_transaction();
1565 if( P("clear")!=0 ){
1566 db_multi_exec("DELETE FROM config WHERE name='css'");
1567 cgi_replace_parameter("css", builtin_text("skins/default/css.txt"));
1568 db_end_transaction(0);
1569 cgi_redirect("setup_editcss");
1570 }
1571 if( P("submit")!=0 ){
1572 textarea_attribute(0, 0, 0, "css", "css",
1573 builtin_text("skins/default/css.txt"), 0);
1574 db_end_transaction(0);
1575 cgi_redirect("setup_editcss");
1576 }
1577 style_header("Edit CSS");
1578 @ <form action="%s(g.zTop)/setup_editcss" method="post"><div>
1579 login_insert_csrf_secret();
1580 @ Edit the CSS below:<br />
1581 textarea_attribute("", 35, 80, "css", "css",
1582 builtin_text("skins/default/css.txt"), 0);
1583 @ <br />
1584 @ <input type="submit" name="submit" value="Apply Changes" />
1585 @ <input type="submit" name="clear" value="Revert To Default" />
1586 @ </div></form>
1587 @ <p><span class="note">Note:</span> Press your browser Reload button after
1588 @ modifying the CSS in order to pull in the modified CSS file.</p>
1589 @ <hr />
1590 @ The default CSS is shown below for reference. Other examples
1591 @ of CSS files can be seen on the <a href="setup_skin">skins page</a>.
1592 @ See also the <a href="setup_header">header</a> and
1593 @ <a href="setup_footer">footer</a> editing screens.
1594 @ <blockquote><pre>
1595 cgi_append_default_css();
1596 @ </pre></blockquote>
1597 style_footer();
1598 db_end_transaction(0);
1599 }
1600
1601 /*
1602 ** WEBPAGE: setup_header
1603 */
1604 void setup_header(void){
1605 login_check_credentials();
1606 if( !g.perm.Setup ){
1607 login_needed(0);
1608 return;
1609 }
1610 db_begin_transaction();
1611 if( P("clear")!=0 ){
1612 db_multi_exec("DELETE FROM config WHERE name='header'");
1613 cgi_replace_parameter("header", builtin_text("skins/default/header.txt"));
1614 }else if( P("submit")!=0 ){
1615 textarea_attribute(0, 0, 0, "header", "header",
1616 builtin_text("skins/default/header.txt"), 0);
1617 }else if( P("fixbase")!=0 ){
1618 const char *z = db_get("header",
1619 (char*)builtin_text("skins/default/header.txt"));
1620 char *zHead = strstr(z, "<head>");
1621 if( strstr(z, "<base href=")==0 && zHead!=0 ){
1622 char *zNew;
1623 char *zTail = &zHead[6];
1624 while( fossil_isspace(zTail[0]) ) zTail++;
1625 zNew = mprintf("%.*s\n<base href=\"$secureurl/$current_page\" />\n%s",
1626 zHead+6-z, z, zTail);
1627 cgi_replace_parameter("header", zNew);
1628 db_set("header", zNew, 0);
1629 }
1630 }
1631
1632 style_header("Edit Page Header");
1633 @ <form action="%R/setup_header" method="post"><div>
1634
1635 /* Make sure the header contains <base href="...">. Issue a warning
1636 ** if it does not. */
1637 if( !cgi_header_contains("<base href=") ){
1638 @ <p class="generalError">Please add
1639 @ <tt>&lt;base href="$secureurl/$current_page"&gt;</tt> after
1640 @ <tt>&lt;head&gt;</tt> in the header!
1641 @ <input type="submit" name="fixbase" value="Add &lt;base&gt; Now"></p>
1642 }
1643
1644 login_insert_csrf_secret();
1645 @ <p>Edit HTML text with embedded TH1 (a Tcl dialect) that will be used to
1646 @ generate the beginning of every page through start of the main
1647 @ menu.</p>
1648 textarea_attribute("", 35, 80, "header", "header",
1649 builtin_text("skins/default/header.txt"), 0);
1650 @ <br />
1651 @ <input type="submit" name="submit" value="Apply Changes" />
1652 @ <input type="submit" name="clear" value="Revert To Default" />
1653 @ </div></form>
1654 @ <hr />
1655 @ The default header is shown below for reference. Other examples
1656 @ of headers can be seen on the <a href="setup_skin">skins page</a>.
1657 @ See also the <a href="setup_editcss">CSS</a> and
1658 @ <a href="setup_footer">footer</a> editing screens.
1659 @ <blockquote><pre>
1660 @ %h(builtin_text("skins/default/header.txt"))
1661 @ </pre></blockquote>
1662 style_footer();
1663 db_end_transaction(0);
1664 }
1665
1666 /*
1667 ** WEBPAGE: setup_footer
1668 */
1669 void setup_footer(void){
1670 login_check_credentials();
1671 if( !g.perm.Setup ){
1672 login_needed(0);
1673 return;
1674 }
1675 db_begin_transaction();
1676 if( P("clear")!=0 ){
1677 db_multi_exec("DELETE FROM config WHERE name='footer'");
1678 cgi_replace_parameter("footer", builtin_text("skins/default/footer.txt"));
1679 }
1680
1681 style_header("Edit Page Footer");
1682 @ <form action="%s(g.zTop)/setup_footer" method="post"><div>
1683 login_insert_csrf_secret();
1684 @ <p>Edit HTML text with embedded TH1 (a Tcl dialect) that will be used to
1685 @ generate the end of every page.</p>
1686 textarea_attribute("", 20, 80, "footer", "footer",
1687 builtin_text("skins/default/footer.txt"), 0);
1688 @ <br />
1689 @ <input type="submit" name="submit" value="Apply Changes" />
1690 @ <input type="submit" name="clear" value="Revert To Default" />
1691 @ </div></form>
1692 @ <hr />
1693 @ The default footer is shown below for reference. Other examples
1694 @ of footers can be seen on the <a href="setup_skin">skins page</a>.
1695 @ See also the <a href="setup_editcss">CSS</a> and
1696 @ <a href="setup_header">header</a> editing screens.
1697 @ <blockquote><pre>
1698 @ %h(builtin_text("skins/default/footer.txt"))
1699 @ </pre></blockquote>
1700 style_footer();
1701 db_end_transaction(0);
1702 }
1703
1704 /*
1705 ** WEBPAGE: setup_modreq
1706 */
1707 void setup_modreq(void){
1708 login_check_credentials();
@@ -1783,11 +1629,11 @@
1783 @ <b>Ad-Unit Notes:</b><ul>
1784 @ <li>Leave both Ad-Units blank to disable all advertising.
1785 @ <li>The "Banner Ad-Unit" is used for wide pages.
1786 @ <li>The "Right-Column Ad-Unit" is used on pages with tall, narrow content.
1787 @ <li>If the "Right-Column Ad-Unit" is blank, the "Banner Ad-Unit" is used on all pages.
1788 @ <li>Suggested <a href="setup_editcss">CSS</a> changes:
1789 @ <blockquote><pre>
1790 @ div.adunit_banner {
1791 @ margin: auto;
1792 @ width: 100%;
1793 @ }
@@ -1897,12 +1743,12 @@
1897 @ <form action="%s(g.zTop)/setup_logo" method="post"
1898 @ enctype="multipart/form-data"><div>
1899 @ <p>The logo is accessible to all users at this URL:
1900 @ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
1901 @ The logo may or may not appear on each
1902 @ page depending on the <a href="setup_editcss">CSS</a> and
1903 @ <a href="setup_header">header setup</a>.
1904 @ To change the logo image, use the following form:</p>
1905 login_insert_csrf_secret();
1906 @ Logo Image file:
1907 @ <input type="file" name="logoim" size="60" accept="image/*" />
1908 @ <p align="center">
@@ -1919,12 +1765,12 @@
1919 @ <form action="%s(g.zTop)/setup_logo" method="post"
1920 @ enctype="multipart/form-data"><div>
1921 @ <p>The background image is accessible to all users at this URL:
1922 @ <a href="%s(g.zBaseURL)/background">%s(g.zBaseURL)/background</a>.
1923 @ The background image may or may not appear on each
1924 @ page depending on the <a href="setup_editcss">CSS</a> and
1925 @ <a href="setup_header">header setup</a>.
1926 @ To change the background image, use the following form:</p>
1927 login_insert_csrf_secret();
1928 @ Background image file:
1929 @ <input type="file" name="bgim" size="60" accept="image/*" />
1930 @ <p align="center">
1931
--- src/setup.c
+++ src/setup.c
@@ -69,11 +69,11 @@
69 /* Make sure the header contains <base href="...">. Issue a warning
70 ** if it does not. */
71 if( !cgi_header_contains("<base href=") ){
72 @ <p class="generalError"><b>Configuration Error:</b> Please add
73 @ <tt>&lt;base href="$secureurl/$current_page"&gt;</tt> after
74 @ <tt>&lt;head&gt;</tt> in the <a href="setup_skinedit?w=2">HTML header</a>!</p>
75 }
76
77 #if !defined(_WIN32)
78 /* Check for /dev/null and /dev/urandom. We want both devices to be present,
79 ** but they are sometimes omitted (by mistake) from chroot jails. */
@@ -107,17 +107,11 @@
107 setup_menu_entry("Search","srchsetup",
108 "Configure the built-in search engine");
109 setup_menu_entry("Transfers", "xfersetup",
110 "Configure the transfer system for this repository");
111 setup_menu_entry("Skins", "setup_skin",
112 "Select and/or modify the web interface \"skins\"");
 
 
 
 
 
 
113 setup_menu_entry("Moderation", "setup_modreq",
114 "Enable/Disable requiring moderator approval of Wiki and/or Ticket"
115 " changes and attachments.");
116 setup_menu_entry("Ad-Unit", "setup_adunit",
117 "Edit HTML text for an ad unit inserted after the menu bar");
@@ -930,11 +924,11 @@
924 }
925
926 /*
927 ** Generate a text box for an attribute.
928 */
929 const char *textarea_attribute(
930 const char *zLabel, /* The text label on the textarea */
931 int rows, /* Rows in the textarea */
932 int cols, /* Columns in the textarea */
933 const char *zVar, /* The corresponding row in the VAR table */
934 const char *zQP, /* The query parameter */
@@ -959,10 +953,11 @@
953 @ cols="%d(cols)">%h(z)</textarea>
954 if( zLabel && *zLabel ){
955 @ <span class="textareaLabel">%s(zLabel)</span>
956 }
957 }
958 return z;
959 }
960
961 /*
962 ** Generate a text box for an attribute.
963 */
@@ -1550,159 +1545,10 @@
1545 @ </div></form>
1546 db_end_transaction(0);
1547 style_footer();
1548 }
1549
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1550 /*
1551 ** WEBPAGE: setup_modreq
1552 */
1553 void setup_modreq(void){
1554 login_check_credentials();
@@ -1783,11 +1629,11 @@
1629 @ <b>Ad-Unit Notes:</b><ul>
1630 @ <li>Leave both Ad-Units blank to disable all advertising.
1631 @ <li>The "Banner Ad-Unit" is used for wide pages.
1632 @ <li>The "Right-Column Ad-Unit" is used on pages with tall, narrow content.
1633 @ <li>If the "Right-Column Ad-Unit" is blank, the "Banner Ad-Unit" is used on all pages.
1634 @ <li>Suggested <a href="setup_skinedit?w=0">CSS</a> changes:
1635 @ <blockquote><pre>
1636 @ div.adunit_banner {
1637 @ margin: auto;
1638 @ width: 100%;
1639 @ }
@@ -1897,12 +1743,12 @@
1743 @ <form action="%s(g.zTop)/setup_logo" method="post"
1744 @ enctype="multipart/form-data"><div>
1745 @ <p>The logo is accessible to all users at this URL:
1746 @ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
1747 @ The logo may or may not appear on each
1748 @ page depending on the <a href="setup_skinedit?w=0">CSS</a> and
1749 @ <a href="setup_skinedit?w=2">header setup</a>.
1750 @ To change the logo image, use the following form:</p>
1751 login_insert_csrf_secret();
1752 @ Logo Image file:
1753 @ <input type="file" name="logoim" size="60" accept="image/*" />
1754 @ <p align="center">
@@ -1919,12 +1765,12 @@
1765 @ <form action="%s(g.zTop)/setup_logo" method="post"
1766 @ enctype="multipart/form-data"><div>
1767 @ <p>The background image is accessible to all users at this URL:
1768 @ <a href="%s(g.zBaseURL)/background">%s(g.zBaseURL)/background</a>.
1769 @ The background image may or may not appear on each
1770 @ page depending on the <a href="setup_skinedit?w=0">CSS</a> and
1771 @ <a href="setup_skinedit?w=2">header setup</a>.
1772 @ To change the background image, use the following form:</p>
1773 login_insert_csrf_secret();
1774 @ Background image file:
1775 @ <input type="file" name="bgim" size="60" accept="image/*" />
1776 @ <p align="center">
1777
+12 -12
--- src/shell.c
+++ src/shell.c
@@ -25,11 +25,11 @@
2525
#endif
2626
2727
/*
2828
** No support for loadable extensions in VxWorks.
2929
*/
30
-#if defined(_WRS_KERNEL) && !SQLITE_OMIT_LOAD_EXTENSION
30
+#if (defined(__RTP__) || defined(_WRS_KERNEL)) && !SQLITE_OMIT_LOAD_EXTENSION
3131
# define SQLITE_OMIT_LOAD_EXTENSION 1
3232
#endif
3333
3434
/*
3535
** Enable large-file support for fopen() and friends on unix.
@@ -368,11 +368,11 @@
368368
** format string and subsequent arguments are values to be substituted
369369
** in place of % fields. The result of formatting this string
370370
** is written to iotrace.
371371
*/
372372
#ifdef SQLITE_ENABLE_IOTRACE
373
-static void iotracePrintf(const char *zFormat, ...){
373
+static void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){
374374
va_list ap;
375375
char *z;
376376
if( iotrace==0 ) return;
377377
va_start(ap, zFormat);
378378
z = sqlite3_vmprintf(zFormat, ap);
@@ -2141,11 +2141,11 @@
21412141
** + Keep track of the line number in p->nLine.
21422142
** + Store the character that terminates the field in p->cTerm. Store
21432143
** EOF on end-of-file.
21442144
** + Report syntax errors on stderr
21452145
*/
2146
-static char *csv_read_one_field(ImportCtx *p){
2146
+static char *SQLITE_CDECL csv_read_one_field(ImportCtx *p){
21472147
int c;
21482148
int cSep = p->cColSep;
21492149
int rSep = p->cRowSep;
21502150
p->n = 0;
21512151
c = fgetc(p->in);
@@ -2215,11 +2215,11 @@
22152215
** + Keep track of the row number in p->nLine.
22162216
** + Store the character that terminates the field in p->cTerm. Store
22172217
** EOF on end-of-file.
22182218
** + Report syntax errors on stderr
22192219
*/
2220
-static char *ascii_read_one_field(ImportCtx *p){
2220
+static char *SQLITE_CDECL ascii_read_one_field(ImportCtx *p){
22212221
int c;
22222222
int cSep = p->cColSep;
22232223
int rSep = p->cRowSep;
22242224
p->n = 0;
22252225
c = fgetc(p->in);
@@ -2909,12 +2909,12 @@
29092909
int i, j; /* Loop counters */
29102910
int needCommit; /* True to COMMIT or ROLLBACK at end */
29112911
int nSep; /* Number of bytes in p->colSeparator[] */
29122912
char *zSql; /* An SQL statement */
29132913
ImportCtx sCtx; /* Reader context */
2914
- char *(*xRead)(ImportCtx*); /* Procedure to read one value */
2915
- int (*xCloser)(FILE*); /* Procedure to close th3 connection */
2914
+ char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
2915
+ int (SQLITE_CDECL *xCloser)(FILE*); /* Func to close file */
29162916
29172917
if( nArg!=3 ){
29182918
fprintf(stderr, "Usage: .import FILE TABLE\n");
29192919
goto meta_command_exit;
29202920
}
@@ -2953,11 +2953,11 @@
29532953
}
29542954
sCtx.zFile = zFile;
29552955
sCtx.nLine = 1;
29562956
if( sCtx.zFile[0]=='|' ){
29572957
#ifdef SQLITE_OMIT_POPEN
2958
- fprintf(stderr, "Error: pipes are not supporte in this OS\n");
2958
+ fprintf(stderr, "Error: pipes are not supported in this OS\n");
29592959
return 1;
29602960
#else
29612961
sCtx.in = popen(sCtx.zFile+1, "r");
29622962
sCtx.zFile = "<pipe>";
29632963
xCloser = pclose;
@@ -3142,11 +3142,11 @@
31423142
}
31433143
}else
31443144
31453145
#ifdef SQLITE_ENABLE_IOTRACE
31463146
if( c=='i' && strncmp(azArg[0], "iotrace", n)==0 ){
3147
- extern void (*sqlite3IoTrace)(const char*, ...);
3147
+ SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...);
31483148
if( iotrace && iotrace!=stdout ) fclose(iotrace);
31493149
iotrace = 0;
31503150
if( nArg<2 ){
31513151
sqlite3IoTrace = 0;
31523152
}else if( strcmp(azArg[1], "-")==0 ){
@@ -3801,13 +3801,13 @@
38013801
if( nArg==5 ){
38023802
rc = sqlite3_test_control(testctrl, p->db,
38033803
azArg[2],
38043804
integerValue(azArg[3]),
38053805
integerValue(azArg[4]));
3806
+ fprintf(p->out, "%d (0x%08x)\n", rc, rc);
38063807
}else{
3807
- fprintf(stderr,"Usage: .testctrl initmode dbName onoff tnum\n");
3808
- rc = 1;
3808
+ fprintf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n");
38093809
}
38103810
break;
38113811
38123812
case SQLITE_TESTCTRL_BITVEC_TEST:
38133813
case SQLITE_TESTCTRL_FAULT_INSTALL:
@@ -3839,16 +3839,16 @@
38393839
}
38403840
}else
38413841
38423842
if( c=='t' && strncmp(azArg[0], "trace", n)==0 ){
38433843
open_db(p, 0);
3844
- output_file_close(p->traceOut);
38453844
if( nArg!=2 ){
38463845
fprintf(stderr, "Usage: .trace FILE|off\n");
38473846
rc = 1;
38483847
goto meta_command_exit;
38493848
}
3849
+ output_file_close(p->traceOut);
38503850
p->traceOut = output_file_open(azArg[1]);
38513851
#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
38523852
if( p->traceOut==0 ){
38533853
sqlite3_trace(p->db, 0, 0);
38543854
}else{
@@ -4352,11 +4352,11 @@
43524352
exit(1);
43534353
}
43544354
return argv[i];
43554355
}
43564356
4357
-int main(int argc, char **argv){
4357
+int SQLITE_CDECL main(int argc, char **argv){
43584358
char *zErrMsg = 0;
43594359
ShellState data;
43604360
const char *zInitFile = 0;
43614361
int i;
43624362
int rc = 0;
43634363
--- src/shell.c
+++ src/shell.c
@@ -25,11 +25,11 @@
25 #endif
26
27 /*
28 ** No support for loadable extensions in VxWorks.
29 */
30 #if defined(_WRS_KERNEL) && !SQLITE_OMIT_LOAD_EXTENSION
31 # define SQLITE_OMIT_LOAD_EXTENSION 1
32 #endif
33
34 /*
35 ** Enable large-file support for fopen() and friends on unix.
@@ -368,11 +368,11 @@
368 ** format string and subsequent arguments are values to be substituted
369 ** in place of % fields. The result of formatting this string
370 ** is written to iotrace.
371 */
372 #ifdef SQLITE_ENABLE_IOTRACE
373 static void iotracePrintf(const char *zFormat, ...){
374 va_list ap;
375 char *z;
376 if( iotrace==0 ) return;
377 va_start(ap, zFormat);
378 z = sqlite3_vmprintf(zFormat, ap);
@@ -2141,11 +2141,11 @@
2141 ** + Keep track of the line number in p->nLine.
2142 ** + Store the character that terminates the field in p->cTerm. Store
2143 ** EOF on end-of-file.
2144 ** + Report syntax errors on stderr
2145 */
2146 static char *csv_read_one_field(ImportCtx *p){
2147 int c;
2148 int cSep = p->cColSep;
2149 int rSep = p->cRowSep;
2150 p->n = 0;
2151 c = fgetc(p->in);
@@ -2215,11 +2215,11 @@
2215 ** + Keep track of the row number in p->nLine.
2216 ** + Store the character that terminates the field in p->cTerm. Store
2217 ** EOF on end-of-file.
2218 ** + Report syntax errors on stderr
2219 */
2220 static char *ascii_read_one_field(ImportCtx *p){
2221 int c;
2222 int cSep = p->cColSep;
2223 int rSep = p->cRowSep;
2224 p->n = 0;
2225 c = fgetc(p->in);
@@ -2909,12 +2909,12 @@
2909 int i, j; /* Loop counters */
2910 int needCommit; /* True to COMMIT or ROLLBACK at end */
2911 int nSep; /* Number of bytes in p->colSeparator[] */
2912 char *zSql; /* An SQL statement */
2913 ImportCtx sCtx; /* Reader context */
2914 char *(*xRead)(ImportCtx*); /* Procedure to read one value */
2915 int (*xCloser)(FILE*); /* Procedure to close th3 connection */
2916
2917 if( nArg!=3 ){
2918 fprintf(stderr, "Usage: .import FILE TABLE\n");
2919 goto meta_command_exit;
2920 }
@@ -2953,11 +2953,11 @@
2953 }
2954 sCtx.zFile = zFile;
2955 sCtx.nLine = 1;
2956 if( sCtx.zFile[0]=='|' ){
2957 #ifdef SQLITE_OMIT_POPEN
2958 fprintf(stderr, "Error: pipes are not supporte in this OS\n");
2959 return 1;
2960 #else
2961 sCtx.in = popen(sCtx.zFile+1, "r");
2962 sCtx.zFile = "<pipe>";
2963 xCloser = pclose;
@@ -3142,11 +3142,11 @@
3142 }
3143 }else
3144
3145 #ifdef SQLITE_ENABLE_IOTRACE
3146 if( c=='i' && strncmp(azArg[0], "iotrace", n)==0 ){
3147 extern void (*sqlite3IoTrace)(const char*, ...);
3148 if( iotrace && iotrace!=stdout ) fclose(iotrace);
3149 iotrace = 0;
3150 if( nArg<2 ){
3151 sqlite3IoTrace = 0;
3152 }else if( strcmp(azArg[1], "-")==0 ){
@@ -3801,13 +3801,13 @@
3801 if( nArg==5 ){
3802 rc = sqlite3_test_control(testctrl, p->db,
3803 azArg[2],
3804 integerValue(azArg[3]),
3805 integerValue(azArg[4]));
 
3806 }else{
3807 fprintf(stderr,"Usage: .testctrl initmode dbName onoff tnum\n");
3808 rc = 1;
3809 }
3810 break;
3811
3812 case SQLITE_TESTCTRL_BITVEC_TEST:
3813 case SQLITE_TESTCTRL_FAULT_INSTALL:
@@ -3839,16 +3839,16 @@
3839 }
3840 }else
3841
3842 if( c=='t' && strncmp(azArg[0], "trace", n)==0 ){
3843 open_db(p, 0);
3844 output_file_close(p->traceOut);
3845 if( nArg!=2 ){
3846 fprintf(stderr, "Usage: .trace FILE|off\n");
3847 rc = 1;
3848 goto meta_command_exit;
3849 }
 
3850 p->traceOut = output_file_open(azArg[1]);
3851 #if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
3852 if( p->traceOut==0 ){
3853 sqlite3_trace(p->db, 0, 0);
3854 }else{
@@ -4352,11 +4352,11 @@
4352 exit(1);
4353 }
4354 return argv[i];
4355 }
4356
4357 int main(int argc, char **argv){
4358 char *zErrMsg = 0;
4359 ShellState data;
4360 const char *zInitFile = 0;
4361 int i;
4362 int rc = 0;
4363
--- src/shell.c
+++ src/shell.c
@@ -25,11 +25,11 @@
25 #endif
26
27 /*
28 ** No support for loadable extensions in VxWorks.
29 */
30 #if (defined(__RTP__) || defined(_WRS_KERNEL)) && !SQLITE_OMIT_LOAD_EXTENSION
31 # define SQLITE_OMIT_LOAD_EXTENSION 1
32 #endif
33
34 /*
35 ** Enable large-file support for fopen() and friends on unix.
@@ -368,11 +368,11 @@
368 ** format string and subsequent arguments are values to be substituted
369 ** in place of % fields. The result of formatting this string
370 ** is written to iotrace.
371 */
372 #ifdef SQLITE_ENABLE_IOTRACE
373 static void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){
374 va_list ap;
375 char *z;
376 if( iotrace==0 ) return;
377 va_start(ap, zFormat);
378 z = sqlite3_vmprintf(zFormat, ap);
@@ -2141,11 +2141,11 @@
2141 ** + Keep track of the line number in p->nLine.
2142 ** + Store the character that terminates the field in p->cTerm. Store
2143 ** EOF on end-of-file.
2144 ** + Report syntax errors on stderr
2145 */
2146 static char *SQLITE_CDECL csv_read_one_field(ImportCtx *p){
2147 int c;
2148 int cSep = p->cColSep;
2149 int rSep = p->cRowSep;
2150 p->n = 0;
2151 c = fgetc(p->in);
@@ -2215,11 +2215,11 @@
2215 ** + Keep track of the row number in p->nLine.
2216 ** + Store the character that terminates the field in p->cTerm. Store
2217 ** EOF on end-of-file.
2218 ** + Report syntax errors on stderr
2219 */
2220 static char *SQLITE_CDECL ascii_read_one_field(ImportCtx *p){
2221 int c;
2222 int cSep = p->cColSep;
2223 int rSep = p->cRowSep;
2224 p->n = 0;
2225 c = fgetc(p->in);
@@ -2909,12 +2909,12 @@
2909 int i, j; /* Loop counters */
2910 int needCommit; /* True to COMMIT or ROLLBACK at end */
2911 int nSep; /* Number of bytes in p->colSeparator[] */
2912 char *zSql; /* An SQL statement */
2913 ImportCtx sCtx; /* Reader context */
2914 char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
2915 int (SQLITE_CDECL *xCloser)(FILE*); /* Func to close file */
2916
2917 if( nArg!=3 ){
2918 fprintf(stderr, "Usage: .import FILE TABLE\n");
2919 goto meta_command_exit;
2920 }
@@ -2953,11 +2953,11 @@
2953 }
2954 sCtx.zFile = zFile;
2955 sCtx.nLine = 1;
2956 if( sCtx.zFile[0]=='|' ){
2957 #ifdef SQLITE_OMIT_POPEN
2958 fprintf(stderr, "Error: pipes are not supported in this OS\n");
2959 return 1;
2960 #else
2961 sCtx.in = popen(sCtx.zFile+1, "r");
2962 sCtx.zFile = "<pipe>";
2963 xCloser = pclose;
@@ -3142,11 +3142,11 @@
3142 }
3143 }else
3144
3145 #ifdef SQLITE_ENABLE_IOTRACE
3146 if( c=='i' && strncmp(azArg[0], "iotrace", n)==0 ){
3147 SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...);
3148 if( iotrace && iotrace!=stdout ) fclose(iotrace);
3149 iotrace = 0;
3150 if( nArg<2 ){
3151 sqlite3IoTrace = 0;
3152 }else if( strcmp(azArg[1], "-")==0 ){
@@ -3801,13 +3801,13 @@
3801 if( nArg==5 ){
3802 rc = sqlite3_test_control(testctrl, p->db,
3803 azArg[2],
3804 integerValue(azArg[3]),
3805 integerValue(azArg[4]));
3806 fprintf(p->out, "%d (0x%08x)\n", rc, rc);
3807 }else{
3808 fprintf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n");
 
3809 }
3810 break;
3811
3812 case SQLITE_TESTCTRL_BITVEC_TEST:
3813 case SQLITE_TESTCTRL_FAULT_INSTALL:
@@ -3839,16 +3839,16 @@
3839 }
3840 }else
3841
3842 if( c=='t' && strncmp(azArg[0], "trace", n)==0 ){
3843 open_db(p, 0);
 
3844 if( nArg!=2 ){
3845 fprintf(stderr, "Usage: .trace FILE|off\n");
3846 rc = 1;
3847 goto meta_command_exit;
3848 }
3849 output_file_close(p->traceOut);
3850 p->traceOut = output_file_open(azArg[1]);
3851 #if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
3852 if( p->traceOut==0 ){
3853 sqlite3_trace(p->db, 0, 0);
3854 }else{
@@ -4352,11 +4352,11 @@
4352 exit(1);
4353 }
4354 return argv[i];
4355 }
4356
4357 int SQLITE_CDECL main(int argc, char **argv){
4358 char *zErrMsg = 0;
4359 ShellState data;
4360 const char *zInitFile = 0;
4361 int i;
4362 int rc = 0;
4363
+189 -24
--- src/skins.c
+++ src/skins.c
@@ -37,24 +37,23 @@
3737
** 4. Make an entry in the following array for the new skin.
3838
*/
3939
static struct BuiltinSkin {
4040
const char *zDesc; /* Description of this skin */
4141
const char *zLabel; /* The directory under skins/ holding this skin */
42
- int whiteForeground; /* True if this skin uses a light-colored foreground */
4342
char *zSQL; /* Filled in at run-time with SQL to insert this skin */
4443
} aBuiltinSkin[] = {
45
- { "Default", "default", 0, 0 },
46
- { "Blitz", "blitz", 0, 0 },
47
- { "Blitz, No Logo", "blitz_no_logo", 0, 0 },
48
- { "Xekri", "xekri", 0, 0 },
49
- { "Original", "original", 0, 0 },
50
- { "Enhanced Original", "enhanced1", 0, 0 },
51
- { "Shadow boxes & Rounded Corners", "rounded1", 0, 0 },
52
- { "Eagle", "eagle", 1, 0 },
53
- { "Black & White, Menu on Left", "black_and_white", 0, 0 },
54
- { "Plain Gray, No Logo", "plain_gray", 0, 0 },
55
- { "Khaki, No Logo", "khaki", 0, 0 },
44
+ { "Default", "default", 0 },
45
+ { "Blitz", "blitz", 0 },
46
+ { "Blitz, No Logo", "blitz_no_logo", 0 },
47
+ { "Xekri", "xekri", 0 },
48
+ { "Original", "original", 0 },
49
+ { "Enhanced Original", "enhanced1", 0 },
50
+ { "Shadow boxes & Rounded Corners", "rounded1", 0 },
51
+ { "Eagle", "eagle", 0 },
52
+ { "Black & White, Menu on Left", "black_and_white", 0 },
53
+ { "Plain Gray, No Logo", "plain_gray", 0 },
54
+ { "Khaki, No Logo", "khaki", 0 },
5655
};
5756
5857
/*
5958
** Alternative skins can be specified in the CGI script or by options
6059
** on the "http", "ui", and "server" commands. The alternative skin
@@ -64,10 +63,27 @@
6463
** The following static variable holds the name of the alternative skin,
6564
** or NULL if the skin should be as configured.
6665
*/
6766
static struct BuiltinSkin *pAltSkin = 0;
6867
static char *zAltSkinDir = 0;
68
+
69
+/*
70
+** Skin details are a set of key/value pairs that define display
71
+** attributes of the skin that cannot be easily specified using CSS
72
+** or that need to be known on the server-side.
73
+**
74
+** The following array holds the value for all known skin details.
75
+*/
76
+static struct SkinDetail {
77
+ const char *zName; /* Name of the detail */
78
+ char *zValue; /* Value of the detail */
79
+} aSkinDetail[] = {
80
+ { "timeline-arrowheads", "1" },
81
+ { "timeline-circle-nodes", "0" },
82
+ { "timeline-color-graph-lines", "0" },
83
+ { "white-foreground", "0" },
84
+};
6985
7086
/*
7187
** Invoke this routine to set the alternative skin. Return NULL if the
7288
** alternative was successfully installed. Return a string listing all
7389
** available skins if zName does not match an available skin. Memory
@@ -141,18 +157,75 @@
141157
fossil_free(z);
142158
}
143159
}
144160
return zOut;
145161
}
146
-int skin_white_foreground(void){
147
- int rc;
148
- if( pAltSkin ){
149
- rc = pAltSkin->whiteForeground;
150
- }else{
151
- rc = db_get_boolean("white-foreground",0);
152
- }
153
- return rc;
162
+
163
+/*
164
+** Return a pointer to a SkinDetail element. Return 0 if not found.
165
+*/
166
+static struct SkinDetail *skin_detail_find(const char *zName){
167
+ int lwr = 0;
168
+ int upr = ArraySize(aSkinDetail);
169
+ while( upr>=lwr ){
170
+ int mid = (upr+lwr)/2;
171
+ int c = fossil_strcmp(aSkinDetail[mid].zName, zName);
172
+ if( c==0 ) return &aSkinDetail[mid];
173
+ if( c<0 ){
174
+ lwr = mid+1;
175
+ }else{
176
+ upr = mid-1;
177
+ }
178
+ }
179
+ return 0;
180
+}
181
+
182
+/* Initialize the aSkinDetail array using the text in the details.txt
183
+** file.
184
+*/
185
+static void skin_detail_initialize(void){
186
+ static int isInit = 0;
187
+ char *zDetail;
188
+ Blob detail, line, key, value;
189
+ if( isInit ) return;
190
+ isInit = 1;
191
+ zDetail = (char*)skin_get("details");
192
+ if( zDetail==0 ) return;
193
+ zDetail = fossil_strdup(zDetail);
194
+ blob_init(&detail, zDetail, -1);
195
+ while( blob_line(&detail, &line) ){
196
+ char *zKey;
197
+ int nKey;
198
+ struct SkinDetail *pDetail;
199
+ if( !blob_token(&line, &key) ) continue;
200
+ zKey = blob_buffer(&key);
201
+ if( zKey[0]=='#' ) continue;
202
+ nKey = blob_size(&key);
203
+ if( nKey<2 ) continue;
204
+ if( zKey[nKey-1]!=':' ) continue;
205
+ zKey[nKey-1] = 0;
206
+ pDetail = skin_detail_find(zKey);
207
+ if( pDetail==0 ) continue;
208
+ if( !blob_token(&line, &value) ) continue;
209
+ pDetail->zValue = fossil_strdup(blob_str(&value));
210
+ }
211
+ blob_reset(&detail);
212
+ fossil_free(zDetail);
213
+}
214
+
215
+/*
216
+** Return a skin detail setting
217
+*/
218
+const char *skin_detail(const char *zName){
219
+ struct SkinDetail *pDetail;
220
+ skin_detail_initialize();
221
+ pDetail = skin_detail_find(zName);
222
+ if( pDetail==0 ) fossil_fatal("no such skin detail: %s", zName);
223
+ return pDetail->zValue;
224
+}
225
+int skin_detail_boolean(const char *zName){
226
+ return !is_false(skin_detail(zName));
154227
}
155228
156229
/*
157230
** Hash function for computing a skin id.
158231
*/
@@ -227,11 +300,11 @@
227300
** Memory to hold the returned string is obtained from malloc.
228301
*/
229302
static char *getSkin(const char *zName){
230303
const char *z;
231304
char *zLabel;
232
- static const char *azType[] = { "css", "header", "footer" };
305
+ static const char *azType[] = { "css", "header", "footer", "details" };
233306
int i;
234307
Blob val;
235308
blob_zero(&val);
236309
for(i=0; i<sizeof(azType)/sizeof(azType[0]); i++){
237310
if( zName ){
@@ -420,13 +493,15 @@
420493
style_header("Skins");
421494
if( zErr ){
422495
@ <p><font color="red">%h(zErr)</font></p>
423496
}
424497
@ <p>A "skin" is a combination of
425
- @ <a href="setup_editcss">CSS</a>,
426
- @ <a href="setup_header">Header</a>, and
427
- @ <a href="setup_footer">Footer</a> that determines the look and feel
498
+ @ <a href="setup_skinedit?w=0">CSS</a>,
499
+ @ <a href="setup_skinedit?w=2">Header</a>,
500
+ @ <a href="setup_skinedit?w=1">Footer</a>, and
501
+ @ <a href="setup_skinedit?w=3">Details</a>
502
+ @ that determines the look and feel
428503
@ of the web interface.</p>
429504
@
430505
if( pAltSkin ){
431506
@ <p class="generalError">
432507
@ This page is generated using an skin override named
@@ -483,8 +558,98 @@
483558
@ <form action="%s(g.zTop)/setup_skin" method="post">
484559
@ <input type="submit" name="save" value="Save">
485560
@ </form>
486561
}
487562
@ </table>
563
+ style_footer();
564
+ db_end_transaction(0);
565
+}
566
+
567
+
568
+/*
569
+** WEBPAGE: setup_skinedit
570
+**
571
+** w=N -- 0=CSS, 1=footer, 2=header, 3=details
572
+*/
573
+void setup_skinedit(void){
574
+ static const struct sSkinAddr {
575
+ const char *zFile;
576
+ const char *zTitle;
577
+ const char *zSubmenu;
578
+ } aSkinAttr[] = {
579
+ /* 0 */ { "css", "CSS", "CSS", },
580
+ /* 1 */ { "footer", "Page Footer", "Footer", },
581
+ /* 2 */ { "header", "Page Header", "Header", },
582
+ /* 3 */ { "details", "Display Details", "Details", },
583
+ };
584
+ const char *zBasis;
585
+ const char *zContent;
586
+ char *zDflt;
587
+ int ii;
588
+ int j;
589
+
590
+ login_check_credentials();
591
+ if( !g.perm.Setup ){
592
+ login_needed(0);
593
+ return;
594
+ }
595
+ ii = atoi(PD("w","0"));
596
+ if( ii<0 || ii>ArraySize(aSkinAttr) ) ii = 0;
597
+ zBasis = PD("basis","default");
598
+ zDflt = mprintf("skins/%s/%s.txt", zBasis, aSkinAttr[ii].zFile);
599
+ db_begin_transaction();
600
+ if( P("revert")!=0 ){
601
+ db_multi_exec("DELETE FROM config WHERE name=%Q", aSkinAttr[ii].zFile);
602
+ cgi_replace_parameter(aSkinAttr[ii].zFile, builtin_text(zDflt));
603
+ }
604
+ style_header("%s", aSkinAttr[ii].zTitle);
605
+ for(j=0; j<ArraySize(aSkinAttr); j++){
606
+ if( j==ii ) continue;
607
+ style_submenu_element(aSkinAttr[j].zSubmenu, 0,
608
+ "%R/setup_skinedit?w=%d&basis=%h",j,zBasis);
609
+ }
610
+ style_submenu_element("Skins", 0, "%R/setup_skin");
611
+ @ <form action="%s(g.zTop)/setup_skinedit" method="post"><div>
612
+ login_insert_csrf_secret();
613
+ @ <input type='hidden' name='w' value='%d(ii)'>
614
+ @ <h2>Edit %s(aSkinAttr[ii].zTitle):</h2>
615
+ zContent = textarea_attribute("", 10, 80, aSkinAttr[ii].zFile,
616
+ aSkinAttr[ii].zFile, builtin_text(zDflt), 0);
617
+ @ <br />
618
+ @ <input type="submit" name="submit" value="Apply Changes" />
619
+ @ <hr />
620
+ @ Baseline: <select size='1' name='basis'>
621
+ for(j=0; j<ArraySize(aBuiltinSkin); j++){
622
+ cgi_printf("<option value='%h'%s>%h</option>\n",
623
+ aBuiltinSkin[j].zLabel,
624
+ fossil_strcmp(zBasis,aBuiltinSkin[j].zLabel)==0 ? " selected" : "",
625
+ aBuiltinSkin[j].zDesc
626
+ );
627
+ }
628
+ @ </select>
629
+ @ <input type="submit" name="diff" value="Diff" />
630
+ if( P("diff")!=0 ){
631
+ u64 diffFlags = construct_diff_flags(0,0) |
632
+ DIFF_STRIP_EOLCR;
633
+ Blob from, to, out;
634
+ blob_init(&to, zContent, -1);
635
+ blob_init(&from, builtin_text(zDflt), -1);
636
+ blob_zero(&out);
637
+ @ <input type="submit" name="revert" value="Revert" /><p>
638
+ if( diffFlags & DIFF_SIDEBYSIDE ){
639
+ text_diff(&from, &to, &out, 0, diffFlags | DIFF_HTML | DIFF_NOTTOOBIG);
640
+ @ %s(blob_str(&out))
641
+ }else{
642
+ text_diff(&from, &to, &out, 0,
643
+ diffFlags | DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG);
644
+ @ <pre class="udiff">
645
+ @ %s(blob_str(&out))
646
+ @ </pre>
647
+ }
648
+ blob_reset(&from);
649
+ blob_reset(&to);
650
+ blob_reset(&out);
651
+ }
652
+ @ </div></form>
488653
style_footer();
489654
db_end_transaction(0);
490655
}
491656
--- src/skins.c
+++ src/skins.c
@@ -37,24 +37,23 @@
37 ** 4. Make an entry in the following array for the new skin.
38 */
39 static struct BuiltinSkin {
40 const char *zDesc; /* Description of this skin */
41 const char *zLabel; /* The directory under skins/ holding this skin */
42 int whiteForeground; /* True if this skin uses a light-colored foreground */
43 char *zSQL; /* Filled in at run-time with SQL to insert this skin */
44 } aBuiltinSkin[] = {
45 { "Default", "default", 0, 0 },
46 { "Blitz", "blitz", 0, 0 },
47 { "Blitz, No Logo", "blitz_no_logo", 0, 0 },
48 { "Xekri", "xekri", 0, 0 },
49 { "Original", "original", 0, 0 },
50 { "Enhanced Original", "enhanced1", 0, 0 },
51 { "Shadow boxes & Rounded Corners", "rounded1", 0, 0 },
52 { "Eagle", "eagle", 1, 0 },
53 { "Black & White, Menu on Left", "black_and_white", 0, 0 },
54 { "Plain Gray, No Logo", "plain_gray", 0, 0 },
55 { "Khaki, No Logo", "khaki", 0, 0 },
56 };
57
58 /*
59 ** Alternative skins can be specified in the CGI script or by options
60 ** on the "http", "ui", and "server" commands. The alternative skin
@@ -64,10 +63,27 @@
64 ** The following static variable holds the name of the alternative skin,
65 ** or NULL if the skin should be as configured.
66 */
67 static struct BuiltinSkin *pAltSkin = 0;
68 static char *zAltSkinDir = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
70 /*
71 ** Invoke this routine to set the alternative skin. Return NULL if the
72 ** alternative was successfully installed. Return a string listing all
73 ** available skins if zName does not match an available skin. Memory
@@ -141,18 +157,75 @@
141 fossil_free(z);
142 }
143 }
144 return zOut;
145 }
146 int skin_white_foreground(void){
147 int rc;
148 if( pAltSkin ){
149 rc = pAltSkin->whiteForeground;
150 }else{
151 rc = db_get_boolean("white-foreground",0);
152 }
153 return rc;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154 }
155
156 /*
157 ** Hash function for computing a skin id.
158 */
@@ -227,11 +300,11 @@
227 ** Memory to hold the returned string is obtained from malloc.
228 */
229 static char *getSkin(const char *zName){
230 const char *z;
231 char *zLabel;
232 static const char *azType[] = { "css", "header", "footer" };
233 int i;
234 Blob val;
235 blob_zero(&val);
236 for(i=0; i<sizeof(azType)/sizeof(azType[0]); i++){
237 if( zName ){
@@ -420,13 +493,15 @@
420 style_header("Skins");
421 if( zErr ){
422 @ <p><font color="red">%h(zErr)</font></p>
423 }
424 @ <p>A "skin" is a combination of
425 @ <a href="setup_editcss">CSS</a>,
426 @ <a href="setup_header">Header</a>, and
427 @ <a href="setup_footer">Footer</a> that determines the look and feel
 
 
428 @ of the web interface.</p>
429 @
430 if( pAltSkin ){
431 @ <p class="generalError">
432 @ This page is generated using an skin override named
@@ -483,8 +558,98 @@
483 @ <form action="%s(g.zTop)/setup_skin" method="post">
484 @ <input type="submit" name="save" value="Save">
485 @ </form>
486 }
487 @ </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
488 style_footer();
489 db_end_transaction(0);
490 }
491
--- src/skins.c
+++ src/skins.c
@@ -37,24 +37,23 @@
37 ** 4. Make an entry in the following array for the new skin.
38 */
39 static struct BuiltinSkin {
40 const char *zDesc; /* Description of this skin */
41 const char *zLabel; /* The directory under skins/ holding this skin */
 
42 char *zSQL; /* Filled in at run-time with SQL to insert this skin */
43 } aBuiltinSkin[] = {
44 { "Default", "default", 0 },
45 { "Blitz", "blitz", 0 },
46 { "Blitz, No Logo", "blitz_no_logo", 0 },
47 { "Xekri", "xekri", 0 },
48 { "Original", "original", 0 },
49 { "Enhanced Original", "enhanced1", 0 },
50 { "Shadow boxes & Rounded Corners", "rounded1", 0 },
51 { "Eagle", "eagle", 0 },
52 { "Black & White, Menu on Left", "black_and_white", 0 },
53 { "Plain Gray, No Logo", "plain_gray", 0 },
54 { "Khaki, No Logo", "khaki", 0 },
55 };
56
57 /*
58 ** Alternative skins can be specified in the CGI script or by options
59 ** on the "http", "ui", and "server" commands. The alternative skin
@@ -64,10 +63,27 @@
63 ** The following static variable holds the name of the alternative skin,
64 ** or NULL if the skin should be as configured.
65 */
66 static struct BuiltinSkin *pAltSkin = 0;
67 static char *zAltSkinDir = 0;
68
69 /*
70 ** Skin details are a set of key/value pairs that define display
71 ** attributes of the skin that cannot be easily specified using CSS
72 ** or that need to be known on the server-side.
73 **
74 ** The following array holds the value for all known skin details.
75 */
76 static struct SkinDetail {
77 const char *zName; /* Name of the detail */
78 char *zValue; /* Value of the detail */
79 } aSkinDetail[] = {
80 { "timeline-arrowheads", "1" },
81 { "timeline-circle-nodes", "0" },
82 { "timeline-color-graph-lines", "0" },
83 { "white-foreground", "0" },
84 };
85
86 /*
87 ** Invoke this routine to set the alternative skin. Return NULL if the
88 ** alternative was successfully installed. Return a string listing all
89 ** available skins if zName does not match an available skin. Memory
@@ -141,18 +157,75 @@
157 fossil_free(z);
158 }
159 }
160 return zOut;
161 }
162
163 /*
164 ** Return a pointer to a SkinDetail element. Return 0 if not found.
165 */
166 static struct SkinDetail *skin_detail_find(const char *zName){
167 int lwr = 0;
168 int upr = ArraySize(aSkinDetail);
169 while( upr>=lwr ){
170 int mid = (upr+lwr)/2;
171 int c = fossil_strcmp(aSkinDetail[mid].zName, zName);
172 if( c==0 ) return &aSkinDetail[mid];
173 if( c<0 ){
174 lwr = mid+1;
175 }else{
176 upr = mid-1;
177 }
178 }
179 return 0;
180 }
181
182 /* Initialize the aSkinDetail array using the text in the details.txt
183 ** file.
184 */
185 static void skin_detail_initialize(void){
186 static int isInit = 0;
187 char *zDetail;
188 Blob detail, line, key, value;
189 if( isInit ) return;
190 isInit = 1;
191 zDetail = (char*)skin_get("details");
192 if( zDetail==0 ) return;
193 zDetail = fossil_strdup(zDetail);
194 blob_init(&detail, zDetail, -1);
195 while( blob_line(&detail, &line) ){
196 char *zKey;
197 int nKey;
198 struct SkinDetail *pDetail;
199 if( !blob_token(&line, &key) ) continue;
200 zKey = blob_buffer(&key);
201 if( zKey[0]=='#' ) continue;
202 nKey = blob_size(&key);
203 if( nKey<2 ) continue;
204 if( zKey[nKey-1]!=':' ) continue;
205 zKey[nKey-1] = 0;
206 pDetail = skin_detail_find(zKey);
207 if( pDetail==0 ) continue;
208 if( !blob_token(&line, &value) ) continue;
209 pDetail->zValue = fossil_strdup(blob_str(&value));
210 }
211 blob_reset(&detail);
212 fossil_free(zDetail);
213 }
214
215 /*
216 ** Return a skin detail setting
217 */
218 const char *skin_detail(const char *zName){
219 struct SkinDetail *pDetail;
220 skin_detail_initialize();
221 pDetail = skin_detail_find(zName);
222 if( pDetail==0 ) fossil_fatal("no such skin detail: %s", zName);
223 return pDetail->zValue;
224 }
225 int skin_detail_boolean(const char *zName){
226 return !is_false(skin_detail(zName));
227 }
228
229 /*
230 ** Hash function for computing a skin id.
231 */
@@ -227,11 +300,11 @@
300 ** Memory to hold the returned string is obtained from malloc.
301 */
302 static char *getSkin(const char *zName){
303 const char *z;
304 char *zLabel;
305 static const char *azType[] = { "css", "header", "footer", "details" };
306 int i;
307 Blob val;
308 blob_zero(&val);
309 for(i=0; i<sizeof(azType)/sizeof(azType[0]); i++){
310 if( zName ){
@@ -420,13 +493,15 @@
493 style_header("Skins");
494 if( zErr ){
495 @ <p><font color="red">%h(zErr)</font></p>
496 }
497 @ <p>A "skin" is a combination of
498 @ <a href="setup_skinedit?w=0">CSS</a>,
499 @ <a href="setup_skinedit?w=2">Header</a>,
500 @ <a href="setup_skinedit?w=1">Footer</a>, and
501 @ <a href="setup_skinedit?w=3">Details</a>
502 @ that determines the look and feel
503 @ of the web interface.</p>
504 @
505 if( pAltSkin ){
506 @ <p class="generalError">
507 @ This page is generated using an skin override named
@@ -483,8 +558,98 @@
558 @ <form action="%s(g.zTop)/setup_skin" method="post">
559 @ <input type="submit" name="save" value="Save">
560 @ </form>
561 }
562 @ </table>
563 style_footer();
564 db_end_transaction(0);
565 }
566
567
568 /*
569 ** WEBPAGE: setup_skinedit
570 **
571 ** w=N -- 0=CSS, 1=footer, 2=header, 3=details
572 */
573 void setup_skinedit(void){
574 static const struct sSkinAddr {
575 const char *zFile;
576 const char *zTitle;
577 const char *zSubmenu;
578 } aSkinAttr[] = {
579 /* 0 */ { "css", "CSS", "CSS", },
580 /* 1 */ { "footer", "Page Footer", "Footer", },
581 /* 2 */ { "header", "Page Header", "Header", },
582 /* 3 */ { "details", "Display Details", "Details", },
583 };
584 const char *zBasis;
585 const char *zContent;
586 char *zDflt;
587 int ii;
588 int j;
589
590 login_check_credentials();
591 if( !g.perm.Setup ){
592 login_needed(0);
593 return;
594 }
595 ii = atoi(PD("w","0"));
596 if( ii<0 || ii>ArraySize(aSkinAttr) ) ii = 0;
597 zBasis = PD("basis","default");
598 zDflt = mprintf("skins/%s/%s.txt", zBasis, aSkinAttr[ii].zFile);
599 db_begin_transaction();
600 if( P("revert")!=0 ){
601 db_multi_exec("DELETE FROM config WHERE name=%Q", aSkinAttr[ii].zFile);
602 cgi_replace_parameter(aSkinAttr[ii].zFile, builtin_text(zDflt));
603 }
604 style_header("%s", aSkinAttr[ii].zTitle);
605 for(j=0; j<ArraySize(aSkinAttr); j++){
606 if( j==ii ) continue;
607 style_submenu_element(aSkinAttr[j].zSubmenu, 0,
608 "%R/setup_skinedit?w=%d&basis=%h",j,zBasis);
609 }
610 style_submenu_element("Skins", 0, "%R/setup_skin");
611 @ <form action="%s(g.zTop)/setup_skinedit" method="post"><div>
612 login_insert_csrf_secret();
613 @ <input type='hidden' name='w' value='%d(ii)'>
614 @ <h2>Edit %s(aSkinAttr[ii].zTitle):</h2>
615 zContent = textarea_attribute("", 10, 80, aSkinAttr[ii].zFile,
616 aSkinAttr[ii].zFile, builtin_text(zDflt), 0);
617 @ <br />
618 @ <input type="submit" name="submit" value="Apply Changes" />
619 @ <hr />
620 @ Baseline: <select size='1' name='basis'>
621 for(j=0; j<ArraySize(aBuiltinSkin); j++){
622 cgi_printf("<option value='%h'%s>%h</option>\n",
623 aBuiltinSkin[j].zLabel,
624 fossil_strcmp(zBasis,aBuiltinSkin[j].zLabel)==0 ? " selected" : "",
625 aBuiltinSkin[j].zDesc
626 );
627 }
628 @ </select>
629 @ <input type="submit" name="diff" value="Diff" />
630 if( P("diff")!=0 ){
631 u64 diffFlags = construct_diff_flags(0,0) |
632 DIFF_STRIP_EOLCR;
633 Blob from, to, out;
634 blob_init(&to, zContent, -1);
635 blob_init(&from, builtin_text(zDflt), -1);
636 blob_zero(&out);
637 @ <input type="submit" name="revert" value="Revert" /><p>
638 if( diffFlags & DIFF_SIDEBYSIDE ){
639 text_diff(&from, &to, &out, 0, diffFlags | DIFF_HTML | DIFF_NOTTOOBIG);
640 @ %s(blob_str(&out))
641 }else{
642 text_diff(&from, &to, &out, 0,
643 diffFlags | DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG);
644 @ <pre class="udiff">
645 @ %s(blob_str(&out))
646 @ </pre>
647 }
648 blob_reset(&from);
649 blob_reset(&to);
650 blob_reset(&out);
651 }
652 @ </div></form>
653 style_footer();
654 db_end_transaction(0);
655 }
656
+1368 -764
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -20,13 +20,10 @@
2020
#define SQLITE_CORE 1
2121
#define SQLITE_AMALGAMATION 1
2222
#ifndef SQLITE_PRIVATE
2323
# define SQLITE_PRIVATE static
2424
#endif
25
-#ifndef SQLITE_API
26
-# define SQLITE_API
27
-#endif
2825
/************** Begin file sqliteInt.h ***************************************/
2926
/*
3027
** 2001 September 15
3128
**
3229
** The author disclaims copyright to this source code. In place of
@@ -250,20 +247,24 @@
250247
extern "C" {
251248
#endif
252249
253250
254251
/*
255
-** Add the ability to override 'extern'
252
+** Provide the ability to override linkage features of the interface.
256253
*/
257254
#ifndef SQLITE_EXTERN
258255
# define SQLITE_EXTERN extern
259256
#endif
260
-
261257
#ifndef SQLITE_API
262258
# define SQLITE_API
263259
#endif
264
-
260
+#ifndef SQLITE_CDECL
261
+# define SQLITE_CDECL
262
+#endif
263
+#ifndef SQLITE_STDCALL
264
+# define SQLITE_STDCALL
265
+#endif
265266
266267
/*
267268
** These no-op macros are used in front of interfaces to mark those
268269
** interfaces as either deprecated or experimental. New applications
269270
** should not use deprecated interfaces - they are supported for backwards
@@ -316,11 +317,11 @@
316317
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
317318
** [sqlite_version()] and [sqlite_source_id()].
318319
*/
319320
#define SQLITE_VERSION "3.8.9"
320321
#define SQLITE_VERSION_NUMBER 3008009
321
-#define SQLITE_SOURCE_ID "2015-03-09 10:40:48 e5da5e7d5dc5a3438ced23f1ee83e695abc29c45"
322
+#define SQLITE_SOURCE_ID "2015-03-30 23:43:56 395bb3e677a6551b06ba96fc58c393132b93d1e8"
322323
323324
/*
324325
** CAPI3REF: Run-Time Library Version Numbers
325326
** KEYWORDS: sqlite3_version, sqlite3_sourceid
326327
**
@@ -349,13 +350,13 @@
349350
** [SQLITE_SOURCE_ID] C preprocessor macro.
350351
**
351352
** See also: [sqlite_version()] and [sqlite_source_id()].
352353
*/
353354
SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
354
-SQLITE_API const char *sqlite3_libversion(void);
355
-SQLITE_API const char *sqlite3_sourceid(void);
356
-SQLITE_API int sqlite3_libversion_number(void);
355
+SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void);
356
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void);
357
+SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void);
357358
358359
/*
359360
** CAPI3REF: Run-Time Library Compilation Options Diagnostics
360361
**
361362
** ^The sqlite3_compileoption_used() function returns 0 or 1
@@ -376,12 +377,12 @@
376377
**
377378
** See also: SQL functions [sqlite_compileoption_used()] and
378379
** [sqlite_compileoption_get()] and the [compile_options pragma].
379380
*/
380381
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
381
-SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
382
-SQLITE_API const char *sqlite3_compileoption_get(int N);
382
+SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName);
383
+SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N);
383384
#endif
384385
385386
/*
386387
** CAPI3REF: Test To See If The Library Is Threadsafe
387388
**
@@ -416,11 +417,11 @@
416417
** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
417418
** is unchanged by calls to sqlite3_config().)^
418419
**
419420
** See the [threading mode] documentation for additional information.
420421
*/
421
-SQLITE_API int sqlite3_threadsafe(void);
422
+SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void);
422423
423424
/*
424425
** CAPI3REF: Database Connection Handle
425426
** KEYWORDS: {database connection} {database connections}
426427
**
@@ -512,12 +513,12 @@
512513
** from [sqlite3_open()], [sqlite3_open16()], or
513514
** [sqlite3_open_v2()], and not previously closed.
514515
** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
515516
** argument is a harmless no-op.
516517
*/
517
-SQLITE_API int sqlite3_close(sqlite3*);
518
-SQLITE_API int sqlite3_close_v2(sqlite3*);
518
+SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*);
519
+SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*);
519520
520521
/*
521522
** The type for a callback function.
522523
** This is legacy and deprecated. It is included for historical
523524
** compatibility and is not documented.
@@ -583,11 +584,11 @@
583584
** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
584585
** <li> The application must not modify the SQL statement text passed into
585586
** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
586587
** </ul>
587588
*/
588
-SQLITE_API int sqlite3_exec(
589
+SQLITE_API int SQLITE_STDCALL sqlite3_exec(
589590
sqlite3*, /* An open database */
590591
const char *sql, /* SQL to be evaluated */
591592
int (*callback)(void*,int,char**,char**), /* Callback function */
592593
void *, /* 1st argument to callback */
593594
char **errmsg /* Error msg written here */
@@ -1157,10 +1158,17 @@
11571158
** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
11581159
** opcode causes the xFileControl method to swap the file handle with the one
11591160
** pointed to by the pArg argument. This capability is used during testing
11601161
** and only needs to be supported when SQLITE_TEST is defined.
11611162
**
1163
+** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
1164
+** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
1165
+** be advantageous to block on the next WAL lock if the lock is not immediately
1166
+** available. The WAL subsystem issues this signal during rare
1167
+** circumstances in order to fix a problem with priority inversion.
1168
+** Applications should <em>not</em> use this file-control.
1169
+**
11621170
** </ul>
11631171
*/
11641172
#define SQLITE_FCNTL_LOCKSTATE 1
11651173
#define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
11661174
#define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
@@ -1181,10 +1189,11 @@
11811189
#define SQLITE_FCNTL_TRACE 19
11821190
#define SQLITE_FCNTL_HAS_MOVED 20
11831191
#define SQLITE_FCNTL_SYNC 21
11841192
#define SQLITE_FCNTL_COMMIT_PHASETWO 22
11851193
#define SQLITE_FCNTL_WIN32_SET_HANDLE 23
1194
+#define SQLITE_FCNTL_WAL_BLOCK 24
11861195
11871196
/* deprecated names */
11881197
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
11891198
#define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
11901199
#define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -1535,14 +1544,14 @@
15351544
** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
15361545
** implementation of sqlite3_os_init() or sqlite3_os_end()
15371546
** must return [SQLITE_OK] on success and some other [error code] upon
15381547
** failure.
15391548
*/
1540
-SQLITE_API int sqlite3_initialize(void);
1541
-SQLITE_API int sqlite3_shutdown(void);
1542
-SQLITE_API int sqlite3_os_init(void);
1543
-SQLITE_API int sqlite3_os_end(void);
1549
+SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void);
1550
+SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void);
1551
+SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void);
1552
+SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void);
15441553
15451554
/*
15461555
** CAPI3REF: Configuring The SQLite Library
15471556
**
15481557
** The sqlite3_config() interface is used to make global configuration
@@ -1569,11 +1578,11 @@
15691578
**
15701579
** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
15711580
** ^If the option is unknown or SQLite is unable to set the option
15721581
** then this routine returns a non-zero [error code].
15731582
*/
1574
-SQLITE_API int sqlite3_config(int, ...);
1583
+SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...);
15751584
15761585
/*
15771586
** CAPI3REF: Configure database connections
15781587
**
15791588
** The sqlite3_db_config() interface is used to make configuration
@@ -1587,11 +1596,11 @@
15871596
** Subsequent arguments vary depending on the configuration verb.
15881597
**
15891598
** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
15901599
** the call is considered successful.
15911600
*/
1592
-SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
1601
+SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...);
15931602
15941603
/*
15951604
** CAPI3REF: Memory Allocation Routines
15961605
**
15971606
** An instance of this object defines the interface between SQLite
@@ -1747,11 +1756,11 @@
17471756
** disabled, the following SQLite interfaces become non-operational:
17481757
** <ul>
17491758
** <li> [sqlite3_memory_used()]
17501759
** <li> [sqlite3_memory_highwater()]
17511760
** <li> [sqlite3_soft_heap_limit64()]
1752
-** <li> [sqlite3_status()]
1761
+** <li> [sqlite3_status64()]
17531762
** </ul>)^
17541763
** ^Memory allocation statistics are enabled by default unless SQLite is
17551764
** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
17561765
** allocation statistics are disabled by default.
17571766
** </dd>
@@ -2075,11 +2084,11 @@
20752084
**
20762085
** ^The sqlite3_extended_result_codes() routine enables or disables the
20772086
** [extended result codes] feature of SQLite. ^The extended result
20782087
** codes are disabled by default for historical compatibility.
20792088
*/
2080
-SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
2089
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff);
20812090
20822091
/*
20832092
** CAPI3REF: Last Insert Rowid
20842093
**
20852094
** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
@@ -2126,11 +2135,11 @@
21262135
** function is running and thus changes the last insert [rowid],
21272136
** then the value returned by [sqlite3_last_insert_rowid()] is
21282137
** unpredictable and might not equal either the old or the new
21292138
** last insert [rowid].
21302139
*/
2131
-SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
2140
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*);
21322141
21332142
/*
21342143
** CAPI3REF: Count The Number Of Rows Modified
21352144
**
21362145
** ^This function returns the number of rows modified, inserted or
@@ -2178,11 +2187,11 @@
21782187
**
21792188
** If a separate thread makes changes on the same database connection
21802189
** while [sqlite3_changes()] is running then the value returned
21812190
** is unpredictable and not meaningful.
21822191
*/
2183
-SQLITE_API int sqlite3_changes(sqlite3*);
2192
+SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*);
21842193
21852194
/*
21862195
** CAPI3REF: Total Number Of Rows Modified
21872196
**
21882197
** ^This function returns the total number of rows inserted, modified or
@@ -2201,11 +2210,11 @@
22012210
**
22022211
** If a separate thread makes changes on the same database connection
22032212
** while [sqlite3_total_changes()] is running then the value
22042213
** returned is unpredictable and not meaningful.
22052214
*/
2206
-SQLITE_API int sqlite3_total_changes(sqlite3*);
2215
+SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*);
22072216
22082217
/*
22092218
** CAPI3REF: Interrupt A Long-Running Query
22102219
**
22112220
** ^This function causes any pending database operation to abort and
@@ -2240,11 +2249,11 @@
22402249
** that are started after the sqlite3_interrupt() call returns.
22412250
**
22422251
** If the database connection closes while [sqlite3_interrupt()]
22432252
** is running then bad things will likely happen.
22442253
*/
2245
-SQLITE_API void sqlite3_interrupt(sqlite3*);
2254
+SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*);
22462255
22472256
/*
22482257
** CAPI3REF: Determine If An SQL Statement Is Complete
22492258
**
22502259
** These routines are useful during command-line input to determine if the
@@ -2275,12 +2284,12 @@
22752284
** UTF-8 string.
22762285
**
22772286
** The input to [sqlite3_complete16()] must be a zero-terminated
22782287
** UTF-16 string in native byte order.
22792288
*/
2280
-SQLITE_API int sqlite3_complete(const char *sql);
2281
-SQLITE_API int sqlite3_complete16(const void *sql);
2289
+SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql);
2290
+SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
22822291
22832292
/*
22842293
** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
22852294
** KEYWORDS: {busy-handler callback} {busy handler}
22862295
**
@@ -2336,11 +2345,11 @@
23362345
** result in undefined behavior.
23372346
**
23382347
** A busy handler must not close the database connection
23392348
** or [prepared statement] that invoked the busy handler.
23402349
*/
2341
-SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2350
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
23422351
23432352
/*
23442353
** CAPI3REF: Set A Busy Timeout
23452354
**
23462355
** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
@@ -2358,11 +2367,11 @@
23582367
** was defined (using [sqlite3_busy_handler()]) prior to calling
23592368
** this routine, that other busy handler is cleared.)^
23602369
**
23612370
** See also: [PRAGMA busy_timeout]
23622371
*/
2363
-SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
2372
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms);
23642373
23652374
/*
23662375
** CAPI3REF: Convenience Routines For Running Queries
23672376
**
23682377
** This is a legacy interface that is preserved for backwards compatibility.
@@ -2432,19 +2441,19 @@
24322441
** interface defined here. As a consequence, errors that occur in the
24332442
** wrapper layer outside of the internal [sqlite3_exec()] call are not
24342443
** reflected in subsequent calls to [sqlite3_errcode()] or
24352444
** [sqlite3_errmsg()].
24362445
*/
2437
-SQLITE_API int sqlite3_get_table(
2446
+SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
24382447
sqlite3 *db, /* An open database */
24392448
const char *zSql, /* SQL to be evaluated */
24402449
char ***pazResult, /* Results of the query */
24412450
int *pnRow, /* Number of result rows written here */
24422451
int *pnColumn, /* Number of result columns written here */
24432452
char **pzErrmsg /* Error msg written here */
24442453
);
2445
-SQLITE_API void sqlite3_free_table(char **result);
2454
+SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result);
24462455
24472456
/*
24482457
** CAPI3REF: Formatted String Printing Functions
24492458
**
24502459
** These routines are work-alikes of the "printf()" family of functions
@@ -2546,14 +2555,14 @@
25462555
**
25472556
** ^(The "%z" formatting option works like "%s" but with the
25482557
** addition that after the string has been read and copied into
25492558
** the result, [sqlite3_free()] is called on the input string.)^
25502559
*/
2551
-SQLITE_API char *sqlite3_mprintf(const char*,...);
2552
-SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
2553
-SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
2554
-SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
2560
+SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...);
2561
+SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list);
2562
+SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...);
2563
+SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list);
25552564
25562565
/*
25572566
** CAPI3REF: Memory Allocation Subsystem
25582567
**
25592568
** The SQLite core uses these three routines for all of its own
@@ -2639,16 +2648,16 @@
26392648
**
26402649
** The application must not read or write any part of
26412650
** a block of memory after it has been released using
26422651
** [sqlite3_free()] or [sqlite3_realloc()].
26432652
*/
2644
-SQLITE_API void *sqlite3_malloc(int);
2645
-SQLITE_API void *sqlite3_malloc64(sqlite3_uint64);
2646
-SQLITE_API void *sqlite3_realloc(void*, int);
2647
-SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);
2648
-SQLITE_API void sqlite3_free(void*);
2649
-SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
2653
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int);
2654
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64);
2655
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int);
2656
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64);
2657
+SQLITE_API void SQLITE_STDCALL sqlite3_free(void*);
2658
+SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*);
26502659
26512660
/*
26522661
** CAPI3REF: Memory Allocator Statistics
26532662
**
26542663
** SQLite provides these two interfaces for reporting on the status
@@ -2669,12 +2678,12 @@
26692678
** [sqlite3_memory_used()] if and only if the parameter to
26702679
** [sqlite3_memory_highwater()] is true. ^The value returned
26712680
** by [sqlite3_memory_highwater(1)] is the high-water mark
26722681
** prior to the reset.
26732682
*/
2674
-SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
2675
-SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
2683
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void);
2684
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag);
26762685
26772686
/*
26782687
** CAPI3REF: Pseudo-Random Number Generator
26792688
**
26802689
** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
@@ -2693,11 +2702,11 @@
26932702
** ^If the previous call to this routine had an N of 1 or more and a
26942703
** non-NULL P then the pseudo-randomness is generated
26952704
** internally and without recourse to the [sqlite3_vfs] xRandomness
26962705
** method.
26972706
*/
2698
-SQLITE_API void sqlite3_randomness(int N, void *P);
2707
+SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P);
26992708
27002709
/*
27012710
** CAPI3REF: Compile-Time Authorization Callbacks
27022711
**
27032712
** ^This routine registers an authorizer callback with a particular
@@ -2775,11 +2784,11 @@
27752784
** [sqlite3_prepare()] or its variants. Authorization is not
27762785
** performed during statement evaluation in [sqlite3_step()], unless
27772786
** as stated in the previous paragraph, sqlite3_step() invokes
27782787
** sqlite3_prepare_v2() to reprepare a statement after a schema change.
27792788
*/
2780
-SQLITE_API int sqlite3_set_authorizer(
2789
+SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
27812790
sqlite3*,
27822791
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
27832792
void *pUserData
27842793
);
27852794
@@ -2879,12 +2888,12 @@
28792888
** digits in the time are meaningless. Future versions of SQLite
28802889
** might provide greater resolution on the profiler callback. The
28812890
** sqlite3_profile() function is considered experimental and is
28822891
** subject to change in future versions of SQLite.
28832892
*/
2884
-SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2885
-SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
2893
+SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2894
+SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
28862895
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
28872896
28882897
/*
28892898
** CAPI3REF: Query Progress Callbacks
28902899
**
@@ -2914,11 +2923,11 @@
29142923
** the database connection that invoked the progress handler.
29152924
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
29162925
** database connections for the meaning of "modify" in this paragraph.
29172926
**
29182927
*/
2919
-SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2928
+SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
29202929
29212930
/*
29222931
** CAPI3REF: Opening A New Database Connection
29232932
**
29242933
** ^These routines open an SQLite database file as specified by the
@@ -3142,19 +3151,19 @@
31423151
** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various
31433152
** features that require the use of temporary files may fail.
31443153
**
31453154
** See also: [sqlite3_temp_directory]
31463155
*/
3147
-SQLITE_API int sqlite3_open(
3156
+SQLITE_API int SQLITE_STDCALL sqlite3_open(
31483157
const char *filename, /* Database filename (UTF-8) */
31493158
sqlite3 **ppDb /* OUT: SQLite db handle */
31503159
);
3151
-SQLITE_API int sqlite3_open16(
3160
+SQLITE_API int SQLITE_STDCALL sqlite3_open16(
31523161
const void *filename, /* Database filename (UTF-16) */
31533162
sqlite3 **ppDb /* OUT: SQLite db handle */
31543163
);
3155
-SQLITE_API int sqlite3_open_v2(
3164
+SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
31563165
const char *filename, /* Database filename (UTF-8) */
31573166
sqlite3 **ppDb, /* OUT: SQLite db handle */
31583167
int flags, /* Flags */
31593168
const char *zVfs /* Name of VFS module to use */
31603169
);
@@ -3196,23 +3205,25 @@
31963205
** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
31973206
** is not a database file pathname pointer that SQLite passed into the xOpen
31983207
** VFS method, then the behavior of this routine is undefined and probably
31993208
** undesirable.
32003209
*/
3201
-SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3202
-SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3203
-SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3210
+SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3211
+SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3212
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
32043213
32053214
32063215
/*
32073216
** CAPI3REF: Error Codes And Messages
32083217
**
3209
-** ^The sqlite3_errcode() interface returns the numeric [result code] or
3210
-** [extended result code] for the most recent failed sqlite3_* API call
3211
-** associated with a [database connection]. If a prior API call failed
3212
-** but the most recent API call succeeded, the return value from
3213
-** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode()
3218
+** ^If the most recent sqlite3_* API call associated with
3219
+** [database connection] D failed, then the sqlite3_errcode(D) interface
3220
+** returns the numeric [result code] or [extended result code] for that
3221
+** API call.
3222
+** If the most recent API call was successful,
3223
+** then the return value from sqlite3_errcode() is undefined.
3224
+** ^The sqlite3_extended_errcode()
32143225
** interface is the same except that it always returns the
32153226
** [extended result code] even when extended result codes are
32163227
** disabled.
32173228
**
32183229
** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -3239,15 +3250,15 @@
32393250
**
32403251
** If an interface fails with SQLITE_MISUSE, that means the interface
32413252
** was invoked incorrectly by the application. In that case, the
32423253
** error code and message may or may not be set.
32433254
*/
3244
-SQLITE_API int sqlite3_errcode(sqlite3 *db);
3245
-SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
3246
-SQLITE_API const char *sqlite3_errmsg(sqlite3*);
3247
-SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
3248
-SQLITE_API const char *sqlite3_errstr(int);
3255
+SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db);
3256
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db);
3257
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*);
3258
+SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*);
3259
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int);
32493260
32503261
/*
32513262
** CAPI3REF: SQL Statement Object
32523263
** KEYWORDS: {prepared statement} {prepared statements}
32533264
**
@@ -3310,11 +3321,11 @@
33103321
** created by an untrusted script can be contained using the
33113322
** [max_page_count] [PRAGMA].
33123323
**
33133324
** New run-time limit categories may be added in future releases.
33143325
*/
3315
-SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
3326
+SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal);
33163327
33173328
/*
33183329
** CAPI3REF: Run-Time Limit Categories
33193330
** KEYWORDS: {limit category} {*limit categories}
33203331
**
@@ -3460,32 +3471,32 @@
34603471
** or [GLOB] operator or if the parameter is compared to an indexed column
34613472
** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
34623473
** </li>
34633474
** </ol>
34643475
*/
3465
-SQLITE_API int sqlite3_prepare(
3476
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
34663477
sqlite3 *db, /* Database handle */
34673478
const char *zSql, /* SQL statement, UTF-8 encoded */
34683479
int nByte, /* Maximum length of zSql in bytes. */
34693480
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
34703481
const char **pzTail /* OUT: Pointer to unused portion of zSql */
34713482
);
3472
-SQLITE_API int sqlite3_prepare_v2(
3483
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
34733484
sqlite3 *db, /* Database handle */
34743485
const char *zSql, /* SQL statement, UTF-8 encoded */
34753486
int nByte, /* Maximum length of zSql in bytes. */
34763487
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
34773488
const char **pzTail /* OUT: Pointer to unused portion of zSql */
34783489
);
3479
-SQLITE_API int sqlite3_prepare16(
3490
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
34803491
sqlite3 *db, /* Database handle */
34813492
const void *zSql, /* SQL statement, UTF-16 encoded */
34823493
int nByte, /* Maximum length of zSql in bytes. */
34833494
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
34843495
const void **pzTail /* OUT: Pointer to unused portion of zSql */
34853496
);
3486
-SQLITE_API int sqlite3_prepare16_v2(
3497
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
34873498
sqlite3 *db, /* Database handle */
34883499
const void *zSql, /* SQL statement, UTF-16 encoded */
34893500
int nByte, /* Maximum length of zSql in bytes. */
34903501
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
34913502
const void **pzTail /* OUT: Pointer to unused portion of zSql */
@@ -3496,11 +3507,11 @@
34963507
**
34973508
** ^This interface can be used to retrieve a saved copy of the original
34983509
** SQL text used to create a [prepared statement] if that statement was
34993510
** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
35003511
*/
3501
-SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
3512
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
35023513
35033514
/*
35043515
** CAPI3REF: Determine If An SQL Statement Writes The Database
35053516
**
35063517
** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
@@ -3527,11 +3538,11 @@
35273538
** database. ^The [ATTACH] and [DETACH] statements also cause
35283539
** sqlite3_stmt_readonly() to return true since, while those statements
35293540
** change the configuration of a database connection, they do not make
35303541
** changes to the content of the database files on disk.
35313542
*/
3532
-SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
3543
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
35333544
35343545
/*
35353546
** CAPI3REF: Determine If A Prepared Statement Has Been Reset
35363547
**
35373548
** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
@@ -3546,11 +3557,11 @@
35463557
** to locate all prepared statements associated with a database
35473558
** connection that are in need of being reset. This can be used,
35483559
** for example, in diagnostic routines to search for prepared
35493560
** statements that are holding a transaction open.
35503561
*/
3551
-SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
3562
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*);
35523563
35533564
/*
35543565
** CAPI3REF: Dynamically Typed Value Object
35553566
** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
35563567
**
@@ -3707,23 +3718,23 @@
37073718
** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
37083719
**
37093720
** See also: [sqlite3_bind_parameter_count()],
37103721
** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
37113722
*/
3712
-SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3713
-SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
3723
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3724
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
37143725
void(*)(void*));
3715
-SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
3716
-SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
3717
-SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3718
-SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
3719
-SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3720
-SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3721
-SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3726
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double);
3727
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int);
3728
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3729
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int);
3730
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3731
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3732
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
37223733
void(*)(void*), unsigned char encoding);
3723
-SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3724
-SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3734
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3735
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
37253736
37263737
/*
37273738
** CAPI3REF: Number Of SQL Parameters
37283739
**
37293740
** ^This routine can be used to find the number of [SQL parameters]
@@ -3739,11 +3750,11 @@
37393750
**
37403751
** See also: [sqlite3_bind_blob|sqlite3_bind()],
37413752
** [sqlite3_bind_parameter_name()], and
37423753
** [sqlite3_bind_parameter_index()].
37433754
*/
3744
-SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
3755
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*);
37453756
37463757
/*
37473758
** CAPI3REF: Name Of A Host Parameter
37483759
**
37493760
** ^The sqlite3_bind_parameter_name(P,N) interface returns
@@ -3766,11 +3777,11 @@
37663777
**
37673778
** See also: [sqlite3_bind_blob|sqlite3_bind()],
37683779
** [sqlite3_bind_parameter_count()], and
37693780
** [sqlite3_bind_parameter_index()].
37703781
*/
3771
-SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3782
+SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int);
37723783
37733784
/*
37743785
** CAPI3REF: Index Of A Parameter With A Given Name
37753786
**
37763787
** ^Return the index of an SQL parameter given its name. ^The
@@ -3782,20 +3793,20 @@
37823793
**
37833794
** See also: [sqlite3_bind_blob|sqlite3_bind()],
37843795
** [sqlite3_bind_parameter_count()], and
37853796
** [sqlite3_bind_parameter_index()].
37863797
*/
3787
-SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3798
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
37883799
37893800
/*
37903801
** CAPI3REF: Reset All Bindings On A Prepared Statement
37913802
**
37923803
** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
37933804
** the [sqlite3_bind_blob | bindings] on a [prepared statement].
37943805
** ^Use this routine to reset all host parameters to NULL.
37953806
*/
3796
-SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
3807
+SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*);
37973808
37983809
/*
37993810
** CAPI3REF: Number Of Columns In A Result Set
38003811
**
38013812
** ^Return the number of columns in the result set returned by the
@@ -3802,11 +3813,11 @@
38023813
** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
38033814
** statement that does not return data (for example an [UPDATE]).
38043815
**
38053816
** See also: [sqlite3_data_count()]
38063817
*/
3807
-SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
3818
+SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt);
38083819
38093820
/*
38103821
** CAPI3REF: Column Names In A Result Set
38113822
**
38123823
** ^These routines return the name assigned to a particular column
@@ -3830,12 +3841,12 @@
38303841
** ^The name of a result column is the value of the "AS" clause for
38313842
** that column, if there is an AS clause. If there is no AS clause
38323843
** then the name of the column is unspecified and may change from
38333844
** one release of SQLite to the next.
38343845
*/
3835
-SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
3836
-SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
3846
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N);
3847
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N);
38373848
38383849
/*
38393850
** CAPI3REF: Source Of Data In A Query Result
38403851
**
38413852
** ^These routines provide a means to determine the database, table, and
@@ -3878,16 +3889,16 @@
38783889
** If two or more threads call one or more
38793890
** [sqlite3_column_database_name | column metadata interfaces]
38803891
** for the same [prepared statement] and result column
38813892
** at the same time then the results are undefined.
38823893
*/
3883
-SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
3884
-SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
3885
-SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
3886
-SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
3887
-SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
3888
-SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
3894
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int);
3895
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int);
3896
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int);
3897
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int);
3898
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int);
3899
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int);
38893900
38903901
/*
38913902
** CAPI3REF: Declared Datatype Of A Query Result
38923903
**
38933904
** ^(The first parameter is a [prepared statement].
@@ -3914,12 +3925,12 @@
39143925
** data stored in that column is of the declared type. SQLite is
39153926
** strongly typed, but the typing is dynamic not static. ^Type
39163927
** is associated with individual values, not with the containers
39173928
** used to hold those values.
39183929
*/
3919
-SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
3920
-SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
3930
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int);
3931
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int);
39213932
39223933
/*
39233934
** CAPI3REF: Evaluate An SQL Statement
39243935
**
39253936
** After a [prepared statement] has been prepared using either
@@ -3994,11 +4005,11 @@
39944005
** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
39954006
** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
39964007
** then the more specific [error codes] are returned directly
39974008
** by sqlite3_step(). The use of the "v2" interface is recommended.
39984009
*/
3999
-SQLITE_API int sqlite3_step(sqlite3_stmt*);
4010
+SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*);
40004011
40014012
/*
40024013
** CAPI3REF: Number of columns in a result set
40034014
**
40044015
** ^The sqlite3_data_count(P) interface returns the number of columns in the
@@ -4014,11 +4025,11 @@
40144025
** where it always returns zero since each step of that multi-step
40154026
** pragma returns 0 columns of data.
40164027
**
40174028
** See also: [sqlite3_column_count()]
40184029
*/
4019
-SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
4030
+SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt);
40204031
40214032
/*
40224033
** CAPI3REF: Fundamental Datatypes
40234034
** KEYWORDS: SQLITE_TEXT
40244035
**
@@ -4210,20 +4221,20 @@
42104221
** of these routines, a default value is returned. The default value
42114222
** is either the integer 0, the floating point number 0.0, or a NULL
42124223
** pointer. Subsequent calls to [sqlite3_errcode()] will return
42134224
** [SQLITE_NOMEM].)^
42144225
*/
4215
-SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
4216
-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4217
-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4218
-SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
4219
-SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
4220
-SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
4221
-SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
4222
-SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
4223
-SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
4224
-SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
4226
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol);
4227
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4228
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4229
+SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol);
4230
+SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol);
4231
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol);
4232
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol);
4233
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol);
4234
+SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol);
4235
+SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol);
42254236
42264237
/*
42274238
** CAPI3REF: Destroy A Prepared Statement Object
42284239
**
42294240
** ^The sqlite3_finalize() function is called to delete a [prepared statement].
@@ -4246,11 +4257,11 @@
42464257
** resource leaks. It is a grievous error for the application to try to use
42474258
** a prepared statement after it has been finalized. Any use of a prepared
42484259
** statement after it has been finalized can result in undefined and
42494260
** undesirable behavior such as segfaults and heap corruption.
42504261
*/
4251
-SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
4262
+SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt);
42524263
42534264
/*
42544265
** CAPI3REF: Reset A Prepared Statement Object
42554266
**
42564267
** The sqlite3_reset() function is called to reset a [prepared statement]
@@ -4272,11 +4283,11 @@
42724283
** [sqlite3_reset(S)] returns an appropriate [error code].
42734284
**
42744285
** ^The [sqlite3_reset(S)] interface does not change the values
42754286
** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
42764287
*/
4277
-SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
4288
+SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt);
42784289
42794290
/*
42804291
** CAPI3REF: Create Or Redefine SQL Functions
42814292
** KEYWORDS: {function creation routines}
42824293
** KEYWORDS: {application-defined SQL function}
@@ -4371,31 +4382,31 @@
43714382
** ^An application-defined function is permitted to call other
43724383
** SQLite interfaces. However, such calls must not
43734384
** close the database connection nor finalize or reset the prepared
43744385
** statement in which the function is running.
43754386
*/
4376
-SQLITE_API int sqlite3_create_function(
4387
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
43774388
sqlite3 *db,
43784389
const char *zFunctionName,
43794390
int nArg,
43804391
int eTextRep,
43814392
void *pApp,
43824393
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
43834394
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
43844395
void (*xFinal)(sqlite3_context*)
43854396
);
4386
-SQLITE_API int sqlite3_create_function16(
4397
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
43874398
sqlite3 *db,
43884399
const void *zFunctionName,
43894400
int nArg,
43904401
int eTextRep,
43914402
void *pApp,
43924403
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
43934404
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
43944405
void (*xFinal)(sqlite3_context*)
43954406
);
4396
-SQLITE_API int sqlite3_create_function_v2(
4407
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
43974408
sqlite3 *db,
43984409
const char *zFunctionName,
43994410
int nArg,
44004411
int eTextRep,
44014412
void *pApp,
@@ -4437,16 +4448,16 @@
44374448
** to be supported. However, new applications should avoid
44384449
** the use of these functions. To encourage programmers to avoid
44394450
** these functions, we will not explain what they do.
44404451
*/
44414452
#ifndef SQLITE_OMIT_DEPRECATED
4442
-SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
4443
-SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
4444
-SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4445
-SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
4446
-SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
4447
-SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4453
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*);
4454
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*);
4455
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4456
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void);
4457
+SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void);
4458
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
44484459
void*,sqlite3_int64);
44494460
#endif
44504461
44514462
/*
44524463
** CAPI3REF: Obtaining SQL Function Parameter Values
@@ -4491,22 +4502,22 @@
44914502
** or [sqlite3_value_text16()].
44924503
**
44934504
** These routines must be called from the same thread as
44944505
** the SQL function that supplied the [sqlite3_value*] parameters.
44954506
*/
4496
-SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4497
-SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
4498
-SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
4499
-SQLITE_API double sqlite3_value_double(sqlite3_value*);
4500
-SQLITE_API int sqlite3_value_int(sqlite3_value*);
4501
-SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4502
-SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
4503
-SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
4504
-SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
4505
-SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
4506
-SQLITE_API int sqlite3_value_type(sqlite3_value*);
4507
-SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
4507
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*);
4508
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*);
4509
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*);
4510
+SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*);
4511
+SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*);
4512
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*);
4513
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*);
4514
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*);
4515
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*);
4516
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*);
4517
+SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*);
4518
+SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*);
45084519
45094520
/*
45104521
** CAPI3REF: Obtain Aggregate Function Context
45114522
**
45124523
** Implementations of aggregate SQL functions use this
@@ -4546,11 +4557,11 @@
45464557
** function.
45474558
**
45484559
** This routine must be called from the same thread in which
45494560
** the aggregate SQL function is running.
45504561
*/
4551
-SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
4562
+SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes);
45524563
45534564
/*
45544565
** CAPI3REF: User Data For Functions
45554566
**
45564567
** ^The sqlite3_user_data() interface returns a copy of
@@ -4560,11 +4571,11 @@
45604571
** registered the application defined function.
45614572
**
45624573
** This routine must be called from the same thread in which
45634574
** the application-defined function is running.
45644575
*/
4565
-SQLITE_API void *sqlite3_user_data(sqlite3_context*);
4576
+SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*);
45664577
45674578
/*
45684579
** CAPI3REF: Database Connection For Functions
45694580
**
45704581
** ^The sqlite3_context_db_handle() interface returns a copy of
@@ -4571,11 +4582,11 @@
45714582
** the pointer to the [database connection] (the 1st parameter)
45724583
** of the [sqlite3_create_function()]
45734584
** and [sqlite3_create_function16()] routines that originally
45744585
** registered the application defined function.
45754586
*/
4576
-SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4587
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
45774588
45784589
/*
45794590
** CAPI3REF: Function Auxiliary Data
45804591
**
45814592
** These functions may be used by (non-aggregate) SQL functions to
@@ -4623,12 +4634,12 @@
46234634
** values and [parameters] and expressions composed from the same.)^
46244635
**
46254636
** These routines must be called from the same thread in which
46264637
** the SQL function is running.
46274638
*/
4628
-SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
4629
-SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
4639
+SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N);
4640
+SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
46304641
46314642
46324643
/*
46334644
** CAPI3REF: Constants Defining Special Destructor Behavior
46344645
**
@@ -4759,30 +4770,30 @@
47594770
**
47604771
** If these routines are called from within the different thread
47614772
** than the one containing the application-defined function that received
47624773
** the [sqlite3_context] pointer, the results are undefined.
47634774
*/
4764
-SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4765
-SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
4775
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4776
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*,
47664777
sqlite3_uint64,void(*)(void*));
4767
-SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
4768
-SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
4769
-SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
4770
-SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
4771
-SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
4772
-SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
4773
-SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
4774
-SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4775
-SQLITE_API void sqlite3_result_null(sqlite3_context*);
4776
-SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4777
-SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
4778
+SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double);
4779
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int);
4780
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int);
4781
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*);
4782
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*);
4783
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int);
4784
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int);
4785
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4786
+SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*);
4787
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4788
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
47784789
void(*)(void*), unsigned char encoding);
4779
-SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4780
-SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4781
-SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4782
-SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4783
-SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
4790
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4791
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4792
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4793
+SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4794
+SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n);
47844795
47854796
/*
47864797
** CAPI3REF: Define New Collating Sequences
47874798
**
47884799
** ^These functions add, remove, or modify a [collation] associated
@@ -4859,26 +4870,26 @@
48594870
** is unfortunate but cannot be changed without breaking backwards
48604871
** compatibility.
48614872
**
48624873
** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
48634874
*/
4864
-SQLITE_API int sqlite3_create_collation(
4875
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
48654876
sqlite3*,
48664877
const char *zName,
48674878
int eTextRep,
48684879
void *pArg,
48694880
int(*xCompare)(void*,int,const void*,int,const void*)
48704881
);
4871
-SQLITE_API int sqlite3_create_collation_v2(
4882
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
48724883
sqlite3*,
48734884
const char *zName,
48744885
int eTextRep,
48754886
void *pArg,
48764887
int(*xCompare)(void*,int,const void*,int,const void*),
48774888
void(*xDestroy)(void*)
48784889
);
4879
-SQLITE_API int sqlite3_create_collation16(
4890
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
48804891
sqlite3*,
48814892
const void *zName,
48824893
int eTextRep,
48834894
void *pArg,
48844895
int(*xCompare)(void*,int,const void*,int,const void*)
@@ -4908,16 +4919,16 @@
49084919
**
49094920
** The callback function should register the desired collation using
49104921
** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
49114922
** [sqlite3_create_collation_v2()].
49124923
*/
4913
-SQLITE_API int sqlite3_collation_needed(
4924
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
49144925
sqlite3*,
49154926
void*,
49164927
void(*)(void*,sqlite3*,int eTextRep,const char*)
49174928
);
4918
-SQLITE_API int sqlite3_collation_needed16(
4929
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
49194930
sqlite3*,
49204931
void*,
49214932
void(*)(void*,sqlite3*,int eTextRep,const void*)
49224933
);
49234934
@@ -4927,15 +4938,15 @@
49274938
** called right after sqlite3_open().
49284939
**
49294940
** The code to implement this API is not available in the public release
49304941
** of SQLite.
49314942
*/
4932
-SQLITE_API int sqlite3_key(
4943
+SQLITE_API int SQLITE_STDCALL sqlite3_key(
49334944
sqlite3 *db, /* Database to be rekeyed */
49344945
const void *pKey, int nKey /* The key */
49354946
);
4936
-SQLITE_API int sqlite3_key_v2(
4947
+SQLITE_API int SQLITE_STDCALL sqlite3_key_v2(
49374948
sqlite3 *db, /* Database to be rekeyed */
49384949
const char *zDbName, /* Name of the database */
49394950
const void *pKey, int nKey /* The key */
49404951
);
49414952
@@ -4945,35 +4956,35 @@
49454956
** database is decrypted.
49464957
**
49474958
** The code to implement this API is not available in the public release
49484959
** of SQLite.
49494960
*/
4950
-SQLITE_API int sqlite3_rekey(
4961
+SQLITE_API int SQLITE_STDCALL sqlite3_rekey(
49514962
sqlite3 *db, /* Database to be rekeyed */
49524963
const void *pKey, int nKey /* The new key */
49534964
);
4954
-SQLITE_API int sqlite3_rekey_v2(
4965
+SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2(
49554966
sqlite3 *db, /* Database to be rekeyed */
49564967
const char *zDbName, /* Name of the database */
49574968
const void *pKey, int nKey /* The new key */
49584969
);
49594970
49604971
/*
49614972
** Specify the activation key for a SEE database. Unless
49624973
** activated, none of the SEE routines will work.
49634974
*/
4964
-SQLITE_API void sqlite3_activate_see(
4975
+SQLITE_API void SQLITE_STDCALL sqlite3_activate_see(
49654976
const char *zPassPhrase /* Activation phrase */
49664977
);
49674978
#endif
49684979
49694980
#ifdef SQLITE_ENABLE_CEROD
49704981
/*
49714982
** Specify the activation key for a CEROD database. Unless
49724983
** activated, none of the CEROD routines will work.
49734984
*/
4974
-SQLITE_API void sqlite3_activate_cerod(
4985
+SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod(
49754986
const char *zPassPhrase /* Activation phrase */
49764987
);
49774988
#endif
49784989
49794990
/*
@@ -4991,11 +5002,11 @@
49915002
** method of the default [sqlite3_vfs] object. If the xSleep() method
49925003
** of the default VFS is not implemented correctly, or not implemented at
49935004
** all, then the behavior of sqlite3_sleep() may deviate from the description
49945005
** in the previous paragraphs.
49955006
*/
4996
-SQLITE_API int sqlite3_sleep(int);
5007
+SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int);
49975008
49985009
/*
49995010
** CAPI3REF: Name Of The Folder Holding Temporary Files
50005011
**
50015012
** ^(If this global variable is made to point to a string which is
@@ -5109,11 +5120,11 @@
51095120
**
51105121
** If another thread changes the autocommit status of the database
51115122
** connection while this routine is running, then the return value
51125123
** is undefined.
51135124
*/
5114
-SQLITE_API int sqlite3_get_autocommit(sqlite3*);
5125
+SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*);
51155126
51165127
/*
51175128
** CAPI3REF: Find The Database Handle Of A Prepared Statement
51185129
**
51195130
** ^The sqlite3_db_handle interface returns the [database connection] handle
@@ -5121,11 +5132,11 @@
51215132
** returned by sqlite3_db_handle is the same [database connection]
51225133
** that was the first argument
51235134
** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
51245135
** create the statement in the first place.
51255136
*/
5126
-SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
5137
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*);
51275138
51285139
/*
51295140
** CAPI3REF: Return The Filename For A Database Connection
51305141
**
51315142
** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
@@ -5137,20 +5148,20 @@
51375148
** ^The filename returned by this function is the output of the
51385149
** xFullPathname method of the [VFS]. ^In other words, the filename
51395150
** will be an absolute pathname, even if the filename used
51405151
** to open the database originally was a URI or relative pathname.
51415152
*/
5142
-SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
5153
+SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName);
51435154
51445155
/*
51455156
** CAPI3REF: Determine if a database is read-only
51465157
**
51475158
** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
51485159
** of connection D is read-only, 0 if it is read/write, or -1 if N is not
51495160
** the name of a database on connection D.
51505161
*/
5151
-SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
5162
+SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
51525163
51535164
/*
51545165
** CAPI3REF: Find the next prepared statement
51555166
**
51565167
** ^This interface returns a pointer to the next [prepared statement] after
@@ -5161,11 +5172,11 @@
51615172
**
51625173
** The [database connection] pointer D in a call to
51635174
** [sqlite3_next_stmt(D,S)] must refer to an open database
51645175
** connection and in particular must not be a NULL pointer.
51655176
*/
5166
-SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
5177
+SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
51675178
51685179
/*
51695180
** CAPI3REF: Commit And Rollback Notification Callbacks
51705181
**
51715182
** ^The sqlite3_commit_hook() interface registers a callback
@@ -5209,12 +5220,12 @@
52095220
** ^The rollback callback is not invoked if a transaction is
52105221
** automatically rolled back because the database connection is closed.
52115222
**
52125223
** See also the [sqlite3_update_hook()] interface.
52135224
*/
5214
-SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5215
-SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
5225
+SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5226
+SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
52165227
52175228
/*
52185229
** CAPI3REF: Data Change Notification Callbacks
52195230
**
52205231
** ^The sqlite3_update_hook() interface registers a callback function
@@ -5260,11 +5271,11 @@
52605271
** the first call on D.
52615272
**
52625273
** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
52635274
** interfaces.
52645275
*/
5265
-SQLITE_API void *sqlite3_update_hook(
5276
+SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
52665277
sqlite3*,
52675278
void(*)(void *,int ,char const *,char const *,sqlite3_int64),
52685279
void*
52695280
);
52705281
@@ -5300,11 +5311,11 @@
53005311
** This interface is threadsafe on processors where writing a
53015312
** 32-bit integer is atomic.
53025313
**
53035314
** See Also: [SQLite Shared-Cache Mode]
53045315
*/
5305
-SQLITE_API int sqlite3_enable_shared_cache(int);
5316
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int);
53065317
53075318
/*
53085319
** CAPI3REF: Attempt To Free Heap Memory
53095320
**
53105321
** ^The sqlite3_release_memory() interface attempts to free N bytes
@@ -5316,11 +5327,11 @@
53165327
** ^The sqlite3_release_memory() routine is a no-op returning zero
53175328
** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
53185329
**
53195330
** See also: [sqlite3_db_release_memory()]
53205331
*/
5321
-SQLITE_API int sqlite3_release_memory(int);
5332
+SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int);
53225333
53235334
/*
53245335
** CAPI3REF: Free Memory Used By A Database Connection
53255336
**
53265337
** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
@@ -5329,11 +5340,11 @@
53295340
** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
53305341
** omitted.
53315342
**
53325343
** See also: [sqlite3_release_memory()]
53335344
*/
5334
-SQLITE_API int sqlite3_db_release_memory(sqlite3*);
5345
+SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*);
53355346
53365347
/*
53375348
** CAPI3REF: Impose A Limit On Heap Size
53385349
**
53395350
** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
@@ -5381,11 +5392,11 @@
53815392
** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
53825393
**
53835394
** The circumstances under which SQLite will enforce the soft heap limit may
53845395
** changes in future releases of SQLite.
53855396
*/
5386
-SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
5397
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N);
53875398
53885399
/*
53895400
** CAPI3REF: Deprecated Soft Heap Limit Interface
53905401
** DEPRECATED
53915402
**
@@ -5392,11 +5403,11 @@
53925403
** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
53935404
** interface. This routine is provided for historical compatibility
53945405
** only. All new applications should use the
53955406
** [sqlite3_soft_heap_limit64()] interface rather than this one.
53965407
*/
5397
-SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
5408
+SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
53985409
53995410
54005411
/*
54015412
** CAPI3REF: Extract Metadata About A Column Of A Table
54025413
**
@@ -5461,11 +5472,11 @@
54615472
**
54625473
** ^This function causes all database schemas to be read from disk and
54635474
** parsed, if that has not already been done, and returns an error if
54645475
** any errors are encountered while loading the schema.
54655476
*/
5466
-SQLITE_API int sqlite3_table_column_metadata(
5477
+SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
54675478
sqlite3 *db, /* Connection handle */
54685479
const char *zDbName, /* Database name or NULL */
54695480
const char *zTableName, /* Table name */
54705481
const char *zColumnName, /* Column name */
54715482
char const **pzDataType, /* OUTPUT: Declared data type */
@@ -5507,11 +5518,11 @@
55075518
** [sqlite3_enable_load_extension()] prior to calling this API,
55085519
** otherwise an error will be returned.
55095520
**
55105521
** See also the [load_extension() SQL function].
55115522
*/
5512
-SQLITE_API int sqlite3_load_extension(
5523
+SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
55135524
sqlite3 *db, /* Load the extension into this database connection */
55145525
const char *zFile, /* Name of the shared library containing extension */
55155526
const char *zProc, /* Entry point. Derived from zFile if 0 */
55165527
char **pzErrMsg /* Put error message here if not 0 */
55175528
);
@@ -5527,11 +5538,11 @@
55275538
** ^Extension loading is off by default.
55285539
** ^Call the sqlite3_enable_load_extension() routine with onoff==1
55295540
** to turn extension loading on and call it with onoff==0 to turn
55305541
** it back off again.
55315542
*/
5532
-SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
5543
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
55335544
55345545
/*
55355546
** CAPI3REF: Automatically Load Statically Linked Extensions
55365547
**
55375548
** ^This interface causes the xEntryPoint() function to be invoked for
@@ -5565,11 +5576,11 @@
55655576
** will be called more than once for each database connection that is opened.
55665577
**
55675578
** See also: [sqlite3_reset_auto_extension()]
55685579
** and [sqlite3_cancel_auto_extension()]
55695580
*/
5570
-SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
5581
+SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
55715582
55725583
/*
55735584
** CAPI3REF: Cancel Automatic Extension Loading
55745585
**
55755586
** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5577,19 +5588,19 @@
55775588
** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
55785589
** routine returns 1 if initialization routine X was successfully
55795590
** unregistered and it returns 0 if X was not on the list of initialization
55805591
** routines.
55815592
*/
5582
-SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5593
+SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
55835594
55845595
/*
55855596
** CAPI3REF: Reset Automatic Extension Loading
55865597
**
55875598
** ^This interface disables all automatic extensions previously
55885599
** registered using [sqlite3_auto_extension()].
55895600
*/
5590
-SQLITE_API void sqlite3_reset_auto_extension(void);
5601
+SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void);
55915602
55925603
/*
55935604
** The interface to the virtual-table mechanism is currently considered
55945605
** to be experimental. The interface might change in incompatible ways.
55955606
** If this is a problem for you, do not use the interface at this time.
@@ -5788,17 +5799,17 @@
57885799
** be invoked if the call to sqlite3_create_module_v2() fails.
57895800
** ^The sqlite3_create_module()
57905801
** interface is equivalent to sqlite3_create_module_v2() with a NULL
57915802
** destructor.
57925803
*/
5793
-SQLITE_API int sqlite3_create_module(
5804
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
57945805
sqlite3 *db, /* SQLite connection to register module with */
57955806
const char *zName, /* Name of the module */
57965807
const sqlite3_module *p, /* Methods for the module */
57975808
void *pClientData /* Client data for xCreate/xConnect */
57985809
);
5799
-SQLITE_API int sqlite3_create_module_v2(
5810
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
58005811
sqlite3 *db, /* SQLite connection to register module with */
58015812
const char *zName, /* Name of the module */
58025813
const sqlite3_module *p, /* Methods for the module */
58035814
void *pClientData, /* Client data for xCreate/xConnect */
58045815
void(*xDestroy)(void*) /* Module destructor function */
@@ -5822,11 +5833,11 @@
58225833
** is delivered up to the client application, the string will be automatically
58235834
** freed by sqlite3_free() and the zErrMsg field will be zeroed.
58245835
*/
58255836
struct sqlite3_vtab {
58265837
const sqlite3_module *pModule; /* The module for this virtual table */
5827
- int nRef; /* NO LONGER USED */
5838
+ int nRef; /* Number of open cursors */
58285839
char *zErrMsg; /* Error message from sqlite3_mprintf() */
58295840
/* Virtual table implementations will typically add additional fields */
58305841
};
58315842
58325843
/*
@@ -5857,11 +5868,11 @@
58575868
** ^The [xCreate] and [xConnect] methods of a
58585869
** [virtual table module] call this interface
58595870
** to declare the format (the names and datatypes of the columns) of
58605871
** the virtual tables they implement.
58615872
*/
5862
-SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
5873
+SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL);
58635874
58645875
/*
58655876
** CAPI3REF: Overload A Function For A Virtual Table
58665877
**
58675878
** ^(Virtual tables can provide alternative implementations of functions
@@ -5875,11 +5886,11 @@
58755886
** of the new function always causes an exception to be thrown. So
58765887
** the new function is not good for anything by itself. Its only
58775888
** purpose is to be a placeholder function that can be overloaded
58785889
** by a [virtual table].
58795890
*/
5880
-SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
5891
+SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
58815892
58825893
/*
58835894
** The interface to the virtual-table mechanism defined above (back up
58845895
** to a comment remarkably similar to this one) is currently considered
58855896
** to be experimental. The interface might change in incompatible ways.
@@ -5972,11 +5983,11 @@
59725983
** zero-filled blob to read or write using the incremental-blob interface.
59735984
**
59745985
** To avoid a resource leak, every open [BLOB handle] should eventually
59755986
** be released by a call to [sqlite3_blob_close()].
59765987
*/
5977
-SQLITE_API int sqlite3_blob_open(
5988
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
59785989
sqlite3*,
59795990
const char *zDb,
59805991
const char *zTable,
59815992
const char *zColumn,
59825993
sqlite3_int64 iRow,
@@ -6004,11 +6015,11 @@
60046015
** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
60056016
** always returns zero.
60066017
**
60076018
** ^This function sets the database handle error code and message.
60086019
*/
6009
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
6020
+SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
60106021
60116022
/*
60126023
** CAPI3REF: Close A BLOB Handle
60136024
**
60146025
** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
@@ -6026,11 +6037,11 @@
60266037
** with a null pointer (such as would be returned by a failed call to
60276038
** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
60286039
** is passed a valid open blob handle, the values returned by the
60296040
** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
60306041
*/
6031
-SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
6042
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *);
60326043
60336044
/*
60346045
** CAPI3REF: Return The Size Of An Open BLOB
60356046
**
60366047
** ^Returns the size in bytes of the BLOB accessible via the
@@ -6041,11 +6052,11 @@
60416052
** This routine only works on a [BLOB handle] which has been created
60426053
** by a prior successful call to [sqlite3_blob_open()] and which has not
60436054
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
60446055
** to this routine results in undefined and probably undesirable behavior.
60456056
*/
6046
-SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
6057
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *);
60476058
60486059
/*
60496060
** CAPI3REF: Read Data From A BLOB Incrementally
60506061
**
60516062
** ^(This function is used to read data from an open [BLOB handle] into a
@@ -6069,11 +6080,11 @@
60696080
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
60706081
** to this routine results in undefined and probably undesirable behavior.
60716082
**
60726083
** See also: [sqlite3_blob_write()].
60736084
*/
6074
-SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
6085
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
60756086
60766087
/*
60776088
** CAPI3REF: Write Data Into A BLOB Incrementally
60786089
**
60796090
** ^(This function is used to write data into an open [BLOB handle] from a
@@ -6110,11 +6121,11 @@
61106121
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
61116122
** to this routine results in undefined and probably undesirable behavior.
61126123
**
61136124
** See also: [sqlite3_blob_read()].
61146125
*/
6115
-SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
6126
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
61166127
61176128
/*
61186129
** CAPI3REF: Virtual File System Objects
61196130
**
61206131
** A virtual filesystem (VFS) is an [sqlite3_vfs] object
@@ -6141,13 +6152,13 @@
61416152
**
61426153
** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
61436154
** ^(If the default VFS is unregistered, another VFS is chosen as
61446155
** the default. The choice for the new VFS is arbitrary.)^
61456156
*/
6146
-SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
6147
-SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
6148
-SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
6157
+SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName);
6158
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
6159
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*);
61496160
61506161
/*
61516162
** CAPI3REF: Mutexes
61526163
**
61536164
** The SQLite core uses these routines for thread
@@ -6256,15 +6267,15 @@
62566267
** sqlite3_mutex_leave() is a NULL pointer, then all three routines
62576268
** behave as no-ops.
62586269
**
62596270
** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
62606271
*/
6261
-SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
6262
-SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
6263
-SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
6264
-SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
6265
-SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
6272
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int);
6273
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*);
6274
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*);
6275
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*);
6276
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*);
62666277
62676278
/*
62686279
** CAPI3REF: Mutex Methods Object
62696280
**
62706281
** An instance of this structure defines the low-level routines
@@ -6370,12 +6381,12 @@
63706381
** call to sqlite3_mutex_held() to fail, so a non-zero return is
63716382
** the appropriate thing to do. The sqlite3_mutex_notheld()
63726383
** interface should also return 1 when given a NULL pointer.
63736384
*/
63746385
#ifndef NDEBUG
6375
-SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
6376
-SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
6386
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*);
6387
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*);
63776388
#endif
63786389
63796390
/*
63806391
** CAPI3REF: Mutex Types
63816392
**
@@ -6407,11 +6418,11 @@
64076418
** serializes access to the [database connection] given in the argument
64086419
** when the [threading mode] is Serialized.
64096420
** ^If the [threading mode] is Single-thread or Multi-thread then this
64106421
** routine returns a NULL pointer.
64116422
*/
6412
-SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
6423
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*);
64136424
64146425
/*
64156426
** CAPI3REF: Low-Level Control Of Database Files
64166427
**
64176428
** ^The [sqlite3_file_control()] interface makes a direct call to the
@@ -6441,11 +6452,11 @@
64416452
** an incorrect zDbName and an SQLITE_ERROR return from the underlying
64426453
** xFileControl method.
64436454
**
64446455
** See also: [SQLITE_FCNTL_LOCKSTATE]
64456456
*/
6446
-SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
6457
+SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
64476458
64486459
/*
64496460
** CAPI3REF: Testing Interface
64506461
**
64516462
** ^The sqlite3_test_control() interface is used to read out internal
@@ -6460,11 +6471,11 @@
64606471
** The details of the operation codes, their meanings, the parameters
64616472
** they take, and what they do are all subject to change without notice.
64626473
** Unlike most of the SQLite API, this function is not guaranteed to
64636474
** operate consistently from one release to the next.
64646475
*/
6465
-SQLITE_API int sqlite3_test_control(int op, ...);
6476
+SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...);
64666477
64676478
/*
64686479
** CAPI3REF: Testing Interface Operation Codes
64696480
**
64706481
** These constants are the valid operation code parameters used
@@ -6500,11 +6511,11 @@
65006511
#define SQLITE_TESTCTRL_LAST 25
65016512
65026513
/*
65036514
** CAPI3REF: SQLite Runtime Status
65046515
**
6505
-** ^This interface is used to retrieve runtime status information
6516
+** ^These interfaces are used to retrieve runtime status information
65066517
** about the performance of SQLite, and optionally to reset various
65076518
** highwater marks. ^The first argument is an integer code for
65086519
** the specific parameter to measure. ^(Recognized integer codes
65096520
** are of the form [status parameters | SQLITE_STATUS_...].)^
65106521
** ^The current value of the parameter is returned into *pCurrent.
@@ -6514,23 +6525,26 @@
65146525
** value. For those parameters
65156526
** nothing is written into *pHighwater and the resetFlag is ignored.)^
65166527
** ^(Other parameters record only the highwater mark and not the current
65176528
** value. For these latter parameters nothing is written into *pCurrent.)^
65186529
**
6519
-** ^The sqlite3_status() routine returns SQLITE_OK on success and a
6520
-** non-zero [error code] on failure.
6530
+** ^The sqlite3_status() and sqlite3_status64() routines return
6531
+** SQLITE_OK on success and a non-zero [error code] on failure.
65216532
**
6522
-** This routine is threadsafe but is not atomic. This routine can be
6523
-** called while other threads are running the same or different SQLite
6524
-** interfaces. However the values returned in *pCurrent and
6525
-** *pHighwater reflect the status of SQLite at different points in time
6526
-** and it is possible that another thread might change the parameter
6527
-** in between the times when *pCurrent and *pHighwater are written.
6533
+** If either the current value or the highwater mark is too large to
6534
+** be represented by a 32-bit integer, then the values returned by
6535
+** sqlite3_status() are undefined.
65286536
**
65296537
** See also: [sqlite3_db_status()]
65306538
*/
6531
-SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6539
+SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6540
+SQLITE_API int SQLITE_STDCALL sqlite3_status64(
6541
+ int op,
6542
+ sqlite3_int64 *pCurrent,
6543
+ sqlite3_int64 *pHighwater,
6544
+ int resetFlag
6545
+);
65326546
65336547
65346548
/*
65356549
** CAPI3REF: Status Parameters
65366550
** KEYWORDS: {status parameters}
@@ -6644,11 +6658,11 @@
66446658
** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
66456659
** non-zero [error code] on failure.
66466660
**
66476661
** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
66486662
*/
6649
-SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
6663
+SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
66506664
66516665
/*
66526666
** CAPI3REF: Status Parameters for database connections
66536667
** KEYWORDS: {SQLITE_DBSTATUS options}
66546668
**
@@ -6773,11 +6787,11 @@
67736787
** ^If the resetFlg is true, then the counter is reset to zero after this
67746788
** interface call returns.
67756789
**
67766790
** See also: [sqlite3_status()] and [sqlite3_db_status()].
67776791
*/
6778
-SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
6792
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
67796793
67806794
/*
67816795
** CAPI3REF: Status Parameters for prepared statements
67826796
** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}
67836797
**
@@ -7242,20 +7256,20 @@
72427256
** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
72437257
** APIs are not strictly speaking threadsafe. If they are invoked at the
72447258
** same time as another thread is invoking sqlite3_backup_step() it is
72457259
** possible that they return invalid values.
72467260
*/
7247
-SQLITE_API sqlite3_backup *sqlite3_backup_init(
7261
+SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
72487262
sqlite3 *pDest, /* Destination database handle */
72497263
const char *zDestName, /* Destination database name */
72507264
sqlite3 *pSource, /* Source database handle */
72517265
const char *zSourceName /* Source database name */
72527266
);
7253
-SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
7254
-SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
7255
-SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
7256
-SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
7267
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage);
7268
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p);
7269
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p);
7270
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p);
72577271
72587272
/*
72597273
** CAPI3REF: Unlock Notification
72607274
**
72617275
** ^When running in shared-cache mode, a database operation may fail with
@@ -7367,11 +7381,11 @@
73677381
** by an sqlite3_step() call. ^(If there is a blocking connection, then the
73687382
** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
73697383
** the special "DROP TABLE/INDEX" case, the extended error code is just
73707384
** SQLITE_LOCKED.)^
73717385
*/
7372
-SQLITE_API int sqlite3_unlock_notify(
7386
+SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
73737387
sqlite3 *pBlocked, /* Waiting connection */
73747388
void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
73757389
void *pNotifyArg /* Argument to pass to xNotify */
73767390
);
73777391
@@ -7382,12 +7396,12 @@
73827396
** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
73837397
** and extensions to compare the contents of two buffers containing UTF-8
73847398
** strings in a case-independent fashion, using the same definition of "case
73857399
** independence" that SQLite uses internally when comparing identifiers.
73867400
*/
7387
-SQLITE_API int sqlite3_stricmp(const char *, const char *);
7388
-SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
7401
+SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *);
7402
+SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
73897403
73907404
/*
73917405
** CAPI3REF: String Globbing
73927406
*
73937407
** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
@@ -7398,11 +7412,11 @@
73987412
** sensitive.
73997413
**
74007414
** Note that this routine returns zero on a match and non-zero if the strings
74017415
** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
74027416
*/
7403
-SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
7417
+SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
74047418
74057419
/*
74067420
** CAPI3REF: Error Logging Interface
74077421
**
74087422
** ^The [sqlite3_log()] interface writes a message into the [error log]
@@ -7421,11 +7435,11 @@
74217435
** will not use dynamically allocated memory. The log message is stored in
74227436
** a fixed-length buffer on the stack. If the log message is longer than
74237437
** a few hundred characters, it will be truncated to the length of the
74247438
** buffer.
74257439
*/
7426
-SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
7440
+SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...);
74277441
74287442
/*
74297443
** CAPI3REF: Write-Ahead Log Commit Hook
74307444
**
74317445
** ^The [sqlite3_wal_hook()] function is used to register a callback that
@@ -7456,11 +7470,11 @@
74567470
** previously registered write-ahead log callback. ^Note that the
74577471
** [sqlite3_wal_autocheckpoint()] interface and the
74587472
** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
74597473
** those overwrite any prior [sqlite3_wal_hook()] settings.
74607474
*/
7461
-SQLITE_API void *sqlite3_wal_hook(
7475
+SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
74627476
sqlite3*,
74637477
int(*)(void *,sqlite3*,const char*,int),
74647478
void*
74657479
);
74667480
@@ -7490,11 +7504,11 @@
74907504
** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
74917505
** pages. The use of this interface
74927506
** is only necessary if the default setting is found to be suboptimal
74937507
** for a particular application.
74947508
*/
7495
-SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
7509
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
74967510
74977511
/*
74987512
** CAPI3REF: Checkpoint a database
74997513
**
75007514
** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
@@ -7511,11 +7525,11 @@
75117525
** interface was added. This interface is retained for backwards
75127526
** compatibility and as a convenience for applications that need to manually
75137527
** start a callback but which do not need the full power (and corresponding
75147528
** complication) of [sqlite3_wal_checkpoint_v2()].
75157529
*/
7516
-SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
7530
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
75177531
75187532
/*
75197533
** CAPI3REF: Checkpoint a database
75207534
**
75217535
** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
@@ -7604,11 +7618,11 @@
76047618
** [sqlite3_errcode()] and [sqlite3_errmsg()].
76057619
**
76067620
** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
76077621
** from SQL.
76087622
*/
7609
-SQLITE_API int sqlite3_wal_checkpoint_v2(
7623
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
76107624
sqlite3 *db, /* Database handle */
76117625
const char *zDb, /* Name of attached database (or NULL) */
76127626
int eMode, /* SQLITE_CHECKPOINT_* value */
76137627
int *pnLog, /* OUT: Size of WAL log in frames */
76147628
int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -7640,11 +7654,11 @@
76407654
**
76417655
** At present, there is only one option that may be configured using
76427656
** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
76437657
** may be added in the future.
76447658
*/
7645
-SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
7659
+SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...);
76467660
76477661
/*
76487662
** CAPI3REF: Virtual Table Configuration Options
76497663
**
76507664
** These macros define the various options to the
@@ -7693,11 +7707,11 @@
76937707
** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],
76947708
** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode
76957709
** of the SQL statement that triggered the call to the [xUpdate] method of the
76967710
** [virtual table].
76977711
*/
7698
-SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
7712
+SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *);
76997713
77007714
/*
77017715
** CAPI3REF: Conflict resolution modes
77027716
** KEYWORDS: {conflict resolution mode}
77037717
**
@@ -7797,11 +7811,11 @@
77977811
** as if the loop did not exist - it returns non-zero and leave the variable
77987812
** that pOut points to unchanged.
77997813
**
78007814
** See also: [sqlite3_stmt_scanstatus_reset()]
78017815
*/
7802
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_scanstatus(
7816
+SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_stmt_scanstatus(
78037817
sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
78047818
int idx, /* Index of loop to report on */
78057819
int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
78067820
void *pOut /* Result written here */
78077821
);
@@ -7812,11 +7826,11 @@
78127826
** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
78137827
**
78147828
** This API is only available if the library is built with pre-processor
78157829
** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
78167830
*/
7817
-SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
7831
+SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
78187832
78197833
78207834
/*
78217835
** Undo the hack that converts floating point types to integer for
78227836
** builds on processors without floating point support.
@@ -7867,11 +7881,11 @@
78677881
** Register a geometry callback named zGeom that can be used as part of an
78687882
** R-Tree geometry query as follows:
78697883
**
78707884
** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
78717885
*/
7872
-SQLITE_API int sqlite3_rtree_geometry_callback(
7886
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
78737887
sqlite3 *db,
78747888
const char *zGeom,
78757889
int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
78767890
void *pContext
78777891
);
@@ -7893,11 +7907,11 @@
78937907
** Register a 2nd-generation geometry callback named zScore that can be
78947908
** used as part of an R-Tree geometry query as follows:
78957909
**
78967910
** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
78977911
*/
7898
-SQLITE_API int sqlite3_rtree_query_callback(
7912
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
78997913
sqlite3 *db,
79007914
const char *zQueryFunc,
79017915
int (*xQueryFunc)(sqlite3_rtree_query_info*),
79027916
void *pContext,
79037917
void (*xDestructor)(void*)
@@ -8911,10 +8925,24 @@
89118925
**
89128926
** 0.5 -> -10 0.1 -> -33 0.0625 -> -40
89138927
*/
89148928
typedef INT16_TYPE LogEst;
89158929
8930
+/*
8931
+** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer
8932
+*/
8933
+#ifndef SQLITE_PTRSIZE
8934
+# if defined(__SIZEOF_POINTER__)
8935
+# define SQLITE_PTRSIZE __SIZEOF_POINTER__
8936
+# elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \
8937
+ defined(_M_ARM) || defined(__arm__) || defined(__x86)
8938
+# define SQLITE_PTRSIZE 4
8939
+# else
8940
+# define SQLITE_PTRSIZE 8
8941
+# endif
8942
+#endif
8943
+
89168944
/*
89178945
** Macros to determine whether the machine is big or little endian,
89188946
** and whether or not that determination is run-time or compile-time.
89198947
**
89208948
** For best performance, an attempt is made to guess at the byte-order
@@ -9123,12 +9151,12 @@
91239151
*/
91249152
#ifdef SQLITE_OMIT_WSD
91259153
#define SQLITE_WSD const
91269154
#define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
91279155
#define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
9128
-SQLITE_API int sqlite3_wsd_init(int N, int J);
9129
-SQLITE_API void *sqlite3_wsd_find(void *K, int L);
9156
+SQLITE_API int SQLITE_STDCALL sqlite3_wsd_init(int N, int J);
9157
+SQLITE_API void *SQLITE_STDCALL sqlite3_wsd_find(void *K, int L);
91309158
#else
91319159
#define SQLITE_WSD
91329160
#define GLOBAL(t,v) v
91339161
#define sqlite3GlobalConfig sqlite3Config
91349162
#endif
@@ -9361,12 +9389,22 @@
93619389
#define BTREE_DATA_VERSION 15 /* A virtual meta-value */
93629390
93639391
/*
93649392
** Values that may be OR'd together to form the second argument of an
93659393
** sqlite3BtreeCursorHints() call.
9394
+**
9395
+** The BTREE_BULKLOAD flag is set on index cursors when the index is going
9396
+** to be filled with content that is already in sorted order.
9397
+**
9398
+** The BTREE_SEEK_EQ flag is set on cursors that will get OP_SeekGE or
9399
+** OP_SeekLE opcodes for a range search, but where the range of entries
9400
+** selected will all have the same key. In other words, the cursor will
9401
+** be used only for equality key searches.
9402
+**
93669403
*/
9367
-#define BTREE_BULKLOAD 0x00000001
9404
+#define BTREE_BULKLOAD 0x00000001 /* Used to full index in sorted order */
9405
+#define BTREE_SEEK_EQ 0x00000002 /* EQ seeks only - no range seeks */
93689406
93699407
SQLITE_PRIVATE int sqlite3BtreeCursor(
93709408
Btree*, /* BTree containing table to open */
93719409
int iTable, /* Index of root page */
93729410
int wrFlag, /* 1 for writing. 0 for read-only */
@@ -9408,10 +9446,13 @@
94089446
SQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
94099447
SQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *);
94109448
SQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *);
94119449
SQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);
94129450
SQLITE_PRIVATE void sqlite3BtreeCursorHints(BtCursor *, unsigned int mask);
9451
+#ifdef SQLITE_DEBUG
9452
+SQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor*, unsigned int mask);
9453
+#endif
94139454
SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *pBt);
94149455
SQLITE_PRIVATE int sqlite3HeaderSizeBtree(void);
94159456
94169457
#ifndef NDEBUG
94179458
SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*);
@@ -10908,10 +10949,11 @@
1090810949
} init;
1090910950
int nVdbeActive; /* Number of VDBEs currently running */
1091010951
int nVdbeRead; /* Number of active VDBEs that read or write */
1091110952
int nVdbeWrite; /* Number of active VDBEs that read and write */
1091210953
int nVdbeExec; /* Number of nested calls to VdbeExec() */
10954
+ int nVDestroy; /* Number of active OP_VDestroy operations */
1091310955
int nExtension; /* Number of loaded extensions */
1091410956
void **aExtension; /* Array of shared library handles */
1091510957
void (*xTrace)(void*,const char*); /* Trace function */
1091610958
void *pTraceArg; /* Argument to the trace function */
1091710959
void (*xProfile)(void*,const char*,u64); /* Profiling function */
@@ -12502,11 +12544,12 @@
1250212544
#define OPFLAG_APPEND 0x08 /* This is likely to be an append */
1250312545
#define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
1250412546
#define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */
1250512547
#define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */
1250612548
#define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */
12507
-#define OPFLAG_P2ISREG 0x02 /* P2 to OP_Open** is a register number */
12549
+#define OPFLAG_SEEKEQ 0x02 /* OP_Open** cursor uses EQ seek only */
12550
+#define OPFLAG_P2ISREG 0x04 /* P2 to OP_Open** is a register number */
1250812551
#define OPFLAG_PERMUTE 0x01 /* OP_Compare: use the permutation */
1250912552
1251012553
/*
1251112554
* Each trigger present in the database schema is stored as an instance of
1251212555
* struct Trigger.
@@ -12906,14 +12949,19 @@
1290612949
SQLITE_PRIVATE sqlite3_mutex *sqlite3MutexAlloc(int);
1290712950
SQLITE_PRIVATE int sqlite3MutexInit(void);
1290812951
SQLITE_PRIVATE int sqlite3MutexEnd(void);
1290912952
#endif
1291012953
12911
-SQLITE_PRIVATE int sqlite3StatusValue(int);
12912
-SQLITE_PRIVATE void sqlite3StatusAdd(int, int);
12954
+SQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int);
12955
+SQLITE_PRIVATE void sqlite3StatusUp(int, int);
12956
+SQLITE_PRIVATE void sqlite3StatusDown(int, int);
1291312957
SQLITE_PRIVATE void sqlite3StatusSet(int, int);
1291412958
12959
+/* Access to mutexes used by sqlite3_status() */
12960
+SQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void);
12961
+SQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void);
12962
+
1291512963
#ifndef SQLITE_OMIT_FLOATING_POINT
1291612964
SQLITE_PRIVATE int sqlite3IsNaN(double);
1291712965
#else
1291812966
# define sqlite3IsNaN(X) 0
1291912967
#endif
@@ -13289,11 +13337,11 @@
1328913337
SQLITE_PRIVATE const char *sqlite3ErrStr(int);
1329013338
SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);
1329113339
SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);
1329213340
SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);
1329313341
SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
13294
-SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*);
13342
+SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
1329513343
SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
1329613344
SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
1329713345
SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
1329813346
SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *, const char *);
1329913347
SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);
@@ -13592,11 +13640,11 @@
1359213640
** print I/O tracing messages.
1359313641
*/
1359413642
#ifdef SQLITE_ENABLE_IOTRACE
1359513643
# define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; }
1359613644
SQLITE_PRIVATE void sqlite3VdbeIOTraceSql(Vdbe*);
13597
-void (*sqlite3IoTrace)(const char*,...);
13645
+SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);
1359813646
#else
1359913647
# define IOTRACE(A)
1360013648
# define sqlite3VdbeIOTraceSql(X)
1360113649
#endif
1360213650
@@ -14305,11 +14353,11 @@
1430514353
** was used and false if not.
1430614354
**
1430714355
** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
1430814356
** is not required for a match.
1430914357
*/
14310
-SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
14358
+SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName){
1431114359
int i, n;
1431214360
1431314361
#if SQLITE_ENABLE_API_ARMOR
1431414362
if( zOptName==0 ){
1431514363
(void)SQLITE_MISUSE_BKPT;
@@ -14333,11 +14381,11 @@
1433314381
1433414382
/*
1433514383
** Return the N-th compile-time option string. If N is out of range,
1433614384
** return a NULL pointer.
1433714385
*/
14338
-SQLITE_API const char *sqlite3_compileoption_get(int N){
14386
+SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N){
1433914387
if( N>=0 && N<ArraySize(azCompileOpt) ){
1434014388
return azCompileOpt[N];
1434114389
}
1434214390
return 0;
1434314391
}
@@ -14676,18 +14724,10 @@
1467614724
** An instance of the virtual machine. This structure contains the complete
1467714725
** state of the virtual machine.
1467814726
**
1467914727
** The "sqlite3_stmt" structure pointer that is returned by sqlite3_prepare()
1468014728
** is really a pointer to an instance of this structure.
14681
-**
14682
-** The Vdbe.inVtabMethod variable is set to non-zero for the duration of
14683
-** any virtual table method invocations made by the vdbe program. It is
14684
-** set to 2 for xDestroy method calls and 1 for all other methods. This
14685
-** variable is used for two purposes: to allow xDestroy methods to execute
14686
-** "DROP TABLE" statements and to prevent some nasty side effects of
14687
-** malloc failure when SQLite is invoked recursively by a virtual table
14688
-** method function.
1468914729
*/
1469014730
struct Vdbe {
1469114731
sqlite3 *db; /* The database connection that owns this statement */
1469214732
Op *aOp; /* Space to hold the virtual machine's program */
1469314733
Mem *aMem; /* The memory locations */
@@ -14714,11 +14754,10 @@
1471414754
#endif
1471514755
u16 nResColumn; /* Number of columns in one row of the result set */
1471614756
u8 errorAction; /* Recovery action to do in case of an error */
1471714757
u8 minWriteFileFormat; /* Minimum file format for writable database files */
1471814758
bft explain:2; /* True if EXPLAIN present on SQL command */
14719
- bft inVtabMethod:2; /* See comments above */
1472014759
bft changeCntOn:1; /* True to update the change-counter */
1472114760
bft expired:1; /* True if the VM needs to be recompiled */
1472214761
bft runOnlyOnce:1; /* Automatically expire on reset */
1472314762
bft usesStmtJournal:1; /* True if uses a statement journal */
1472414763
bft readOnly:1; /* True for statements that do not write */
@@ -14874,13 +14913,35 @@
1487414913
/*
1487514914
** Variables in which to record status information.
1487614915
*/
1487714916
typedef struct sqlite3StatType sqlite3StatType;
1487814917
static SQLITE_WSD struct sqlite3StatType {
14879
- int nowValue[10]; /* Current value */
14880
- int mxValue[10]; /* Maximum value */
14918
+#if SQLITE_PTRSIZE>4
14919
+ sqlite3_int64 nowValue[10]; /* Current value */
14920
+ sqlite3_int64 mxValue[10]; /* Maximum value */
14921
+#else
14922
+ u32 nowValue[10]; /* Current value */
14923
+ u32 mxValue[10]; /* Maximum value */
14924
+#endif
1488114925
} sqlite3Stat = { {0,}, {0,} };
14926
+
14927
+/*
14928
+** Elements of sqlite3Stat[] are protected by either the memory allocator
14929
+** mutex, or by the pcache1 mutex. The following array determines which.
14930
+*/
14931
+static const char statMutex[] = {
14932
+ 0, /* SQLITE_STATUS_MEMORY_USED */
14933
+ 1, /* SQLITE_STATUS_PAGECACHE_USED */
14934
+ 1, /* SQLITE_STATUS_PAGECACHE_OVERFLOW */
14935
+ 0, /* SQLITE_STATUS_SCRATCH_USED */
14936
+ 0, /* SQLITE_STATUS_SCRATCH_OVERFLOW */
14937
+ 0, /* SQLITE_STATUS_MALLOC_SIZE */
14938
+ 0, /* SQLITE_STATUS_PARSER_STACK */
14939
+ 1, /* SQLITE_STATUS_PAGECACHE_SIZE */
14940
+ 0, /* SQLITE_STATUS_SCRATCH_SIZE */
14941
+ 0, /* SQLITE_STATUS_MALLOC_COUNT */
14942
+};
1488214943
1488314944
1488414945
/* The "wsdStat" macro will resolve to the status information
1488514946
** state vector. If writable static data is unsupported on the target,
1488614947
** we have to locate the state vector at run-time. In the more common
@@ -14894,70 +14955,116 @@
1489414955
# define wsdStatInit
1489514956
# define wsdStat sqlite3Stat
1489614957
#endif
1489714958
1489814959
/*
14899
-** Return the current value of a status parameter.
14960
+** Return the current value of a status parameter. The caller must
14961
+** be holding the appropriate mutex.
1490014962
*/
14901
-SQLITE_PRIVATE int sqlite3StatusValue(int op){
14963
+SQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int op){
1490214964
wsdStatInit;
1490314965
assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
14966
+ assert( op>=0 && op<ArraySize(statMutex) );
14967
+ assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()
14968
+ : sqlite3MallocMutex()) );
1490414969
return wsdStat.nowValue[op];
1490514970
}
1490614971
1490714972
/*
14908
-** Add N to the value of a status record. It is assumed that the
14909
-** caller holds appropriate locks.
14973
+** Add N to the value of a status record. The caller must hold the
14974
+** appropriate mutex. (Locking is checked by assert()).
14975
+**
14976
+** The StatusUp() routine can accept positive or negative values for N.
14977
+** The value of N is added to the current status value and the high-water
14978
+** mark is adjusted if necessary.
14979
+**
14980
+** The StatusDown() routine lowers the current value by N. The highwater
14981
+** mark is unchanged. N must be non-negative for StatusDown().
1491014982
*/
14911
-SQLITE_PRIVATE void sqlite3StatusAdd(int op, int N){
14983
+SQLITE_PRIVATE void sqlite3StatusUp(int op, int N){
1491214984
wsdStatInit;
1491314985
assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
14986
+ assert( op>=0 && op<ArraySize(statMutex) );
14987
+ assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()
14988
+ : sqlite3MallocMutex()) );
1491414989
wsdStat.nowValue[op] += N;
1491514990
if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){
1491614991
wsdStat.mxValue[op] = wsdStat.nowValue[op];
1491714992
}
1491814993
}
14994
+SQLITE_PRIVATE void sqlite3StatusDown(int op, int N){
14995
+ wsdStatInit;
14996
+ assert( N>=0 );
14997
+ assert( op>=0 && op<ArraySize(statMutex) );
14998
+ assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()
14999
+ : sqlite3MallocMutex()) );
15000
+ assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
15001
+ wsdStat.nowValue[op] -= N;
15002
+}
1491915003
1492015004
/*
14921
-** Set the value of a status to X.
15005
+** Set the value of a status to X. The highwater mark is adjusted if
15006
+** necessary. The caller must hold the appropriate mutex.
1492215007
*/
1492315008
SQLITE_PRIVATE void sqlite3StatusSet(int op, int X){
1492415009
wsdStatInit;
1492515010
assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
15011
+ assert( op>=0 && op<ArraySize(statMutex) );
15012
+ assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()
15013
+ : sqlite3MallocMutex()) );
1492615014
wsdStat.nowValue[op] = X;
1492715015
if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){
1492815016
wsdStat.mxValue[op] = wsdStat.nowValue[op];
1492915017
}
1493015018
}
1493115019
1493215020
/*
1493315021
** Query status information.
14934
-**
14935
-** This implementation assumes that reading or writing an aligned
14936
-** 32-bit integer is an atomic operation. If that assumption is not true,
14937
-** then this routine is not threadsafe.
1493815022
*/
14939
-SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
15023
+SQLITE_API int SQLITE_STDCALL sqlite3_status64(
15024
+ int op,
15025
+ sqlite3_int64 *pCurrent,
15026
+ sqlite3_int64 *pHighwater,
15027
+ int resetFlag
15028
+){
15029
+ sqlite3_mutex *pMutex;
1494015030
wsdStatInit;
1494115031
if( op<0 || op>=ArraySize(wsdStat.nowValue) ){
1494215032
return SQLITE_MISUSE_BKPT;
1494315033
}
1494415034
#ifdef SQLITE_ENABLE_API_ARMOR
1494515035
if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;
1494615036
#endif
15037
+ pMutex = statMutex[op] ? sqlite3Pcache1Mutex() : sqlite3MallocMutex();
15038
+ sqlite3_mutex_enter(pMutex);
1494715039
*pCurrent = wsdStat.nowValue[op];
1494815040
*pHighwater = wsdStat.mxValue[op];
1494915041
if( resetFlag ){
1495015042
wsdStat.mxValue[op] = wsdStat.nowValue[op];
1495115043
}
15044
+ sqlite3_mutex_leave(pMutex);
15045
+ (void)pMutex; /* Prevent warning when SQLITE_THREADSAFE=0 */
1495215046
return SQLITE_OK;
15047
+}
15048
+SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
15049
+ sqlite3_int64 iCur, iHwtr;
15050
+ int rc;
15051
+#ifdef SQLITE_ENABLE_API_ARMOR
15052
+ if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;
15053
+#endif
15054
+ rc = sqlite3_status64(op, &iCur, &iHwtr, resetFlag);
15055
+ if( rc==0 ){
15056
+ *pCurrent = (int)iCur;
15057
+ *pHighwater = (int)iHwtr;
15058
+ }
15059
+ return rc;
1495315060
}
1495415061
1495515062
/*
1495615063
** Query status information for a single database connection
1495715064
*/
14958
-SQLITE_API int sqlite3_db_status(
15065
+SQLITE_API int SQLITE_STDCALL sqlite3_db_status(
1495915066
sqlite3 *db, /* The database connection whose status is desired */
1496015067
int op, /* Status verb */
1496115068
int *pCurrent, /* Write current value here */
1496215069
int *pHighwater, /* Write high-water mark here */
1496315070
int resetFlag /* Reset high-water mark if true */
@@ -16577,11 +16684,11 @@
1657716684
1657816685
/*
1657916686
** Locate a VFS by name. If no name is given, simply return the
1658016687
** first VFS on the list.
1658116688
*/
16582
-SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){
16689
+SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfs){
1658316690
sqlite3_vfs *pVfs = 0;
1658416691
#if SQLITE_THREADSAFE
1658516692
sqlite3_mutex *mutex;
1658616693
#endif
1658716694
#ifndef SQLITE_OMIT_AUTOINIT
@@ -16623,11 +16730,11 @@
1662316730
/*
1662416731
** Register a VFS with the system. It is harmless to register the same
1662516732
** VFS multiple times. The new VFS becomes the default if makeDflt is
1662616733
** true.
1662716734
*/
16628
-SQLITE_API int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
16735
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
1662916736
MUTEX_LOGIC(sqlite3_mutex *mutex;)
1663016737
#ifndef SQLITE_OMIT_AUTOINIT
1663116738
int rc = sqlite3_initialize();
1663216739
if( rc ) return rc;
1663316740
#endif
@@ -16651,11 +16758,11 @@
1665116758
}
1665216759
1665316760
/*
1665416761
** Unregister a VFS so that it is no longer accessible.
1665516762
*/
16656
-SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
16763
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
1665716764
#if SQLITE_THREADSAFE
1665816765
sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
1665916766
#endif
1666016767
sqlite3_mutex_enter(mutex);
1666116768
vfsUnlink(pVfs);
@@ -18987,11 +19094,11 @@
1898719094
}
1898819095
1898919096
/*
1899019097
** Retrieve a pointer to a static mutex or allocate a new dynamic one.
1899119098
*/
18992
-SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int id){
19099
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int id){
1899319100
#ifndef SQLITE_OMIT_AUTOINIT
1899419101
if( id<=SQLITE_MUTEX_RECURSIVE && sqlite3_initialize() ) return 0;
1899519102
if( id>SQLITE_MUTEX_RECURSIVE && sqlite3MutexInit() ) return 0;
1899619103
#endif
1899719104
return sqlite3GlobalConfig.mutex.xMutexAlloc(id);
@@ -19006,31 +19113,31 @@
1900619113
}
1900719114
1900819115
/*
1900919116
** Free a dynamic mutex.
1901019117
*/
19011
-SQLITE_API void sqlite3_mutex_free(sqlite3_mutex *p){
19118
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex *p){
1901219119
if( p ){
1901319120
sqlite3GlobalConfig.mutex.xMutexFree(p);
1901419121
}
1901519122
}
1901619123
1901719124
/*
1901819125
** Obtain the mutex p. If some other thread already has the mutex, block
1901919126
** until it can be obtained.
1902019127
*/
19021
-SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex *p){
19128
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex *p){
1902219129
if( p ){
1902319130
sqlite3GlobalConfig.mutex.xMutexEnter(p);
1902419131
}
1902519132
}
1902619133
1902719134
/*
1902819135
** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another
1902919136
** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.
1903019137
*/
19031
-SQLITE_API int sqlite3_mutex_try(sqlite3_mutex *p){
19138
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex *p){
1903219139
int rc = SQLITE_OK;
1903319140
if( p ){
1903419141
return sqlite3GlobalConfig.mutex.xMutexTry(p);
1903519142
}
1903619143
return rc;
@@ -19040,11 +19147,11 @@
1904019147
** The sqlite3_mutex_leave() routine exits a mutex that was previously
1904119148
** entered by the same thread. The behavior is undefined if the mutex
1904219149
** is not currently entered. If a NULL pointer is passed as an argument
1904319150
** this function is a no-op.
1904419151
*/
19045
-SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex *p){
19152
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex *p){
1904619153
if( p ){
1904719154
sqlite3GlobalConfig.mutex.xMutexLeave(p);
1904819155
}
1904919156
}
1905019157
@@ -19051,14 +19158,14 @@
1905119158
#ifndef NDEBUG
1905219159
/*
1905319160
** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are
1905419161
** intended for use inside assert() statements.
1905519162
*/
19056
-SQLITE_API int sqlite3_mutex_held(sqlite3_mutex *p){
19163
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex *p){
1905719164
return p==0 || sqlite3GlobalConfig.mutex.xMutexHeld(p);
1905819165
}
19059
-SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){
19166
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex *p){
1906019167
return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
1906119168
}
1906219169
#endif
1906319170
1906419171
#endif /* !defined(SQLITE_MUTEX_OMIT) */
@@ -20050,12 +20157,12 @@
2005020157
** of the sqlite3_initialize() and sqlite3_shutdown() processing, the
2005120158
** "interlocked" magic used here is probably not strictly necessary.
2005220159
*/
2005320160
static LONG SQLITE_WIN32_VOLATILE winMutex_lock = 0;
2005420161
20055
-SQLITE_API int sqlite3_win32_is_nt(void); /* os_win.c */
20056
-SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */
20162
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_is_nt(void); /* os_win.c */
20163
+SQLITE_API void SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */
2005720164
2005820165
static int winMutexInit(void){
2005920166
/* The first to increment to 1 does actual initialization */
2006020167
if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){
2006120168
int i;
@@ -20347,11 +20454,11 @@
2034720454
/*
2034820455
** Attempt to release up to n bytes of non-essential memory currently
2034920456
** held by SQLite. An example of non-essential memory is memory used to
2035020457
** cache database pages that are not currently in use.
2035120458
*/
20352
-SQLITE_API int sqlite3_release_memory(int n){
20459
+SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int n){
2035320460
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
2035420461
return sqlite3PcacheReleaseMemory(n);
2035520462
#else
2035620463
/* IMPLEMENTATION-OF: R-34391-24921 The sqlite3_release_memory() routine
2035720464
** is a no-op returning zero if SQLite is not compiled with
@@ -20401,10 +20508,17 @@
2040120508
*/
2040220509
int nearlyFull;
2040320510
} mem0 = { 0, 0, 0, 0, 0, 0, 0, 0 };
2040420511
2040520512
#define mem0 GLOBAL(struct Mem0Global, mem0)
20513
+
20514
+/*
20515
+** Return the memory allocator mutex. sqlite3_status() needs it.
20516
+*/
20517
+SQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void){
20518
+ return mem0.mutex;
20519
+}
2040620520
2040720521
/*
2040820522
** This routine runs when the memory allocator sees that the
2040920523
** total memory allocation is about to exceed the soft heap
2041020524
** limit.
@@ -20424,11 +20538,11 @@
2042420538
static int sqlite3MemoryAlarm(
2042520539
void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
2042620540
void *pArg,
2042720541
sqlite3_int64 iThreshold
2042820542
){
20429
- int nUsed;
20543
+ sqlite3_int64 nUsed;
2043020544
sqlite3_mutex_enter(mem0.mutex);
2043120545
mem0.alarmCallback = xCallback;
2043220546
mem0.alarmArg = pArg;
2043320547
mem0.alarmThreshold = iThreshold;
2043420548
nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
@@ -20440,11 +20554,11 @@
2044020554
#ifndef SQLITE_OMIT_DEPRECATED
2044120555
/*
2044220556
** Deprecated external interface. Internal/core SQLite code
2044320557
** should call sqlite3MemoryAlarm.
2044420558
*/
20445
-SQLITE_API int sqlite3_memory_alarm(
20559
+SQLITE_API int SQLITE_STDCALL sqlite3_memory_alarm(
2044620560
void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
2044720561
void *pArg,
2044820562
sqlite3_int64 iThreshold
2044920563
){
2045020564
return sqlite3MemoryAlarm(xCallback, pArg, iThreshold);
@@ -20453,11 +20567,11 @@
2045320567
2045420568
/*
2045520569
** Set the soft heap-size limit for the library. Passing a zero or
2045620570
** negative value indicates no limit.
2045720571
*/
20458
-SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){
20572
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 n){
2045920573
sqlite3_int64 priorLimit;
2046020574
sqlite3_int64 excess;
2046120575
#ifndef SQLITE_OMIT_AUTOINIT
2046220576
int rc = sqlite3_initialize();
2046320577
if( rc ) return -1;
@@ -20473,19 +20587,20 @@
2047320587
}
2047420588
excess = sqlite3_memory_used() - n;
2047520589
if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff));
2047620590
return priorLimit;
2047720591
}
20478
-SQLITE_API void sqlite3_soft_heap_limit(int n){
20592
+SQLITE_API void SQLITE_STDCALL sqlite3_soft_heap_limit(int n){
2047920593
if( n<0 ) n = 0;
2048020594
sqlite3_soft_heap_limit64(n);
2048120595
}
2048220596
2048320597
/*
2048420598
** Initialize the memory allocation subsystem.
2048520599
*/
2048620600
SQLITE_PRIVATE int sqlite3MallocInit(void){
20601
+ int rc;
2048720602
if( sqlite3GlobalConfig.m.xMalloc==0 ){
2048820603
sqlite3MemSetDefault();
2048920604
}
2049020605
memset(&mem0, 0, sizeof(mem0));
2049120606
if( sqlite3GlobalConfig.bCoreMutex ){
@@ -20517,11 +20632,13 @@
2051720632
|| sqlite3GlobalConfig.nPage<1 ){
2051820633
sqlite3GlobalConfig.pPage = 0;
2051920634
sqlite3GlobalConfig.szPage = 0;
2052020635
sqlite3GlobalConfig.nPage = 0;
2052120636
}
20522
- return sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
20637
+ rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
20638
+ if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));
20639
+ return rc;
2052320640
}
2052420641
2052520642
/*
2052620643
** Return true if the heap is currently under memory pressure - in other
2052720644
** words if the amount of heap used is close to the limit set by
@@ -20542,11 +20659,11 @@
2054220659
}
2054320660
2054420661
/*
2054520662
** Return the amount of memory currently checked out.
2054620663
*/
20547
-SQLITE_API sqlite3_int64 sqlite3_memory_used(void){
20664
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void){
2054820665
int n, mx;
2054920666
sqlite3_int64 res;
2055020667
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, 0);
2055120668
res = (sqlite3_int64)n; /* Work around bug in Borland C. Ticket #3216 */
2055220669
return res;
@@ -20555,11 +20672,11 @@
2055520672
/*
2055620673
** Return the maximum amount of memory that has ever been
2055720674
** checked out since either the beginning of this process
2055820675
** or since the most recent reset.
2055920676
*/
20560
-SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag){
20677
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag){
2056120678
int n, mx;
2056220679
sqlite3_int64 res;
2056320680
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, resetFlag);
2056420681
res = (sqlite3_int64)mx; /* Work around bug in Borland C. Ticket #3216 */
2056520682
return res;
@@ -20593,11 +20710,11 @@
2059320710
void *p;
2059420711
assert( sqlite3_mutex_held(mem0.mutex) );
2059520712
nFull = sqlite3GlobalConfig.m.xRoundup(n);
2059620713
sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n);
2059720714
if( mem0.alarmCallback!=0 ){
20598
- int nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
20715
+ sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
2059920716
if( nUsed >= mem0.alarmThreshold - nFull ){
2060020717
mem0.nearlyFull = 1;
2060120718
sqlite3MallocAlarm(nFull);
2060220719
}else{
2060320720
mem0.nearlyFull = 0;
@@ -20610,12 +20727,12 @@
2061020727
p = sqlite3GlobalConfig.m.xMalloc(nFull);
2061120728
}
2061220729
#endif
2061320730
if( p ){
2061420731
nFull = sqlite3MallocSize(p);
20615
- sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull);
20616
- sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, 1);
20732
+ sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nFull);
20733
+ sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1);
2061720734
}
2061820735
*pp = p;
2061920736
return nFull;
2062020737
}
2062120738
@@ -20646,17 +20763,17 @@
2064620763
/*
2064720764
** This version of the memory allocation is for use by the application.
2064820765
** First make sure the memory subsystem is initialized, then do the
2064920766
** allocation.
2065020767
*/
20651
-SQLITE_API void *sqlite3_malloc(int n){
20768
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int n){
2065220769
#ifndef SQLITE_OMIT_AUTOINIT
2065320770
if( sqlite3_initialize() ) return 0;
2065420771
#endif
2065520772
return n<=0 ? 0 : sqlite3Malloc(n);
2065620773
}
20657
-SQLITE_API void *sqlite3_malloc64(sqlite3_uint64 n){
20774
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64 n){
2065820775
#ifndef SQLITE_OMIT_AUTOINIT
2065920776
if( sqlite3_initialize() ) return 0;
2066020777
#endif
2066120778
return sqlite3Malloc(n);
2066220779
}
@@ -20688,18 +20805,18 @@
2068820805
sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);
2068920806
if( mem0.nScratchFree && sqlite3GlobalConfig.szScratch>=n ){
2069020807
p = mem0.pScratchFree;
2069120808
mem0.pScratchFree = mem0.pScratchFree->pNext;
2069220809
mem0.nScratchFree--;
20693
- sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1);
20810
+ sqlite3StatusUp(SQLITE_STATUS_SCRATCH_USED, 1);
2069420811
sqlite3_mutex_leave(mem0.mutex);
2069520812
}else{
2069620813
sqlite3_mutex_leave(mem0.mutex);
2069720814
p = sqlite3Malloc(n);
2069820815
if( sqlite3GlobalConfig.bMemstat && p ){
2069920816
sqlite3_mutex_enter(mem0.mutex);
20700
- sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, sqlite3MallocSize(p));
20817
+ sqlite3StatusUp(SQLITE_STATUS_SCRATCH_OVERFLOW, sqlite3MallocSize(p));
2070120818
sqlite3_mutex_leave(mem0.mutex);
2070220819
}
2070320820
sqlite3MemdebugSetType(p, MEMTYPE_SCRATCH);
2070420821
}
2070520822
assert( sqlite3_mutex_notheld(mem0.mutex) );
@@ -20736,23 +20853,23 @@
2073620853
sqlite3_mutex_enter(mem0.mutex);
2073720854
pSlot->pNext = mem0.pScratchFree;
2073820855
mem0.pScratchFree = pSlot;
2073920856
mem0.nScratchFree++;
2074020857
assert( mem0.nScratchFree <= (u32)sqlite3GlobalConfig.nScratch );
20741
- sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1);
20858
+ sqlite3StatusDown(SQLITE_STATUS_SCRATCH_USED, 1);
2074220859
sqlite3_mutex_leave(mem0.mutex);
2074320860
}else{
2074420861
/* Release memory back to the heap */
2074520862
assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) );
20746
- assert( sqlite3MemdebugNoType(p, ~MEMTYPE_SCRATCH) );
20863
+ assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_SCRATCH) );
2074720864
sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
2074820865
if( sqlite3GlobalConfig.bMemstat ){
2074920866
int iSize = sqlite3MallocSize(p);
2075020867
sqlite3_mutex_enter(mem0.mutex);
20751
- sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize);
20752
- sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize);
20753
- sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1);
20868
+ sqlite3StatusDown(SQLITE_STATUS_SCRATCH_OVERFLOW, iSize);
20869
+ sqlite3StatusDown(SQLITE_STATUS_MEMORY_USED, iSize);
20870
+ sqlite3StatusDown(SQLITE_STATUS_MALLOC_COUNT, 1);
2075420871
sqlite3GlobalConfig.m.xFree(p);
2075520872
sqlite3_mutex_leave(mem0.mutex);
2075620873
}else{
2075720874
sqlite3GlobalConfig.m.xFree(p);
2075820875
}
@@ -20779,41 +20896,41 @@
2077920896
assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
2078020897
return sqlite3GlobalConfig.m.xSize(p);
2078120898
}
2078220899
SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){
2078320900
if( db==0 ){
20784
- assert( sqlite3MemdebugNoType(p, ~MEMTYPE_HEAP) );
20901
+ assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
2078520902
assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
2078620903
return sqlite3MallocSize(p);
2078720904
}else{
2078820905
assert( sqlite3_mutex_held(db->mutex) );
2078920906
if( isLookaside(db, p) ){
2079020907
return db->lookaside.sz;
2079120908
}else{
2079220909
assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
20793
- assert( sqlite3MemdebugNoType(p, ~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
20910
+ assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
2079420911
return sqlite3GlobalConfig.m.xSize(p);
2079520912
}
2079620913
}
2079720914
}
20798
-SQLITE_API sqlite3_uint64 sqlite3_msize(void *p){
20799
- assert( sqlite3MemdebugNoType(p, ~MEMTYPE_HEAP) );
20915
+SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void *p){
20916
+ assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
2080020917
assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
2080120918
return (sqlite3_uint64)sqlite3GlobalConfig.m.xSize(p);
2080220919
}
2080320920
2080420921
/*
2080520922
** Free memory previously obtained from sqlite3Malloc().
2080620923
*/
20807
-SQLITE_API void sqlite3_free(void *p){
20924
+SQLITE_API void SQLITE_STDCALL sqlite3_free(void *p){
2080820925
if( p==0 ) return; /* IMP: R-49053-54554 */
2080920926
assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
20810
- assert( sqlite3MemdebugNoType(p, ~MEMTYPE_HEAP) );
20927
+ assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
2081120928
if( sqlite3GlobalConfig.bMemstat ){
2081220929
sqlite3_mutex_enter(mem0.mutex);
20813
- sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -sqlite3MallocSize(p));
20814
- sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1);
20930
+ sqlite3StatusDown(SQLITE_STATUS_MEMORY_USED, sqlite3MallocSize(p));
20931
+ sqlite3StatusDown(SQLITE_STATUS_MALLOC_COUNT, 1);
2081520932
sqlite3GlobalConfig.m.xFree(p);
2081620933
sqlite3_mutex_leave(mem0.mutex);
2081720934
}else{
2081820935
sqlite3GlobalConfig.m.xFree(p);
2081920936
}
@@ -20850,11 +20967,11 @@
2085020967
db->lookaside.nOut--;
2085120968
return;
2085220969
}
2085320970
}
2085420971
assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
20855
- assert( sqlite3MemdebugNoType(p, ~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
20972
+ assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
2085620973
assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) );
2085720974
sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
2085820975
sqlite3_free(p);
2085920976
}
2086020977
@@ -20863,11 +20980,11 @@
2086320980
*/
2086420981
SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, u64 nBytes){
2086520982
int nOld, nNew, nDiff;
2086620983
void *pNew;
2086720984
assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) );
20868
- assert( sqlite3MemdebugNoType(pOld, ~MEMTYPE_HEAP) );
20985
+ assert( sqlite3MemdebugNoType(pOld, (u8)~MEMTYPE_HEAP) );
2086920986
if( pOld==0 ){
2087020987
return sqlite3Malloc(nBytes); /* IMP: R-04300-56712 */
2087120988
}
2087220989
if( nBytes==0 ){
2087320990
sqlite3_free(pOld); /* IMP: R-26507-47431 */
@@ -20897,11 +21014,11 @@
2089721014
sqlite3MallocAlarm((int)nBytes);
2089821015
pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
2089921016
}
2090021017
if( pNew ){
2090121018
nNew = sqlite3MallocSize(pNew);
20902
- sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld);
21019
+ sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nNew-nOld);
2090321020
}
2090421021
sqlite3_mutex_leave(mem0.mutex);
2090521022
}else{
2090621023
pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
2090721024
}
@@ -20911,18 +21028,18 @@
2091121028
2091221029
/*
2091321030
** The public interface to sqlite3Realloc. Make sure that the memory
2091421031
** subsystem is initialized prior to invoking sqliteRealloc.
2091521032
*/
20916
-SQLITE_API void *sqlite3_realloc(void *pOld, int n){
21033
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void *pOld, int n){
2091721034
#ifndef SQLITE_OMIT_AUTOINIT
2091821035
if( sqlite3_initialize() ) return 0;
2091921036
#endif
2092021037
if( n<0 ) n = 0; /* IMP: R-26507-47431 */
2092121038
return sqlite3Realloc(pOld, n);
2092221039
}
20923
-SQLITE_API void *sqlite3_realloc64(void *pOld, sqlite3_uint64 n){
21040
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void *pOld, sqlite3_uint64 n){
2092421041
#ifndef SQLITE_OMIT_AUTOINIT
2092521042
if( sqlite3_initialize() ) return 0;
2092621043
#endif
2092721044
return sqlite3Realloc(pOld, n);
2092821045
}
@@ -21030,11 +21147,11 @@
2103021147
memcpy(pNew, p, db->lookaside.sz);
2103121148
sqlite3DbFree(db, p);
2103221149
}
2103321150
}else{
2103421151
assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
21035
- assert( sqlite3MemdebugNoType(p, ~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
21152
+ assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
2103621153
sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
2103721154
pNew = sqlite3_realloc64(p, n);
2103821155
if( !pNew ){
2103921156
db->mallocFailed = 1;
2104021157
}
@@ -22084,11 +22201,11 @@
2208422201
2208522202
/*
2208622203
** Print into memory obtained from sqlite3_malloc(). Omit the internal
2208722204
** %-conversion extensions.
2208822205
*/
22089
-SQLITE_API char *sqlite3_vmprintf(const char *zFormat, va_list ap){
22206
+SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char *zFormat, va_list ap){
2209022207
char *z;
2209122208
char zBase[SQLITE_PRINT_BUF_SIZE];
2209222209
StrAccum acc;
2209322210
2209422211
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -22109,11 +22226,11 @@
2210922226
2211022227
/*
2211122228
** Print into memory obtained from sqlite3_malloc()(). Omit the internal
2211222229
** %-conversion extensions.
2211322230
*/
22114
-SQLITE_API char *sqlite3_mprintf(const char *zFormat, ...){
22231
+SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char *zFormat, ...){
2211522232
va_list ap;
2211622233
char *z;
2211722234
#ifndef SQLITE_OMIT_AUTOINIT
2211822235
if( sqlite3_initialize() ) return 0;
2211922236
#endif
@@ -22134,11 +22251,11 @@
2213422251
** this without breaking compatibility, so we just have to live with the
2213522252
** mistake.
2213622253
**
2213722254
** sqlite3_vsnprintf() is the varargs version.
2213822255
*/
22139
-SQLITE_API char *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){
22256
+SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){
2214022257
StrAccum acc;
2214122258
if( n<=0 ) return zBuf;
2214222259
#ifdef SQLITE_ENABLE_API_ARMOR
2214322260
if( zBuf==0 || zFormat==0 ) {
2214422261
(void)SQLITE_MISUSE_BKPT;
@@ -22149,11 +22266,11 @@
2214922266
sqlite3StrAccumInit(&acc, zBuf, n, 0);
2215022267
acc.useMalloc = 0;
2215122268
sqlite3VXPrintf(&acc, 0, zFormat, ap);
2215222269
return sqlite3StrAccumFinish(&acc);
2215322270
}
22154
-SQLITE_API char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
22271
+SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
2215522272
char *z;
2215622273
va_list ap;
2215722274
va_start(ap,zFormat);
2215822275
z = sqlite3_vsnprintf(n, zBuf, zFormat, ap);
2215922276
va_end(ap);
@@ -22181,11 +22298,11 @@
2218122298
}
2218222299
2218322300
/*
2218422301
** Format and write a message to the log if logging is enabled.
2218522302
*/
22186
-SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...){
22303
+SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...){
2218722304
va_list ap; /* Vararg list */
2218822305
if( sqlite3GlobalConfig.xLog ){
2218922306
va_start(ap, zFormat);
2219022307
renderLogMsg(iErrCode, zFormat, ap);
2219122308
va_end(ap);
@@ -22317,11 +22434,11 @@
2231722434
} sqlite3Prng;
2231822435
2231922436
/*
2232022437
** Return N random bytes.
2232122438
*/
22322
-SQLITE_API void sqlite3_randomness(int N, void *pBuf){
22439
+SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *pBuf){
2232322440
unsigned char t;
2232422441
unsigned char *zBuf = pBuf;
2232522442
2232622443
/* The "wsdPrng" macro will resolve to the pseudo-random number generator
2232722444
** state vector. If writable static data is unsupported on the target,
@@ -23469,11 +23586,11 @@
2346923586
** sqlite3_strnicmp() APIs allow applications and extensions to compare
2347023587
** the contents of two buffers containing UTF-8 strings in a
2347123588
** case-independent fashion, using the same definition of "case
2347223589
** independence" that SQLite uses internally when comparing identifiers.
2347323590
*/
23474
-SQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){
23591
+SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *zLeft, const char *zRight){
2347523592
register unsigned char *a, *b;
2347623593
if( zLeft==0 ){
2347723594
return zRight ? -1 : 0;
2347823595
}else if( zRight==0 ){
2347923596
return 1;
@@ -23481,11 +23598,11 @@
2348123598
a = (unsigned char *)zLeft;
2348223599
b = (unsigned char *)zRight;
2348323600
while( *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }
2348423601
return UpperToLower[*a] - UpperToLower[*b];
2348523602
}
23486
-SQLITE_API int sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){
23603
+SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){
2348723604
register unsigned char *a, *b;
2348823605
if( zLeft==0 ){
2348923606
return zRight ? -1 : 0;
2349023607
}else if( zRight==0 ){
2349123608
return 1;
@@ -25287,10 +25404,11 @@
2528725404
#define UNIXFILE_PSOW 0x10 /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */
2528825405
#define UNIXFILE_DELETE 0x20 /* Delete on close */
2528925406
#define UNIXFILE_URI 0x40 /* Filename might have query parameters */
2529025407
#define UNIXFILE_NOLOCK 0x80 /* Do no file locking */
2529125408
#define UNIXFILE_WARNED 0x0100 /* verifyDbFile() warnings issued */
25409
+#define UNIXFILE_BLOCK 0x0200 /* Next SHM lock might block */
2529225410
2529325411
/*
2529425412
** Include code that is common to all os_*.c files
2529525413
*/
2529625414
/************** Include os_common.h in the middle of os_unix.c ***************/
@@ -26782,11 +26900,11 @@
2678226900
2678326901
assert( pFile );
2678426902
OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (unix)\n", pFile->h,
2678526903
azFileLock(eFileLock), azFileLock(pFile->eFileLock),
2678626904
azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared,
26787
- osGetpid()));
26905
+ osGetpid(0)));
2678826906
2678926907
/* If there is already a lock of this type or more restrictive on the
2679026908
** unixFile, do nothing. Don't use the end_lock: exit path, as
2679126909
** unixEnterMutex() hasn't been called yet.
2679226910
*/
@@ -26990,11 +27108,11 @@
2699027108
int rc = SQLITE_OK;
2699127109
2699227110
assert( pFile );
2699327111
OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (unix)\n", pFile->h, eFileLock,
2699427112
pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
26995
- osGetpid()));
27113
+ osGetpid(0)));
2699627114
2699727115
assert( eFileLock<=SHARED_LOCK );
2699827116
if( pFile->eFileLock<=eFileLock ){
2699927117
return SQLITE_OK;
2700027118
}
@@ -27417,11 +27535,11 @@
2741727535
char *zLockFile = (char *)pFile->lockingContext;
2741827536
int rc;
2741927537
2742027538
assert( pFile );
2742127539
OSTRACE(("UNLOCK %d %d was %d pid=%d (dotlock)\n", pFile->h, eFileLock,
27422
- pFile->eFileLock, osGetpid()));
27540
+ pFile->eFileLock, osGetpid(0)));
2742327541
assert( eFileLock<=SHARED_LOCK );
2742427542
2742527543
/* no-op if possible */
2742627544
if( pFile->eFileLock==eFileLock ){
2742727545
return SQLITE_OK;
@@ -27635,11 +27753,11 @@
2763527753
static int flockUnlock(sqlite3_file *id, int eFileLock) {
2763627754
unixFile *pFile = (unixFile*)id;
2763727755
2763827756
assert( pFile );
2763927757
OSTRACE(("UNLOCK %d %d was %d pid=%d (flock)\n", pFile->h, eFileLock,
27640
- pFile->eFileLock, osGetpid()));
27758
+ pFile->eFileLock, osGetpid(0)));
2764127759
assert( eFileLock<=SHARED_LOCK );
2764227760
2764327761
/* no-op if possible */
2764427762
if( pFile->eFileLock==eFileLock ){
2764527763
return SQLITE_OK;
@@ -27803,11 +27921,11 @@
2780327921
sem_t *pSem = pFile->pInode->pSem;
2780427922
2780527923
assert( pFile );
2780627924
assert( pSem );
2780727925
OSTRACE(("UNLOCK %d %d was %d pid=%d (sem)\n", pFile->h, eFileLock,
27808
- pFile->eFileLock, osGetpid()));
27926
+ pFile->eFileLock, osGetpid(0)));
2780927927
assert( eFileLock<=SHARED_LOCK );
2781027928
2781127929
/* no-op if possible */
2781227930
if( pFile->eFileLock==eFileLock ){
2781327931
return SQLITE_OK;
@@ -28017,11 +28135,11 @@
2801728135
afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;
2801828136
2801928137
assert( pFile );
2802028138
OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (afp)\n", pFile->h,
2802128139
azFileLock(eFileLock), azFileLock(pFile->eFileLock),
28022
- azFileLock(pInode->eFileLock), pInode->nShared , osGetpid()));
28140
+ azFileLock(pInode->eFileLock), pInode->nShared , osGetpid(0)));
2802328141
2802428142
/* If there is already a lock of this type or more restrictive on the
2802528143
** unixFile, do nothing. Don't use the afp_end_lock: exit path, as
2802628144
** unixEnterMutex() hasn't been called yet.
2802728145
*/
@@ -28203,11 +28321,11 @@
2820328321
#endif
2820428322
2820528323
assert( pFile );
2820628324
OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock,
2820728325
pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
28208
- osGetpid()));
28326
+ osGetpid(0)));
2820928327
2821028328
assert( eFileLock<=SHARED_LOCK );
2821128329
if( pFile->eFileLock<=eFileLock ){
2821228330
return SQLITE_OK;
2821328331
}
@@ -29028,10 +29146,14 @@
2902829146
** Information and control of an open file handle.
2902929147
*/
2903029148
static int unixFileControl(sqlite3_file *id, int op, void *pArg){
2903129149
unixFile *pFile = (unixFile*)id;
2903229150
switch( op ){
29151
+ case SQLITE_FCNTL_WAL_BLOCK: {
29152
+ pFile->ctrlFlags |= UNIXFILE_BLOCK;
29153
+ return SQLITE_OK;
29154
+ }
2903329155
case SQLITE_FCNTL_LOCKSTATE: {
2903429156
*(int*)pArg = pFile->eFileLock;
2903529157
return SQLITE_OK;
2903629158
}
2903729159
case SQLITE_FCNTL_LAST_ERRNO: {
@@ -29337,37 +29459,42 @@
2933729459
**
2933829460
** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking
2933929461
** otherwise.
2934029462
*/
2934129463
static int unixShmSystemLock(
29342
- unixShmNode *pShmNode, /* Apply locks to this open shared-memory segment */
29464
+ unixFile *pFile, /* Open connection to the WAL file */
2934329465
int lockType, /* F_UNLCK, F_RDLCK, or F_WRLCK */
2934429466
int ofst, /* First byte of the locking range */
2934529467
int n /* Number of bytes to lock */
2934629468
){
29347
- struct flock f; /* The posix advisory locking structure */
29348
- int rc = SQLITE_OK; /* Result code form fcntl() */
29469
+ unixShmNode *pShmNode; /* Apply locks to this open shared-memory segment */
29470
+ struct flock f; /* The posix advisory locking structure */
29471
+ int rc = SQLITE_OK; /* Result code form fcntl() */
2934929472
2935029473
/* Access to the unixShmNode object is serialized by the caller */
29474
+ pShmNode = pFile->pInode->pShmNode;
2935129475
assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 );
2935229476
2935329477
/* Shared locks never span more than one byte */
2935429478
assert( n==1 || lockType!=F_RDLCK );
2935529479
2935629480
/* Locks are within range */
2935729481
assert( n>=1 && n<SQLITE_SHM_NLOCK );
2935829482
2935929483
if( pShmNode->h>=0 ){
29484
+ int lkType;
2936029485
/* Initialize the locking parameters */
2936129486
memset(&f, 0, sizeof(f));
2936229487
f.l_type = lockType;
2936329488
f.l_whence = SEEK_SET;
2936429489
f.l_start = ofst;
2936529490
f.l_len = n;
2936629491
29367
- rc = osFcntl(pShmNode->h, F_SETLK, &f);
29492
+ lkType = (pFile->ctrlFlags & UNIXFILE_BLOCK)!=0 ? F_SETLKW : F_SETLK;
29493
+ rc = osFcntl(pShmNode->h, lkType, &f);
2936829494
rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
29495
+ pFile->ctrlFlags &= ~UNIXFILE_BLOCK;
2936929496
}
2937029497
2937129498
/* Update the global lock state and do debug tracing */
2937229499
#ifdef SQLITE_DEBUG
2937329500
{ u16 mask;
@@ -29573,17 +29700,17 @@
2957329700
2957429701
/* Check to see if another process is holding the dead-man switch.
2957529702
** If not, truncate the file to zero length.
2957629703
*/
2957729704
rc = SQLITE_OK;
29578
- if( unixShmSystemLock(pShmNode, F_WRLCK, UNIX_SHM_DMS, 1)==SQLITE_OK ){
29705
+ if( unixShmSystemLock(pDbFd, F_WRLCK, UNIX_SHM_DMS, 1)==SQLITE_OK ){
2957929706
if( robust_ftruncate(pShmNode->h, 0) ){
2958029707
rc = unixLogError(SQLITE_IOERR_SHMOPEN, "ftruncate", zShmFilename);
2958129708
}
2958229709
}
2958329710
if( rc==SQLITE_OK ){
29584
- rc = unixShmSystemLock(pShmNode, F_RDLCK, UNIX_SHM_DMS, 1);
29711
+ rc = unixShmSystemLock(pDbFd, F_RDLCK, UNIX_SHM_DMS, 1);
2958529712
}
2958629713
if( rc ) goto shm_open_err;
2958729714
}
2958829715
}
2958929716
@@ -29811,11 +29938,11 @@
2981129938
allMask |= pX->sharedMask;
2981229939
}
2981329940
2981429941
/* Unlock the system-level locks */
2981529942
if( (mask & allMask)==0 ){
29816
- rc = unixShmSystemLock(pShmNode, F_UNLCK, ofst+UNIX_SHM_BASE, n);
29943
+ rc = unixShmSystemLock(pDbFd, F_UNLCK, ofst+UNIX_SHM_BASE, n);
2981729944
}else{
2981829945
rc = SQLITE_OK;
2981929946
}
2982029947
2982129948
/* Undo the local locks */
@@ -29839,11 +29966,11 @@
2983929966
}
2984029967
2984129968
/* Get shared locks at the system level, if necessary */
2984229969
if( rc==SQLITE_OK ){
2984329970
if( (allShared & mask)==0 ){
29844
- rc = unixShmSystemLock(pShmNode, F_RDLCK, ofst+UNIX_SHM_BASE, n);
29971
+ rc = unixShmSystemLock(pDbFd, F_RDLCK, ofst+UNIX_SHM_BASE, n);
2984529972
}else{
2984629973
rc = SQLITE_OK;
2984729974
}
2984829975
}
2984929976
@@ -29864,20 +29991,20 @@
2986429991
2986529992
/* Get the exclusive locks at the system level. Then if successful
2986629993
** also mark the local connection as being locked.
2986729994
*/
2986829995
if( rc==SQLITE_OK ){
29869
- rc = unixShmSystemLock(pShmNode, F_WRLCK, ofst+UNIX_SHM_BASE, n);
29996
+ rc = unixShmSystemLock(pDbFd, F_WRLCK, ofst+UNIX_SHM_BASE, n);
2987029997
if( rc==SQLITE_OK ){
2987129998
assert( (p->sharedMask & mask)==0 );
2987229999
p->exclMask |= mask;
2987330000
}
2987430001
}
2987530002
}
2987630003
sqlite3_mutex_leave(pShmNode->mutex);
2987730004
OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n",
29878
- p->id, osGetpid(), p->sharedMask, p->exclMask));
30005
+ p->id, osGetpid(0), p->sharedMask, p->exclMask));
2987930006
return rc;
2988030007
}
2988130008
2988230009
/*
2988330010
** Implement a memory barrier or memory fence on shared memory.
@@ -30968,12 +31095,12 @@
3096831095
/* Detect a pid change and reset the PRNG. There is a race condition
3096931096
** here such that two or more threads all trying to open databases at
3097031097
** the same instant might all reset the PRNG. But multiple resets
3097131098
** are harmless.
3097231099
*/
30973
- if( randomnessPid!=osGetpid() ){
30974
- randomnessPid = osGetpid();
31100
+ if( randomnessPid!=osGetpid(0) ){
31101
+ randomnessPid = osGetpid(0);
3097531102
sqlite3_randomness(0,0);
3097631103
}
3097731104
3097831105
memset(p, 0, sizeof(unixFile));
3097931106
@@ -31360,11 +31487,11 @@
3136031487
** When testing, initializing zBuf[] to zero is all we do. That means
3136131488
** that we always use the same random number sequence. This makes the
3136231489
** tests repeatable.
3136331490
*/
3136431491
memset(zBuf, 0, nBuf);
31365
- randomnessPid = osGetpid();
31492
+ randomnessPid = osGetpid(0);
3136631493
#if !defined(SQLITE_TEST)
3136731494
{
3136831495
int fd, got;
3136931496
fd = robust_open("/dev/urandom", O_RDONLY, 0);
3137031497
if( fd<0 ){
@@ -31681,11 +31808,11 @@
3168131808
#else
3168231809
# ifdef _CS_DARWIN_USER_TEMP_DIR
3168331810
{
3168431811
if( !confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen) ){
3168531812
OSTRACE(("GETLOCKPATH failed %s errno=%d pid=%d\n",
31686
- lPath, errno, osGetpid()));
31813
+ lPath, errno, osGetpid(0)));
3168731814
return SQLITE_IOERR_LOCK;
3168831815
}
3168931816
len = strlcat(lPath, "sqliteplocks", maxLen);
3169031817
}
3169131818
# else
@@ -31703,11 +31830,11 @@
3170331830
char c = dbPath[i];
3170431831
lPath[i+len] = (c=='/')?'_':c;
3170531832
}
3170631833
lPath[i+len]='\0';
3170731834
strlcat(lPath, ":auto:", maxLen);
31708
- OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, osGetpid()));
31835
+ OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, osGetpid(0)));
3170931836
return SQLITE_OK;
3171031837
}
3171131838
3171231839
/*
3171331840
** Creates the lock file and any missing directories in lockPath
@@ -31730,20 +31857,20 @@
3173031857
if( osMkdir(buf, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){
3173131858
int err=errno;
3173231859
if( err!=EEXIST ) {
3173331860
OSTRACE(("CREATELOCKPATH FAILED creating %s, "
3173431861
"'%s' proxy lock path=%s pid=%d\n",
31735
- buf, strerror(err), lockPath, osGetpid()));
31862
+ buf, strerror(err), lockPath, osGetpid(0)));
3173631863
return err;
3173731864
}
3173831865
}
3173931866
}
3174031867
start=i+1;
3174131868
}
3174231869
buf[i] = lockPath[i];
3174331870
}
31744
- OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n", lockPath, osGetpid()));
31871
+ OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n", lockPath, osGetpid(0)));
3174531872
return 0;
3174631873
}
3174731874
3174831875
/*
3174931876
** Create a new VFS file descriptor (stored in memory obtained from
@@ -32045,11 +32172,11 @@
3204532172
int tryOldLockPath = 0;
3204632173
int forceNewLockPath = 0;
3204732174
3204832175
OSTRACE(("TAKECONCH %d for %s pid=%d\n", conchFile->h,
3204932176
(pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"),
32050
- osGetpid()));
32177
+ osGetpid(0)));
3205132178
3205232179
rc = proxyGetHostID(myHostID, &pError);
3205332180
if( (rc&0xff)==SQLITE_IOERR ){
3205432181
storeLastErrno(pFile, pError);
3205532182
goto end_takeconch;
@@ -32255,11 +32382,11 @@
3225532382
3225632383
pCtx = (proxyLockingContext *)pFile->lockingContext;
3225732384
conchFile = pCtx->conchFile;
3225832385
OSTRACE(("RELEASECONCH %d for %s pid=%d\n", conchFile->h,
3225932386
(pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"),
32260
- osGetpid()));
32387
+ osGetpid(0)));
3226132388
if( pCtx->conchHeld>0 ){
3226232389
rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);
3226332390
}
3226432391
pCtx->conchHeld = 0;
3226532392
OSTRACE(("RELEASECONCH %d %s\n", conchFile->h,
@@ -32397,11 +32524,11 @@
3239732524
}else{
3239832525
lockPath=(char *)path;
3239932526
}
3240032527
3240132528
OSTRACE(("TRANSPROXY %d for %s pid=%d\n", pFile->h,
32402
- (lockPath ? lockPath : ":auto:"), osGetpid()));
32529
+ (lockPath ? lockPath : ":auto:"), osGetpid(0)));
3240332530
3240432531
pCtx = sqlite3_malloc( sizeof(*pCtx) );
3240532532
if( pCtx==0 ){
3240632533
return SQLITE_NOMEM;
3240732534
}
@@ -32684,11 +32811,11 @@
3268432811
** This routine is called once during SQLite initialization and by a
3268532812
** single thread. The memory allocation and mutex subsystems have not
3268632813
** necessarily been initialized when this routine is called, and so they
3268732814
** should not be used.
3268832815
*/
32689
-SQLITE_API int sqlite3_os_init(void){
32816
+SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
3269032817
/*
3269132818
** The following macro defines an initializer for an sqlite3_vfs object.
3269232819
** The name of the VFS is NAME. The pAppData is a pointer to a pointer
3269332820
** to the "finder" function. (pAppData is a pointer to a pointer because
3269432821
** silly C90 rules prohibit a void* from being cast to a function pointer
@@ -32783,11 +32910,11 @@
3278332910
**
3278432911
** Some operating systems might need to do some cleanup in this routine,
3278532912
** to release dynamically allocated objects. But not on unix.
3278632913
** This routine is a no-op for unix.
3278732914
*/
32788
-SQLITE_API int sqlite3_os_end(void){
32915
+SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
3278932916
return SQLITE_OK;
3279032917
}
3279132918
3279232919
#endif /* SQLITE_OS_UNIX */
3279332920
@@ -34175,11 +34302,11 @@
3417534302
** compact it. Upon success, SQLITE_OK will be returned. Upon failure, one
3417634303
** of SQLITE_NOMEM, SQLITE_ERROR, or SQLITE_NOTFOUND will be returned. The
3417734304
** "pnLargest" argument, if non-zero, will be used to return the size of the
3417834305
** largest committed free block in the heap, in bytes.
3417934306
*/
34180
-SQLITE_API int sqlite3_win32_compact_heap(LPUINT pnLargest){
34307
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_compact_heap(LPUINT pnLargest){
3418134308
int rc = SQLITE_OK;
3418234309
UINT nLargest = 0;
3418334310
HANDLE hHeap;
3418434311
3418534312
winMemAssertMagic();
@@ -34215,11 +34342,11 @@
3421534342
** If a Win32 native heap has been configured, this function will attempt to
3421634343
** destroy and recreate it. If the Win32 native heap is not isolated and/or
3421734344
** the sqlite3_memory_used() function does not return zero, SQLITE_BUSY will
3421834345
** be returned and no changes will be made to the Win32 native heap.
3421934346
*/
34220
-SQLITE_API int sqlite3_win32_reset_heap(){
34347
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_reset_heap(){
3422134348
int rc;
3422234349
MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
3422334350
MUTEX_LOGIC( sqlite3_mutex *pMem; ) /* The memsys static mutex */
3422434351
MUTEX_LOGIC( pMaster = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); )
3422534352
MUTEX_LOGIC( pMem = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); )
@@ -34260,11 +34387,11 @@
3426034387
/*
3426134388
** This function outputs the specified (ANSI) string to the Win32 debugger
3426234389
** (if available).
3426334390
*/
3426434391
34265
-SQLITE_API void sqlite3_win32_write_debug(const char *zBuf, int nBuf){
34392
+SQLITE_API void SQLITE_STDCALL sqlite3_win32_write_debug(const char *zBuf, int nBuf){
3426634393
char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE];
3426734394
int nMin = MIN(nBuf, (SQLITE_WIN32_DBG_BUF_SIZE - 1)); /* may be negative. */
3426834395
if( nMin<-1 ) nMin = -1; /* all negative values become -1. */
3426934396
assert( nMin==-1 || nMin==0 || nMin<SQLITE_WIN32_DBG_BUF_SIZE );
3427034397
#if defined(SQLITE_WIN32_HAS_ANSI)
@@ -34300,11 +34427,11 @@
3430034427
*/
3430134428
#if SQLITE_OS_WINRT
3430234429
static HANDLE sleepObj = NULL;
3430334430
#endif
3430434431
34305
-SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds){
34432
+SQLITE_API void SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds){
3430634433
#if SQLITE_OS_WINRT
3430734434
if ( sleepObj==NULL ){
3430834435
sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET,
3430934436
SYNCHRONIZE);
3431034437
}
@@ -34349,11 +34476,11 @@
3434934476
3435034477
/*
3435134478
** This function determines if the machine is running a version of Windows
3435234479
** based on the NT kernel.
3435334480
*/
34354
-SQLITE_API int sqlite3_win32_is_nt(void){
34481
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_is_nt(void){
3435534482
#if SQLITE_OS_WINRT
3435634483
/*
3435734484
** NOTE: The WinRT sub-platform is always assumed to be based on the NT
3435834485
** kernel.
3435934486
*/
@@ -34703,11 +34830,11 @@
3470334830
3470434831
/*
3470534832
** Convert multibyte character string to UTF-8. Space to hold the
3470634833
** returned string is obtained from sqlite3_malloc().
3470734834
*/
34708
-SQLITE_API char *sqlite3_win32_mbcs_to_utf8(const char *zFilename){
34835
+SQLITE_API char *SQLITE_STDCALL sqlite3_win32_mbcs_to_utf8(const char *zFilename){
3470934836
char *zFilenameUtf8;
3471034837
LPWSTR zTmpWide;
3471134838
3471234839
zTmpWide = winMbcsToUnicode(zFilename);
3471334840
if( zTmpWide==0 ){
@@ -34720,11 +34847,11 @@
3472034847
3472134848
/*
3472234849
** Convert UTF-8 to multibyte character string. Space to hold the
3472334850
** returned string is obtained from sqlite3_malloc().
3472434851
*/
34725
-SQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){
34852
+SQLITE_API char *SQLITE_STDCALL sqlite3_win32_utf8_to_mbcs(const char *zFilename){
3472634853
char *zFilenameMbcs;
3472734854
LPWSTR zTmpWide;
3472834855
3472934856
zTmpWide = winUtf8ToUnicode(zFilename);
3473034857
if( zTmpWide==0 ){
@@ -34740,11 +34867,11 @@
3474034867
** the provided arguments. The type argument must be 1 in order to set the
3474134868
** data directory or 2 in order to set the temporary directory. The zValue
3474234869
** argument is the name of the directory to use. The return value will be
3474334870
** SQLITE_OK if successful.
3474434871
*/
34745
-SQLITE_API int sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){
34872
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){
3474634873
char **ppDirectory = 0;
3474734874
#ifndef SQLITE_OMIT_AUTOINIT
3474834875
int rc = sqlite3_initialize();
3474934876
if( rc ) return rc;
3475034877
#endif
@@ -34965,15 +35092,15 @@
3496535092
}
3496635093
3496735094
/*
3496835095
** Log a I/O error retry episode.
3496935096
*/
34970
-static void winLogIoerr(int nRetry){
35097
+static void winLogIoerr(int nRetry, int lineno){
3497135098
if( nRetry ){
3497235099
sqlite3_log(SQLITE_IOERR,
34973
- "delayed %dms for lock/sharing conflict",
34974
- winIoerrRetryDelay*nRetry*(nRetry+1)/2
35100
+ "delayed %dms for lock/sharing conflict at line %d",
35101
+ winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno
3497535102
);
3497635103
}
3497735104
}
3497835105
3497935106
#if SQLITE_OS_WINCE
@@ -35449,11 +35576,12 @@
3544935576
assert( id!=0 );
3545035577
#ifndef SQLITE_OMIT_WAL
3545135578
assert( pFile->pShm==0 );
3545235579
#endif
3545335580
assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
35454
- OSTRACE(("CLOSE file=%p\n", pFile->h));
35581
+ OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p\n",
35582
+ osGetCurrentProcessId(), pFile, pFile->h));
3545535583
3545635584
#if SQLITE_MAX_MMAP_SIZE>0
3545735585
winUnmapfile(pFile);
3545835586
#endif
3545935587
@@ -35478,11 +35606,12 @@
3547835606
#endif
3547935607
if( rc ){
3548035608
pFile->h = NULL;
3548135609
}
3548235610
OpenCounter(-1);
35483
- OSTRACE(("CLOSE file=%p, rc=%s\n", pFile->h, rc ? "ok" : "failed"));
35611
+ OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p, rc=%s\n",
35612
+ osGetCurrentProcessId(), pFile, pFile->h, rc ? "ok" : "failed"));
3548435613
return rc ? SQLITE_OK
3548535614
: winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
3548635615
"winClose", pFile->zPath);
3548735616
}
3548835617
@@ -35506,20 +35635,22 @@
3550635635
3550735636
assert( id!=0 );
3550835637
assert( amt>0 );
3550935638
assert( offset>=0 );
3551035639
SimulateIOError(return SQLITE_IOERR_READ);
35511
- OSTRACE(("READ file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
35640
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
35641
+ "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
3551235642
pFile->h, pBuf, amt, offset, pFile->locktype));
3551335643
3551435644
#if SQLITE_MAX_MMAP_SIZE>0
3551535645
/* Deal with as much of this read request as possible by transfering
3551635646
** data from the memory mapping using memcpy(). */
3551735647
if( offset<pFile->mmapSize ){
3551835648
if( offset+amt <= pFile->mmapSize ){
3551935649
memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);
35520
- OSTRACE(("READ-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
35650
+ OSTRACE(("READ-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35651
+ osGetCurrentProcessId(), pFile, pFile->h));
3552135652
return SQLITE_OK;
3552235653
}else{
3552335654
int nCopy = (int)(pFile->mmapSize - offset);
3552435655
memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);
3552535656
pBuf = &((u8 *)pBuf)[nCopy];
@@ -35529,11 +35660,12 @@
3552935660
}
3553035661
#endif
3553135662
3553235663
#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)
3553335664
if( winSeekFile(pFile, offset) ){
35534
- OSTRACE(("READ file=%p, rc=SQLITE_FULL\n", pFile->h));
35665
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n",
35666
+ osGetCurrentProcessId(), pFile, pFile->h));
3553535667
return SQLITE_FULL;
3553635668
}
3553735669
while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
3553835670
#else
3553935671
memset(&overlapped, 0, sizeof(OVERLAPPED));
@@ -35543,23 +35675,26 @@
3554335675
osGetLastError()!=ERROR_HANDLE_EOF ){
3554435676
#endif
3554535677
DWORD lastErrno;
3554635678
if( winRetryIoerr(&nRetry, &lastErrno) ) continue;
3554735679
pFile->lastErrno = lastErrno;
35548
- OSTRACE(("READ file=%p, rc=SQLITE_IOERR_READ\n", pFile->h));
35680
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_READ\n",
35681
+ osGetCurrentProcessId(), pFile, pFile->h));
3554935682
return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
3555035683
"winRead", pFile->zPath);
3555135684
}
35552
- winLogIoerr(nRetry);
35685
+ winLogIoerr(nRetry, __LINE__);
3555335686
if( nRead<(DWORD)amt ){
3555435687
/* Unread parts of the buffer must be zero-filled */
3555535688
memset(&((char*)pBuf)[nRead], 0, amt-nRead);
35556
- OSTRACE(("READ file=%p, rc=SQLITE_IOERR_SHORT_READ\n", pFile->h));
35689
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_SHORT_READ\n",
35690
+ osGetCurrentProcessId(), pFile, pFile->h));
3555735691
return SQLITE_IOERR_SHORT_READ;
3555835692
}
3555935693
35560
- OSTRACE(("READ file=%p, rc=SQLITE_OK\n", pFile->h));
35694
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35695
+ osGetCurrentProcessId(), pFile, pFile->h));
3556135696
return SQLITE_OK;
3556235697
}
3556335698
3556435699
/*
3556535700
** Write data from a buffer into a file. Return SQLITE_OK on success
@@ -35578,20 +35713,22 @@
3557835713
assert( amt>0 );
3557935714
assert( pFile );
3558035715
SimulateIOError(return SQLITE_IOERR_WRITE);
3558135716
SimulateDiskfullError(return SQLITE_FULL);
3558235717
35583
- OSTRACE(("WRITE file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
35718
+ OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
35719
+ "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
3558435720
pFile->h, pBuf, amt, offset, pFile->locktype));
3558535721
3558635722
#if SQLITE_MAX_MMAP_SIZE>0
3558735723
/* Deal with as much of this write request as possible by transfering
3558835724
** data from the memory mapping using memcpy(). */
3558935725
if( offset<pFile->mmapSize ){
3559035726
if( offset+amt <= pFile->mmapSize ){
3559135727
memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);
35592
- OSTRACE(("WRITE-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
35728
+ OSTRACE(("WRITE-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35729
+ osGetCurrentProcessId(), pFile, pFile->h));
3559335730
return SQLITE_OK;
3559435731
}else{
3559535732
int nCopy = (int)(pFile->mmapSize - offset);
3559635733
memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);
3559735734
pBuf = &((u8 *)pBuf)[nCopy];
@@ -35650,21 +35787,24 @@
3565035787
}
3565135788
3565235789
if( rc ){
3565335790
if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
3565435791
|| ( pFile->lastErrno==ERROR_DISK_FULL )){
35655
- OSTRACE(("WRITE file=%p, rc=SQLITE_FULL\n", pFile->h));
35792
+ OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n",
35793
+ osGetCurrentProcessId(), pFile, pFile->h));
3565635794
return winLogError(SQLITE_FULL, pFile->lastErrno,
3565735795
"winWrite1", pFile->zPath);
3565835796
}
35659
- OSTRACE(("WRITE file=%p, rc=SQLITE_IOERR_WRITE\n", pFile->h));
35797
+ OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_WRITE\n",
35798
+ osGetCurrentProcessId(), pFile, pFile->h));
3566035799
return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,
3566135800
"winWrite2", pFile->zPath);
3566235801
}else{
35663
- winLogIoerr(nRetry);
35802
+ winLogIoerr(nRetry, __LINE__);
3566435803
}
35665
- OSTRACE(("WRITE file=%p, rc=SQLITE_OK\n", pFile->h));
35804
+ OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35805
+ osGetCurrentProcessId(), pFile, pFile->h));
3566635806
return SQLITE_OK;
3566735807
}
3566835808
3566935809
/*
3567035810
** Truncate an open file to a specified size
@@ -35674,12 +35814,12 @@
3567435814
int rc = SQLITE_OK; /* Return code for this function */
3567535815
DWORD lastErrno;
3567635816
3567735817
assert( pFile );
3567835818
SimulateIOError(return SQLITE_IOERR_TRUNCATE);
35679
- OSTRACE(("TRUNCATE file=%p, size=%lld, lock=%d\n",
35680
- pFile->h, nByte, pFile->locktype));
35819
+ OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\n",
35820
+ osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype));
3568135821
3568235822
/* If the user has configured a chunk-size for this file, truncate the
3568335823
** file so that it consists of an integer number of chunks (i.e. the
3568435824
** actual file size after the operation may be larger than the requested
3568535825
** size).
@@ -35707,11 +35847,12 @@
3570735847
if( pFile->pMapRegion && nByte<pFile->mmapSize ){
3570835848
pFile->mmapSize = nByte;
3570935849
}
3571035850
#endif
3571135851
35712
- OSTRACE(("TRUNCATE file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
35852
+ OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, rc=%s\n",
35853
+ osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc)));
3571335854
return rc;
3571435855
}
3571535856
3571635857
#ifdef SQLITE_TEST
3571735858
/*
@@ -35752,12 +35893,13 @@
3575235893
/* Unix cannot, but some systems may return SQLITE_FULL from here. This
3575335894
** line is to test that doing so does not cause any problems.
3575435895
*/
3575535896
SimulateDiskfullError( return SQLITE_FULL );
3575635897
35757
- OSTRACE(("SYNC file=%p, flags=%x, lock=%d\n",
35758
- pFile->h, flags, pFile->locktype));
35898
+ OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, flags=%x, lock=%d\n",
35899
+ osGetCurrentProcessId(), pFile, pFile->h, flags,
35900
+ pFile->locktype));
3575935901
3576035902
#ifndef SQLITE_TEST
3576135903
UNUSED_PARAMETER(flags);
3576235904
#else
3576335905
if( (flags&0x0F)==SQLITE_SYNC_FULL ){
@@ -35768,21 +35910,24 @@
3576835910
3576935911
/* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a
3577035912
** no-op
3577135913
*/
3577235914
#ifdef SQLITE_NO_SYNC
35773
- OSTRACE(("SYNC-NOP file=%p, rc=SQLITE_OK\n", pFile->h));
35915
+ OSTRACE(("SYNC-NOP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35916
+ osGetCurrentProcessId(), pFile, pFile->h));
3577435917
return SQLITE_OK;
3577535918
#else
3577635919
rc = osFlushFileBuffers(pFile->h);
3577735920
SimulateIOError( rc=FALSE );
3577835921
if( rc ){
35779
- OSTRACE(("SYNC file=%p, rc=SQLITE_OK\n", pFile->h));
35922
+ OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35923
+ osGetCurrentProcessId(), pFile, pFile->h));
3578035924
return SQLITE_OK;
3578135925
}else{
3578235926
pFile->lastErrno = osGetLastError();
35783
- OSTRACE(("SYNC file=%p, rc=SQLITE_IOERR_FSYNC\n", pFile->h));
35927
+ OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_FSYNC\n",
35928
+ osGetCurrentProcessId(), pFile, pFile->h));
3578435929
return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,
3578535930
"winSync", pFile->zPath);
3578635931
}
3578735932
#endif
3578835933
}
@@ -37751,11 +37896,11 @@
3775137896
winRetryIoerr(&cnt, &lastErrno) ){
3775237897
/* Noop */
3775337898
}
3775437899
}
3775537900
#endif
37756
- winLogIoerr(cnt);
37901
+ winLogIoerr(cnt, __LINE__);
3775737902
3775837903
OSTRACE(("OPEN file=%p, name=%s, access=%lx, rc=%s\n", h, zUtf8Name,
3775937904
dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
3776037905
3776137906
if( h==INVALID_HANDLE_VALUE ){
@@ -37935,11 +38080,11 @@
3793538080
}
3793638081
#endif
3793738082
if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
3793838083
rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename);
3793938084
}else{
37940
- winLogIoerr(cnt);
38085
+ winLogIoerr(cnt, __LINE__);
3794138086
}
3794238087
sqlite3_free(zConverted);
3794338088
OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc)));
3794438089
return rc;
3794538090
}
@@ -37985,11 +38130,11 @@
3798538130
attr = INVALID_FILE_ATTRIBUTES;
3798638131
}else{
3798738132
attr = sAttrData.dwFileAttributes;
3798838133
}
3798938134
}else{
37990
- winLogIoerr(cnt);
38135
+ winLogIoerr(cnt, __LINE__);
3799138136
if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){
3799238137
sqlite3_free(zConverted);
3799338138
return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess",
3799438139
zFilename);
3799538140
}else{
@@ -38500,11 +38645,11 @@
3850038645
}
3850138646
3850238647
/*
3850338648
** Initialize and deinitialize the operating system interface.
3850438649
*/
38505
-SQLITE_API int sqlite3_os_init(void){
38650
+SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
3850638651
static sqlite3_vfs winVfs = {
3850738652
3, /* iVersion */
3850838653
sizeof(winFile), /* szOsFile */
3850938654
SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
3851038655
0, /* pNext */
@@ -38575,11 +38720,11 @@
3857538720
#endif
3857638721
3857738722
return SQLITE_OK;
3857838723
}
3857938724
38580
-SQLITE_API int sqlite3_os_end(void){
38725
+SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
3858138726
#if SQLITE_OS_WINRT
3858238727
if( sleepObj!=NULL ){
3858338728
osCloseHandle(sleepObj);
3858438729
sleepObj = NULL;
3858538730
}
@@ -39866,20 +40011,20 @@
3986640011
** in pcache1 need to be protected via mutex.
3986740012
*/
3986840013
static void *pcache1Alloc(int nByte){
3986940014
void *p = 0;
3987040015
assert( sqlite3_mutex_notheld(pcache1.grp.mutex) );
39871
- sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);
3987240016
if( nByte<=pcache1.szSlot ){
3987340017
sqlite3_mutex_enter(pcache1.mutex);
3987440018
p = (PgHdr1 *)pcache1.pFree;
3987540019
if( p ){
3987640020
pcache1.pFree = pcache1.pFree->pNext;
3987740021
pcache1.nFreeSlot--;
3987840022
pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;
3987940023
assert( pcache1.nFreeSlot>=0 );
39880
- sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1);
40024
+ sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);
40025
+ sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_USED, 1);
3988140026
}
3988240027
sqlite3_mutex_leave(pcache1.mutex);
3988340028
}
3988440029
if( p==0 ){
3988540030
/* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool. Get
@@ -39888,11 +40033,12 @@
3988840033
p = sqlite3Malloc(nByte);
3988940034
#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
3989040035
if( p ){
3989140036
int sz = sqlite3MallocSize(p);
3989240037
sqlite3_mutex_enter(pcache1.mutex);
39893
- sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);
40038
+ sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);
40039
+ sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);
3989440040
sqlite3_mutex_leave(pcache1.mutex);
3989540041
}
3989640042
#endif
3989740043
sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);
3989840044
}
@@ -39906,11 +40052,11 @@
3990640052
int nFreed = 0;
3990740053
if( p==0 ) return 0;
3990840054
if( p>=pcache1.pStart && p<pcache1.pEnd ){
3990940055
PgFreeslot *pSlot;
3991040056
sqlite3_mutex_enter(pcache1.mutex);
39911
- sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, -1);
40057
+ sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_USED, 1);
3991240058
pSlot = (PgFreeslot*)p;
3991340059
pSlot->pNext = pcache1.pFree;
3991440060
pcache1.pFree = pSlot;
3991540061
pcache1.nFreeSlot++;
3991640062
pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;
@@ -39920,11 +40066,11 @@
3992040066
assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );
3992140067
sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
3992240068
nFreed = sqlite3MallocSize(p);
3992340069
#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
3992440070
sqlite3_mutex_enter(pcache1.mutex);
39925
- sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -nFreed);
40071
+ sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_OVERFLOW, nFreed);
3992640072
sqlite3_mutex_leave(pcache1.mutex);
3992740073
#endif
3992840074
sqlite3_free(p);
3992940075
}
3993040076
return nFreed;
@@ -40656,10 +40802,18 @@
4065640802
4065740803
/*
4065840804
** Return the size of the header on each page of this PCACHE implementation.
4065940805
*/
4066040806
SQLITE_PRIVATE int sqlite3HeaderSizePcache1(void){ return ROUND8(sizeof(PgHdr1)); }
40807
+
40808
+/*
40809
+** Return the global mutex used by this PCACHE implementation. The
40810
+** sqlite3_status() routine needs access to this mutex.
40811
+*/
40812
+SQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void){
40813
+ return pcache1.mutex;
40814
+}
4066140815
4066240816
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
4066340817
/*
4066440818
** This function is called to free superfluous dynamically allocated memory
4066540819
** held by the pager system. Memory in use by any SQLite pager allocated
@@ -49429,13 +49583,14 @@
4942949583
if( pWal->exclusiveMode ) return;
4943049584
(void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,
4943149585
SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED);
4943249586
WALTRACE(("WAL%p: release SHARED-%s\n", pWal, walLockName(lockIdx)));
4943349587
}
49434
-static int walLockExclusive(Wal *pWal, int lockIdx, int n){
49588
+static int walLockExclusive(Wal *pWal, int lockIdx, int n, int fBlock){
4943549589
int rc;
4943649590
if( pWal->exclusiveMode ) return SQLITE_OK;
49591
+ if( fBlock ) sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_WAL_BLOCK, 0);
4943749592
rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,
4943849593
SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE);
4943949594
WALTRACE(("WAL%p: acquire EXCLUSIVE-%s cnt=%d %s\n", pWal,
4944049595
walLockName(lockIdx), n, rc ? "failed" : "ok"));
4944149596
VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )
@@ -49717,11 +49872,11 @@
4971749872
assert( WAL_ALL_BUT_WRITE==WAL_WRITE_LOCK+1 );
4971849873
assert( WAL_CKPT_LOCK==WAL_ALL_BUT_WRITE );
4971949874
assert( pWal->writeLock );
4972049875
iLock = WAL_ALL_BUT_WRITE + pWal->ckptLock;
4972149876
nLock = SQLITE_SHM_NLOCK - iLock;
49722
- rc = walLockExclusive(pWal, iLock, nLock);
49877
+ rc = walLockExclusive(pWal, iLock, nLock, 0);
4972349878
if( rc ){
4972449879
return rc;
4972549880
}
4972649881
WALTRACE(("WAL%p: recovery begin...\n", pWal));
4972749882
@@ -50251,11 +50406,11 @@
5025150406
int lockIdx, /* Offset of first byte to lock */
5025250407
int n /* Number of bytes to lock */
5025350408
){
5025450409
int rc;
5025550410
do {
50256
- rc = walLockExclusive(pWal, lockIdx, n);
50411
+ rc = walLockExclusive(pWal, lockIdx, n, 0);
5025750412
}while( xBusy && rc==SQLITE_BUSY && xBusy(pBusyArg) );
5025850413
return rc;
5025950414
}
5026050415
5026150416
/*
@@ -50684,11 +50839,11 @@
5068450839
if( pWal->readOnly & WAL_SHM_RDONLY ){
5068550840
if( SQLITE_OK==(rc = walLockShared(pWal, WAL_WRITE_LOCK)) ){
5068650841
walUnlockShared(pWal, WAL_WRITE_LOCK);
5068750842
rc = SQLITE_READONLY_RECOVERY;
5068850843
}
50689
- }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1)) ){
50844
+ }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1, 1)) ){
5069050845
pWal->writeLock = 1;
5069150846
if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){
5069250847
badHdr = walIndexTryHdr(pWal, pChanged);
5069350848
if( badHdr ){
5069450849
/* If the wal-index header is still malformed even while holding
@@ -50890,11 +51045,11 @@
5089051045
{
5089151046
if( (pWal->readOnly & WAL_SHM_RDONLY)==0
5089251047
&& (mxReadMark<pWal->hdr.mxFrame || mxI==0)
5089351048
){
5089451049
for(i=1; i<WAL_NREADER; i++){
50895
- rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
51050
+ rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1, 0);
5089651051
if( rc==SQLITE_OK ){
5089751052
mxReadMark = pInfo->aReadMark[i] = pWal->hdr.mxFrame;
5089851053
mxI = i;
5089951054
walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
5090051055
break;
@@ -51146,11 +51301,11 @@
5114651301
}
5114751302
5114851303
/* Only one writer allowed at a time. Get the write lock. Return
5114951304
** SQLITE_BUSY if unable.
5115051305
*/
51151
- rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1);
51306
+ rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1, 0);
5115251307
if( rc ){
5115351308
return rc;
5115451309
}
5115551310
pWal->writeLock = 1;
5115651311
@@ -51291,11 +51446,11 @@
5129151446
volatile WalCkptInfo *pInfo = walCkptInfo(pWal);
5129251447
assert( pInfo->nBackfill==pWal->hdr.mxFrame );
5129351448
if( pInfo->nBackfill>0 ){
5129451449
u32 salt1;
5129551450
sqlite3_randomness(4, &salt1);
51296
- rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
51451
+ rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1, 0);
5129751452
if( rc==SQLITE_OK ){
5129851453
/* If all readers are using WAL_READ_LOCK(0) (in other words if no
5129951454
** readers are currently using the WAL), then the transactions
5130051455
** frames will overwrite the start of the existing log. Update the
5130151456
** wal-index header to reflect this.
@@ -51616,11 +51771,11 @@
5161651771
if( pWal->readOnly ) return SQLITE_READONLY;
5161751772
WALTRACE(("WAL%p: checkpoint begins\n", pWal));
5161851773
5161951774
/* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive
5162051775
** "checkpoint" lock on the database file. */
51621
- rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);
51776
+ rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1, 0);
5162251777
if( rc ){
5162351778
/* EVIDENCE-OF: R-10421-19736 If any other process is running a
5162451779
** checkpoint operation at the same time, the lock cannot be obtained and
5162551780
** SQLITE_BUSY is returned.
5162651781
** EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured,
@@ -52618,10 +52773,11 @@
5261852773
5261952774
/*
5262052775
** Exit the recursive mutex on a Btree.
5262152776
*/
5262252777
SQLITE_PRIVATE void sqlite3BtreeLeave(Btree *p){
52778
+ assert( sqlite3_mutex_held(p->db->mutex) );
5262352779
if( p->sharable ){
5262452780
assert( p->wantToLock>0 );
5262552781
p->wantToLock--;
5262652782
if( p->wantToLock==0 ){
5262752783
unlockBtreeMutex(p);
@@ -52865,11 +53021,11 @@
5286553021
**
5286653022
** This routine has no effect on existing database connections.
5286753023
** The shared cache setting effects only future calls to
5286853024
** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2().
5286953025
*/
52870
-SQLITE_API int sqlite3_enable_shared_cache(int enable){
53026
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int enable){
5287153027
sqlite3GlobalConfig.sharedCacheEnabled = enable;
5287253028
return SQLITE_OK;
5287353029
}
5287453030
#endif
5287553031
@@ -53379,14 +53535,19 @@
5337953535
** prior to calling this routine.
5338053536
*/
5338153537
static int saveCursorPosition(BtCursor *pCur){
5338253538
int rc;
5338353539
53384
- assert( CURSOR_VALID==pCur->eState );
53540
+ assert( CURSOR_VALID==pCur->eState || CURSOR_SKIPNEXT==pCur->eState );
5338553541
assert( 0==pCur->pKey );
5338653542
assert( cursorHoldsMutex(pCur) );
5338753543
53544
+ if( pCur->eState==CURSOR_SKIPNEXT ){
53545
+ pCur->eState = CURSOR_VALID;
53546
+ }else{
53547
+ pCur->skipNext = 0;
53548
+ }
5338853549
rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
5338953550
assert( rc==SQLITE_OK ); /* KeySize() cannot fail */
5339053551
5339153552
/* If this is an intKey table, then the above call to BtreeKeySize()
5339253553
** stores the integer key in pCur->nKey. In this case this value is
@@ -53453,11 +53614,11 @@
5345353614
Pgno iRoot, /* Only save cursor with this iRoot. Save all if zero */
5345453615
BtCursor *pExcept /* Do not save this cursor */
5345553616
){
5345653617
do{
5345753618
if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){
53458
- if( p->eState==CURSOR_VALID ){
53619
+ if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){
5345953620
int rc = saveCursorPosition(p);
5346053621
if( SQLITE_OK!=rc ){
5346153622
return rc;
5346253623
}
5346353624
}else{
@@ -53525,21 +53686,23 @@
5352553686
** at most one effective restoreCursorPosition() call after each
5352653687
** saveCursorPosition().
5352753688
*/
5352853689
static int btreeRestoreCursorPosition(BtCursor *pCur){
5352953690
int rc;
53691
+ int skipNext;
5353053692
assert( cursorHoldsMutex(pCur) );
5353153693
assert( pCur->eState>=CURSOR_REQUIRESEEK );
5353253694
if( pCur->eState==CURSOR_FAULT ){
5353353695
return pCur->skipNext;
5353453696
}
5353553697
pCur->eState = CURSOR_INVALID;
53536
- rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &pCur->skipNext);
53698
+ rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext);
5353753699
if( rc==SQLITE_OK ){
5353853700
sqlite3_free(pCur->pKey);
5353953701
pCur->pKey = 0;
5354053702
assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
53703
+ pCur->skipNext |= skipNext;
5354153704
if( pCur->skipNext && pCur->eState==CURSOR_VALID ){
5354253705
pCur->eState = CURSOR_SKIPNEXT;
5354353706
}
5354453707
}
5354553708
return rc;
@@ -53587,13 +53750,14 @@
5358753750
rc = restoreCursorPosition(pCur);
5358853751
if( rc ){
5358953752
*pDifferentRow = 1;
5359053753
return rc;
5359153754
}
53592
- if( pCur->eState!=CURSOR_VALID || NEVER(pCur->skipNext!=0) ){
53755
+ if( pCur->eState!=CURSOR_VALID ){
5359353756
*pDifferentRow = 1;
5359453757
}else{
53758
+ assert( pCur->skipNext==0 );
5359553759
*pDifferentRow = 0;
5359653760
}
5359753761
return SQLITE_OK;
5359853762
}
5359953763
@@ -54796,12 +54960,12 @@
5479654960
/*
5479754961
** The following asserts make sure that structures used by the btree are
5479854962
** the right size. This is to guard against size changes that result
5479954963
** when compiling on a different architecture.
5480054964
*/
54801
- assert( sizeof(i64)==8 || sizeof(i64)==4 );
54802
- assert( sizeof(u64)==8 || sizeof(u64)==4 );
54965
+ assert( sizeof(i64)==8 );
54966
+ assert( sizeof(u64)==8 );
5480354967
assert( sizeof(u32)==4 );
5480454968
assert( sizeof(u16)==2 );
5480554969
assert( sizeof(Pgno)==4 );
5480654970
5480754971
pBt = sqlite3MallocZero( sizeof(*pBt) );
@@ -56404,11 +56568,11 @@
5640456568
if( pBtree ){
5640556569
sqlite3BtreeEnter(pBtree);
5640656570
for(p=pBtree->pBt->pCursor; p; p=p->pNext){
5640756571
int i;
5640856572
if( writeOnly && (p->curFlags & BTCF_WriteFlag)==0 ){
56409
- if( p->eState==CURSOR_VALID ){
56573
+ if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){
5641056574
rc = saveCursorPosition(p);
5641156575
if( rc!=SQLITE_OK ){
5641256576
(void)sqlite3BtreeTripAllCursors(pBtree, rc, 0);
5641356577
break;
5641456578
}
@@ -56810,10 +56974,12 @@
5681056974
** to return an integer result code for historical reasons.
5681156975
*/
5681256976
SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
5681356977
assert( cursorHoldsMutex(pCur) );
5681456978
assert( pCur->eState==CURSOR_VALID );
56979
+ assert( pCur->iPage>=0 );
56980
+ assert( pCur->iPage<BTCURSOR_MAX_DEPTH );
5681556981
assert( pCur->apPage[pCur->iPage]->intKeyLeaf==1 );
5681656982
getCellInfo(pCur);
5681756983
*pSize = pCur->info.nPayload;
5681856984
return SQLITE_OK;
5681956985
}
@@ -57288,19 +57454,21 @@
5728857454
return SQLITE_CORRUPT_BKPT;
5728957455
}
5729057456
return SQLITE_OK;
5729157457
}
5729257458
57293
-#if 0
57459
+#if SQLITE_DEBUG
5729457460
/*
5729557461
** Page pParent is an internal (non-leaf) tree page. This function
5729657462
** asserts that page number iChild is the left-child if the iIdx'th
5729757463
** cell in page pParent. Or, if iIdx is equal to the total number of
5729857464
** cells in pParent, that page number iChild is the right-child of
5729957465
** the page.
5730057466
*/
5730157467
static void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){
57468
+ if( CORRUPT_DB ) return; /* The conditions tested below might not be true
57469
+ ** in a corrupt database */
5730257470
assert( iIdx<=pParent->nCell );
5730357471
if( iIdx==pParent->nCell ){
5730457472
assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild );
5730557473
}else{
5730657474
assert( get4byte(findCell(pParent, iIdx))==iChild );
@@ -57321,23 +57489,15 @@
5732157489
static void moveToParent(BtCursor *pCur){
5732257490
assert( cursorHoldsMutex(pCur) );
5732357491
assert( pCur->eState==CURSOR_VALID );
5732457492
assert( pCur->iPage>0 );
5732557493
assert( pCur->apPage[pCur->iPage] );
57326
-
57327
- /* UPDATE: It is actually possible for the condition tested by the assert
57328
- ** below to be untrue if the database file is corrupt. This can occur if
57329
- ** one cursor has modified page pParent while a reference to it is held
57330
- ** by a second cursor. Which can only happen if a single page is linked
57331
- ** into more than one b-tree structure in a corrupt database. */
57332
-#if 0
5733357494
assertParentIndex(
5733457495
pCur->apPage[pCur->iPage-1],
5733557496
pCur->aiIdx[pCur->iPage-1],
5733657497
pCur->apPage[pCur->iPage]->pgno
5733757498
);
57338
-#endif
5733957499
testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell );
5734057500
5734157501
releasePage(pCur->apPage[pCur->iPage]);
5734257502
pCur->iPage--;
5734357503
pCur->info.nSize = 0;
@@ -60259,11 +60419,12 @@
6025960419
** the previous call, as the overflow cell data will have been
6026060420
** copied either into the body of a database page or into the new
6026160421
** pSpace buffer passed to the latter call to balance_nonroot().
6026260422
*/
6026360423
u8 *pSpace = sqlite3PageMalloc(pCur->pBt->pageSize);
60264
- rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1, pCur->hints);
60424
+ rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1,
60425
+ pCur->hints&BTREE_BULKLOAD);
6026560426
if( pFree ){
6026660427
/* If pFree is not NULL, it points to the pSpace buffer used
6026760428
** by a previous call to balance_nonroot(). Its contents are
6026860429
** now stored either on real database pages or within the
6026960430
** new pSpace buffer, so it may be safely freed here. */
@@ -60280,10 +60441,11 @@
6028060441
pPage->nOverflow = 0;
6028160442
6028260443
/* The next iteration of the do-loop balances the parent page. */
6028360444
releasePage(pPage);
6028460445
pCur->iPage--;
60446
+ assert( pCur->iPage>=0 );
6028560447
}
6028660448
}while( rc==SQLITE_OK );
6028760449
6028860450
if( pFree ){
6028960451
sqlite3PageFree(pFree);
@@ -60751,29 +60913,32 @@
6075160913
int rc;
6075260914
unsigned char *pCell;
6075360915
int i;
6075460916
int hdr;
6075560917
u16 szCell;
60918
+ u8 hasChildren;
6075660919
6075760920
assert( sqlite3_mutex_held(pBt->mutex) );
6075860921
if( pgno>btreePagecount(pBt) ){
6075960922
return SQLITE_CORRUPT_BKPT;
6076060923
}
6076160924
6076260925
rc = getAndInitPage(pBt, pgno, &pPage, 0);
6076360926
if( rc ) return rc;
60927
+ hasChildren = !pPage->leaf;
60928
+ pPage->leaf = 1; /* Block looping if the database is corrupt */
6076460929
hdr = pPage->hdrOffset;
6076560930
for(i=0; i<pPage->nCell; i++){
6076660931
pCell = findCell(pPage, i);
60767
- if( !pPage->leaf ){
60932
+ if( hasChildren ){
6076860933
rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
6076960934
if( rc ) goto cleardatabasepage_out;
6077060935
}
6077160936
rc = clearCell(pPage, pCell, &szCell);
6077260937
if( rc ) goto cleardatabasepage_out;
6077360938
}
60774
- if( !pPage->leaf ){
60939
+ if( hasChildren ){
6077560940
rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
6077660941
if( rc ) goto cleardatabasepage_out;
6077760942
}else if( pnChange ){
6077860943
assert( pPage->intKey );
6077960944
*pnChange += pPage->nCell;
@@ -61922,17 +62087,26 @@
6192262087
pBt->btsFlags &= ~BTS_NO_WAL;
6192362088
return rc;
6192462089
}
6192562090
6192662091
/*
61927
-** set the mask of hint flags for cursor pCsr. Currently the only valid
61928
-** values are 0 and BTREE_BULKLOAD.
62092
+** set the mask of hint flags for cursor pCsr.
6192962093
*/
6193062094
SQLITE_PRIVATE void sqlite3BtreeCursorHints(BtCursor *pCsr, unsigned int mask){
61931
- assert( mask==BTREE_BULKLOAD || mask==0 );
62095
+ assert( mask==BTREE_BULKLOAD || mask==BTREE_SEEK_EQ || mask==0 );
6193262096
pCsr->hints = mask;
6193362097
}
62098
+
62099
+#ifdef SQLITE_DEBUG
62100
+/*
62101
+** Return true if the cursor has a hint specified. This routine is
62102
+** only used from within assert() statements
62103
+*/
62104
+SQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor *pCsr, unsigned int mask){
62105
+ return (pCsr->hints & mask)!=0;
62106
+}
62107
+#endif
6193462108
6193562109
/*
6193662110
** Return true if the given Btree is read-only.
6193762111
*/
6193862112
SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *p){
@@ -62088,11 +62262,11 @@
6208862262
** a pointer to the new sqlite3_backup object.
6208962263
**
6209062264
** If an error occurs, NULL is returned and an error code and error message
6209162265
** stored in database handle pDestDb.
6209262266
*/
62093
-SQLITE_API sqlite3_backup *sqlite3_backup_init(
62267
+SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
6209462268
sqlite3* pDestDb, /* Database to write to */
6209562269
const char *zDestDb, /* Name of database within pDestDb */
6209662270
sqlite3* pSrcDb, /* Database connection to read from */
6209762271
const char *zSrcDb /* Name of database within pSrcDb */
6209862272
){
@@ -62296,11 +62470,11 @@
6229662470
}
6229762471
6229862472
/*
6229962473
** Copy nPage pages from the source b-tree to the destination.
6230062474
*/
62301
-SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){
62475
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage){
6230262476
int rc;
6230362477
int destMode; /* Destination journal mode */
6230462478
int pgszSrc = 0; /* Source page size */
6230562479
int pgszDest = 0; /* Destination page size */
6230662480
@@ -62541,11 +62715,11 @@
6254162715
}
6254262716
6254362717
/*
6254462718
** Release all resources associated with an sqlite3_backup* handle.
6254562719
*/
62546
-SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p){
62720
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p){
6254762721
sqlite3_backup **pp; /* Ptr to head of pagers backup list */
6254862722
sqlite3 *pSrcDb; /* Source database connection */
6254962723
int rc; /* Value to return */
6255062724
6255162725
/* Enter the mutexes */
@@ -62593,11 +62767,11 @@
6259362767
6259462768
/*
6259562769
** Return the number of pages still to be backed up as of the most recent
6259662770
** call to sqlite3_backup_step().
6259762771
*/
62598
-SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p){
62772
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p){
6259962773
#ifdef SQLITE_ENABLE_API_ARMOR
6260062774
if( p==0 ){
6260162775
(void)SQLITE_MISUSE_BKPT;
6260262776
return 0;
6260362777
}
@@ -62607,11 +62781,11 @@
6260762781
6260862782
/*
6260962783
** Return the total number of pages in the source database as of the most
6261062784
** recent call to sqlite3_backup_step().
6261162785
*/
62612
-SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p){
62786
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p){
6261362787
#ifdef SQLITE_ENABLE_API_ARMOR
6261462788
if( p==0 ){
6261562789
(void)SQLITE_MISUSE_BKPT;
6261662790
return 0;
6261762791
}
@@ -63822,11 +63996,11 @@
6382263996
** by calling sqlite3ValueNew().
6382363997
**
6382463998
** Otherwise, if the second argument is non-zero, then this function is
6382563999
** being called indirectly by sqlite3Stat4ProbeSetValue(). If it has not
6382664000
** already been allocated, allocate the UnpackedRecord structure that
63827
-** that function will return to its caller here. Then return a pointer
64001
+** that function will return to its caller here. Then return a pointer to
6382864002
** an sqlite3_value within the UnpackedRecord.a[] array.
6382964003
*/
6383064004
static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){
6383164005
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
6383264006
if( p ){
@@ -63866,10 +64040,117 @@
6386664040
UNUSED_PARAMETER(p);
6386764041
#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
6386864042
return sqlite3ValueNew(db);
6386964043
}
6387064044
64045
+/*
64046
+** The expression object indicated by the second argument is guaranteed
64047
+** to be a scalar SQL function. If
64048
+**
64049
+** * all function arguments are SQL literals,
64050
+** * the SQLITE_FUNC_CONSTANT function flag is set, and
64051
+** * the SQLITE_FUNC_NEEDCOLL function flag is not set,
64052
+**
64053
+** then this routine attempts to invoke the SQL function. Assuming no
64054
+** error occurs, output parameter (*ppVal) is set to point to a value
64055
+** object containing the result before returning SQLITE_OK.
64056
+**
64057
+** Affinity aff is applied to the result of the function before returning.
64058
+** If the result is a text value, the sqlite3_value object uses encoding
64059
+** enc.
64060
+**
64061
+** If the conditions above are not met, this function returns SQLITE_OK
64062
+** and sets (*ppVal) to NULL. Or, if an error occurs, (*ppVal) is set to
64063
+** NULL and an SQLite error code returned.
64064
+*/
64065
+#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
64066
+static int valueFromFunction(
64067
+ sqlite3 *db, /* The database connection */
64068
+ Expr *p, /* The expression to evaluate */
64069
+ u8 enc, /* Encoding to use */
64070
+ u8 aff, /* Affinity to use */
64071
+ sqlite3_value **ppVal, /* Write the new value here */
64072
+ struct ValueNewStat4Ctx *pCtx /* Second argument for valueNew() */
64073
+){
64074
+ sqlite3_context ctx; /* Context object for function invocation */
64075
+ sqlite3_value **apVal = 0; /* Function arguments */
64076
+ int nVal = 0; /* Size of apVal[] array */
64077
+ FuncDef *pFunc = 0; /* Function definition */
64078
+ sqlite3_value *pVal = 0; /* New value */
64079
+ int rc = SQLITE_OK; /* Return code */
64080
+ int nName; /* Size of function name in bytes */
64081
+ ExprList *pList = 0; /* Function arguments */
64082
+ int i; /* Iterator variable */
64083
+
64084
+ assert( pCtx!=0 );
64085
+ assert( (p->flags & EP_TokenOnly)==0 );
64086
+ pList = p->x.pList;
64087
+ if( pList ) nVal = pList->nExpr;
64088
+ nName = sqlite3Strlen30(p->u.zToken);
64089
+ pFunc = sqlite3FindFunction(db, p->u.zToken, nName, nVal, enc, 0);
64090
+ assert( pFunc );
64091
+ if( (pFunc->funcFlags & SQLITE_FUNC_CONSTANT)==0
64092
+ || (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)
64093
+ ){
64094
+ return SQLITE_OK;
64095
+ }
64096
+
64097
+ if( pList ){
64098
+ apVal = (sqlite3_value**)sqlite3DbMallocZero(db, sizeof(apVal[0]) * nVal);
64099
+ if( apVal==0 ){
64100
+ rc = SQLITE_NOMEM;
64101
+ goto value_from_function_out;
64102
+ }
64103
+ for(i=0; i<nVal; i++){
64104
+ rc = sqlite3ValueFromExpr(db, pList->a[i].pExpr, enc, aff, &apVal[i]);
64105
+ if( apVal[i]==0 || rc!=SQLITE_OK ) goto value_from_function_out;
64106
+ }
64107
+ }
64108
+
64109
+ pVal = valueNew(db, pCtx);
64110
+ if( pVal==0 ){
64111
+ rc = SQLITE_NOMEM;
64112
+ goto value_from_function_out;
64113
+ }
64114
+
64115
+ assert( pCtx->pParse->rc==SQLITE_OK );
64116
+ memset(&ctx, 0, sizeof(ctx));
64117
+ ctx.pOut = pVal;
64118
+ ctx.pFunc = pFunc;
64119
+ pFunc->xFunc(&ctx, nVal, apVal);
64120
+ if( ctx.isError ){
64121
+ rc = ctx.isError;
64122
+ sqlite3ErrorMsg(pCtx->pParse, "%s", sqlite3_value_text(pVal));
64123
+ }else{
64124
+ sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8);
64125
+ assert( rc==SQLITE_OK );
64126
+ rc = sqlite3VdbeChangeEncoding(pVal, enc);
64127
+ if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){
64128
+ rc = SQLITE_TOOBIG;
64129
+ pCtx->pParse->nErr++;
64130
+ }
64131
+ }
64132
+ pCtx->pParse->rc = rc;
64133
+
64134
+ value_from_function_out:
64135
+ if( rc!=SQLITE_OK ){
64136
+ pVal = 0;
64137
+ }
64138
+ if( apVal ){
64139
+ for(i=0; i<nVal; i++){
64140
+ sqlite3ValueFree(apVal[i]);
64141
+ }
64142
+ sqlite3DbFree(db, apVal);
64143
+ }
64144
+
64145
+ *ppVal = pVal;
64146
+ return rc;
64147
+}
64148
+#else
64149
+# define valueFromFunction(a,b,c,d,e,f) SQLITE_OK
64150
+#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
64151
+
6387164152
/*
6387264153
** Extract a value from the supplied expression in the manner described
6387364154
** above sqlite3ValueFromExpr(). Allocate the sqlite3_value object
6387464155
** using valueNew().
6387564156
**
@@ -63897,10 +64178,16 @@
6389764178
*ppVal = 0;
6389864179
return SQLITE_OK;
6389964180
}
6390064181
while( (op = pExpr->op)==TK_UPLUS ) pExpr = pExpr->pLeft;
6390164182
if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
64183
+
64184
+ /* Compressed expressions only appear when parsing the DEFAULT clause
64185
+ ** on a table column definition, and hence only when pCtx==0. This
64186
+ ** check ensures that an EP_TokenOnly expression is never passed down
64187
+ ** into valueFromFunction(). */
64188
+ assert( (pExpr->flags & EP_TokenOnly)==0 || pCtx==0 );
6390264189
6390364190
if( op==TK_CAST ){
6390464191
u8 aff = sqlite3AffinityType(pExpr->u.zToken,0);
6390564192
rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx);
6390664193
testcase( rc!=SQLITE_OK );
@@ -63973,10 +64260,16 @@
6397364260
assert( zVal[nVal]=='\'' );
6397464261
sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,
6397564262
0, SQLITE_DYNAMIC);
6397664263
}
6397764264
#endif
64265
+
64266
+#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
64267
+ else if( op==TK_FUNCTION && pCtx!=0 ){
64268
+ rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);
64269
+ }
64270
+#endif
6397864271
6397964272
*ppVal = pVal;
6398064273
return rc;
6398164274
6398264275
no_mem:
@@ -64363,11 +64656,11 @@
6436364656
}
6436464657
6436564658
/*
6436664659
** Return the SQL associated with a prepared statement
6436764660
*/
64368
-SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt){
64661
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){
6436964662
Vdbe *p = (Vdbe *)pStmt;
6437064663
return (p && p->isPrepareV2) ? p->zSql : 0;
6437164664
}
6437264665
6437364666
/*
@@ -65426,11 +65719,11 @@
6542665719
break;
6542765720
}
6542865721
#ifndef SQLITE_OMIT_VIRTUALTABLE
6542965722
case P4_VTAB: {
6543065723
sqlite3_vtab *pVtab = pOp->p4.pVtab->pVtab;
65431
- sqlite3_snprintf(nTemp, zTemp, "vtab:%p:%p", pVtab, pVtab->pModule);
65724
+ sqlite3_snprintf(nTemp, zTemp, "vtab:%p", pVtab);
6543265725
break;
6543365726
}
6543465727
#endif
6543565728
case P4_INTARRAY: {
6543665729
sqlite3_snprintf(nTemp, zTemp, "intarray");
@@ -66090,13 +66383,13 @@
6609066383
}
6609166384
#ifndef SQLITE_OMIT_VIRTUALTABLE
6609266385
else if( pCx->pVtabCursor ){
6609366386
sqlite3_vtab_cursor *pVtabCursor = pCx->pVtabCursor;
6609466387
const sqlite3_module *pModule = pVtabCursor->pVtab->pModule;
66095
- p->inVtabMethod = 1;
66388
+ assert( pVtabCursor->pVtab->nRef>0 );
66389
+ pVtabCursor->pVtab->nRef--;
6609666390
pModule->xClose(pVtabCursor);
66097
- p->inVtabMethod = 0;
6609866391
}
6609966392
#endif
6610066393
}
6610166394
6610266395
/*
@@ -66451,11 +66744,11 @@
6645166744
6645266745
/* Delete the master journal file. This commits the transaction. After
6645366746
** doing this the directory is synced again before any individual
6645466747
** transaction files are deleted.
6645566748
*/
66456
- rc = sqlite3OsDelete(pVfs, zMaster, 1);
66749
+ rc = sqlite3OsDelete(pVfs, zMaster, needSync);
6645766750
sqlite3DbFree(db, zMaster);
6645866751
zMaster = 0;
6645966752
if( rc ){
6646066753
return rc;
6646166754
}
@@ -68519,11 +68812,11 @@
6851968812
** execution environment changes in a way that would alter the program
6852068813
** that sqlite3_prepare() generates. For example, if new functions or
6852168814
** collating sequences are registered or if an authorizer function is
6852268815
** added or changed.
6852368816
*/
68524
-SQLITE_API int sqlite3_expired(sqlite3_stmt *pStmt){
68817
+SQLITE_API int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt *pStmt){
6852568818
Vdbe *p = (Vdbe*)pStmt;
6852668819
return p==0 || p->expired;
6852768820
}
6852868821
#endif
6852968822
@@ -68556,11 +68849,11 @@
6855668849
** machine.
6855768850
**
6855868851
** This routine sets the error code and string returned by
6855968852
** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
6856068853
*/
68561
-SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt){
68854
+SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt){
6856268855
int rc;
6856368856
if( pStmt==0 ){
6856468857
/* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL
6856568858
** pointer is a harmless no-op. */
6856668859
rc = SQLITE_OK;
@@ -68582,11 +68875,11 @@
6858268875
** the prior execution is returned.
6858368876
**
6858468877
** This routine sets the error code and string returned by
6858568878
** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
6858668879
*/
68587
-SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt){
68880
+SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt){
6858868881
int rc;
6858968882
if( pStmt==0 ){
6859068883
rc = SQLITE_OK;
6859168884
}else{
6859268885
Vdbe *v = (Vdbe*)pStmt;
@@ -68601,11 +68894,11 @@
6860168894
}
6860268895
6860368896
/*
6860468897
** Set all the parameters in the compiled SQL statement to NULL.
6860568898
*/
68606
-SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *pStmt){
68899
+SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt *pStmt){
6860768900
int i;
6860868901
int rc = SQLITE_OK;
6860968902
Vdbe *p = (Vdbe*)pStmt;
6861068903
#if SQLITE_THREADSAFE
6861168904
sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex;
@@ -68625,54 +68918,54 @@
6862568918
6862668919
/**************************** sqlite3_value_ *******************************
6862768920
** The following routines extract information from a Mem or sqlite3_value
6862868921
** structure.
6862968922
*/
68630
-SQLITE_API const void *sqlite3_value_blob(sqlite3_value *pVal){
68923
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value *pVal){
6863168924
Mem *p = (Mem*)pVal;
6863268925
if( p->flags & (MEM_Blob|MEM_Str) ){
6863368926
sqlite3VdbeMemExpandBlob(p);
6863468927
p->flags |= MEM_Blob;
6863568928
return p->n ? p->z : 0;
6863668929
}else{
6863768930
return sqlite3_value_text(pVal);
6863868931
}
6863968932
}
68640
-SQLITE_API int sqlite3_value_bytes(sqlite3_value *pVal){
68933
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value *pVal){
6864168934
return sqlite3ValueBytes(pVal, SQLITE_UTF8);
6864268935
}
68643
-SQLITE_API int sqlite3_value_bytes16(sqlite3_value *pVal){
68936
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value *pVal){
6864468937
return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE);
6864568938
}
68646
-SQLITE_API double sqlite3_value_double(sqlite3_value *pVal){
68939
+SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value *pVal){
6864768940
return sqlite3VdbeRealValue((Mem*)pVal);
6864868941
}
68649
-SQLITE_API int sqlite3_value_int(sqlite3_value *pVal){
68942
+SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value *pVal){
6865068943
return (int)sqlite3VdbeIntValue((Mem*)pVal);
6865168944
}
68652
-SQLITE_API sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){
68945
+SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value *pVal){
6865368946
return sqlite3VdbeIntValue((Mem*)pVal);
6865468947
}
68655
-SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
68948
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value *pVal){
6865668949
return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
6865768950
}
6865868951
#ifndef SQLITE_OMIT_UTF16
68659
-SQLITE_API const void *sqlite3_value_text16(sqlite3_value* pVal){
68952
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value* pVal){
6866068953
return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE);
6866168954
}
68662
-SQLITE_API const void *sqlite3_value_text16be(sqlite3_value *pVal){
68955
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value *pVal){
6866368956
return sqlite3ValueText(pVal, SQLITE_UTF16BE);
6866468957
}
68665
-SQLITE_API const void *sqlite3_value_text16le(sqlite3_value *pVal){
68958
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value *pVal){
6866668959
return sqlite3ValueText(pVal, SQLITE_UTF16LE);
6866768960
}
6866868961
#endif /* SQLITE_OMIT_UTF16 */
6866968962
/* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five
6867068963
** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating
6867168964
** point number string BLOB NULL
6867268965
*/
68673
-SQLITE_API int sqlite3_value_type(sqlite3_value* pVal){
68966
+SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value* pVal){
6867468967
static const u8 aType[] = {
6867568968
SQLITE_BLOB, /* 0x00 */
6867668969
SQLITE_NULL, /* 0x01 */
6867768970
SQLITE_TEXT, /* 0x02 */
6867868971
SQLITE_NULL, /* 0x03 */
@@ -68744,21 +69037,21 @@
6874469037
xDel((void*)p);
6874569038
}
6874669039
if( pCtx ) sqlite3_result_error_toobig(pCtx);
6874769040
return SQLITE_TOOBIG;
6874869041
}
68749
-SQLITE_API void sqlite3_result_blob(
69042
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(
6875069043
sqlite3_context *pCtx,
6875169044
const void *z,
6875269045
int n,
6875369046
void (*xDel)(void *)
6875469047
){
6875569048
assert( n>=0 );
6875669049
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6875769050
setResultStrOrError(pCtx, z, n, 0, xDel);
6875869051
}
68759
-SQLITE_API void sqlite3_result_blob64(
69052
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(
6876069053
sqlite3_context *pCtx,
6876169054
const void *z,
6876269055
sqlite3_uint64 n,
6876369056
void (*xDel)(void *)
6876469057
){
@@ -68768,50 +69061,50 @@
6876869061
(void)invokeValueDestructor(z, xDel, pCtx);
6876969062
}else{
6877069063
setResultStrOrError(pCtx, z, (int)n, 0, xDel);
6877169064
}
6877269065
}
68773
-SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){
69066
+SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context *pCtx, double rVal){
6877469067
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6877569068
sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);
6877669069
}
68777
-SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
69070
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
6877869071
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6877969072
pCtx->isError = SQLITE_ERROR;
6878069073
pCtx->fErrorOrAux = 1;
6878169074
sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);
6878269075
}
6878369076
#ifndef SQLITE_OMIT_UTF16
68784
-SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
69077
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
6878569078
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6878669079
pCtx->isError = SQLITE_ERROR;
6878769080
pCtx->fErrorOrAux = 1;
6878869081
sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);
6878969082
}
6879069083
#endif
68791
-SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){
69084
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context *pCtx, int iVal){
6879269085
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6879369086
sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal);
6879469087
}
68795
-SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
69088
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
6879669089
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6879769090
sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);
6879869091
}
68799
-SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){
69092
+SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context *pCtx){
6880069093
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6880169094
sqlite3VdbeMemSetNull(pCtx->pOut);
6880269095
}
68803
-SQLITE_API void sqlite3_result_text(
69096
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text(
6880469097
sqlite3_context *pCtx,
6880569098
const char *z,
6880669099
int n,
6880769100
void (*xDel)(void *)
6880869101
){
6880969102
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6881069103
setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);
6881169104
}
68812
-SQLITE_API void sqlite3_result_text64(
69105
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(
6881369106
sqlite3_context *pCtx,
6881469107
const char *z,
6881569108
sqlite3_uint64 n,
6881669109
void (*xDel)(void *),
6881769110
unsigned char enc
@@ -68824,69 +69117,69 @@
6882469117
}else{
6882569118
setResultStrOrError(pCtx, z, (int)n, enc, xDel);
6882669119
}
6882769120
}
6882869121
#ifndef SQLITE_OMIT_UTF16
68829
-SQLITE_API void sqlite3_result_text16(
69122
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(
6883069123
sqlite3_context *pCtx,
6883169124
const void *z,
6883269125
int n,
6883369126
void (*xDel)(void *)
6883469127
){
6883569128
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6883669129
setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel);
6883769130
}
68838
-SQLITE_API void sqlite3_result_text16be(
69131
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(
6883969132
sqlite3_context *pCtx,
6884069133
const void *z,
6884169134
int n,
6884269135
void (*xDel)(void *)
6884369136
){
6884469137
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6884569138
setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel);
6884669139
}
68847
-SQLITE_API void sqlite3_result_text16le(
69140
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(
6884869141
sqlite3_context *pCtx,
6884969142
const void *z,
6885069143
int n,
6885169144
void (*xDel)(void *)
6885269145
){
6885369146
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6885469147
setResultStrOrError(pCtx, z, n, SQLITE_UTF16LE, xDel);
6885569148
}
6885669149
#endif /* SQLITE_OMIT_UTF16 */
68857
-SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){
69150
+SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){
6885869151
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6885969152
sqlite3VdbeMemCopy(pCtx->pOut, pValue);
6886069153
}
68861
-SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){
69154
+SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){
6886269155
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6886369156
sqlite3VdbeMemSetZeroBlob(pCtx->pOut, n);
6886469157
}
68865
-SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
69158
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
6886669159
pCtx->isError = errCode;
6886769160
pCtx->fErrorOrAux = 1;
6886869161
#ifdef SQLITE_DEBUG
68869
- pCtx->pVdbe->rcApp = errCode;
69162
+ if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode;
6887069163
#endif
6887169164
if( pCtx->pOut->flags & MEM_Null ){
6887269165
sqlite3VdbeMemSetStr(pCtx->pOut, sqlite3ErrStr(errCode), -1,
6887369166
SQLITE_UTF8, SQLITE_STATIC);
6887469167
}
6887569168
}
6887669169
6887769170
/* Force an SQLITE_TOOBIG error. */
68878
-SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){
69171
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context *pCtx){
6887969172
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6888069173
pCtx->isError = SQLITE_TOOBIG;
6888169174
pCtx->fErrorOrAux = 1;
6888269175
sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1,
6888369176
SQLITE_UTF8, SQLITE_STATIC);
6888469177
}
6888569178
6888669179
/* An SQLITE_NOMEM error. */
68887
-SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){
69180
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context *pCtx){
6888869181
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6888969182
sqlite3VdbeMemSetNull(pCtx->pOut);
6889069183
pCtx->isError = SQLITE_NOMEM;
6889169184
pCtx->fErrorOrAux = 1;
6889269185
pCtx->pOut->db->mallocFailed = 1;
@@ -69055,11 +69348,11 @@
6905569348
/*
6905669349
** This is the top-level implementation of sqlite3_step(). Call
6905769350
** sqlite3Step() to do most of the work. If a schema error occurs,
6905869351
** call sqlite3Reprepare() and try again.
6905969352
*/
69060
-SQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){
69353
+SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt *pStmt){
6906169354
int rc = SQLITE_OK; /* Result from sqlite3Step() */
6906269355
int rc2 = SQLITE_OK; /* Result from sqlite3Reprepare() */
6906369356
Vdbe *v = (Vdbe*)pStmt; /* the prepared statement */
6906469357
int cnt = 0; /* Counter to prevent infinite loop of reprepares */
6906569358
sqlite3 *db; /* The database connection */
@@ -69106,11 +69399,11 @@
6910669399
6910769400
/*
6910869401
** Extract the user data from a sqlite3_context structure and return a
6910969402
** pointer to it.
6911069403
*/
69111
-SQLITE_API void *sqlite3_user_data(sqlite3_context *p){
69404
+SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context *p){
6911269405
assert( p && p->pFunc );
6911369406
return p->pFunc->pUserData;
6911469407
}
6911569408
6911669409
/*
@@ -69121,26 +69414,36 @@
6912169414
** returns a copy of the pointer to the database connection (the 1st
6912269415
** parameter) of the sqlite3_create_function() and
6912369416
** sqlite3_create_function16() routines that originally registered the
6912469417
** application defined function.
6912569418
*/
69126
-SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){
69419
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context *p){
6912769420
assert( p && p->pFunc );
6912869421
return p->pOut->db;
6912969422
}
6913069423
6913169424
/*
69132
-** Return the current time for a statement
69425
+** Return the current time for a statement. If the current time
69426
+** is requested more than once within the same run of a single prepared
69427
+** statement, the exact same time is returned for each invocation regardless
69428
+** of the amount of time that elapses between invocations. In other words,
69429
+** the time returned is always the time of the first call.
6913369430
*/
6913469431
SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){
69135
- Vdbe *v = p->pVdbe;
6913669432
int rc;
69137
- if( v->iCurrentTime==0 ){
69138
- rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, &v->iCurrentTime);
69139
- if( rc ) v->iCurrentTime = 0;
69433
+#ifndef SQLITE_ENABLE_STAT3_OR_STAT4
69434
+ sqlite3_int64 *piTime = &p->pVdbe->iCurrentTime;
69435
+ assert( p->pVdbe!=0 );
69436
+#else
69437
+ sqlite3_int64 iTime = 0;
69438
+ sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;
69439
+#endif
69440
+ if( *piTime==0 ){
69441
+ rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime);
69442
+ if( rc ) *piTime = 0;
6914069443
}
69141
- return v->iCurrentTime;
69444
+ return *piTime;
6914269445
}
6914369446
6914469447
/*
6914569448
** The following is the implementation of an SQL function that always
6914669449
** fails with an error message stating that the function is used in the
@@ -69187,11 +69490,11 @@
6918769490
/*
6918869491
** Allocate or return the aggregate context for a user function. A new
6918969492
** context is allocated on the first call. Subsequent calls return the
6919069493
** same context that was returned on prior calls.
6919169494
*/
69192
-SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
69495
+SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context *p, int nByte){
6919369496
assert( p && p->pFunc && p->pFunc->xStep );
6919469497
assert( sqlite3_mutex_held(p->pOut->db->mutex) );
6919569498
testcase( nByte<0 );
6919669499
if( (p->pMem->flags & MEM_Agg)==0 ){
6919769500
return createAggContext(p, nByte);
@@ -69202,14 +69505,19 @@
6920269505
6920369506
/*
6920469507
** Return the auxiliary data pointer, if any, for the iArg'th argument to
6920569508
** the user-function defined by pCtx.
6920669509
*/
69207
-SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
69510
+SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
6920869511
AuxData *pAuxData;
6920969512
6921069513
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69514
+#if SQLITE_ENABLE_STAT3_OR_STAT4
69515
+ if( pCtx->pVdbe==0 ) return 0;
69516
+#else
69517
+ assert( pCtx->pVdbe!=0 );
69518
+#endif
6921169519
for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
6921269520
if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
6921369521
}
6921469522
6921569523
return (pAuxData ? pAuxData->pAux : 0);
@@ -69218,11 +69526,11 @@
6921869526
/*
6921969527
** Set the auxiliary data pointer and delete function, for the iArg'th
6922069528
** argument to the user-function defined by pCtx. Any previous value is
6922169529
** deleted by calling the delete function specified when it was set.
6922269530
*/
69223
-SQLITE_API void sqlite3_set_auxdata(
69531
+SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(
6922469532
sqlite3_context *pCtx,
6922569533
int iArg,
6922669534
void *pAux,
6922769535
void (*xDelete)(void*)
6922869536
){
@@ -69229,10 +69537,15 @@
6922969537
AuxData *pAuxData;
6923069538
Vdbe *pVdbe = pCtx->pVdbe;
6923169539
6923269540
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6923369541
if( iArg<0 ) goto failed;
69542
+#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
69543
+ if( pVdbe==0 ) goto failed;
69544
+#else
69545
+ assert( pVdbe!=0 );
69546
+#endif
6923469547
6923569548
for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
6923669549
if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
6923769550
}
6923869551
if( pAuxData==0 ){
@@ -69268,29 +69581,29 @@
6926869581
** This function is deprecated. Do not use it for new code. It is
6926969582
** provide only to avoid breaking legacy code. New aggregate function
6927069583
** implementations should keep their own counts within their aggregate
6927169584
** context.
6927269585
*/
69273
-SQLITE_API int sqlite3_aggregate_count(sqlite3_context *p){
69586
+SQLITE_API int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context *p){
6927469587
assert( p && p->pMem && p->pFunc && p->pFunc->xStep );
6927569588
return p->pMem->n;
6927669589
}
6927769590
#endif
6927869591
6927969592
/*
6928069593
** Return the number of columns in the result set for the statement pStmt.
6928169594
*/
69282
-SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt){
69595
+SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt){
6928369596
Vdbe *pVm = (Vdbe *)pStmt;
6928469597
return pVm ? pVm->nResColumn : 0;
6928569598
}
6928669599
6928769600
/*
6928869601
** Return the number of values available from the current row of the
6928969602
** currently executing statement pStmt.
6929069603
*/
69291
-SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt){
69604
+SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt){
6929269605
Vdbe *pVm = (Vdbe *)pStmt;
6929369606
if( pVm==0 || pVm->pResultSet==0 ) return 0;
6929469607
return pVm->nResColumn;
6929569608
}
6929669609
@@ -69388,67 +69701,67 @@
6938869701
6938969702
/**************************** sqlite3_column_ *******************************
6939069703
** The following routines are used to access elements of the current row
6939169704
** in the result set.
6939269705
*/
69393
-SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt *pStmt, int i){
69706
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt *pStmt, int i){
6939469707
const void *val;
6939569708
val = sqlite3_value_blob( columnMem(pStmt,i) );
6939669709
/* Even though there is no encoding conversion, value_blob() might
6939769710
** need to call malloc() to expand the result of a zeroblob()
6939869711
** expression.
6939969712
*/
6940069713
columnMallocFailure(pStmt);
6940169714
return val;
6940269715
}
69403
-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){
69716
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){
6940469717
int val = sqlite3_value_bytes( columnMem(pStmt,i) );
6940569718
columnMallocFailure(pStmt);
6940669719
return val;
6940769720
}
69408
-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){
69721
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){
6940969722
int val = sqlite3_value_bytes16( columnMem(pStmt,i) );
6941069723
columnMallocFailure(pStmt);
6941169724
return val;
6941269725
}
69413
-SQLITE_API double sqlite3_column_double(sqlite3_stmt *pStmt, int i){
69726
+SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt *pStmt, int i){
6941469727
double val = sqlite3_value_double( columnMem(pStmt,i) );
6941569728
columnMallocFailure(pStmt);
6941669729
return val;
6941769730
}
69418
-SQLITE_API int sqlite3_column_int(sqlite3_stmt *pStmt, int i){
69731
+SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt *pStmt, int i){
6941969732
int val = sqlite3_value_int( columnMem(pStmt,i) );
6942069733
columnMallocFailure(pStmt);
6942169734
return val;
6942269735
}
69423
-SQLITE_API sqlite_int64 sqlite3_column_int64(sqlite3_stmt *pStmt, int i){
69736
+SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt *pStmt, int i){
6942469737
sqlite_int64 val = sqlite3_value_int64( columnMem(pStmt,i) );
6942569738
columnMallocFailure(pStmt);
6942669739
return val;
6942769740
}
69428
-SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt *pStmt, int i){
69741
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt *pStmt, int i){
6942969742
const unsigned char *val = sqlite3_value_text( columnMem(pStmt,i) );
6943069743
columnMallocFailure(pStmt);
6943169744
return val;
6943269745
}
69433
-SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt *pStmt, int i){
69746
+SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt *pStmt, int i){
6943469747
Mem *pOut = columnMem(pStmt, i);
6943569748
if( pOut->flags&MEM_Static ){
6943669749
pOut->flags &= ~MEM_Static;
6943769750
pOut->flags |= MEM_Ephem;
6943869751
}
6943969752
columnMallocFailure(pStmt);
6944069753
return (sqlite3_value *)pOut;
6944169754
}
6944269755
#ifndef SQLITE_OMIT_UTF16
69443
-SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt *pStmt, int i){
69756
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt *pStmt, int i){
6944469757
const void *val = sqlite3_value_text16( columnMem(pStmt,i) );
6944569758
columnMallocFailure(pStmt);
6944669759
return val;
6944769760
}
6944869761
#endif /* SQLITE_OMIT_UTF16 */
69449
-SQLITE_API int sqlite3_column_type(sqlite3_stmt *pStmt, int i){
69762
+SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt *pStmt, int i){
6945069763
int iType = sqlite3_value_type( columnMem(pStmt,i) );
6945169764
columnMallocFailure(pStmt);
6945269765
return iType;
6945369766
}
6945469767
@@ -69508,16 +69821,16 @@
6950869821
6950969822
/*
6951069823
** Return the name of the Nth column of the result set returned by SQL
6951169824
** statement pStmt.
6951269825
*/
69513
-SQLITE_API const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){
69826
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt *pStmt, int N){
6951469827
return columnName(
6951569828
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_NAME);
6951669829
}
6951769830
#ifndef SQLITE_OMIT_UTF16
69518
-SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
69831
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
6951969832
return columnName(
6952069833
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_NAME);
6952169834
}
6952269835
#endif
6952369836
@@ -69533,16 +69846,16 @@
6953369846
#ifndef SQLITE_OMIT_DECLTYPE
6953469847
/*
6953569848
** Return the column declaration type (if applicable) of the 'i'th column
6953669849
** of the result set of SQL statement pStmt.
6953769850
*/
69538
-SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){
69851
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){
6953969852
return columnName(
6954069853
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DECLTYPE);
6954169854
}
6954269855
#ifndef SQLITE_OMIT_UTF16
69543
-SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
69856
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
6954469857
return columnName(
6954569858
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DECLTYPE);
6954669859
}
6954769860
#endif /* SQLITE_OMIT_UTF16 */
6954869861
#endif /* SQLITE_OMIT_DECLTYPE */
@@ -69551,16 +69864,16 @@
6955169864
/*
6955269865
** Return the name of the database from which a result column derives.
6955369866
** NULL is returned if the result column is an expression or constant or
6955469867
** anything else which is not an unambiguous reference to a database column.
6955569868
*/
69556
-SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){
69869
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){
6955769870
return columnName(
6955869871
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DATABASE);
6955969872
}
6956069873
#ifndef SQLITE_OMIT_UTF16
69561
-SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){
69874
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){
6956269875
return columnName(
6956369876
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DATABASE);
6956469877
}
6956569878
#endif /* SQLITE_OMIT_UTF16 */
6956669879
@@ -69567,16 +69880,16 @@
6956769880
/*
6956869881
** Return the name of the table from which a result column derives.
6956969882
** NULL is returned if the result column is an expression or constant or
6957069883
** anything else which is not an unambiguous reference to a database column.
6957169884
*/
69572
-SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){
69885
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){
6957369886
return columnName(
6957469887
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_TABLE);
6957569888
}
6957669889
#ifndef SQLITE_OMIT_UTF16
69577
-SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){
69890
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){
6957869891
return columnName(
6957969892
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_TABLE);
6958069893
}
6958169894
#endif /* SQLITE_OMIT_UTF16 */
6958269895
@@ -69583,16 +69896,16 @@
6958369896
/*
6958469897
** Return the name of the table column from which a result column derives.
6958569898
** NULL is returned if the result column is an expression or constant or
6958669899
** anything else which is not an unambiguous reference to a database column.
6958769900
*/
69588
-SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){
69901
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){
6958969902
return columnName(
6959069903
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_COLUMN);
6959169904
}
6959269905
#ifndef SQLITE_OMIT_UTF16
69593
-SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){
69906
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){
6959469907
return columnName(
6959569908
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN);
6959669909
}
6959769910
#endif /* SQLITE_OMIT_UTF16 */
6959869911
#endif /* SQLITE_ENABLE_COLUMN_METADATA */
@@ -69689,20 +70002,20 @@
6968970002
6969070003
6969170004
/*
6969270005
** Bind a blob value to an SQL statement variable.
6969370006
*/
69694
-SQLITE_API int sqlite3_bind_blob(
70007
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(
6969570008
sqlite3_stmt *pStmt,
6969670009
int i,
6969770010
const void *zData,
6969870011
int nData,
6969970012
void (*xDel)(void*)
6970070013
){
6970170014
return bindText(pStmt, i, zData, nData, xDel, 0);
6970270015
}
69703
-SQLITE_API int sqlite3_bind_blob64(
70016
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(
6970470017
sqlite3_stmt *pStmt,
6970570018
int i,
6970670019
const void *zData,
6970770020
sqlite3_uint64 nData,
6970870021
void (*xDel)(void*)
@@ -69712,52 +70025,52 @@
6971270025
return invokeValueDestructor(zData, xDel, 0);
6971370026
}else{
6971470027
return bindText(pStmt, i, zData, (int)nData, xDel, 0);
6971570028
}
6971670029
}
69717
-SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
70030
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
6971870031
int rc;
6971970032
Vdbe *p = (Vdbe *)pStmt;
6972070033
rc = vdbeUnbind(p, i);
6972170034
if( rc==SQLITE_OK ){
6972270035
sqlite3VdbeMemSetDouble(&p->aVar[i-1], rValue);
6972370036
sqlite3_mutex_leave(p->db->mutex);
6972470037
}
6972570038
return rc;
6972670039
}
69727
-SQLITE_API int sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){
70040
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){
6972870041
return sqlite3_bind_int64(p, i, (i64)iValue);
6972970042
}
69730
-SQLITE_API int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){
70043
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){
6973170044
int rc;
6973270045
Vdbe *p = (Vdbe *)pStmt;
6973370046
rc = vdbeUnbind(p, i);
6973470047
if( rc==SQLITE_OK ){
6973570048
sqlite3VdbeMemSetInt64(&p->aVar[i-1], iValue);
6973670049
sqlite3_mutex_leave(p->db->mutex);
6973770050
}
6973870051
return rc;
6973970052
}
69740
-SQLITE_API int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
70053
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
6974170054
int rc;
6974270055
Vdbe *p = (Vdbe*)pStmt;
6974370056
rc = vdbeUnbind(p, i);
6974470057
if( rc==SQLITE_OK ){
6974570058
sqlite3_mutex_leave(p->db->mutex);
6974670059
}
6974770060
return rc;
6974870061
}
69749
-SQLITE_API int sqlite3_bind_text(
70062
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(
6975070063
sqlite3_stmt *pStmt,
6975170064
int i,
6975270065
const char *zData,
6975370066
int nData,
6975470067
void (*xDel)(void*)
6975570068
){
6975670069
return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);
6975770070
}
69758
-SQLITE_API int sqlite3_bind_text64(
70071
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(
6975970072
sqlite3_stmt *pStmt,
6976070073
int i,
6976170074
const char *zData,
6976270075
sqlite3_uint64 nData,
6976370076
void (*xDel)(void*),
@@ -69770,21 +70083,21 @@
6977070083
if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
6977170084
return bindText(pStmt, i, zData, (int)nData, xDel, enc);
6977270085
}
6977370086
}
6977470087
#ifndef SQLITE_OMIT_UTF16
69775
-SQLITE_API int sqlite3_bind_text16(
70088
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(
6977670089
sqlite3_stmt *pStmt,
6977770090
int i,
6977870091
const void *zData,
6977970092
int nData,
6978070093
void (*xDel)(void*)
6978170094
){
6978270095
return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);
6978370096
}
6978470097
#endif /* SQLITE_OMIT_UTF16 */
69785
-SQLITE_API int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
70098
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
6978670099
int rc;
6978770100
switch( sqlite3_value_type((sqlite3_value*)pValue) ){
6978870101
case SQLITE_INTEGER: {
6978970102
rc = sqlite3_bind_int64(pStmt, i, pValue->u.i);
6979070103
break;
@@ -69811,11 +70124,11 @@
6981170124
break;
6981270125
}
6981370126
}
6981470127
return rc;
6981570128
}
69816
-SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
70129
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
6981770130
int rc;
6981870131
Vdbe *p = (Vdbe *)pStmt;
6981970132
rc = vdbeUnbind(p, i);
6982070133
if( rc==SQLITE_OK ){
6982170134
sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n);
@@ -69826,11 +70139,11 @@
6982670139
6982770140
/*
6982870141
** Return the number of wildcards that can be potentially bound to.
6982970142
** This routine is added to support DBD::SQLite.
6983070143
*/
69831
-SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){
70144
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){
6983270145
Vdbe *p = (Vdbe*)pStmt;
6983370146
return p ? p->nVar : 0;
6983470147
}
6983570148
6983670149
/*
@@ -69837,11 +70150,11 @@
6983770150
** Return the name of a wildcard parameter. Return NULL if the index
6983870151
** is out of range or if the wildcard is unnamed.
6983970152
**
6984070153
** The result is always UTF-8.
6984170154
*/
69842
-SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){
70155
+SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){
6984370156
Vdbe *p = (Vdbe*)pStmt;
6984470157
if( p==0 || i<1 || i>p->nzVar ){
6984570158
return 0;
6984670159
}
6984770160
return p->azVar[i-1];
@@ -69865,11 +70178,11 @@
6986570178
}
6986670179
}
6986770180
}
6986870181
return 0;
6986970182
}
69870
-SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){
70183
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){
6987170184
return sqlite3VdbeParameterIndex((Vdbe*)pStmt, zName, sqlite3Strlen30(zName));
6987270185
}
6987370186
6987470187
/*
6987570188
** Transfer all bindings from the first statement over to the second.
@@ -69899,11 +70212,11 @@
6989970212
**
6990070213
** If the two statements contain a different number of bindings, then
6990170214
** an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise
6990270215
** SQLITE_OK is returned.
6990370216
*/
69904
-SQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
70217
+SQLITE_API int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
6990570218
Vdbe *pFrom = (Vdbe*)pFromStmt;
6990670219
Vdbe *pTo = (Vdbe*)pToStmt;
6990770220
if( pFrom->nVar!=pTo->nVar ){
6990870221
return SQLITE_ERROR;
6990970222
}
@@ -69921,26 +70234,26 @@
6992170234
** Return the sqlite3* database handle to which the prepared statement given
6992270235
** in the argument belongs. This is the same database handle that was
6992370236
** the first argument to the sqlite3_prepare() that was used to create
6992470237
** the statement in the first place.
6992570238
*/
69926
-SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt *pStmt){
70239
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt *pStmt){
6992770240
return pStmt ? ((Vdbe*)pStmt)->db : 0;
6992870241
}
6992970242
6993070243
/*
6993170244
** Return true if the prepared statement is guaranteed to not modify the
6993270245
** database.
6993370246
*/
69934
-SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt){
70247
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt){
6993570248
return pStmt ? ((Vdbe*)pStmt)->readOnly : 1;
6993670249
}
6993770250
6993870251
/*
6993970252
** Return true if the prepared statement is in need of being reset.
6994070253
*/
69941
-SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *pStmt){
70254
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt *pStmt){
6994270255
Vdbe *v = (Vdbe*)pStmt;
6994370256
return v!=0 && v->pc>=0 && v->magic==VDBE_MAGIC_RUN;
6994470257
}
6994570258
6994670259
/*
@@ -69947,11 +70260,11 @@
6994770260
** Return a pointer to the next prepared statement after pStmt associated
6994870261
** with database connection pDb. If pStmt is NULL, return the first
6994970262
** prepared statement for the database connection. Return NULL if there
6995070263
** are no more.
6995170264
*/
69952
-SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){
70265
+SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){
6995370266
sqlite3_stmt *pNext;
6995470267
#ifdef SQLITE_ENABLE_API_ARMOR
6995570268
if( !sqlite3SafetyCheckOk(pDb) ){
6995670269
(void)SQLITE_MISUSE_BKPT;
6995770270
return 0;
@@ -69968,11 +70281,11 @@
6996870281
}
6996970282
6997070283
/*
6997170284
** Return the value of a status counter for a prepared statement
6997270285
*/
69973
-SQLITE_API int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
70286
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
6997470287
Vdbe *pVdbe = (Vdbe*)pStmt;
6997570288
u32 v;
6997670289
#ifdef SQLITE_ENABLE_API_ARMOR
6997770290
if( !pStmt ){
6997870291
(void)SQLITE_MISUSE_BKPT;
@@ -69986,11 +70299,11 @@
6998670299
6998770300
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
6998870301
/*
6998970302
** Return status data for a single loop within query pStmt.
6999070303
*/
69991
-SQLITE_API int sqlite3_stmt_scanstatus(
70304
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_scanstatus(
6999270305
sqlite3_stmt *pStmt, /* Prepared statement being queried */
6999370306
int idx, /* Index of loop to report on */
6999470307
int iScanStatusOp, /* Which metric to return */
6999570308
void *pOut /* OUT: Write the answer here */
6999670309
){
@@ -70045,11 +70358,11 @@
7004570358
}
7004670359
7004770360
/*
7004870361
** Zero all counters associated with the sqlite3_stmt_scanstatus() data.
7004970362
*/
70050
-SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){
70363
+SQLITE_API void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){
7005170364
Vdbe *p = (Vdbe*)pStmt;
7005270365
memset(p->anExec, 0, p->nOp * sizeof(i64));
7005370366
}
7005470367
#endif /* SQLITE_ENABLE_STMT_SCANSTATUS */
7005570368
@@ -70544,11 +70857,11 @@
7054470857
** Try to convert the type of a function argument or a result column
7054570858
** into a numeric representation. Use either INTEGER or REAL whichever
7054670859
** is appropriate. But only do the conversion if it is possible without
7054770860
** loss of information and return the revised type of the argument.
7054870861
*/
70549
-SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){
70862
+SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value *pVal){
7055070863
int eType = sqlite3_value_type(pVal);
7055170864
if( eType==SQLITE_TEXT ){
7055270865
Mem *pMem = (Mem*)pVal;
7055370866
applyNumericAffinity(pMem, 0);
7055470867
eType = sqlite3_value_type(pVal);
@@ -71845,11 +72158,11 @@
7184572158
** max() aggregate will set to 1 if the current row is not the minimum or
7184672159
** maximum. The P1 register is initialized to 0 by this instruction.
7184772160
**
7184872161
** The interface used by the implementation of the aforementioned functions
7184972162
** to retrieve the collation sequence set by this opcode is not available
71850
-** publicly, only to user functions defined in func.c.
72163
+** publicly. Only built-in functions have access to this feature.
7185172164
*/
7185272165
case OP_CollSeq: {
7185372166
assert( pOp->p4type==P4_COLLSEQ );
7185472167
if( pOp->p1 ){
7185572168
sqlite3VdbeMemSetInt64(&aMem[pOp->p1], 0);
@@ -73563,35 +73876,33 @@
7356373876
** cursors or a single read/write cursor but not both.
7356473877
**
7356573878
** See also OpenRead.
7356673879
*/
7356773880
case OP_ReopenIdx: {
73568
- VdbeCursor *pCur;
73569
-
73570
- assert( pOp->p5==0 );
73571
- assert( pOp->p4type==P4_KEYINFO );
73572
- pCur = p->apCsr[pOp->p1];
73573
- if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){
73574
- assert( pCur->iDb==pOp->p3 ); /* Guaranteed by the code generator */
73575
- break;
73576
- }
73577
- /* If the cursor is not currently open or is open on a different
73578
- ** index, then fall through into OP_OpenRead to force a reopen */
73579
-}
73580
-case OP_OpenRead:
73581
-case OP_OpenWrite: {
7358273881
int nField;
7358373882
KeyInfo *pKeyInfo;
7358473883
int p2;
7358573884
int iDb;
7358673885
int wrFlag;
7358773886
Btree *pX;
7358873887
VdbeCursor *pCur;
7358973888
Db *pDb;
7359073889
73591
- assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR))==pOp->p5 );
73592
- assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 );
73890
+ assert( pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );
73891
+ assert( pOp->p4type==P4_KEYINFO );
73892
+ pCur = p->apCsr[pOp->p1];
73893
+ if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){
73894
+ assert( pCur->iDb==pOp->p3 ); /* Guaranteed by the code generator */
73895
+ goto open_cursor_set_hints;
73896
+ }
73897
+ /* If the cursor is not currently open or is open on a different
73898
+ ** index, then fall through into OP_OpenRead to force a reopen */
73899
+case OP_OpenRead:
73900
+case OP_OpenWrite:
73901
+
73902
+ assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR|OPFLAG_SEEKEQ))==pOp->p5 );
73903
+ assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );
7359373904
assert( p->bIsReader );
7359473905
assert( pOp->opcode==OP_OpenRead || pOp->opcode==OP_ReopenIdx
7359573906
|| p->readOnly==0 );
7359673907
7359773908
if( p->expired ){
@@ -73650,18 +73961,21 @@
7365073961
pCur->nullRow = 1;
7365173962
pCur->isOrdered = 1;
7365273963
pCur->pgnoRoot = p2;
7365373964
rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur->pCursor);
7365473965
pCur->pKeyInfo = pKeyInfo;
73655
- assert( OPFLAG_BULKCSR==BTREE_BULKLOAD );
73656
- sqlite3BtreeCursorHints(pCur->pCursor, (pOp->p5 & OPFLAG_BULKCSR));
73657
-
7365873966
/* Set the VdbeCursor.isTable variable. Previous versions of
7365973967
** SQLite used to check if the root-page flags were sane at this point
7366073968
** and report database corruption if they were not, but this check has
7366173969
** since moved into the btree layer. */
7366273970
pCur->isTable = pOp->p4type!=P4_KEYINFO;
73971
+
73972
+open_cursor_set_hints:
73973
+ assert( OPFLAG_BULKCSR==BTREE_BULKLOAD );
73974
+ assert( OPFLAG_SEEKEQ==BTREE_SEEK_EQ );
73975
+ sqlite3BtreeCursorHints(pCur->pCursor,
73976
+ (pOp->p5 & (OPFLAG_BULKCSR|OPFLAG_SEEKEQ)));
7366373977
break;
7366473978
}
7366573979
7366673980
/* Opcode: OpenEphemeral P1 P2 * P4 P5
7366773981
** Synopsis: nColumn=P2
@@ -73918,10 +74232,26 @@
7391874232
oc = pOp->opcode;
7391974233
pC->nullRow = 0;
7392074234
#ifdef SQLITE_DEBUG
7392174235
pC->seekOp = pOp->opcode;
7392274236
#endif
74237
+
74238
+ /* For a cursor with the BTREE_SEEK_EQ hint, only the OP_SeekGE and
74239
+ ** OP_SeekLE opcodes are allowed, and these must be immediately followed
74240
+ ** by an OP_IdxGT or OP_IdxLT opcode, respectively, with the same key.
74241
+ */
74242
+#ifdef SQLITE_DEBUG
74243
+ if( sqlite3BtreeCursorHasHint(pC->pCursor, BTREE_SEEK_EQ) ){
74244
+ assert( pOp->opcode==OP_SeekGE || pOp->opcode==OP_SeekLE );
74245
+ assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
74246
+ assert( pOp[1].p1==pOp[0].p1 );
74247
+ assert( pOp[1].p2==pOp[0].p2 );
74248
+ assert( pOp[1].p3==pOp[0].p3 );
74249
+ assert( pOp[1].p4.i==pOp[0].p4.i );
74250
+ }
74251
+#endif
74252
+
7392374253
if( pC->isTable ){
7392474254
/* The input value in P3 might be of any type: integer, real, string,
7392574255
** blob, or NULL. But it needs to be an integer before we can do
7392674256
** the seek, so convert it. */
7392774257
pIn3 = &aMem[pOp->p3];
@@ -75257,34 +75587,19 @@
7525775587
**
7525875588
** See also: Clear
7525975589
*/
7526075590
case OP_Destroy: { /* out2-prerelease */
7526175591
int iMoved;
75262
- int iCnt;
75263
- Vdbe *pVdbe;
7526475592
int iDb;
7526575593
7526675594
assert( p->readOnly==0 );
75267
-#ifndef SQLITE_OMIT_VIRTUALTABLE
75268
- iCnt = 0;
75269
- for(pVdbe=db->pVdbe; pVdbe; pVdbe = pVdbe->pNext){
75270
- if( pVdbe->magic==VDBE_MAGIC_RUN && pVdbe->bIsReader
75271
- && pVdbe->inVtabMethod<2 && pVdbe->pc>=0
75272
- ){
75273
- iCnt++;
75274
- }
75275
- }
75276
-#else
75277
- iCnt = db->nVdbeRead;
75278
-#endif
7527975595
pOut->flags = MEM_Null;
75280
- if( iCnt>1 ){
75596
+ if( db->nVdbeRead > db->nVDestroy+1 ){
7528175597
rc = SQLITE_LOCKED;
7528275598
p->errorAction = OE_Abort;
7528375599
}else{
7528475600
iDb = pOp->p3;
75285
- assert( iCnt==1 );
7528675601
assert( DbMaskTest(p->btreeMask, iDb) );
7528775602
iMoved = 0; /* Not needed. Only to silence a warning. */
7528875603
rc = sqlite3BtreeDropTable(db->aDb[iDb].pBt, pOp->p1, &iMoved);
7528975604
pOut->flags = MEM_Int;
7529075605
pOut->u.i = iMoved;
@@ -76337,17 +76652,33 @@
7633776652
break;
7633876653
}
7633976654
#endif /* SQLITE_OMIT_VIRTUALTABLE */
7634076655
7634176656
#ifndef SQLITE_OMIT_VIRTUALTABLE
76342
-/* Opcode: VCreate P1 * * P4 *
76657
+/* Opcode: VCreate P1 P2 * * *
7634376658
**
76344
-** P4 is the name of a virtual table in database P1. Call the xCreate method
76345
-** for that table.
76659
+** P2 is a register that holds the name of a virtual table in database
76660
+** P1. Call the xCreate method for that table.
7634676661
*/
7634776662
case OP_VCreate: {
76348
- rc = sqlite3VtabCallCreate(db, pOp->p1, pOp->p4.z, &p->zErrMsg);
76663
+ Mem sMem; /* For storing the record being decoded */
76664
+ const char *zTab; /* Name of the virtual table */
76665
+
76666
+ memset(&sMem, 0, sizeof(sMem));
76667
+ sMem.db = db;
76668
+ /* Because P2 is always a static string, it is impossible for the
76669
+ ** sqlite3VdbeMemCopy() to fail */
76670
+ assert( (aMem[pOp->p2].flags & MEM_Str)!=0 );
76671
+ assert( (aMem[pOp->p2].flags & MEM_Static)!=0 );
76672
+ rc = sqlite3VdbeMemCopy(&sMem, &aMem[pOp->p2]);
76673
+ assert( rc==SQLITE_OK );
76674
+ zTab = (const char*)sqlite3_value_text(&sMem);
76675
+ assert( zTab || db->mallocFailed );
76676
+ if( zTab ){
76677
+ rc = sqlite3VtabCallCreate(db, pOp->p1, zTab, &p->zErrMsg);
76678
+ }
76679
+ sqlite3VdbeMemRelease(&sMem);
7634976680
break;
7635076681
}
7635176682
#endif /* SQLITE_OMIT_VIRTUALTABLE */
7635276683
7635376684
#ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -76355,13 +76686,13 @@
7635576686
**
7635676687
** P4 is the name of a virtual table in database P1. Call the xDestroy method
7635776688
** of that table.
7635876689
*/
7635976690
case OP_VDestroy: {
76360
- p->inVtabMethod = 2;
76691
+ db->nVDestroy++;
7636176692
rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z);
76362
- p->inVtabMethod = 0;
76693
+ db->nVDestroy--;
7636376694
break;
7636476695
}
7636576696
#endif /* SQLITE_OMIT_VIRTUALTABLE */
7636676697
7636776698
#ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -76373,18 +76704,21 @@
7637376704
*/
7637476705
case OP_VOpen: {
7637576706
VdbeCursor *pCur;
7637676707
sqlite3_vtab_cursor *pVtabCursor;
7637776708
sqlite3_vtab *pVtab;
76378
- sqlite3_module *pModule;
76709
+ const sqlite3_module *pModule;
7637976710
7638076711
assert( p->bIsReader );
7638176712
pCur = 0;
7638276713
pVtabCursor = 0;
7638376714
pVtab = pOp->p4.pVtab->pVtab;
76384
- pModule = (sqlite3_module *)pVtab->pModule;
76385
- assert(pVtab && pModule);
76715
+ if( pVtab==0 || NEVER(pVtab->pModule==0) ){
76716
+ rc = SQLITE_LOCKED;
76717
+ break;
76718
+ }
76719
+ pModule = pVtab->pModule;
7638676720
rc = pModule->xOpen(pVtab, &pVtabCursor);
7638776721
sqlite3VtabImportErrmsg(p, pVtab);
7638876722
if( SQLITE_OK==rc ){
7638976723
/* Initialize sqlite3_vtab_cursor base class */
7639076724
pVtabCursor->pVtab = pVtab;
@@ -76391,10 +76725,11 @@
7639176725
7639276726
/* Initialize vdbe cursor object */
7639376727
pCur = allocateCursor(p, pOp->p1, 0, -1, 0);
7639476728
if( pCur ){
7639576729
pCur->pVtabCursor = pVtabCursor;
76730
+ pVtab->nRef++;
7639676731
}else{
7639776732
db->mallocFailed = 1;
7639876733
pModule->xClose(pVtabCursor);
7639976734
}
7640076735
}
@@ -76456,13 +76791,11 @@
7645676791
apArg = p->apArg;
7645776792
for(i = 0; i<nArg; i++){
7645876793
apArg[i] = &pArgc[i+1];
7645976794
}
7646076795
76461
- p->inVtabMethod = 1;
7646276796
rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg);
76463
- p->inVtabMethod = 0;
7646476797
sqlite3VtabImportErrmsg(p, pVtab);
7646576798
if( rc==SQLITE_OK ){
7646676799
res = pModule->xEof(pVtabCursor);
7646776800
}
7646876801
VdbeBranchTaken(res!=0,2);
@@ -76548,13 +76881,11 @@
7654876881
** underlying implementation to return an error if one occurs during
7654976882
** xNext(). Instead, if an error occurs, true is returned (indicating that
7655076883
** data is available) and the error code returned when xColumn or
7655176884
** some other method is next invoked on the save virtual table cursor.
7655276885
*/
76553
- p->inVtabMethod = 1;
7655476886
rc = pModule->xNext(pCur->pVtabCursor);
76555
- p->inVtabMethod = 0;
7655676887
sqlite3VtabImportErrmsg(p, pVtab);
7655776888
if( rc==SQLITE_OK ){
7655876889
res = pModule->xEof(pCur->pVtabCursor);
7655976890
}
7656076891
VdbeBranchTaken(!res,2);
@@ -76625,11 +76956,11 @@
7662576956
** P5 is the error actions (OE_Replace, OE_Fail, OE_Ignore, etc) to
7662676957
** apply in the case of a constraint failure on an insert or update.
7662776958
*/
7662876959
case OP_VUpdate: {
7662976960
sqlite3_vtab *pVtab;
76630
- sqlite3_module *pModule;
76961
+ const sqlite3_module *pModule;
7663176962
int nArg;
7663276963
int i;
7663376964
sqlite_int64 rowid;
7663476965
Mem **apArg;
7663576966
Mem *pX;
@@ -76637,11 +76968,15 @@
7663776968
assert( pOp->p2==1 || pOp->p5==OE_Fail || pOp->p5==OE_Rollback
7663876969
|| pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace
7663976970
);
7664076971
assert( p->readOnly==0 );
7664176972
pVtab = pOp->p4.pVtab->pVtab;
76642
- pModule = (sqlite3_module *)pVtab->pModule;
76973
+ if( pVtab==0 || NEVER(pVtab->pModule==0) ){
76974
+ rc = SQLITE_LOCKED;
76975
+ break;
76976
+ }
76977
+ pModule = pVtab->pModule;
7664376978
nArg = pOp->p2;
7664476979
assert( pOp->p4type==P4_VTAB );
7664576980
if( ALWAYS(pModule->xUpdate) ){
7664676981
u8 vtabOnConflict = db->vtabOnConflict;
7664776982
apArg = p->apArg;
@@ -76984,11 +77319,11 @@
7698477319
}
7698577320
7698677321
/*
7698777322
** Open a blob handle.
7698877323
*/
76989
-SQLITE_API int sqlite3_blob_open(
77324
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
7699077325
sqlite3* db, /* The database connection */
7699177326
const char *zDb, /* The attached database containing the blob */
7699277327
const char *zTable, /* The table containing the blob */
7699377328
const char *zColumn, /* The column containing the blob */
7699477329
sqlite_int64 iRow, /* The row containing the glob */
@@ -77221,11 +77556,11 @@
7722177556
7722277557
/*
7722377558
** Close a blob handle that was previously created using
7722477559
** sqlite3_blob_open().
7722577560
*/
77226
-SQLITE_API int sqlite3_blob_close(sqlite3_blob *pBlob){
77561
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *pBlob){
7722777562
Incrblob *p = (Incrblob *)pBlob;
7722877563
int rc;
7722977564
sqlite3 *db;
7723077565
7723177566
if( p ){
@@ -77290,28 +77625,28 @@
7729077625
}
7729177626
7729277627
/*
7729377628
** Read data from a blob handle.
7729477629
*/
77295
-SQLITE_API int sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){
77630
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){
7729677631
return blobReadWrite(pBlob, z, n, iOffset, sqlite3BtreeData);
7729777632
}
7729877633
7729977634
/*
7730077635
** Write data to a blob handle.
7730177636
*/
77302
-SQLITE_API int sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){
77637
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){
7730377638
return blobReadWrite(pBlob, (void *)z, n, iOffset, sqlite3BtreePutData);
7730477639
}
7730577640
7730677641
/*
7730777642
** Query a blob handle for the size of the data.
7730877643
**
7730977644
** The Incrblob.nByte field is fixed for the lifetime of the Incrblob
7731077645
** so no mutex is required for access.
7731177646
*/
77312
-SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *pBlob){
77647
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *pBlob){
7731377648
Incrblob *p = (Incrblob *)pBlob;
7731477649
return (p && p->pStmt) ? p->nByte : 0;
7731577650
}
7731677651
7731777652
/*
@@ -77322,11 +77657,11 @@
7732277657
** contain a blob or text value, then an error code is returned and the
7732377658
** database handle error code and message set. If this happens, then all
7732477659
** subsequent calls to sqlite3_blob_xxx() functions (except blob_close())
7732577660
** immediately return SQLITE_ABORT.
7732677661
*/
77327
-SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
77662
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
7732877663
int rc;
7732977664
Incrblob *p = (Incrblob *)pBlob;
7733077665
sqlite3 *db;
7733177666
7733277667
if( p==0 ) return SQLITE_MISUSE_BKPT;
@@ -78507,10 +78842,11 @@
7850778842
sqlite3 *db, /* Database handle doing sort */
7850878843
i64 nExtend, /* Attempt to extend file to this size */
7850978844
sqlite3_file **ppFd
7851078845
){
7851178846
int rc;
78847
+ if( sqlite3FaultSim(202) ) return SQLITE_IOERR_ACCESS;
7851278848
rc = sqlite3OsOpenMalloc(db->pVfs, 0, ppFd,
7851378849
SQLITE_OPEN_TEMP_JOURNAL |
7851478850
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |
7851578851
SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE, &rc
7851678852
);
@@ -82098,14 +82434,15 @@
8209882434
** and the pExpr parameter is returned unchanged.
8209982435
*/
8210082436
SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(
8210182437
Parse *pParse, /* Parsing context */
8210282438
Expr *pExpr, /* Add the "COLLATE" clause to this expression */
82103
- const Token *pCollName /* Name of collating sequence */
82439
+ const Token *pCollName, /* Name of collating sequence */
82440
+ int dequote /* True to dequote pCollName */
8210482441
){
8210582442
if( pCollName->n>0 ){
82106
- Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, 1);
82443
+ Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote);
8210782444
if( pNew ){
8210882445
pNew->pLeft = pExpr;
8210982446
pNew->flags |= EP_Collate|EP_Skip;
8211082447
pExpr = pNew;
8211182448
}
@@ -82115,11 +82452,11 @@
8211582452
SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse *pParse, Expr *pExpr, const char *zC){
8211682453
Token s;
8211782454
assert( zC!=0 );
8211882455
s.z = zC;
8211982456
s.n = sqlite3Strlen30(s.z);
82120
- return sqlite3ExprAddCollateToken(pParse, pExpr, &s);
82457
+ return sqlite3ExprAddCollateToken(pParse, pExpr, &s, 0);
8212182458
}
8212282459
8212382460
/*
8212482461
** Skip over any TK_COLLATE or TK_AS operators and any unlikely()
8212582462
** or likelihood() function at the root of an expression.
@@ -82425,10 +82762,11 @@
8242582762
**
8242682763
** Also propagate all EP_Propagate flags from the Expr.x.pList into
8242782764
** Expr.flags.
8242882765
*/
8242982766
SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){
82767
+ if( pParse->nErr ) return;
8243082768
exprSetHeight(p);
8243182769
sqlite3ExprCheckHeight(pParse, p->nHeight);
8243282770
}
8243382771
8243482772
/*
@@ -87139,11 +87477,14 @@
8713987477
/* Ensure the default expression is something that sqlite3ValueFromExpr()
8714087478
** can handle (i.e. not CURRENT_TIME etc.)
8714187479
*/
8714287480
if( pDflt ){
8714387481
sqlite3_value *pVal = 0;
87144
- if( sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal) ){
87482
+ int rc;
87483
+ rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal);
87484
+ assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
87485
+ if( rc!=SQLITE_OK ){
8714587486
db->mallocFailed = 1;
8714687487
return;
8714787488
}
8714887489
if( !pVal ){
8714987490
sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default");
@@ -89824,11 +90165,11 @@
8982490165
** and attempts to write the column will be ignored.
8982590166
**
8982690167
** Setting the auth function to NULL disables this hook. The default
8982790168
** setting of the auth function is NULL.
8982890169
*/
89829
-SQLITE_API int sqlite3_set_authorizer(
90170
+SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
8983090171
sqlite3 *db,
8983190172
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
8983290173
void *pArg
8983390174
){
8983490175
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -93202,10 +93543,11 @@
9320293543
}
9320393544
if( pIdx->onError==OE_Default ){
9320493545
pIdx->onError = pIndex->onError;
9320593546
}
9320693547
}
93548
+ pRet = pIdx;
9320793549
goto exit_create_index;
9320893550
}
9320993551
}
9321093552
}
9321193553
@@ -95661,11 +96003,13 @@
9566196003
9566296004
/*
9566396005
** Return the collating function associated with a function.
9566496006
*/
9566596007
static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){
95666
- VdbeOp *pOp = &context->pVdbe->aOp[context->iOp-1];
96008
+ VdbeOp *pOp;
96009
+ assert( context->pVdbe!=0 );
96010
+ pOp = &context->pVdbe->aOp[context->iOp-1];
9566796011
assert( pOp->opcode==OP_CollSeq );
9566896012
assert( pOp->p4type==P4_COLLSEQ );
9566996013
return pOp->p4.pColl;
9567096014
}
9567196015
@@ -96399,11 +96743,11 @@
9639996743
}
9640096744
9640196745
/*
9640296746
** The sqlite3_strglob() interface.
9640396747
*/
96404
-SQLITE_API int sqlite3_strglob(const char *zGlobPattern, const char *zString){
96748
+SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlobPattern, const char *zString){
9640596749
return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, 0)==0;
9640696750
}
9640796751
9640896752
/*
9640996753
** Count the number of times that the LIKE operator (or GLOB which is
@@ -100894,11 +101238,11 @@
100894101238
** If the SQL is a query, then for each row in the query result
100895101239
** the xCallback() function is called. pArg becomes the first
100896101240
** argument to xCallback(). If xCallback=NULL then no callback
100897101241
** is invoked, even for queries.
100898101242
*/
100899
-SQLITE_API int sqlite3_exec(
101243
+SQLITE_API int SQLITE_STDCALL sqlite3_exec(
100900101244
sqlite3 *db, /* The database on which the SQL executes */
100901101245
const char *zSql, /* The SQL to be executed */
100902101246
sqlite3_callback xCallback, /* Invoke this callback routine */
100903101247
void *pArg, /* First argument to xCallback() */
100904101248
char **pzErrMsg /* Write error messages here */
@@ -102089,11 +102433,11 @@
102089102433
db->aExtension = aHandle;
102090102434
102091102435
db->aExtension[db->nExtension++] = handle;
102092102436
return SQLITE_OK;
102093102437
}
102094
-SQLITE_API int sqlite3_load_extension(
102438
+SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
102095102439
sqlite3 *db, /* Load the extension into this database connection */
102096102440
const char *zFile, /* Name of the shared library containing extension */
102097102441
const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
102098102442
char **pzErrMsg /* Put error message here if not 0 */
102099102443
){
@@ -102120,11 +102464,11 @@
102120102464
102121102465
/*
102122102466
** Enable or disable extension loading. Extension loading is disabled by
102123102467
** default so as not to open security holes in older applications.
102124102468
*/
102125
-SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){
102469
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff){
102126102470
sqlite3_mutex_enter(db->mutex);
102127102471
if( onoff ){
102128102472
db->flags |= SQLITE_LoadExtension;
102129102473
}else{
102130102474
db->flags &= ~SQLITE_LoadExtension;
@@ -102177,11 +102521,11 @@
102177102521
102178102522
/*
102179102523
** Register a statically linked extension that is automatically
102180102524
** loaded by every new database connection.
102181102525
*/
102182
-SQLITE_API int sqlite3_auto_extension(void (*xInit)(void)){
102526
+SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xInit)(void)){
102183102527
int rc = SQLITE_OK;
102184102528
#ifndef SQLITE_OMIT_AUTOINIT
102185102529
rc = sqlite3_initialize();
102186102530
if( rc ){
102187102531
return rc;
@@ -102222,11 +102566,11 @@
102222102566
** routine is a no-op.
102223102567
**
102224102568
** Return 1 if xInit was found on the list and removed. Return 0 if xInit
102225102569
** was not on the list.
102226102570
*/
102227
-SQLITE_API int sqlite3_cancel_auto_extension(void (*xInit)(void)){
102571
+SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xInit)(void)){
102228102572
#if SQLITE_THREADSAFE
102229102573
sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
102230102574
#endif
102231102575
int i;
102232102576
int n = 0;
@@ -102245,11 +102589,11 @@
102245102589
}
102246102590
102247102591
/*
102248102592
** Reset the automatic extension loading mechanism.
102249102593
*/
102250
-SQLITE_API void sqlite3_reset_auto_extension(void){
102594
+SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void){
102251102595
#ifndef SQLITE_OMIT_AUTOINIT
102252102596
if( sqlite3_initialize()==SQLITE_OK )
102253102597
#endif
102254102598
{
102255102599
#if SQLITE_THREADSAFE
@@ -105525,11 +105869,11 @@
105525105869
** and so if a schema change occurs, SQLITE_SCHEMA is returned by
105526105870
** sqlite3_step(). In the new version, the original SQL text is retained
105527105871
** and the statement is automatically recompiled if an schema change
105528105872
** occurs.
105529105873
*/
105530
-SQLITE_API int sqlite3_prepare(
105874
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
105531105875
sqlite3 *db, /* Database handle. */
105532105876
const char *zSql, /* UTF-8 encoded SQL statement. */
105533105877
int nBytes, /* Length of zSql in bytes. */
105534105878
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105535105879
const char **pzTail /* OUT: End of parsed string */
@@ -105537,11 +105881,11 @@
105537105881
int rc;
105538105882
rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,0,ppStmt,pzTail);
105539105883
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
105540105884
return rc;
105541105885
}
105542
-SQLITE_API int sqlite3_prepare_v2(
105886
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
105543105887
sqlite3 *db, /* Database handle. */
105544105888
const char *zSql, /* UTF-8 encoded SQL statement. */
105545105889
int nBytes, /* Length of zSql in bytes. */
105546105890
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105547105891
const char **pzTail /* OUT: End of parsed string */
@@ -105613,11 +105957,11 @@
105613105957
** and so if a schema change occurs, SQLITE_SCHEMA is returned by
105614105958
** sqlite3_step(). In the new version, the original SQL text is retained
105615105959
** and the statement is automatically recompiled if an schema change
105616105960
** occurs.
105617105961
*/
105618
-SQLITE_API int sqlite3_prepare16(
105962
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
105619105963
sqlite3 *db, /* Database handle. */
105620105964
const void *zSql, /* UTF-16 encoded SQL statement. */
105621105965
int nBytes, /* Length of zSql in bytes. */
105622105966
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105623105967
const void **pzTail /* OUT: End of parsed string */
@@ -105625,11 +105969,11 @@
105625105969
int rc;
105626105970
rc = sqlite3Prepare16(db,zSql,nBytes,0,ppStmt,pzTail);
105627105971
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
105628105972
return rc;
105629105973
}
105630
-SQLITE_API int sqlite3_prepare16_v2(
105974
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
105631105975
sqlite3 *db, /* Database handle. */
105632105976
const void *zSql, /* UTF-16 encoded SQL statement. */
105633105977
int nBytes, /* Length of zSql in bytes. */
105634105978
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105635105979
const void **pzTail /* OUT: End of parsed string */
@@ -109678,11 +110022,11 @@
109678110022
sqlite3WalkSelect(pWalker, bMayRecursive ? pSel->pPrior : pSel);
109679110023
109680110024
for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior);
109681110025
pEList = pLeft->pEList;
109682110026
if( pCte->pCols ){
109683
- if( pEList->nExpr!=pCte->pCols->nExpr ){
110027
+ if( pEList && pEList->nExpr!=pCte->pCols->nExpr ){
109684110028
sqlite3ErrorMsg(pParse, "table %s has %d values for %d columns",
109685110029
pCte->zName, pEList->nExpr, pCte->pCols->nExpr
109686110030
);
109687110031
pParse->pWith = pSavedWith;
109688110032
return SQLITE_ERROR;
@@ -111361,11 +111705,11 @@
111361111705
** The result that is written to ***pazResult is held in memory obtained
111362111706
** from malloc(). But the caller cannot free this memory directly.
111363111707
** Instead, the entire table should be passed to sqlite3_free_table() when
111364111708
** the calling procedure is finished using it.
111365111709
*/
111366
-SQLITE_API int sqlite3_get_table(
111710
+SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
111367111711
sqlite3 *db, /* The database on which the SQL executes */
111368111712
const char *zSql, /* The SQL to be executed */
111369111713
char ***pazResult, /* Write the result table here */
111370111714
int *pnRow, /* Write the number of rows in the result here */
111371111715
int *pnColumn, /* Write the number of columns of result here */
@@ -111430,11 +111774,11 @@
111430111774
}
111431111775
111432111776
/*
111433111777
** This routine frees the space the sqlite3_get_table() malloced.
111434111778
*/
111435
-SQLITE_API void sqlite3_free_table(
111779
+SQLITE_API void SQLITE_STDCALL sqlite3_free_table(
111436111780
char **azResult /* Result returned from sqlite3_get_table() */
111437111781
){
111438111782
if( azResult ){
111439111783
int i, n;
111440111784
azResult--;
@@ -113790,11 +114134,11 @@
113790114134
113791114135
113792114136
/*
113793114137
** External API function used to create a new virtual-table module.
113794114138
*/
113795
-SQLITE_API int sqlite3_create_module(
114139
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
113796114140
sqlite3 *db, /* Database in which module is registered */
113797114141
const char *zName, /* Name assigned to this module */
113798114142
const sqlite3_module *pModule, /* The definition of the module */
113799114143
void *pAux /* Context pointer for xCreate/xConnect */
113800114144
){
@@ -113805,11 +114149,11 @@
113805114149
}
113806114150
113807114151
/*
113808114152
** External API function used to create a new virtual-table module.
113809114153
*/
113810
-SQLITE_API int sqlite3_create_module_v2(
114154
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
113811114155
sqlite3 *db, /* Database in which module is registered */
113812114156
const char *zName, /* Name assigned to this module */
113813114157
const sqlite3_module *pModule, /* The definition of the module */
113814114158
void *pAux, /* Context pointer for xCreate/xConnect */
113815114159
void (*xDestroy)(void *) /* Module destructor function */
@@ -114104,10 +114448,11 @@
114104114448
*/
114105114449
if( !db->init.busy ){
114106114450
char *zStmt;
114107114451
char *zWhere;
114108114452
int iDb;
114453
+ int iReg;
114109114454
Vdbe *v;
114110114455
114111114456
/* Compute the complete text of the CREATE VIRTUAL TABLE statement */
114112114457
if( pEnd ){
114113114458
pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n;
@@ -114138,12 +114483,14 @@
114138114483
sqlite3ChangeCookie(pParse, iDb);
114139114484
114140114485
sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
114141114486
zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
114142114487
sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
114143
- sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0,
114144
- pTab->zName, sqlite3Strlen30(pTab->zName) + 1);
114488
+
114489
+ iReg = ++pParse->nMem;
114490
+ sqlite3VdbeAddOp4(v, OP_String8, 0, iReg, 0, pTab->zName, 0);
114491
+ sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg);
114145114492
}
114146114493
114147114494
/* If we are rereading the sqlite_master table create the in-memory
114148114495
** record of the table. The xConnect() method is not called until
114149114496
** the first time the virtual table is used in an SQL statement. This
@@ -114417,11 +114764,11 @@
114417114764
/*
114418114765
** This function is used to set the schema of a virtual table. It is only
114419114766
** valid to call this function from within the xCreate() or xConnect() of a
114420114767
** virtual table module.
114421114768
*/
114422
-SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
114769
+SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
114423114770
Parse *pParse;
114424114771
114425114772
int rc = SQLITE_OK;
114426114773
Table *pTab;
114427114774
char *zErr = 0;
@@ -114492,15 +114839,19 @@
114492114839
int rc = SQLITE_OK;
114493114840
Table *pTab;
114494114841
114495114842
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
114496114843
if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){
114497
- VTable *p = vtabDisconnectAll(db, pTab);
114498
-
114499
- assert( rc==SQLITE_OK );
114844
+ VTable *p;
114845
+ for(p=pTab->pVTable; p; p=p->pNext){
114846
+ assert( p->pVtab );
114847
+ if( p->pVtab->nRef>0 ){
114848
+ return SQLITE_LOCKED;
114849
+ }
114850
+ }
114851
+ p = vtabDisconnectAll(db, pTab);
114500114852
rc = p->pMod->pModule->xDestroy(p->pVtab);
114501
-
114502114853
/* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */
114503114854
if( rc==SQLITE_OK ){
114504114855
assert( pTab->pVTable==p && p->pNext==0 );
114505114856
p->pVtab = 0;
114506114857
pTab->pVTable = 0;
@@ -114781,11 +115132,11 @@
114781115132
** table update operation currently in progress.
114782115133
**
114783115134
** The results of this routine are undefined unless it is called from
114784115135
** within an xUpdate method.
114785115136
*/
114786
-SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *db){
115137
+SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *db){
114787115138
static const unsigned char aMap[] = {
114788115139
SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE
114789115140
};
114790115141
#ifdef SQLITE_ENABLE_API_ARMOR
114791115142
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -114799,11 +115150,11 @@
114799115150
/*
114800115151
** Call from within the xCreate() or xConnect() methods to provide
114801115152
** the SQLite core with additional information about the behavior
114802115153
** of the virtual table being implemented.
114803115154
*/
114804
-SQLITE_API int sqlite3_vtab_config(sqlite3 *db, int op, ...){
115155
+SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3 *db, int op, ...){
114805115156
va_list ap;
114806115157
int rc = SQLITE_OK;
114807115158
114808115159
#ifdef SQLITE_ENABLE_API_ARMOR
114809115160
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -116078,10 +116429,83 @@
116078116429
static void markTermAsChild(WhereClause *pWC, int iChild, int iParent){
116079116430
pWC->a[iChild].iParent = iParent;
116080116431
pWC->a[iChild].truthProb = pWC->a[iParent].truthProb;
116081116432
pWC->a[iParent].nChild++;
116082116433
}
116434
+
116435
+/*
116436
+** Return the N-th AND-connected subterm of pTerm. Or if pTerm is not
116437
+** a conjunction, then return just pTerm when N==0. If N is exceeds
116438
+** the number of available subterms, return NULL.
116439
+*/
116440
+static WhereTerm *whereNthSubterm(WhereTerm *pTerm, int N){
116441
+ if( pTerm->eOperator!=WO_AND ){
116442
+ return N==0 ? pTerm : 0;
116443
+ }
116444
+ if( N<pTerm->u.pAndInfo->wc.nTerm ){
116445
+ return &pTerm->u.pAndInfo->wc.a[N];
116446
+ }
116447
+ return 0;
116448
+}
116449
+
116450
+/*
116451
+** Subterms pOne and pTwo are contained within WHERE clause pWC. The
116452
+** two subterms are in disjunction - they are OR-ed together.
116453
+**
116454
+** If these two terms are both of the form: "A op B" with the same
116455
+** A and B values but different operators and if the operators are
116456
+** compatible (if one is = and the other is <, for example) then
116457
+** add a new virtual AND term to pWC that is the combination of the
116458
+** two.
116459
+**
116460
+** Some examples:
116461
+**
116462
+** x<y OR x=y --> x<=y
116463
+** x=y OR x=y --> x=y
116464
+** x<=y OR x<y --> x<=y
116465
+**
116466
+** The following is NOT generated:
116467
+**
116468
+** x<y OR x>y --> x!=y
116469
+*/
116470
+static void whereCombineDisjuncts(
116471
+ SrcList *pSrc, /* the FROM clause */
116472
+ WhereClause *pWC, /* The complete WHERE clause */
116473
+ WhereTerm *pOne, /* First disjunct */
116474
+ WhereTerm *pTwo /* Second disjunct */
116475
+){
116476
+ u16 eOp = pOne->eOperator | pTwo->eOperator;
116477
+ sqlite3 *db; /* Database connection (for malloc) */
116478
+ Expr *pNew; /* New virtual expression */
116479
+ int op; /* Operator for the combined expression */
116480
+ int idxNew; /* Index in pWC of the next virtual term */
116481
+
116482
+ if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
116483
+ if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
116484
+ if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
116485
+ && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;
116486
+ assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );
116487
+ assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );
116488
+ if( sqlite3ExprCompare(pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;
116489
+ if( sqlite3ExprCompare(pOne->pExpr->pRight, pTwo->pExpr->pRight, -1) )return;
116490
+ /* If we reach this point, it means the two subterms can be combined */
116491
+ if( (eOp & (eOp-1))!=0 ){
116492
+ if( eOp & (WO_LT|WO_LE) ){
116493
+ eOp = WO_LE;
116494
+ }else{
116495
+ assert( eOp & (WO_GT|WO_GE) );
116496
+ eOp = WO_GE;
116497
+ }
116498
+ }
116499
+ db = pWC->pWInfo->pParse->db;
116500
+ pNew = sqlite3ExprDup(db, pOne->pExpr, 0);
116501
+ if( pNew==0 ) return;
116502
+ for(op=TK_EQ; eOp!=(WO_EQ<<(op-TK_EQ)); op++){ assert( op<TK_GE ); }
116503
+ pNew->op = op;
116504
+ idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);
116505
+ exprAnalyze(pSrc, pWC, idxNew);
116506
+}
116083116507
116084116508
#if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)
116085116509
/*
116086116510
** Analyze a term that consists of two or more OR-connected
116087116511
** subterms. So in:
@@ -116103,10 +116527,11 @@
116103116527
** (A) t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5
116104116528
** (B) x=expr1 OR expr2=x OR x=expr3
116105116529
** (C) t1.x=t2.y OR (t1.x=t2.z AND t1.y=15)
116106116530
** (D) x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*')
116107116531
** (E) (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6)
116532
+** (F) x>A OR (x=A AND y>=B)
116108116533
**
116109116534
** CASE 1:
116110116535
**
116111116536
** If all subterms are of the form T.C=expr for some single column of C and
116112116537
** a single table T (as shown in example B above) then create a new virtual
@@ -116118,10 +116543,20 @@
116118116543
** then create a new virtual term like this:
116119116544
**
116120116545
** x IN (expr1,expr2,expr3)
116121116546
**
116122116547
** CASE 2:
116548
+**
116549
+** If there are exactly two disjuncts one side has x>A and the other side
116550
+** has x=A (for the same x and A) then add a new virtual conjunct term to the
116551
+** WHERE clause of the form "x>=A". Example:
116552
+**
116553
+** x>A OR (x=A AND y>B) adds: x>=A
116554
+**
116555
+** The added conjunct can sometimes be helpful in query planning.
116556
+**
116557
+** CASE 3:
116123116558
**
116124116559
** If all subterms are indexable by a single table T, then set
116125116560
**
116126116561
** WhereTerm.eOperator = WO_OR
116127116562
** WhereTerm.u.pOrInfo->indexable |= the cursor number for table T
@@ -116245,15 +116680,29 @@
116245116680
}
116246116681
}
116247116682
}
116248116683
116249116684
/*
116250
- ** Record the set of tables that satisfy case 2. The set might be
116685
+ ** Record the set of tables that satisfy case 3. The set might be
116251116686
** empty.
116252116687
*/
116253116688
pOrInfo->indexable = indexable;
116254116689
pTerm->eOperator = indexable==0 ? 0 : WO_OR;
116690
+
116691
+ /* For a two-way OR, attempt to implementation case 2.
116692
+ */
116693
+ if( indexable && pOrWc->nTerm==2 ){
116694
+ int iOne = 0;
116695
+ WhereTerm *pOne;
116696
+ while( (pOne = whereNthSubterm(&pOrWc->a[0],iOne++))!=0 ){
116697
+ int iTwo = 0;
116698
+ WhereTerm *pTwo;
116699
+ while( (pTwo = whereNthSubterm(&pOrWc->a[1],iTwo++))!=0 ){
116700
+ whereCombineDisjuncts(pSrc, pWC, pOne, pTwo);
116701
+ }
116702
+ }
116703
+ }
116255116704
116256116705
/*
116257116706
** chngToIN holds a set of tables that *might* satisfy case 1. But
116258116707
** we have to do some additional checking to see if case 1 really
116259116708
** is satisfied.
@@ -116380,11 +116829,11 @@
116380116829
pTerm = &pWC->a[idxTerm];
116381116830
markTermAsChild(pWC, idxNew, idxTerm);
116382116831
}else{
116383116832
sqlite3ExprListDelete(db, pList);
116384116833
}
116385
- pTerm->eOperator = WO_NOOP; /* case 1 trumps case 2 */
116834
+ pTerm->eOperator = WO_NOOP; /* case 1 trumps case 3 */
116386116835
}
116387116836
}
116388116837
}
116389116838
#endif /* !SQLITE_OMIT_OR_OPTIMIZATION && !SQLITE_OMIT_SUBQUERY */
116390116839
@@ -116575,11 +117024,11 @@
116575117024
Expr *pStr2; /* Copy of pStr1 - RHS of LIKE/GLOB operator */
116576117025
Expr *pNewExpr1;
116577117026
Expr *pNewExpr2;
116578117027
int idxNew1;
116579117028
int idxNew2;
116580
- Token sCollSeqName; /* Name of collating sequence */
117029
+ const char *zCollSeqName; /* Name of collating sequence */
116581117030
const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC;
116582117031
116583117032
pLeft = pExpr->x.pList->a[1].pExpr;
116584117033
pStr2 = sqlite3ExprDup(db, pStr1, 0);
116585117034
@@ -116611,23 +117060,22 @@
116611117060
if( c=='A'-1 ) isComplete = 0;
116612117061
c = sqlite3UpperToLower[c];
116613117062
}
116614117063
*pC = c + 1;
116615117064
}
116616
- sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
116617
- sCollSeqName.n = 6;
117065
+ zCollSeqName = noCase ? "NOCASE" : "BINARY";
116618117066
pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);
116619117067
pNewExpr1 = sqlite3PExpr(pParse, TK_GE,
116620
- sqlite3ExprAddCollateToken(pParse,pNewExpr1,&sCollSeqName),
117068
+ sqlite3ExprAddCollateString(pParse,pNewExpr1,zCollSeqName),
116621117069
pStr1, 0);
116622117070
transferJoinMarkings(pNewExpr1, pExpr);
116623117071
idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags);
116624117072
testcase( idxNew1==0 );
116625117073
exprAnalyze(pSrc, pWC, idxNew1);
116626117074
pNewExpr2 = sqlite3ExprDup(db, pLeft, 0);
116627117075
pNewExpr2 = sqlite3PExpr(pParse, TK_LT,
116628
- sqlite3ExprAddCollateToken(pParse,pNewExpr2,&sCollSeqName),
117076
+ sqlite3ExprAddCollateString(pParse,pNewExpr2,zCollSeqName),
116629117077
pStr2, 0);
116630117078
transferJoinMarkings(pNewExpr2, pExpr);
116631117079
idxNew2 = whereClauseInsert(pWC, pNewExpr2, wtFlags);
116632117080
testcase( idxNew2==0 );
116633117081
exprAnalyze(pSrc, pWC, idxNew2);
@@ -117240,15 +117688,18 @@
117240117688
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
117241117689
/*
117242117690
** Estimate the location of a particular key among all keys in an
117243117691
** index. Store the results in aStat as follows:
117244117692
**
117245
-** aStat[0] Est. number of rows less than pVal
117246
-** aStat[1] Est. number of rows equal to pVal
117693
+** aStat[0] Est. number of rows less than pRec
117694
+** aStat[1] Est. number of rows equal to pRec
117247117695
**
117248117696
** Return the index of the sample that is the smallest sample that
117249
-** is greater than or equal to pRec.
117697
+** is greater than or equal to pRec. Note that this index is not an index
117698
+** into the aSample[] array - it is an index into a virtual set of samples
117699
+** based on the contents of aSample[] and the number of fields in record
117700
+** pRec.
117250117701
*/
117251117702
static int whereKeyStats(
117252117703
Parse *pParse, /* Database connection */
117253117704
Index *pIdx, /* Index to consider domain of */
117254117705
UnpackedRecord *pRec, /* Vector of values to consider */
@@ -117255,71 +117706,162 @@
117255117706
int roundUp, /* Round up if true. Round down if false */
117256117707
tRowcnt *aStat /* OUT: stats written here */
117257117708
){
117258117709
IndexSample *aSample = pIdx->aSample;
117259117710
int iCol; /* Index of required stats in anEq[] etc. */
117711
+ int i; /* Index of first sample >= pRec */
117712
+ int iSample; /* Smallest sample larger than or equal to pRec */
117260117713
int iMin = 0; /* Smallest sample not yet tested */
117261
- int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
117262117714
int iTest; /* Next sample to test */
117263117715
int res; /* Result of comparison operation */
117716
+ int nField; /* Number of fields in pRec */
117717
+ tRowcnt iLower = 0; /* anLt[] + anEq[] of largest sample pRec is > */
117264117718
117265117719
#ifndef SQLITE_DEBUG
117266117720
UNUSED_PARAMETER( pParse );
117267117721
#endif
117268117722
assert( pRec!=0 );
117269
- iCol = pRec->nField - 1;
117270117723
assert( pIdx->nSample>0 );
117271
- assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
117724
+ assert( pRec->nField>0 && pRec->nField<=pIdx->nSampleCol );
117725
+
117726
+ /* Do a binary search to find the first sample greater than or equal
117727
+ ** to pRec. If pRec contains a single field, the set of samples to search
117728
+ ** is simply the aSample[] array. If the samples in aSample[] contain more
117729
+ ** than one fields, all fields following the first are ignored.
117730
+ **
117731
+ ** If pRec contains N fields, where N is more than one, then as well as the
117732
+ ** samples in aSample[] (truncated to N fields), the search also has to
117733
+ ** consider prefixes of those samples. For example, if the set of samples
117734
+ ** in aSample is:
117735
+ **
117736
+ ** aSample[0] = (a, 5)
117737
+ ** aSample[1] = (a, 10)
117738
+ ** aSample[2] = (b, 5)
117739
+ ** aSample[3] = (c, 100)
117740
+ ** aSample[4] = (c, 105)
117741
+ **
117742
+ ** Then the search space should ideally be the samples above and the
117743
+ ** unique prefixes [a], [b] and [c]. But since that is hard to organize,
117744
+ ** the code actually searches this set:
117745
+ **
117746
+ ** 0: (a)
117747
+ ** 1: (a, 5)
117748
+ ** 2: (a, 10)
117749
+ ** 3: (a, 10)
117750
+ ** 4: (b)
117751
+ ** 5: (b, 5)
117752
+ ** 6: (c)
117753
+ ** 7: (c, 100)
117754
+ ** 8: (c, 105)
117755
+ ** 9: (c, 105)
117756
+ **
117757
+ ** For each sample in the aSample[] array, N samples are present in the
117758
+ ** effective sample array. In the above, samples 0 and 1 are based on
117759
+ ** sample aSample[0]. Samples 2 and 3 on aSample[1] etc.
117760
+ **
117761
+ ** Often, sample i of each block of N effective samples has (i+1) fields.
117762
+ ** Except, each sample may be extended to ensure that it is greater than or
117763
+ ** equal to the previous sample in the array. For example, in the above,
117764
+ ** sample 2 is the first sample of a block of N samples, so at first it
117765
+ ** appears that it should be 1 field in size. However, that would make it
117766
+ ** smaller than sample 1, so the binary search would not work. As a result,
117767
+ ** it is extended to two fields. The duplicates that this creates do not
117768
+ ** cause any problems.
117769
+ */
117770
+ nField = pRec->nField;
117771
+ iCol = 0;
117772
+ iSample = pIdx->nSample * nField;
117272117773
do{
117273
- iTest = (iMin+i)/2;
117274
- res = sqlite3VdbeRecordCompare(aSample[iTest].n, aSample[iTest].p, pRec);
117774
+ int iSamp; /* Index in aSample[] of test sample */
117775
+ int n; /* Number of fields in test sample */
117776
+
117777
+ iTest = (iMin+iSample)/2;
117778
+ iSamp = iTest / nField;
117779
+ if( iSamp>0 ){
117780
+ /* The proposed effective sample is a prefix of sample aSample[iSamp].
117781
+ ** Specifically, the shortest prefix of at least (1 + iTest%nField)
117782
+ ** fields that is greater than the previous effective sample. */
117783
+ for(n=(iTest % nField) + 1; n<nField; n++){
117784
+ if( aSample[iSamp-1].anLt[n-1]!=aSample[iSamp].anLt[n-1] ) break;
117785
+ }
117786
+ }else{
117787
+ n = iTest + 1;
117788
+ }
117789
+
117790
+ pRec->nField = n;
117791
+ res = sqlite3VdbeRecordCompare(aSample[iSamp].n, aSample[iSamp].p, pRec);
117275117792
if( res<0 ){
117793
+ iLower = aSample[iSamp].anLt[n-1] + aSample[iSamp].anEq[n-1];
117794
+ iMin = iTest+1;
117795
+ }else if( res==0 && n<nField ){
117796
+ iLower = aSample[iSamp].anLt[n-1];
117276117797
iMin = iTest+1;
117798
+ res = -1;
117277117799
}else{
117278
- i = iTest;
117800
+ iSample = iTest;
117801
+ iCol = n-1;
117279117802
}
117280
- }while( res && iMin<i );
117803
+ }while( res && iMin<iSample );
117804
+ i = iSample / nField;
117281117805
117282117806
#ifdef SQLITE_DEBUG
117283117807
/* The following assert statements check that the binary search code
117284117808
** above found the right answer. This block serves no purpose other
117285117809
** than to invoke the asserts. */
117286
- if( res==0 ){
117287
- /* If (res==0) is true, then sample $i must be equal to pRec */
117288
- assert( i<pIdx->nSample );
117289
- assert( 0==sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)
117290
- || pParse->db->mallocFailed );
117291
- }else{
117292
- /* Otherwise, pRec must be smaller than sample $i and larger than
117293
- ** sample ($i-1). */
117294
- assert( i==pIdx->nSample
117295
- || sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)>0
117296
- || pParse->db->mallocFailed );
117297
- assert( i==0
117298
- || sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0
117299
- || pParse->db->mallocFailed );
117810
+ if( pParse->db->mallocFailed==0 ){
117811
+ if( res==0 ){
117812
+ /* If (res==0) is true, then pRec must be equal to sample i. */
117813
+ assert( i<pIdx->nSample );
117814
+ assert( iCol==nField-1 );
117815
+ pRec->nField = nField;
117816
+ assert( 0==sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)
117817
+ || pParse->db->mallocFailed
117818
+ );
117819
+ }else{
117820
+ /* Unless i==pIdx->nSample, indicating that pRec is larger than
117821
+ ** all samples in the aSample[] array, pRec must be smaller than the
117822
+ ** (iCol+1) field prefix of sample i. */
117823
+ assert( i<=pIdx->nSample && i>=0 );
117824
+ pRec->nField = iCol+1;
117825
+ assert( i==pIdx->nSample
117826
+ || sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)>0
117827
+ || pParse->db->mallocFailed );
117828
+
117829
+ /* if i==0 and iCol==0, then record pRec is smaller than all samples
117830
+ ** in the aSample[] array. Otherwise, if (iCol>0) then pRec must
117831
+ ** be greater than or equal to the (iCol) field prefix of sample i.
117832
+ ** If (i>0), then pRec must also be greater than sample (i-1). */
117833
+ if( iCol>0 ){
117834
+ pRec->nField = iCol;
117835
+ assert( sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)<=0
117836
+ || pParse->db->mallocFailed );
117837
+ }
117838
+ if( i>0 ){
117839
+ pRec->nField = nField;
117840
+ assert( sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0
117841
+ || pParse->db->mallocFailed );
117842
+ }
117843
+ }
117300117844
}
117301117845
#endif /* ifdef SQLITE_DEBUG */
117302117846
117303
- /* At this point, aSample[i] is the first sample that is greater than
117304
- ** or equal to pVal. Or if i==pIdx->nSample, then all samples are less
117305
- ** than pVal. If aSample[i]==pVal, then res==0.
117306
- */
117307117847
if( res==0 ){
117848
+ /* Record pRec is equal to sample i */
117849
+ assert( iCol==nField-1 );
117308117850
aStat[0] = aSample[i].anLt[iCol];
117309117851
aStat[1] = aSample[i].anEq[iCol];
117310117852
}else{
117311
- tRowcnt iLower, iUpper, iGap;
117312
- if( i==0 ){
117313
- iLower = 0;
117314
- iUpper = aSample[0].anLt[iCol];
117853
+ /* At this point, the (iCol+1) field prefix of aSample[i] is the first
117854
+ ** sample that is greater than pRec. Or, if i==pIdx->nSample then pRec
117855
+ ** is larger than all samples in the array. */
117856
+ tRowcnt iUpper, iGap;
117857
+ if( i>=pIdx->nSample ){
117858
+ iUpper = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]);
117315117859
}else{
117316
- i64 nRow0 = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]);
117317
- iUpper = i>=pIdx->nSample ? nRow0 : aSample[i].anLt[iCol];
117318
- iLower = aSample[i-1].anEq[iCol] + aSample[i-1].anLt[iCol];
117860
+ iUpper = aSample[i].anLt[iCol];
117319117861
}
117320
- aStat[1] = pIdx->aAvgEq[iCol];
117862
+
117321117863
if( iLower>=iUpper ){
117322117864
iGap = 0;
117323117865
}else{
117324117866
iGap = iUpper - iLower;
117325117867
}
@@ -117327,11 +117869,15 @@
117327117869
iGap = (iGap*2)/3;
117328117870
}else{
117329117871
iGap = iGap/3;
117330117872
}
117331117873
aStat[0] = iLower + iGap;
117874
+ aStat[1] = pIdx->aAvgEq[iCol];
117332117875
}
117876
+
117877
+ /* Restore the pRec->nField value before returning. */
117878
+ pRec->nField = nField;
117333117879
return i;
117334117880
}
117335117881
#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
117336117882
117337117883
/*
@@ -118322,25 +118868,33 @@
118322118868
#else
118323118869
# define addScanStatus(a, b, c, d) ((void)d)
118324118870
#endif
118325118871
118326118872
/*
118327
-** Look at the last instruction coded. If that instruction is OP_String8
118328
-** and if pLoop->iLikeRepCntr is non-zero, then change the P3 to be
118873
+** If the most recently coded instruction is a constant range contraint
118874
+** that originated from the LIKE optimization, then change the P3 to be
118329118875
** pLoop->iLikeRepCntr and set P5.
118330118876
**
118331118877
** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range
118332118878
** expression: "x>='ABC' AND x<'abd'". But this requires that the range
118333118879
** scan loop run twice, once for strings and a second time for BLOBs.
118334118880
** The OP_String opcodes on the second pass convert the upper and lower
118335118881
** bound string contants to blobs. This routine makes the necessary changes
118336118882
** to the OP_String opcodes for that to happen.
118337118883
*/
118338
-static void whereLikeOptimizationStringFixup(Vdbe *v, WhereLevel *pLevel){
118339
- VdbeOp *pOp;
118340
- pOp = sqlite3VdbeGetOp(v, -1);
118341
- if( pLevel->iLikeRepCntr && pOp->opcode==OP_String8 ){
118884
+static void whereLikeOptimizationStringFixup(
118885
+ Vdbe *v, /* prepared statement under construction */
118886
+ WhereLevel *pLevel, /* The loop that contains the LIKE operator */
118887
+ WhereTerm *pTerm /* The upper or lower bound just coded */
118888
+){
118889
+ if( pTerm->wtFlags & TERM_LIKEOPT ){
118890
+ VdbeOp *pOp;
118891
+ assert( pLevel->iLikeRepCntr>0 );
118892
+ pOp = sqlite3VdbeGetOp(v, -1);
118893
+ assert( pOp!=0 );
118894
+ assert( pOp->opcode==OP_String8
118895
+ || pTerm->pWC->pWInfo->pParse->db->mallocFailed );
118342118896
pOp->p3 = pLevel->iLikeRepCntr;
118343118897
pOp->p5 = 1;
118344118898
}
118345118899
}
118346118900
@@ -118670,18 +119224,20 @@
118670119224
*/
118671119225
j = nEq;
118672119226
if( pLoop->wsFlags & WHERE_BTM_LIMIT ){
118673119227
pRangeStart = pLoop->aLTerm[j++];
118674119228
nExtraReg = 1;
119229
+ /* Like optimization range constraints always occur in pairs */
119230
+ assert( (pRangeStart->wtFlags & TERM_LIKEOPT)==0 ||
119231
+ (pLoop->wsFlags & WHERE_TOP_LIMIT)!=0 );
118675119232
}
118676119233
if( pLoop->wsFlags & WHERE_TOP_LIMIT ){
118677119234
pRangeEnd = pLoop->aLTerm[j++];
118678119235
nExtraReg = 1;
118679
- if( pRangeStart
118680
- && (pRangeStart->wtFlags & TERM_LIKEOPT)!=0
118681
- && (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0
118682
- ){
119236
+ if( (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 ){
119237
+ assert( pRangeStart!=0 ); /* LIKE opt constraints */
119238
+ assert( pRangeStart->wtFlags & TERM_LIKEOPT ); /* occur in pairs */
118683119239
pLevel->iLikeRepCntr = ++pParse->nMem;
118684119240
testcase( bRev );
118685119241
testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC );
118686119242
sqlite3VdbeAddOp2(v, OP_Integer,
118687119243
bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC),
@@ -118729,11 +119285,11 @@
118729119285
/* Seek the index cursor to the start of the range. */
118730119286
nConstraint = nEq;
118731119287
if( pRangeStart ){
118732119288
Expr *pRight = pRangeStart->pExpr->pRight;
118733119289
sqlite3ExprCode(pParse, pRight, regBase+nEq);
118734
- whereLikeOptimizationStringFixup(v, pLevel);
119290
+ whereLikeOptimizationStringFixup(v, pLevel, pRangeStart);
118735119291
if( (pRangeStart->wtFlags & TERM_VNULL)==0
118736119292
&& sqlite3ExprCanBeNull(pRight)
118737119293
){
118738119294
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
118739119295
VdbeCoverage(v);
@@ -118775,11 +119331,11 @@
118775119331
nConstraint = nEq;
118776119332
if( pRangeEnd ){
118777119333
Expr *pRight = pRangeEnd->pExpr->pRight;
118778119334
sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
118779119335
sqlite3ExprCode(pParse, pRight, regBase+nEq);
118780
- whereLikeOptimizationStringFixup(v, pLevel);
119336
+ whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);
118781119337
if( (pRangeEnd->wtFlags & TERM_VNULL)==0
118782119338
&& sqlite3ExprCanBeNull(pRight)
118783119339
){
118784119340
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
118785119341
VdbeCoverage(v);
@@ -119852,10 +120408,14 @@
119852120408
){
119853120409
continue; /* ignore IS [NOT] NULL constraints on NOT NULL columns */
119854120410
}
119855120411
if( pTerm->prereqRight & pNew->maskSelf ) continue;
119856120412
120413
+ /* Do not allow the upper bound of a LIKE optimization range constraint
120414
+ ** to mix with a lower range bound from some other source */
120415
+ if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;
120416
+
119857120417
pNew->wsFlags = saved_wsFlags;
119858120418
pNew->u.btree.nEq = saved_nEq;
119859120419
pNew->nLTerm = saved_nLTerm;
119860120420
if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
119861120421
pNew->aLTerm[pNew->nLTerm++] = pTerm;
@@ -119895,10 +120455,21 @@
119895120455
testcase( eOp & WO_GT );
119896120456
testcase( eOp & WO_GE );
119897120457
pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT;
119898120458
pBtm = pTerm;
119899120459
pTop = 0;
120460
+ if( pTerm->wtFlags & TERM_LIKEOPT ){
120461
+ /* Range contraints that come from the LIKE optimization are
120462
+ ** always used in pairs. */
120463
+ pTop = &pTerm[1];
120464
+ assert( (pTop-(pTerm->pWC->a))<pTerm->pWC->nTerm );
120465
+ assert( pTop->wtFlags & TERM_LIKEOPT );
120466
+ assert( pTop->eOperator==WO_LT );
120467
+ if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
120468
+ pNew->aLTerm[pNew->nLTerm++] = pTop;
120469
+ pNew->wsFlags |= WHERE_TOP_LIMIT;
120470
+ }
119900120471
}else{
119901120472
assert( eOp & (WO_LT|WO_LE) );
119902120473
testcase( eOp & WO_LT );
119903120474
testcase( eOp & WO_LE );
119904120475
pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_TOP_LIMIT;
@@ -121089,14 +121660,14 @@
121089121660
assert( aSortCost==0 || &pSpace[nSpace]==(char*)&aSortCost[nOrderBy] );
121090121661
assert( aSortCost!=0 || &pSpace[nSpace]==(char*)pX );
121091121662
121092121663
/* Seed the search with a single WherePath containing zero WhereLoops.
121093121664
**
121094
- ** TUNING: Do not let the number of iterations go above 25. If the cost
121095
- ** of computing an automatic index is not paid back within the first 25
121665
+ ** TUNING: Do not let the number of iterations go above 28. If the cost
121666
+ ** of computing an automatic index is not paid back within the first 28
121096121667
** rows, then do not use the automatic index. */
121097
- aFrom[0].nRow = MIN(pParse->nQueryLoop, 46); assert( 46==sqlite3LogEst(25) );
121668
+ aFrom[0].nRow = MIN(pParse->nQueryLoop, 48); assert( 48==sqlite3LogEst(28) );
121098121669
nFrom = 1;
121099121670
assert( aFrom[0].isOrdered==0 );
121100121671
if( nOrderBy ){
121101121672
/* If nLoop is zero, then there are no FROM terms in the query. Since
121102121673
** in this case the query may return a maximum of one row, the results
@@ -121890,10 +122461,16 @@
121890122461
assert( pIx->pSchema==pTab->pSchema );
121891122462
assert( iIndexCur>=0 );
121892122463
if( op ){
121893122464
sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb);
121894122465
sqlite3VdbeSetP4KeyInfo(pParse, pIx);
122466
+ if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0
122467
+ && (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0
122468
+ && (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0
122469
+ ){
122470
+ sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ); /* Hint to COMDB2 */
122471
+ }
121895122472
VdbeComment((v, "%s", pIx->zName));
121896122473
}
121897122474
}
121898122475
if( iDb>=0 ) sqlite3CodeVerifySchema(pParse, iDb);
121899122476
notReady &= ~getMask(&pWInfo->sMaskSet, pTabItem->iCursor);
@@ -124891,11 +125468,11 @@
124891125468
spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
124892125469
}
124893125470
break;
124894125471
case 193: /* expr ::= expr COLLATE ID|STRING */
124895125472
{
124896
- yygotominor.yy346.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0);
125473
+ yygotominor.yy346.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0, 1);
124897125474
yygotominor.yy346.zStart = yymsp[-2].minor.yy346.zStart;
124898125475
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
124899125476
}
124900125477
break;
124901125478
case 194: /* expr ::= CAST LP expr AS typetoken RP */
@@ -125171,20 +125748,20 @@
125171125748
case 241: /* uniqueflag ::= */
125172125749
{yygotominor.yy328 = OE_None;}
125173125750
break;
125174125751
case 244: /* idxlist ::= idxlist COMMA nm collate sortorder */
125175125752
{
125176
- Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0);
125753
+ Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0, 1);
125177125754
yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, p);
125178125755
sqlite3ExprListSetName(pParse,yygotominor.yy14,&yymsp[-2].minor.yy0,1);
125179125756
sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
125180125757
if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
125181125758
}
125182125759
break;
125183125760
case 245: /* idxlist ::= nm collate sortorder */
125184125761
{
125185
- Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0);
125762
+ Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0, 1);
125186125763
yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, p);
125187125764
sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
125188125765
sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
125189125766
if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
125190125767
}
@@ -126439,13 +127016,15 @@
126439127016
pParse->zTail = &zSql[i];
126440127017
}
126441127018
sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);
126442127019
}
126443127020
#ifdef YYTRACKMAXSTACKDEPTH
127021
+ sqlite3_mutex_enter(sqlite3MallocMutex());
126444127022
sqlite3StatusSet(SQLITE_STATUS_PARSER_STACK,
126445127023
sqlite3ParserStackPeak(pEngine)
126446127024
);
127025
+ sqlite3_mutex_leave(sqlite3MallocMutex());
126447127026
#endif /* YYDEBUG */
126448127027
sqlite3ParserFree(pEngine, sqlite3_free);
126449127028
db->lookaside.bEnabled = enableLookaside;
126450127029
if( db->mallocFailed ){
126451127030
pParse->rc = SQLITE_NOMEM;
@@ -126605,11 +127184,11 @@
126605127184
**
126606127185
** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
126607127186
** to recognize the end of a trigger can be omitted. All we have to do
126608127187
** is look for a semicolon that is not part of an string or comment.
126609127188
*/
126610
-SQLITE_API int sqlite3_complete(const char *zSql){
127189
+SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *zSql){
126611127190
u8 state = 0; /* Current state, using numbers defined in header comment */
126612127191
u8 token; /* Value of the next token */
126613127192
126614127193
#ifndef SQLITE_OMIT_TRIGGER
126615127194
/* A complex statement machine used to detect the end of a CREATE TRIGGER
@@ -126770,11 +127349,11 @@
126770127349
/*
126771127350
** This routine is the same as the sqlite3_complete() routine described
126772127351
** above, except that the parameter is required to be UTF-16 encoded, not
126773127352
** UTF-8.
126774127353
*/
126775
-SQLITE_API int sqlite3_complete16(const void *zSql){
127354
+SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *zSql){
126776127355
sqlite3_value *pVal;
126777127356
char const *zSql8;
126778127357
int rc = SQLITE_NOMEM;
126779127358
126780127359
#ifndef SQLITE_OMIT_AUTOINIT
@@ -126920,37 +127499,37 @@
126920127499
#endif
126921127500
126922127501
/* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns
126923127502
** a pointer to the to the sqlite3_version[] string constant.
126924127503
*/
126925
-SQLITE_API const char *sqlite3_libversion(void){ return sqlite3_version; }
127504
+SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void){ return sqlite3_version; }
126926127505
126927127506
/* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a
126928127507
** pointer to a string constant whose value is the same as the
126929127508
** SQLITE_SOURCE_ID C preprocessor macro.
126930127509
*/
126931
-SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
127510
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
126932127511
126933127512
/* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function
126934127513
** returns an integer equal to SQLITE_VERSION_NUMBER.
126935127514
*/
126936
-SQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
127515
+SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
126937127516
126938127517
/* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns
126939127518
** zero if and only if SQLite was compiled with mutexing code omitted due to
126940127519
** the SQLITE_THREADSAFE compile-time option being set to 0.
126941127520
*/
126942
-SQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
127521
+SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
126943127522
126944127523
#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
126945127524
/*
126946127525
** If the following function pointer is not NULL and if
126947127526
** SQLITE_ENABLE_IOTRACE is enabled, then messages describing
126948127527
** I/O active are written using this function. These messages
126949127528
** are intended for debugging activity only.
126950127529
*/
126951
-/* not-private */ void (*sqlite3IoTrace)(const char*, ...) = 0;
127530
+SQLITE_API void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...) = 0;
126952127531
#endif
126953127532
126954127533
/*
126955127534
** If the following global variable points to a string which is the
126956127535
** name of a directory, then that directory will be used to store
@@ -126998,11 +127577,11 @@
126998127577
** call by X completes.
126999127578
**
127000127579
** * Recursive calls to this routine from thread X return immediately
127001127580
** without blocking.
127002127581
*/
127003
-SQLITE_API int sqlite3_initialize(void){
127582
+SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void){
127004127583
MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
127005127584
int rc; /* Result code */
127006127585
#ifdef SQLITE_EXTRA_INIT
127007127586
int bRunExtraInit = 0; /* Extra initialization needed */
127008127587
#endif
@@ -127011,10 +127590,15 @@
127011127590
rc = sqlite3_wsd_init(4096, 24);
127012127591
if( rc!=SQLITE_OK ){
127013127592
return rc;
127014127593
}
127015127594
#endif
127595
+
127596
+ /* If the following assert() fails on some obscure processor/compiler
127597
+ ** combination, the work-around is to set the correct pointer
127598
+ ** size at compile-time using -DSQLITE_PTRSIZE=n compile-time option */
127599
+ assert( SQLITE_PTRSIZE==sizeof(char*) );
127016127600
127017127601
/* If SQLite is already completely initialized, then this call
127018127602
** to sqlite3_initialize() should be a no-op. But the initialization
127019127603
** must be complete. So isInit must not be set until the very end
127020127604
** of this routine.
@@ -127154,11 +127738,11 @@
127154127738
** while any part of SQLite is otherwise in use in any thread. This
127155127739
** routine is not threadsafe. But it is safe to invoke this routine
127156127740
** on when SQLite is already shut down. If SQLite is already shut down
127157127741
** when this routine is invoked, then this routine is a harmless no-op.
127158127742
*/
127159
-SQLITE_API int sqlite3_shutdown(void){
127743
+SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void){
127160127744
#ifdef SQLITE_OMIT_WSD
127161127745
int rc = sqlite3_wsd_init(4096, 24);
127162127746
if( rc!=SQLITE_OK ){
127163127747
return rc;
127164127748
}
@@ -127208,11 +127792,11 @@
127208127792
** This routine should only be called when there are no outstanding
127209127793
** database connections or memory allocations. This routine is not
127210127794
** threadsafe. Failure to heed these warnings can lead to unpredictable
127211127795
** behavior.
127212127796
*/
127213
-SQLITE_API int sqlite3_config(int op, ...){
127797
+SQLITE_API int SQLITE_CDECL sqlite3_config(int op, ...){
127214127798
va_list ap;
127215127799
int rc = SQLITE_OK;
127216127800
127217127801
/* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while
127218127802
** the SQLite library is in use. */
@@ -127565,11 +128149,11 @@
127565128149
}
127566128150
127567128151
/*
127568128152
** Return the mutex associated with a database connection.
127569128153
*/
127570
-SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3 *db){
128154
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3 *db){
127571128155
#ifdef SQLITE_ENABLE_API_ARMOR
127572128156
if( !sqlite3SafetyCheckOk(db) ){
127573128157
(void)SQLITE_MISUSE_BKPT;
127574128158
return 0;
127575128159
}
@@ -127579,11 +128163,11 @@
127579128163
127580128164
/*
127581128165
** Free up as much memory as we can from the given database
127582128166
** connection.
127583128167
*/
127584
-SQLITE_API int sqlite3_db_release_memory(sqlite3 *db){
128168
+SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3 *db){
127585128169
int i;
127586128170
127587128171
#ifdef SQLITE_ENABLE_API_ARMOR
127588128172
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
127589128173
#endif
@@ -127602,11 +128186,11 @@
127602128186
}
127603128187
127604128188
/*
127605128189
** Configuration settings for an individual database connection
127606128190
*/
127607
-SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){
128191
+SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3 *db, int op, ...){
127608128192
va_list ap;
127609128193
int rc;
127610128194
va_start(ap, op);
127611128195
switch( op ){
127612128196
case SQLITE_DBCONFIG_LOOKASIDE: {
@@ -127721,11 +128305,11 @@
127721128305
}
127722128306
127723128307
/*
127724128308
** Return the ROWID of the most recent insert
127725128309
*/
127726
-SQLITE_API sqlite_int64 sqlite3_last_insert_rowid(sqlite3 *db){
128310
+SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3 *db){
127727128311
#ifdef SQLITE_ENABLE_API_ARMOR
127728128312
if( !sqlite3SafetyCheckOk(db) ){
127729128313
(void)SQLITE_MISUSE_BKPT;
127730128314
return 0;
127731128315
}
@@ -127734,11 +128318,11 @@
127734128318
}
127735128319
127736128320
/*
127737128321
** Return the number of changes in the most recent call to sqlite3_exec().
127738128322
*/
127739
-SQLITE_API int sqlite3_changes(sqlite3 *db){
128323
+SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3 *db){
127740128324
#ifdef SQLITE_ENABLE_API_ARMOR
127741128325
if( !sqlite3SafetyCheckOk(db) ){
127742128326
(void)SQLITE_MISUSE_BKPT;
127743128327
return 0;
127744128328
}
@@ -127747,11 +128331,11 @@
127747128331
}
127748128332
127749128333
/*
127750128334
** Return the number of changes since the database handle was opened.
127751128335
*/
127752
-SQLITE_API int sqlite3_total_changes(sqlite3 *db){
128336
+SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3 *db){
127753128337
#ifdef SQLITE_ENABLE_API_ARMOR
127754128338
if( !sqlite3SafetyCheckOk(db) ){
127755128339
(void)SQLITE_MISUSE_BKPT;
127756128340
return 0;
127757128341
}
@@ -127889,12 +128473,12 @@
127889128473
** statements or unfinished sqlite3_backups. The sqlite3_close_v2()
127890128474
** version forces the connection to become a zombie if there are
127891128475
** unclosed resources, and arranges for deallocation when the last
127892128476
** prepare statement or sqlite3_backup closes.
127893128477
*/
127894
-SQLITE_API int sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); }
127895
-SQLITE_API int sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); }
128478
+SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); }
128479
+SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); }
127896128480
127897128481
127898128482
/*
127899128483
** Close the mutex on database connection db.
127900128484
**
@@ -128297,11 +128881,11 @@
128297128881
128298128882
/*
128299128883
** This routine sets the busy callback for an Sqlite database to the
128300128884
** given callback function with the given argument.
128301128885
*/
128302
-SQLITE_API int sqlite3_busy_handler(
128886
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(
128303128887
sqlite3 *db,
128304128888
int (*xBusy)(void*,int),
128305128889
void *pArg
128306128890
){
128307128891
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -128320,11 +128904,11 @@
128320128904
/*
128321128905
** This routine sets the progress callback for an Sqlite database to the
128322128906
** given callback function with the given argument. The progress callback will
128323128907
** be invoked every nOps opcodes.
128324128908
*/
128325
-SQLITE_API void sqlite3_progress_handler(
128909
+SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(
128326128910
sqlite3 *db,
128327128911
int nOps,
128328128912
int (*xProgress)(void*),
128329128913
void *pArg
128330128914
){
@@ -128351,11 +128935,11 @@
128351128935
128352128936
/*
128353128937
** This routine installs a default busy handler that waits for the
128354128938
** specified number of milliseconds before returning 0.
128355128939
*/
128356
-SQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){
128940
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3 *db, int ms){
128357128941
#ifdef SQLITE_ENABLE_API_ARMOR
128358128942
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
128359128943
#endif
128360128944
if( ms>0 ){
128361128945
sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)db);
@@ -128367,11 +128951,11 @@
128367128951
}
128368128952
128369128953
/*
128370128954
** Cause any pending operation to stop at its earliest opportunity.
128371128955
*/
128372
-SQLITE_API void sqlite3_interrupt(sqlite3 *db){
128956
+SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3 *db){
128373128957
#ifdef SQLITE_ENABLE_API_ARMOR
128374128958
if( !sqlite3SafetyCheckOk(db) ){
128375128959
(void)SQLITE_MISUSE_BKPT;
128376128960
return;
128377128961
}
@@ -128484,11 +129068,11 @@
128484129068
}
128485129069
128486129070
/*
128487129071
** Create new user functions.
128488129072
*/
128489
-SQLITE_API int sqlite3_create_function(
129073
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
128490129074
sqlite3 *db,
128491129075
const char *zFunc,
128492129076
int nArg,
128493129077
int enc,
128494129078
void *p,
@@ -128498,11 +129082,11 @@
128498129082
){
128499129083
return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xFunc, xStep,
128500129084
xFinal, 0);
128501129085
}
128502129086
128503
-SQLITE_API int sqlite3_create_function_v2(
129087
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
128504129088
sqlite3 *db,
128505129089
const char *zFunc,
128506129090
int nArg,
128507129091
int enc,
128508129092
void *p,
@@ -128541,11 +129125,11 @@
128541129125
sqlite3_mutex_leave(db->mutex);
128542129126
return rc;
128543129127
}
128544129128
128545129129
#ifndef SQLITE_OMIT_UTF16
128546
-SQLITE_API int sqlite3_create_function16(
129130
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
128547129131
sqlite3 *db,
128548129132
const void *zFunctionName,
128549129133
int nArg,
128550129134
int eTextRep,
128551129135
void *p,
@@ -128581,11 +129165,11 @@
128581129165
** When virtual tables intend to provide an overloaded function, they
128582129166
** should call this routine to make sure the global function exists.
128583129167
** A global function must exist in order for name resolution to work
128584129168
** properly.
128585129169
*/
128586
-SQLITE_API int sqlite3_overload_function(
129170
+SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(
128587129171
sqlite3 *db,
128588129172
const char *zName,
128589129173
int nArg
128590129174
){
128591129175
int nName = sqlite3Strlen30(zName);
@@ -128613,11 +129197,11 @@
128613129197
**
128614129198
** A NULL trace function means that no tracing is executes. A non-NULL
128615129199
** trace is a pointer to a function that is invoked at the start of each
128616129200
** SQL statement.
128617129201
*/
128618
-SQLITE_API void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
129202
+SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
128619129203
void *pOld;
128620129204
128621129205
#ifdef SQLITE_ENABLE_API_ARMOR
128622129206
if( !sqlite3SafetyCheckOk(db) ){
128623129207
(void)SQLITE_MISUSE_BKPT;
@@ -128637,11 +129221,11 @@
128637129221
**
128638129222
** A NULL profile function means that no profiling is executes. A non-NULL
128639129223
** profile is a pointer to a function that is invoked at the conclusion of
128640129224
** each SQL statement that is run.
128641129225
*/
128642
-SQLITE_API void *sqlite3_profile(
129226
+SQLITE_API void *SQLITE_STDCALL sqlite3_profile(
128643129227
sqlite3 *db,
128644129228
void (*xProfile)(void*,const char*,sqlite_uint64),
128645129229
void *pArg
128646129230
){
128647129231
void *pOld;
@@ -128664,11 +129248,11 @@
128664129248
/*
128665129249
** Register a function to be invoked when a transaction commits.
128666129250
** If the invoked function returns non-zero, then the commit becomes a
128667129251
** rollback.
128668129252
*/
128669
-SQLITE_API void *sqlite3_commit_hook(
129253
+SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(
128670129254
sqlite3 *db, /* Attach the hook to this database */
128671129255
int (*xCallback)(void*), /* Function to invoke on each commit */
128672129256
void *pArg /* Argument to the function */
128673129257
){
128674129258
void *pOld;
@@ -128689,11 +129273,11 @@
128689129273
128690129274
/*
128691129275
** Register a callback to be invoked each time a row is updated,
128692129276
** inserted or deleted using this database connection.
128693129277
*/
128694
-SQLITE_API void *sqlite3_update_hook(
129278
+SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
128695129279
sqlite3 *db, /* Attach the hook to this database */
128696129280
void (*xCallback)(void*,int,char const *,char const *,sqlite_int64),
128697129281
void *pArg /* Argument to the function */
128698129282
){
128699129283
void *pRet;
@@ -128714,11 +129298,11 @@
128714129298
128715129299
/*
128716129300
** Register a callback to be invoked each time a transaction is rolled
128717129301
** back by this database connection.
128718129302
*/
128719
-SQLITE_API void *sqlite3_rollback_hook(
129303
+SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(
128720129304
sqlite3 *db, /* Attach the hook to this database */
128721129305
void (*xCallback)(void*), /* Callback function */
128722129306
void *pArg /* Argument to the function */
128723129307
){
128724129308
void *pRet;
@@ -128768,11 +129352,11 @@
128768129352
** The callback registered by this function replaces any existing callback
128769129353
** registered using sqlite3_wal_hook(). Likewise, registering a callback
128770129354
** using sqlite3_wal_hook() disables the automatic checkpoint mechanism
128771129355
** configured by this function.
128772129356
*/
128773
-SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
129357
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
128774129358
#ifdef SQLITE_OMIT_WAL
128775129359
UNUSED_PARAMETER(db);
128776129360
UNUSED_PARAMETER(nFrame);
128777129361
#else
128778129362
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -128789,11 +129373,11 @@
128789129373
128790129374
/*
128791129375
** Register a callback to be invoked each time a transaction is written
128792129376
** into the write-ahead-log by this database connection.
128793129377
*/
128794
-SQLITE_API void *sqlite3_wal_hook(
129378
+SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
128795129379
sqlite3 *db, /* Attach the hook to this db handle */
128796129380
int(*xCallback)(void *, sqlite3*, const char*, int),
128797129381
void *pArg /* First argument passed to xCallback() */
128798129382
){
128799129383
#ifndef SQLITE_OMIT_WAL
@@ -128816,11 +129400,11 @@
128816129400
}
128817129401
128818129402
/*
128819129403
** Checkpoint database zDb.
128820129404
*/
128821
-SQLITE_API int sqlite3_wal_checkpoint_v2(
129405
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
128822129406
sqlite3 *db, /* Database handle */
128823129407
const char *zDb, /* Name of attached database (or NULL) */
128824129408
int eMode, /* SQLITE_CHECKPOINT_* value */
128825129409
int *pnLog, /* OUT: Size of WAL log in frames */
128826129410
int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -128871,11 +129455,11 @@
128871129455
/*
128872129456
** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points
128873129457
** to contains a zero-length string, all attached databases are
128874129458
** checkpointed.
128875129459
*/
128876
-SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
129460
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
128877129461
/* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to
128878129462
** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */
128879129463
return sqlite3_wal_checkpoint_v2(db,zDb,SQLITE_CHECKPOINT_PASSIVE,0,0);
128880129464
}
128881129465
@@ -128960,11 +129544,11 @@
128960129544
128961129545
/*
128962129546
** Return UTF-8 encoded English language explanation of the most recent
128963129547
** error.
128964129548
*/
128965
-SQLITE_API const char *sqlite3_errmsg(sqlite3 *db){
129549
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3 *db){
128966129550
const char *z;
128967129551
if( !db ){
128968129552
return sqlite3ErrStr(SQLITE_NOMEM);
128969129553
}
128970129554
if( !sqlite3SafetyCheckSickOrOk(db) ){
@@ -128988,11 +129572,11 @@
128988129572
#ifndef SQLITE_OMIT_UTF16
128989129573
/*
128990129574
** Return UTF-16 encoded English language explanation of the most recent
128991129575
** error.
128992129576
*/
128993
-SQLITE_API const void *sqlite3_errmsg16(sqlite3 *db){
129577
+SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3 *db){
128994129578
static const u16 outOfMem[] = {
128995129579
'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
128996129580
};
128997129581
static const u16 misuse[] = {
128998129582
'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ',
@@ -129033,20 +129617,20 @@
129033129617
129034129618
/*
129035129619
** Return the most recent error code generated by an SQLite routine. If NULL is
129036129620
** passed to this function, we assume a malloc() failed during sqlite3_open().
129037129621
*/
129038
-SQLITE_API int sqlite3_errcode(sqlite3 *db){
129622
+SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db){
129039129623
if( db && !sqlite3SafetyCheckSickOrOk(db) ){
129040129624
return SQLITE_MISUSE_BKPT;
129041129625
}
129042129626
if( !db || db->mallocFailed ){
129043129627
return SQLITE_NOMEM;
129044129628
}
129045129629
return db->errCode & db->errMask;
129046129630
}
129047
-SQLITE_API int sqlite3_extended_errcode(sqlite3 *db){
129631
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db){
129048129632
if( db && !sqlite3SafetyCheckSickOrOk(db) ){
129049129633
return SQLITE_MISUSE_BKPT;
129050129634
}
129051129635
if( !db || db->mallocFailed ){
129052129636
return SQLITE_NOMEM;
@@ -129057,11 +129641,11 @@
129057129641
/*
129058129642
** Return a string that describes the kind of error specified in the
129059129643
** argument. For now, this simply calls the internal sqlite3ErrStr()
129060129644
** function.
129061129645
*/
129062
-SQLITE_API const char *sqlite3_errstr(int rc){
129646
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int rc){
129063129647
return sqlite3ErrStr(rc);
129064129648
}
129065129649
129066129650
/*
129067129651
** Create a new collating function for database "db". The name is zName
@@ -129205,11 +129789,11 @@
129205129789
**
129206129790
** A new lower limit does not shrink existing constructs.
129207129791
** It merely prevents new constructs that exceed the limit
129208129792
** from forming.
129209129793
*/
129210
-SQLITE_API int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
129794
+SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
129211129795
int oldLimit;
129212129796
129213129797
#ifdef SQLITE_ENABLE_API_ARMOR
129214129798
if( !sqlite3SafetyCheckOk(db) ){
129215129799
(void)SQLITE_MISUSE_BKPT;
@@ -129790,18 +130374,18 @@
129790130374
}
129791130375
129792130376
/*
129793130377
** Open a new database handle.
129794130378
*/
129795
-SQLITE_API int sqlite3_open(
130379
+SQLITE_API int SQLITE_STDCALL sqlite3_open(
129796130380
const char *zFilename,
129797130381
sqlite3 **ppDb
129798130382
){
129799130383
return openDatabase(zFilename, ppDb,
129800130384
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
129801130385
}
129802
-SQLITE_API int sqlite3_open_v2(
130386
+SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
129803130387
const char *filename, /* Database filename (UTF-8) */
129804130388
sqlite3 **ppDb, /* OUT: SQLite db handle */
129805130389
int flags, /* Flags */
129806130390
const char *zVfs /* Name of VFS module to use */
129807130391
){
@@ -129810,11 +130394,11 @@
129810130394
129811130395
#ifndef SQLITE_OMIT_UTF16
129812130396
/*
129813130397
** Open a new database handle.
129814130398
*/
129815
-SQLITE_API int sqlite3_open16(
130399
+SQLITE_API int SQLITE_STDCALL sqlite3_open16(
129816130400
const void *zFilename,
129817130401
sqlite3 **ppDb
129818130402
){
129819130403
char const *zFilename8; /* zFilename encoded in UTF-8 instead of UTF-16 */
129820130404
sqlite3_value *pVal;
@@ -129849,11 +130433,11 @@
129849130433
#endif /* SQLITE_OMIT_UTF16 */
129850130434
129851130435
/*
129852130436
** Register a new collation sequence with the database handle db.
129853130437
*/
129854
-SQLITE_API int sqlite3_create_collation(
130438
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
129855130439
sqlite3* db,
129856130440
const char *zName,
129857130441
int enc,
129858130442
void* pCtx,
129859130443
int(*xCompare)(void*,int,const void*,int,const void*)
@@ -129862,11 +130446,11 @@
129862130446
}
129863130447
129864130448
/*
129865130449
** Register a new collation sequence with the database handle db.
129866130450
*/
129867
-SQLITE_API int sqlite3_create_collation_v2(
130451
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
129868130452
sqlite3* db,
129869130453
const char *zName,
129870130454
int enc,
129871130455
void* pCtx,
129872130456
int(*xCompare)(void*,int,const void*,int,const void*),
@@ -129887,11 +130471,11 @@
129887130471
129888130472
#ifndef SQLITE_OMIT_UTF16
129889130473
/*
129890130474
** Register a new collation sequence with the database handle db.
129891130475
*/
129892
-SQLITE_API int sqlite3_create_collation16(
130476
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
129893130477
sqlite3* db,
129894130478
const void *zName,
129895130479
int enc,
129896130480
void* pCtx,
129897130481
int(*xCompare)(void*,int,const void*,int,const void*)
@@ -129917,11 +130501,11 @@
129917130501
129918130502
/*
129919130503
** Register a collation sequence factory callback with the database handle
129920130504
** db. Replace any previously installed collation sequence factory.
129921130505
*/
129922
-SQLITE_API int sqlite3_collation_needed(
130506
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
129923130507
sqlite3 *db,
129924130508
void *pCollNeededArg,
129925130509
void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*)
129926130510
){
129927130511
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -129938,11 +130522,11 @@
129938130522
#ifndef SQLITE_OMIT_UTF16
129939130523
/*
129940130524
** Register a collation sequence factory callback with the database handle
129941130525
** db. Replace any previously installed collation sequence factory.
129942130526
*/
129943
-SQLITE_API int sqlite3_collation_needed16(
130527
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
129944130528
sqlite3 *db,
129945130529
void *pCollNeededArg,
129946130530
void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*)
129947130531
){
129948130532
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -129960,11 +130544,11 @@
129960130544
#ifndef SQLITE_OMIT_DEPRECATED
129961130545
/*
129962130546
** This function is now an anachronism. It used to be used to recover from a
129963130547
** malloc() failure, but SQLite now does this automatically.
129964130548
*/
129965
-SQLITE_API int sqlite3_global_recover(void){
130549
+SQLITE_API int SQLITE_STDCALL sqlite3_global_recover(void){
129966130550
return SQLITE_OK;
129967130551
}
129968130552
#endif
129969130553
129970130554
/*
@@ -129971,11 +130555,11 @@
129971130555
** Test to see whether or not the database connection is in autocommit
129972130556
** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on
129973130557
** by default. Autocommit is disabled by a BEGIN statement and reenabled
129974130558
** by the next COMMIT or ROLLBACK.
129975130559
*/
129976
-SQLITE_API int sqlite3_get_autocommit(sqlite3 *db){
130560
+SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3 *db){
129977130561
#ifdef SQLITE_ENABLE_API_ARMOR
129978130562
if( !sqlite3SafetyCheckOk(db) ){
129979130563
(void)SQLITE_MISUSE_BKPT;
129980130564
return 0;
129981130565
}
@@ -130023,19 +130607,19 @@
130023130607
** data for this thread has been deallocated.
130024130608
**
130025130609
** SQLite no longer uses thread-specific data so this routine is now a
130026130610
** no-op. It is retained for historical compatibility.
130027130611
*/
130028
-SQLITE_API void sqlite3_thread_cleanup(void){
130612
+SQLITE_API void SQLITE_STDCALL sqlite3_thread_cleanup(void){
130029130613
}
130030130614
#endif
130031130615
130032130616
/*
130033130617
** Return meta information about a specific column of a database table.
130034130618
** See comment in sqlite3.h (sqlite.h.in) for details.
130035130619
*/
130036
-SQLITE_API int sqlite3_table_column_metadata(
130620
+SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
130037130621
sqlite3 *db, /* Connection handle */
130038130622
const char *zDbName, /* Database name or NULL */
130039130623
const char *zTableName, /* Table name */
130040130624
const char *zColumnName, /* Column name */
130041130625
char const **pzDataType, /* OUTPUT: Declared data type */
@@ -130149,11 +130733,11 @@
130149130733
}
130150130734
130151130735
/*
130152130736
** Sleep for a little while. Return the amount of time slept.
130153130737
*/
130154
-SQLITE_API int sqlite3_sleep(int ms){
130738
+SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int ms){
130155130739
sqlite3_vfs *pVfs;
130156130740
int rc;
130157130741
pVfs = sqlite3_vfs_find(0);
130158130742
if( pVfs==0 ) return 0;
130159130743
@@ -130165,11 +130749,11 @@
130165130749
}
130166130750
130167130751
/*
130168130752
** Enable or disable the extended result codes.
130169130753
*/
130170
-SQLITE_API int sqlite3_extended_result_codes(sqlite3 *db, int onoff){
130754
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3 *db, int onoff){
130171130755
#ifdef SQLITE_ENABLE_API_ARMOR
130172130756
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
130173130757
#endif
130174130758
sqlite3_mutex_enter(db->mutex);
130175130759
db->errMask = onoff ? 0xffffffff : 0xff;
@@ -130178,11 +130762,11 @@
130178130762
}
130179130763
130180130764
/*
130181130765
** Invoke the xFileControl method on a particular database.
130182130766
*/
130183
-SQLITE_API int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){
130767
+SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){
130184130768
int rc = SQLITE_ERROR;
130185130769
Btree *pBtree;
130186130770
130187130771
#ifdef SQLITE_ENABLE_API_ARMOR
130188130772
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -130212,11 +130796,11 @@
130212130796
}
130213130797
130214130798
/*
130215130799
** Interface to the testing logic.
130216130800
*/
130217
-SQLITE_API int sqlite3_test_control(int op, ...){
130801
+SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...){
130218130802
int rc = 0;
130219130803
#ifndef SQLITE_OMIT_BUILTIN_TEST
130220130804
va_list ap;
130221130805
va_start(ap, op);
130222130806
switch( op ){
@@ -130555,11 +131139,11 @@
130555131139
** method of a VFS implementation. The zParam argument is the name of the
130556131140
** query parameter we seek. This routine returns the value of the zParam
130557131141
** parameter if it exists. If the parameter does not exist, this routine
130558131142
** returns a NULL pointer.
130559131143
*/
130560
-SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){
131144
+SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam){
130561131145
if( zFilename==0 || zParam==0 ) return 0;
130562131146
zFilename += sqlite3Strlen30(zFilename) + 1;
130563131147
while( zFilename[0] ){
130564131148
int x = strcmp(zFilename, zParam);
130565131149
zFilename += sqlite3Strlen30(zFilename) + 1;
@@ -130570,20 +131154,20 @@
130570131154
}
130571131155
130572131156
/*
130573131157
** Return a boolean value for a query parameter.
130574131158
*/
130575
-SQLITE_API int sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){
131159
+SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){
130576131160
const char *z = sqlite3_uri_parameter(zFilename, zParam);
130577131161
bDflt = bDflt!=0;
130578131162
return z ? sqlite3GetBoolean(z, bDflt) : bDflt;
130579131163
}
130580131164
130581131165
/*
130582131166
** Return a 64-bit integer value for a query parameter.
130583131167
*/
130584
-SQLITE_API sqlite3_int64 sqlite3_uri_int64(
131168
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(
130585131169
const char *zFilename, /* Filename as passed to xOpen */
130586131170
const char *zParam, /* URI parameter sought */
130587131171
sqlite3_int64 bDflt /* return if parameter is missing */
130588131172
){
130589131173
const char *z = sqlite3_uri_parameter(zFilename, zParam);
@@ -130611,11 +131195,11 @@
130611131195
130612131196
/*
130613131197
** Return the filename of the database associated with a database
130614131198
** connection.
130615131199
*/
130616
-SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){
131200
+SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName){
130617131201
Btree *pBt;
130618131202
#ifdef SQLITE_ENABLE_API_ARMOR
130619131203
if( !sqlite3SafetyCheckOk(db) ){
130620131204
(void)SQLITE_MISUSE_BKPT;
130621131205
return 0;
@@ -130627,11 +131211,11 @@
130627131211
130628131212
/*
130629131213
** Return 1 if database is read-only or 0 if read/write. Return -1 if
130630131214
** no such database exists.
130631131215
*/
130632
-SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){
131216
+SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName){
130633131217
Btree *pBt;
130634131218
#ifdef SQLITE_ENABLE_API_ARMOR
130635131219
if( !sqlite3SafetyCheckOk(db) ){
130636131220
(void)SQLITE_MISUSE_BKPT;
130637131221
return -1;
@@ -130786,11 +131370,11 @@
130786131370
**
130787131371
** Each call to this routine overrides any prior callbacks registered
130788131372
** on the same "db". If xNotify==0 then any prior callbacks are immediately
130789131373
** cancelled.
130790131374
*/
130791
-SQLITE_API int sqlite3_unlock_notify(
131375
+SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
130792131376
sqlite3 *db,
130793131377
void (*xNotify)(void **, int),
130794131378
void *pArg
130795131379
){
130796131380
int rc = SQLITE_OK;
@@ -132766,15 +133350,20 @@
132766133350
** the output value undefined. Otherwise SQLITE_OK is returned.
132767133351
**
132768133352
** This function is used when parsing the "prefix=" FTS4 parameter.
132769133353
*/
132770133354
static int fts3GobbleInt(const char **pp, int *pnOut){
133355
+ const int MAX_NPREFIX = 10000000;
132771133356
const char *p; /* Iterator pointer */
132772133357
int nInt = 0; /* Output value */
132773133358
132774133359
for(p=*pp; p[0]>='0' && p[0]<='9'; p++){
132775133360
nInt = nInt * 10 + (p[0] - '0');
133361
+ if( nInt>MAX_NPREFIX ){
133362
+ nInt = 0;
133363
+ break;
133364
+ }
132776133365
}
132777133366
if( p==*pp ) return SQLITE_ERROR;
132778133367
*pnOut = nInt;
132779133368
*pp = p;
132780133369
return SQLITE_OK;
@@ -132813,27 +133402,33 @@
132813133402
}
132814133403
}
132815133404
132816133405
aIndex = sqlite3_malloc(sizeof(struct Fts3Index) * nIndex);
132817133406
*apIndex = aIndex;
132818
- *pnIndex = nIndex;
132819133407
if( !aIndex ){
132820133408
return SQLITE_NOMEM;
132821133409
}
132822133410
132823133411
memset(aIndex, 0, sizeof(struct Fts3Index) * nIndex);
132824133412
if( zParam ){
132825133413
const char *p = zParam;
132826133414
int i;
132827133415
for(i=1; i<nIndex; i++){
132828
- int nPrefix;
133416
+ int nPrefix = 0;
132829133417
if( fts3GobbleInt(&p, &nPrefix) ) return SQLITE_ERROR;
132830
- aIndex[i].nPrefix = nPrefix;
133418
+ assert( nPrefix>=0 );
133419
+ if( nPrefix==0 ){
133420
+ nIndex--;
133421
+ i--;
133422
+ }else{
133423
+ aIndex[i].nPrefix = nPrefix;
133424
+ }
132831133425
p++;
132832133426
}
132833133427
}
132834133428
133429
+ *pnIndex = nIndex;
132835133430
return SQLITE_OK;
132836133431
}
132837133432
132838133433
/*
132839133434
** This function is called when initializing an FTS4 table that uses the
@@ -132953,11 +133548,11 @@
132953133548
int nName; /* Bytes required to hold table name */
132954133549
int isFts4 = (argv[0][3]=='4'); /* True for FTS4, false for FTS3 */
132955133550
const char **aCol; /* Array of column names */
132956133551
sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
132957133552
132958
- int nIndex; /* Size of aIndex[] array */
133553
+ int nIndex = 0; /* Size of aIndex[] array */
132959133554
struct Fts3Index *aIndex = 0; /* Array of indexes for this table */
132960133555
132961133556
/* The results of parsing supported FTS4 key=value options: */
132962133557
int bNoDocsize = 0; /* True to omit %_docsize table */
132963133558
int bDescIdx = 0; /* True to store descending indexes */
@@ -137641,11 +138236,11 @@
137641138236
** Initialize API pointer table, if required.
137642138237
*/
137643138238
#ifdef _WIN32
137644138239
__declspec(dllexport)
137645138240
#endif
137646
-SQLITE_API int sqlite3_fts3_init(
138241
+SQLITE_API int SQLITE_STDCALL sqlite3_fts3_init(
137647138242
sqlite3 *db,
137648138243
char **pzErrMsg,
137649138244
const sqlite3_api_routines *pApi
137650138245
){
137651138246
SQLITE_EXTENSION_INIT2(pApi)
@@ -140609,11 +141204,11 @@
140609141204
nName = sqlite3_value_bytes(argv[0])+1;
140610141205
140611141206
if( argc==2 ){
140612141207
void *pOld;
140613141208
int n = sqlite3_value_bytes(argv[1]);
140614
- if( n!=sizeof(pPtr) ){
141209
+ if( zName==0 || n!=sizeof(pPtr) ){
140615141210
sqlite3_result_error(context, "argument type mismatch", -1);
140616141211
return;
140617141212
}
140618141213
pPtr = *(void **)sqlite3_value_blob(argv[1]);
140619141214
pOld = sqlite3Fts3HashInsert(pHash, (void *)zName, nName, pPtr);
@@ -140620,11 +141215,13 @@
140620141215
if( pOld==pPtr ){
140621141216
sqlite3_result_error(context, "out of memory", -1);
140622141217
return;
140623141218
}
140624141219
}else{
140625
- pPtr = sqlite3Fts3HashFind(pHash, zName, nName);
141220
+ if( zName ){
141221
+ pPtr = sqlite3Fts3HashFind(pHash, zName, nName);
141222
+ }
140626141223
if( !pPtr ){
140627141224
char *zErr = sqlite3_mprintf("unknown tokenizer: %s", zName);
140628141225
sqlite3_result_error(context, zErr, -1);
140629141226
sqlite3_free(zErr);
140630141227
return;
@@ -140701,10 +141298,14 @@
140701141298
zCopy = sqlite3_mprintf("%s", zArg);
140702141299
if( !zCopy ) return SQLITE_NOMEM;
140703141300
zEnd = &zCopy[strlen(zCopy)];
140704141301
140705141302
z = (char *)sqlite3Fts3NextToken(zCopy, &n);
141303
+ if( z==0 ){
141304
+ assert( n==0 );
141305
+ z = zCopy;
141306
+ }
140706141307
z[n] = '\0';
140707141308
sqlite3Fts3Dequote(z);
140708141309
140709141310
m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash,z,(int)strlen(z)+1);
140710141311
if( !m ){
@@ -143346,11 +143947,14 @@
143346143947
/*
143347143948
** This is a comparison function used as a qsort() callback when sorting
143348143949
** an array of pending terms by term. This occurs as part of flushing
143349143950
** the contents of the pending-terms hash table to the database.
143350143951
*/
143351
-static int fts3CompareElemByTerm(const void *lhs, const void *rhs){
143952
+static int SQLITE_CDECL fts3CompareElemByTerm(
143953
+ const void *lhs,
143954
+ const void *rhs
143955
+){
143352143956
char *z1 = fts3HashKey(*(Fts3HashElem **)lhs);
143353143957
char *z2 = fts3HashKey(*(Fts3HashElem **)rhs);
143354143958
int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs);
143355143959
int n2 = fts3HashKeysize(*(Fts3HashElem **)rhs);
143356143960
@@ -153079,11 +153683,11 @@
153079153683
}
153080153684
153081153685
/*
153082153686
** Register a new geometry function for use with the r-tree MATCH operator.
153083153687
*/
153084
-SQLITE_API int sqlite3_rtree_geometry_callback(
153688
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
153085153689
sqlite3 *db, /* Register SQL function on this connection */
153086153690
const char *zGeom, /* Name of the new SQL function */
153087153691
int (*xGeom)(sqlite3_rtree_geometry*,int,RtreeDValue*,int*), /* Callback */
153088153692
void *pContext /* Extra data associated with the callback */
153089153693
){
@@ -153103,11 +153707,11 @@
153103153707
153104153708
/*
153105153709
** Register a new 2nd-generation geometry function for use with the
153106153710
** r-tree MATCH operator.
153107153711
*/
153108
-SQLITE_API int sqlite3_rtree_query_callback(
153712
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
153109153713
sqlite3 *db, /* Register SQL function on this connection */
153110153714
const char *zQueryFunc, /* Name of new SQL function */
153111153715
int (*xQueryFunc)(sqlite3_rtree_query_info*), /* Callback */
153112153716
void *pContext, /* Extra data passed into the callback */
153113153717
void (*xDestructor)(void*) /* Destructor for the extra data */
@@ -153128,11 +153732,11 @@
153128153732
153129153733
#if !SQLITE_CORE
153130153734
#ifdef _WIN32
153131153735
__declspec(dllexport)
153132153736
#endif
153133
-SQLITE_API int sqlite3_rtree_init(
153737
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_init(
153134153738
sqlite3 *db,
153135153739
char **pzErrMsg,
153136153740
const sqlite3_api_routines *pApi
153137153741
){
153138153742
SQLITE_EXTENSION_INIT2(pApi)
@@ -153633,11 +154237,11 @@
153633154237
153634154238
#if !SQLITE_CORE
153635154239
#ifdef _WIN32
153636154240
__declspec(dllexport)
153637154241
#endif
153638
-SQLITE_API int sqlite3_icu_init(
154242
+SQLITE_API int SQLITE_STDCALL sqlite3_icu_init(
153639154243
sqlite3 *db,
153640154244
char **pzErrMsg,
153641154245
const sqlite3_api_routines *pApi
153642154246
){
153643154247
SQLITE_EXTENSION_INIT2(pApi)
153644154248
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -20,13 +20,10 @@
20 #define SQLITE_CORE 1
21 #define SQLITE_AMALGAMATION 1
22 #ifndef SQLITE_PRIVATE
23 # define SQLITE_PRIVATE static
24 #endif
25 #ifndef SQLITE_API
26 # define SQLITE_API
27 #endif
28 /************** Begin file sqliteInt.h ***************************************/
29 /*
30 ** 2001 September 15
31 **
32 ** The author disclaims copyright to this source code. In place of
@@ -250,20 +247,24 @@
250 extern "C" {
251 #endif
252
253
254 /*
255 ** Add the ability to override 'extern'
256 */
257 #ifndef SQLITE_EXTERN
258 # define SQLITE_EXTERN extern
259 #endif
260
261 #ifndef SQLITE_API
262 # define SQLITE_API
263 #endif
264
 
 
 
 
 
265
266 /*
267 ** These no-op macros are used in front of interfaces to mark those
268 ** interfaces as either deprecated or experimental. New applications
269 ** should not use deprecated interfaces - they are supported for backwards
@@ -316,11 +317,11 @@
316 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
317 ** [sqlite_version()] and [sqlite_source_id()].
318 */
319 #define SQLITE_VERSION "3.8.9"
320 #define SQLITE_VERSION_NUMBER 3008009
321 #define SQLITE_SOURCE_ID "2015-03-09 10:40:48 e5da5e7d5dc5a3438ced23f1ee83e695abc29c45"
322
323 /*
324 ** CAPI3REF: Run-Time Library Version Numbers
325 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
326 **
@@ -349,13 +350,13 @@
349 ** [SQLITE_SOURCE_ID] C preprocessor macro.
350 **
351 ** See also: [sqlite_version()] and [sqlite_source_id()].
352 */
353 SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
354 SQLITE_API const char *sqlite3_libversion(void);
355 SQLITE_API const char *sqlite3_sourceid(void);
356 SQLITE_API int sqlite3_libversion_number(void);
357
358 /*
359 ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
360 **
361 ** ^The sqlite3_compileoption_used() function returns 0 or 1
@@ -376,12 +377,12 @@
376 **
377 ** See also: SQL functions [sqlite_compileoption_used()] and
378 ** [sqlite_compileoption_get()] and the [compile_options pragma].
379 */
380 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
381 SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
382 SQLITE_API const char *sqlite3_compileoption_get(int N);
383 #endif
384
385 /*
386 ** CAPI3REF: Test To See If The Library Is Threadsafe
387 **
@@ -416,11 +417,11 @@
416 ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
417 ** is unchanged by calls to sqlite3_config().)^
418 **
419 ** See the [threading mode] documentation for additional information.
420 */
421 SQLITE_API int sqlite3_threadsafe(void);
422
423 /*
424 ** CAPI3REF: Database Connection Handle
425 ** KEYWORDS: {database connection} {database connections}
426 **
@@ -512,12 +513,12 @@
512 ** from [sqlite3_open()], [sqlite3_open16()], or
513 ** [sqlite3_open_v2()], and not previously closed.
514 ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
515 ** argument is a harmless no-op.
516 */
517 SQLITE_API int sqlite3_close(sqlite3*);
518 SQLITE_API int sqlite3_close_v2(sqlite3*);
519
520 /*
521 ** The type for a callback function.
522 ** This is legacy and deprecated. It is included for historical
523 ** compatibility and is not documented.
@@ -583,11 +584,11 @@
583 ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
584 ** <li> The application must not modify the SQL statement text passed into
585 ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
586 ** </ul>
587 */
588 SQLITE_API int sqlite3_exec(
589 sqlite3*, /* An open database */
590 const char *sql, /* SQL to be evaluated */
591 int (*callback)(void*,int,char**,char**), /* Callback function */
592 void *, /* 1st argument to callback */
593 char **errmsg /* Error msg written here */
@@ -1157,10 +1158,17 @@
1157 ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
1158 ** opcode causes the xFileControl method to swap the file handle with the one
1159 ** pointed to by the pArg argument. This capability is used during testing
1160 ** and only needs to be supported when SQLITE_TEST is defined.
1161 **
 
 
 
 
 
 
 
1162 ** </ul>
1163 */
1164 #define SQLITE_FCNTL_LOCKSTATE 1
1165 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
1166 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
@@ -1181,10 +1189,11 @@
1181 #define SQLITE_FCNTL_TRACE 19
1182 #define SQLITE_FCNTL_HAS_MOVED 20
1183 #define SQLITE_FCNTL_SYNC 21
1184 #define SQLITE_FCNTL_COMMIT_PHASETWO 22
1185 #define SQLITE_FCNTL_WIN32_SET_HANDLE 23
 
1186
1187 /* deprecated names */
1188 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
1189 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1190 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -1535,14 +1544,14 @@
1535 ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
1536 ** implementation of sqlite3_os_init() or sqlite3_os_end()
1537 ** must return [SQLITE_OK] on success and some other [error code] upon
1538 ** failure.
1539 */
1540 SQLITE_API int sqlite3_initialize(void);
1541 SQLITE_API int sqlite3_shutdown(void);
1542 SQLITE_API int sqlite3_os_init(void);
1543 SQLITE_API int sqlite3_os_end(void);
1544
1545 /*
1546 ** CAPI3REF: Configuring The SQLite Library
1547 **
1548 ** The sqlite3_config() interface is used to make global configuration
@@ -1569,11 +1578,11 @@
1569 **
1570 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1571 ** ^If the option is unknown or SQLite is unable to set the option
1572 ** then this routine returns a non-zero [error code].
1573 */
1574 SQLITE_API int sqlite3_config(int, ...);
1575
1576 /*
1577 ** CAPI3REF: Configure database connections
1578 **
1579 ** The sqlite3_db_config() interface is used to make configuration
@@ -1587,11 +1596,11 @@
1587 ** Subsequent arguments vary depending on the configuration verb.
1588 **
1589 ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
1590 ** the call is considered successful.
1591 */
1592 SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
1593
1594 /*
1595 ** CAPI3REF: Memory Allocation Routines
1596 **
1597 ** An instance of this object defines the interface between SQLite
@@ -1747,11 +1756,11 @@
1747 ** disabled, the following SQLite interfaces become non-operational:
1748 ** <ul>
1749 ** <li> [sqlite3_memory_used()]
1750 ** <li> [sqlite3_memory_highwater()]
1751 ** <li> [sqlite3_soft_heap_limit64()]
1752 ** <li> [sqlite3_status()]
1753 ** </ul>)^
1754 ** ^Memory allocation statistics are enabled by default unless SQLite is
1755 ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
1756 ** allocation statistics are disabled by default.
1757 ** </dd>
@@ -2075,11 +2084,11 @@
2075 **
2076 ** ^The sqlite3_extended_result_codes() routine enables or disables the
2077 ** [extended result codes] feature of SQLite. ^The extended result
2078 ** codes are disabled by default for historical compatibility.
2079 */
2080 SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
2081
2082 /*
2083 ** CAPI3REF: Last Insert Rowid
2084 **
2085 ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
@@ -2126,11 +2135,11 @@
2126 ** function is running and thus changes the last insert [rowid],
2127 ** then the value returned by [sqlite3_last_insert_rowid()] is
2128 ** unpredictable and might not equal either the old or the new
2129 ** last insert [rowid].
2130 */
2131 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
2132
2133 /*
2134 ** CAPI3REF: Count The Number Of Rows Modified
2135 **
2136 ** ^This function returns the number of rows modified, inserted or
@@ -2178,11 +2187,11 @@
2178 **
2179 ** If a separate thread makes changes on the same database connection
2180 ** while [sqlite3_changes()] is running then the value returned
2181 ** is unpredictable and not meaningful.
2182 */
2183 SQLITE_API int sqlite3_changes(sqlite3*);
2184
2185 /*
2186 ** CAPI3REF: Total Number Of Rows Modified
2187 **
2188 ** ^This function returns the total number of rows inserted, modified or
@@ -2201,11 +2210,11 @@
2201 **
2202 ** If a separate thread makes changes on the same database connection
2203 ** while [sqlite3_total_changes()] is running then the value
2204 ** returned is unpredictable and not meaningful.
2205 */
2206 SQLITE_API int sqlite3_total_changes(sqlite3*);
2207
2208 /*
2209 ** CAPI3REF: Interrupt A Long-Running Query
2210 **
2211 ** ^This function causes any pending database operation to abort and
@@ -2240,11 +2249,11 @@
2240 ** that are started after the sqlite3_interrupt() call returns.
2241 **
2242 ** If the database connection closes while [sqlite3_interrupt()]
2243 ** is running then bad things will likely happen.
2244 */
2245 SQLITE_API void sqlite3_interrupt(sqlite3*);
2246
2247 /*
2248 ** CAPI3REF: Determine If An SQL Statement Is Complete
2249 **
2250 ** These routines are useful during command-line input to determine if the
@@ -2275,12 +2284,12 @@
2275 ** UTF-8 string.
2276 **
2277 ** The input to [sqlite3_complete16()] must be a zero-terminated
2278 ** UTF-16 string in native byte order.
2279 */
2280 SQLITE_API int sqlite3_complete(const char *sql);
2281 SQLITE_API int sqlite3_complete16(const void *sql);
2282
2283 /*
2284 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
2285 ** KEYWORDS: {busy-handler callback} {busy handler}
2286 **
@@ -2336,11 +2345,11 @@
2336 ** result in undefined behavior.
2337 **
2338 ** A busy handler must not close the database connection
2339 ** or [prepared statement] that invoked the busy handler.
2340 */
2341 SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2342
2343 /*
2344 ** CAPI3REF: Set A Busy Timeout
2345 **
2346 ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
@@ -2358,11 +2367,11 @@
2358 ** was defined (using [sqlite3_busy_handler()]) prior to calling
2359 ** this routine, that other busy handler is cleared.)^
2360 **
2361 ** See also: [PRAGMA busy_timeout]
2362 */
2363 SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
2364
2365 /*
2366 ** CAPI3REF: Convenience Routines For Running Queries
2367 **
2368 ** This is a legacy interface that is preserved for backwards compatibility.
@@ -2432,19 +2441,19 @@
2432 ** interface defined here. As a consequence, errors that occur in the
2433 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
2434 ** reflected in subsequent calls to [sqlite3_errcode()] or
2435 ** [sqlite3_errmsg()].
2436 */
2437 SQLITE_API int sqlite3_get_table(
2438 sqlite3 *db, /* An open database */
2439 const char *zSql, /* SQL to be evaluated */
2440 char ***pazResult, /* Results of the query */
2441 int *pnRow, /* Number of result rows written here */
2442 int *pnColumn, /* Number of result columns written here */
2443 char **pzErrmsg /* Error msg written here */
2444 );
2445 SQLITE_API void sqlite3_free_table(char **result);
2446
2447 /*
2448 ** CAPI3REF: Formatted String Printing Functions
2449 **
2450 ** These routines are work-alikes of the "printf()" family of functions
@@ -2546,14 +2555,14 @@
2546 **
2547 ** ^(The "%z" formatting option works like "%s" but with the
2548 ** addition that after the string has been read and copied into
2549 ** the result, [sqlite3_free()] is called on the input string.)^
2550 */
2551 SQLITE_API char *sqlite3_mprintf(const char*,...);
2552 SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
2553 SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
2554 SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
2555
2556 /*
2557 ** CAPI3REF: Memory Allocation Subsystem
2558 **
2559 ** The SQLite core uses these three routines for all of its own
@@ -2639,16 +2648,16 @@
2639 **
2640 ** The application must not read or write any part of
2641 ** a block of memory after it has been released using
2642 ** [sqlite3_free()] or [sqlite3_realloc()].
2643 */
2644 SQLITE_API void *sqlite3_malloc(int);
2645 SQLITE_API void *sqlite3_malloc64(sqlite3_uint64);
2646 SQLITE_API void *sqlite3_realloc(void*, int);
2647 SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);
2648 SQLITE_API void sqlite3_free(void*);
2649 SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
2650
2651 /*
2652 ** CAPI3REF: Memory Allocator Statistics
2653 **
2654 ** SQLite provides these two interfaces for reporting on the status
@@ -2669,12 +2678,12 @@
2669 ** [sqlite3_memory_used()] if and only if the parameter to
2670 ** [sqlite3_memory_highwater()] is true. ^The value returned
2671 ** by [sqlite3_memory_highwater(1)] is the high-water mark
2672 ** prior to the reset.
2673 */
2674 SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
2675 SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
2676
2677 /*
2678 ** CAPI3REF: Pseudo-Random Number Generator
2679 **
2680 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
@@ -2693,11 +2702,11 @@
2693 ** ^If the previous call to this routine had an N of 1 or more and a
2694 ** non-NULL P then the pseudo-randomness is generated
2695 ** internally and without recourse to the [sqlite3_vfs] xRandomness
2696 ** method.
2697 */
2698 SQLITE_API void sqlite3_randomness(int N, void *P);
2699
2700 /*
2701 ** CAPI3REF: Compile-Time Authorization Callbacks
2702 **
2703 ** ^This routine registers an authorizer callback with a particular
@@ -2775,11 +2784,11 @@
2775 ** [sqlite3_prepare()] or its variants. Authorization is not
2776 ** performed during statement evaluation in [sqlite3_step()], unless
2777 ** as stated in the previous paragraph, sqlite3_step() invokes
2778 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
2779 */
2780 SQLITE_API int sqlite3_set_authorizer(
2781 sqlite3*,
2782 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2783 void *pUserData
2784 );
2785
@@ -2879,12 +2888,12 @@
2879 ** digits in the time are meaningless. Future versions of SQLite
2880 ** might provide greater resolution on the profiler callback. The
2881 ** sqlite3_profile() function is considered experimental and is
2882 ** subject to change in future versions of SQLite.
2883 */
2884 SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2885 SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
2886 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2887
2888 /*
2889 ** CAPI3REF: Query Progress Callbacks
2890 **
@@ -2914,11 +2923,11 @@
2914 ** the database connection that invoked the progress handler.
2915 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2916 ** database connections for the meaning of "modify" in this paragraph.
2917 **
2918 */
2919 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2920
2921 /*
2922 ** CAPI3REF: Opening A New Database Connection
2923 **
2924 ** ^These routines open an SQLite database file as specified by the
@@ -3142,19 +3151,19 @@
3142 ** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various
3143 ** features that require the use of temporary files may fail.
3144 **
3145 ** See also: [sqlite3_temp_directory]
3146 */
3147 SQLITE_API int sqlite3_open(
3148 const char *filename, /* Database filename (UTF-8) */
3149 sqlite3 **ppDb /* OUT: SQLite db handle */
3150 );
3151 SQLITE_API int sqlite3_open16(
3152 const void *filename, /* Database filename (UTF-16) */
3153 sqlite3 **ppDb /* OUT: SQLite db handle */
3154 );
3155 SQLITE_API int sqlite3_open_v2(
3156 const char *filename, /* Database filename (UTF-8) */
3157 sqlite3 **ppDb, /* OUT: SQLite db handle */
3158 int flags, /* Flags */
3159 const char *zVfs /* Name of VFS module to use */
3160 );
@@ -3196,23 +3205,25 @@
3196 ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
3197 ** is not a database file pathname pointer that SQLite passed into the xOpen
3198 ** VFS method, then the behavior of this routine is undefined and probably
3199 ** undesirable.
3200 */
3201 SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3202 SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3203 SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3204
3205
3206 /*
3207 ** CAPI3REF: Error Codes And Messages
3208 **
3209 ** ^The sqlite3_errcode() interface returns the numeric [result code] or
3210 ** [extended result code] for the most recent failed sqlite3_* API call
3211 ** associated with a [database connection]. If a prior API call failed
3212 ** but the most recent API call succeeded, the return value from
3213 ** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode()
 
 
3214 ** interface is the same except that it always returns the
3215 ** [extended result code] even when extended result codes are
3216 ** disabled.
3217 **
3218 ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -3239,15 +3250,15 @@
3239 **
3240 ** If an interface fails with SQLITE_MISUSE, that means the interface
3241 ** was invoked incorrectly by the application. In that case, the
3242 ** error code and message may or may not be set.
3243 */
3244 SQLITE_API int sqlite3_errcode(sqlite3 *db);
3245 SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
3246 SQLITE_API const char *sqlite3_errmsg(sqlite3*);
3247 SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
3248 SQLITE_API const char *sqlite3_errstr(int);
3249
3250 /*
3251 ** CAPI3REF: SQL Statement Object
3252 ** KEYWORDS: {prepared statement} {prepared statements}
3253 **
@@ -3310,11 +3321,11 @@
3310 ** created by an untrusted script can be contained using the
3311 ** [max_page_count] [PRAGMA].
3312 **
3313 ** New run-time limit categories may be added in future releases.
3314 */
3315 SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
3316
3317 /*
3318 ** CAPI3REF: Run-Time Limit Categories
3319 ** KEYWORDS: {limit category} {*limit categories}
3320 **
@@ -3460,32 +3471,32 @@
3460 ** or [GLOB] operator or if the parameter is compared to an indexed column
3461 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3462 ** </li>
3463 ** </ol>
3464 */
3465 SQLITE_API int sqlite3_prepare(
3466 sqlite3 *db, /* Database handle */
3467 const char *zSql, /* SQL statement, UTF-8 encoded */
3468 int nByte, /* Maximum length of zSql in bytes. */
3469 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3470 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3471 );
3472 SQLITE_API int sqlite3_prepare_v2(
3473 sqlite3 *db, /* Database handle */
3474 const char *zSql, /* SQL statement, UTF-8 encoded */
3475 int nByte, /* Maximum length of zSql in bytes. */
3476 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3477 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3478 );
3479 SQLITE_API int sqlite3_prepare16(
3480 sqlite3 *db, /* Database handle */
3481 const void *zSql, /* SQL statement, UTF-16 encoded */
3482 int nByte, /* Maximum length of zSql in bytes. */
3483 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3484 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3485 );
3486 SQLITE_API int sqlite3_prepare16_v2(
3487 sqlite3 *db, /* Database handle */
3488 const void *zSql, /* SQL statement, UTF-16 encoded */
3489 int nByte, /* Maximum length of zSql in bytes. */
3490 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3491 const void **pzTail /* OUT: Pointer to unused portion of zSql */
@@ -3496,11 +3507,11 @@
3496 **
3497 ** ^This interface can be used to retrieve a saved copy of the original
3498 ** SQL text used to create a [prepared statement] if that statement was
3499 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3500 */
3501 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
3502
3503 /*
3504 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3505 **
3506 ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
@@ -3527,11 +3538,11 @@
3527 ** database. ^The [ATTACH] and [DETACH] statements also cause
3528 ** sqlite3_stmt_readonly() to return true since, while those statements
3529 ** change the configuration of a database connection, they do not make
3530 ** changes to the content of the database files on disk.
3531 */
3532 SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
3533
3534 /*
3535 ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
3536 **
3537 ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
@@ -3546,11 +3557,11 @@
3546 ** to locate all prepared statements associated with a database
3547 ** connection that are in need of being reset. This can be used,
3548 ** for example, in diagnostic routines to search for prepared
3549 ** statements that are holding a transaction open.
3550 */
3551 SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
3552
3553 /*
3554 ** CAPI3REF: Dynamically Typed Value Object
3555 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
3556 **
@@ -3707,23 +3718,23 @@
3707 ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
3708 **
3709 ** See also: [sqlite3_bind_parameter_count()],
3710 ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
3711 */
3712 SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3713 SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
3714 void(*)(void*));
3715 SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
3716 SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
3717 SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3718 SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
3719 SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3720 SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3721 SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3722 void(*)(void*), unsigned char encoding);
3723 SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3724 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3725
3726 /*
3727 ** CAPI3REF: Number Of SQL Parameters
3728 **
3729 ** ^This routine can be used to find the number of [SQL parameters]
@@ -3739,11 +3750,11 @@
3739 **
3740 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3741 ** [sqlite3_bind_parameter_name()], and
3742 ** [sqlite3_bind_parameter_index()].
3743 */
3744 SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
3745
3746 /*
3747 ** CAPI3REF: Name Of A Host Parameter
3748 **
3749 ** ^The sqlite3_bind_parameter_name(P,N) interface returns
@@ -3766,11 +3777,11 @@
3766 **
3767 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3768 ** [sqlite3_bind_parameter_count()], and
3769 ** [sqlite3_bind_parameter_index()].
3770 */
3771 SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3772
3773 /*
3774 ** CAPI3REF: Index Of A Parameter With A Given Name
3775 **
3776 ** ^Return the index of an SQL parameter given its name. ^The
@@ -3782,20 +3793,20 @@
3782 **
3783 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3784 ** [sqlite3_bind_parameter_count()], and
3785 ** [sqlite3_bind_parameter_index()].
3786 */
3787 SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3788
3789 /*
3790 ** CAPI3REF: Reset All Bindings On A Prepared Statement
3791 **
3792 ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
3793 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
3794 ** ^Use this routine to reset all host parameters to NULL.
3795 */
3796 SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
3797
3798 /*
3799 ** CAPI3REF: Number Of Columns In A Result Set
3800 **
3801 ** ^Return the number of columns in the result set returned by the
@@ -3802,11 +3813,11 @@
3802 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
3803 ** statement that does not return data (for example an [UPDATE]).
3804 **
3805 ** See also: [sqlite3_data_count()]
3806 */
3807 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
3808
3809 /*
3810 ** CAPI3REF: Column Names In A Result Set
3811 **
3812 ** ^These routines return the name assigned to a particular column
@@ -3830,12 +3841,12 @@
3830 ** ^The name of a result column is the value of the "AS" clause for
3831 ** that column, if there is an AS clause. If there is no AS clause
3832 ** then the name of the column is unspecified and may change from
3833 ** one release of SQLite to the next.
3834 */
3835 SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
3836 SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
3837
3838 /*
3839 ** CAPI3REF: Source Of Data In A Query Result
3840 **
3841 ** ^These routines provide a means to determine the database, table, and
@@ -3878,16 +3889,16 @@
3878 ** If two or more threads call one or more
3879 ** [sqlite3_column_database_name | column metadata interfaces]
3880 ** for the same [prepared statement] and result column
3881 ** at the same time then the results are undefined.
3882 */
3883 SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
3884 SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
3885 SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
3886 SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
3887 SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
3888 SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
3889
3890 /*
3891 ** CAPI3REF: Declared Datatype Of A Query Result
3892 **
3893 ** ^(The first parameter is a [prepared statement].
@@ -3914,12 +3925,12 @@
3914 ** data stored in that column is of the declared type. SQLite is
3915 ** strongly typed, but the typing is dynamic not static. ^Type
3916 ** is associated with individual values, not with the containers
3917 ** used to hold those values.
3918 */
3919 SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
3920 SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
3921
3922 /*
3923 ** CAPI3REF: Evaluate An SQL Statement
3924 **
3925 ** After a [prepared statement] has been prepared using either
@@ -3994,11 +4005,11 @@
3994 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
3995 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
3996 ** then the more specific [error codes] are returned directly
3997 ** by sqlite3_step(). The use of the "v2" interface is recommended.
3998 */
3999 SQLITE_API int sqlite3_step(sqlite3_stmt*);
4000
4001 /*
4002 ** CAPI3REF: Number of columns in a result set
4003 **
4004 ** ^The sqlite3_data_count(P) interface returns the number of columns in the
@@ -4014,11 +4025,11 @@
4014 ** where it always returns zero since each step of that multi-step
4015 ** pragma returns 0 columns of data.
4016 **
4017 ** See also: [sqlite3_column_count()]
4018 */
4019 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
4020
4021 /*
4022 ** CAPI3REF: Fundamental Datatypes
4023 ** KEYWORDS: SQLITE_TEXT
4024 **
@@ -4210,20 +4221,20 @@
4210 ** of these routines, a default value is returned. The default value
4211 ** is either the integer 0, the floating point number 0.0, or a NULL
4212 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
4213 ** [SQLITE_NOMEM].)^
4214 */
4215 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
4216 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4217 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4218 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
4219 SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
4220 SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
4221 SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
4222 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
4223 SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
4224 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
4225
4226 /*
4227 ** CAPI3REF: Destroy A Prepared Statement Object
4228 **
4229 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
@@ -4246,11 +4257,11 @@
4246 ** resource leaks. It is a grievous error for the application to try to use
4247 ** a prepared statement after it has been finalized. Any use of a prepared
4248 ** statement after it has been finalized can result in undefined and
4249 ** undesirable behavior such as segfaults and heap corruption.
4250 */
4251 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
4252
4253 /*
4254 ** CAPI3REF: Reset A Prepared Statement Object
4255 **
4256 ** The sqlite3_reset() function is called to reset a [prepared statement]
@@ -4272,11 +4283,11 @@
4272 ** [sqlite3_reset(S)] returns an appropriate [error code].
4273 **
4274 ** ^The [sqlite3_reset(S)] interface does not change the values
4275 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
4276 */
4277 SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
4278
4279 /*
4280 ** CAPI3REF: Create Or Redefine SQL Functions
4281 ** KEYWORDS: {function creation routines}
4282 ** KEYWORDS: {application-defined SQL function}
@@ -4371,31 +4382,31 @@
4371 ** ^An application-defined function is permitted to call other
4372 ** SQLite interfaces. However, such calls must not
4373 ** close the database connection nor finalize or reset the prepared
4374 ** statement in which the function is running.
4375 */
4376 SQLITE_API int sqlite3_create_function(
4377 sqlite3 *db,
4378 const char *zFunctionName,
4379 int nArg,
4380 int eTextRep,
4381 void *pApp,
4382 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4383 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4384 void (*xFinal)(sqlite3_context*)
4385 );
4386 SQLITE_API int sqlite3_create_function16(
4387 sqlite3 *db,
4388 const void *zFunctionName,
4389 int nArg,
4390 int eTextRep,
4391 void *pApp,
4392 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4393 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4394 void (*xFinal)(sqlite3_context*)
4395 );
4396 SQLITE_API int sqlite3_create_function_v2(
4397 sqlite3 *db,
4398 const char *zFunctionName,
4399 int nArg,
4400 int eTextRep,
4401 void *pApp,
@@ -4437,16 +4448,16 @@
4437 ** to be supported. However, new applications should avoid
4438 ** the use of these functions. To encourage programmers to avoid
4439 ** these functions, we will not explain what they do.
4440 */
4441 #ifndef SQLITE_OMIT_DEPRECATED
4442 SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
4443 SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
4444 SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4445 SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
4446 SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
4447 SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4448 void*,sqlite3_int64);
4449 #endif
4450
4451 /*
4452 ** CAPI3REF: Obtaining SQL Function Parameter Values
@@ -4491,22 +4502,22 @@
4491 ** or [sqlite3_value_text16()].
4492 **
4493 ** These routines must be called from the same thread as
4494 ** the SQL function that supplied the [sqlite3_value*] parameters.
4495 */
4496 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4497 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
4498 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
4499 SQLITE_API double sqlite3_value_double(sqlite3_value*);
4500 SQLITE_API int sqlite3_value_int(sqlite3_value*);
4501 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4502 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
4503 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
4504 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
4505 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
4506 SQLITE_API int sqlite3_value_type(sqlite3_value*);
4507 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
4508
4509 /*
4510 ** CAPI3REF: Obtain Aggregate Function Context
4511 **
4512 ** Implementations of aggregate SQL functions use this
@@ -4546,11 +4557,11 @@
4546 ** function.
4547 **
4548 ** This routine must be called from the same thread in which
4549 ** the aggregate SQL function is running.
4550 */
4551 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
4552
4553 /*
4554 ** CAPI3REF: User Data For Functions
4555 **
4556 ** ^The sqlite3_user_data() interface returns a copy of
@@ -4560,11 +4571,11 @@
4560 ** registered the application defined function.
4561 **
4562 ** This routine must be called from the same thread in which
4563 ** the application-defined function is running.
4564 */
4565 SQLITE_API void *sqlite3_user_data(sqlite3_context*);
4566
4567 /*
4568 ** CAPI3REF: Database Connection For Functions
4569 **
4570 ** ^The sqlite3_context_db_handle() interface returns a copy of
@@ -4571,11 +4582,11 @@
4571 ** the pointer to the [database connection] (the 1st parameter)
4572 ** of the [sqlite3_create_function()]
4573 ** and [sqlite3_create_function16()] routines that originally
4574 ** registered the application defined function.
4575 */
4576 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4577
4578 /*
4579 ** CAPI3REF: Function Auxiliary Data
4580 **
4581 ** These functions may be used by (non-aggregate) SQL functions to
@@ -4623,12 +4634,12 @@
4623 ** values and [parameters] and expressions composed from the same.)^
4624 **
4625 ** These routines must be called from the same thread in which
4626 ** the SQL function is running.
4627 */
4628 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
4629 SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
4630
4631
4632 /*
4633 ** CAPI3REF: Constants Defining Special Destructor Behavior
4634 **
@@ -4759,30 +4770,30 @@
4759 **
4760 ** If these routines are called from within the different thread
4761 ** than the one containing the application-defined function that received
4762 ** the [sqlite3_context] pointer, the results are undefined.
4763 */
4764 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4765 SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
4766 sqlite3_uint64,void(*)(void*));
4767 SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
4768 SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
4769 SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
4770 SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
4771 SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
4772 SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
4773 SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
4774 SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4775 SQLITE_API void sqlite3_result_null(sqlite3_context*);
4776 SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4777 SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
4778 void(*)(void*), unsigned char encoding);
4779 SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4780 SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4781 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4782 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4783 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
4784
4785 /*
4786 ** CAPI3REF: Define New Collating Sequences
4787 **
4788 ** ^These functions add, remove, or modify a [collation] associated
@@ -4859,26 +4870,26 @@
4859 ** is unfortunate but cannot be changed without breaking backwards
4860 ** compatibility.
4861 **
4862 ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
4863 */
4864 SQLITE_API int sqlite3_create_collation(
4865 sqlite3*,
4866 const char *zName,
4867 int eTextRep,
4868 void *pArg,
4869 int(*xCompare)(void*,int,const void*,int,const void*)
4870 );
4871 SQLITE_API int sqlite3_create_collation_v2(
4872 sqlite3*,
4873 const char *zName,
4874 int eTextRep,
4875 void *pArg,
4876 int(*xCompare)(void*,int,const void*,int,const void*),
4877 void(*xDestroy)(void*)
4878 );
4879 SQLITE_API int sqlite3_create_collation16(
4880 sqlite3*,
4881 const void *zName,
4882 int eTextRep,
4883 void *pArg,
4884 int(*xCompare)(void*,int,const void*,int,const void*)
@@ -4908,16 +4919,16 @@
4908 **
4909 ** The callback function should register the desired collation using
4910 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
4911 ** [sqlite3_create_collation_v2()].
4912 */
4913 SQLITE_API int sqlite3_collation_needed(
4914 sqlite3*,
4915 void*,
4916 void(*)(void*,sqlite3*,int eTextRep,const char*)
4917 );
4918 SQLITE_API int sqlite3_collation_needed16(
4919 sqlite3*,
4920 void*,
4921 void(*)(void*,sqlite3*,int eTextRep,const void*)
4922 );
4923
@@ -4927,15 +4938,15 @@
4927 ** called right after sqlite3_open().
4928 **
4929 ** The code to implement this API is not available in the public release
4930 ** of SQLite.
4931 */
4932 SQLITE_API int sqlite3_key(
4933 sqlite3 *db, /* Database to be rekeyed */
4934 const void *pKey, int nKey /* The key */
4935 );
4936 SQLITE_API int sqlite3_key_v2(
4937 sqlite3 *db, /* Database to be rekeyed */
4938 const char *zDbName, /* Name of the database */
4939 const void *pKey, int nKey /* The key */
4940 );
4941
@@ -4945,35 +4956,35 @@
4945 ** database is decrypted.
4946 **
4947 ** The code to implement this API is not available in the public release
4948 ** of SQLite.
4949 */
4950 SQLITE_API int sqlite3_rekey(
4951 sqlite3 *db, /* Database to be rekeyed */
4952 const void *pKey, int nKey /* The new key */
4953 );
4954 SQLITE_API int sqlite3_rekey_v2(
4955 sqlite3 *db, /* Database to be rekeyed */
4956 const char *zDbName, /* Name of the database */
4957 const void *pKey, int nKey /* The new key */
4958 );
4959
4960 /*
4961 ** Specify the activation key for a SEE database. Unless
4962 ** activated, none of the SEE routines will work.
4963 */
4964 SQLITE_API void sqlite3_activate_see(
4965 const char *zPassPhrase /* Activation phrase */
4966 );
4967 #endif
4968
4969 #ifdef SQLITE_ENABLE_CEROD
4970 /*
4971 ** Specify the activation key for a CEROD database. Unless
4972 ** activated, none of the CEROD routines will work.
4973 */
4974 SQLITE_API void sqlite3_activate_cerod(
4975 const char *zPassPhrase /* Activation phrase */
4976 );
4977 #endif
4978
4979 /*
@@ -4991,11 +5002,11 @@
4991 ** method of the default [sqlite3_vfs] object. If the xSleep() method
4992 ** of the default VFS is not implemented correctly, or not implemented at
4993 ** all, then the behavior of sqlite3_sleep() may deviate from the description
4994 ** in the previous paragraphs.
4995 */
4996 SQLITE_API int sqlite3_sleep(int);
4997
4998 /*
4999 ** CAPI3REF: Name Of The Folder Holding Temporary Files
5000 **
5001 ** ^(If this global variable is made to point to a string which is
@@ -5109,11 +5120,11 @@
5109 **
5110 ** If another thread changes the autocommit status of the database
5111 ** connection while this routine is running, then the return value
5112 ** is undefined.
5113 */
5114 SQLITE_API int sqlite3_get_autocommit(sqlite3*);
5115
5116 /*
5117 ** CAPI3REF: Find The Database Handle Of A Prepared Statement
5118 **
5119 ** ^The sqlite3_db_handle interface returns the [database connection] handle
@@ -5121,11 +5132,11 @@
5121 ** returned by sqlite3_db_handle is the same [database connection]
5122 ** that was the first argument
5123 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
5124 ** create the statement in the first place.
5125 */
5126 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
5127
5128 /*
5129 ** CAPI3REF: Return The Filename For A Database Connection
5130 **
5131 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
@@ -5137,20 +5148,20 @@
5137 ** ^The filename returned by this function is the output of the
5138 ** xFullPathname method of the [VFS]. ^In other words, the filename
5139 ** will be an absolute pathname, even if the filename used
5140 ** to open the database originally was a URI or relative pathname.
5141 */
5142 SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
5143
5144 /*
5145 ** CAPI3REF: Determine if a database is read-only
5146 **
5147 ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
5148 ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
5149 ** the name of a database on connection D.
5150 */
5151 SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
5152
5153 /*
5154 ** CAPI3REF: Find the next prepared statement
5155 **
5156 ** ^This interface returns a pointer to the next [prepared statement] after
@@ -5161,11 +5172,11 @@
5161 **
5162 ** The [database connection] pointer D in a call to
5163 ** [sqlite3_next_stmt(D,S)] must refer to an open database
5164 ** connection and in particular must not be a NULL pointer.
5165 */
5166 SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
5167
5168 /*
5169 ** CAPI3REF: Commit And Rollback Notification Callbacks
5170 **
5171 ** ^The sqlite3_commit_hook() interface registers a callback
@@ -5209,12 +5220,12 @@
5209 ** ^The rollback callback is not invoked if a transaction is
5210 ** automatically rolled back because the database connection is closed.
5211 **
5212 ** See also the [sqlite3_update_hook()] interface.
5213 */
5214 SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5215 SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
5216
5217 /*
5218 ** CAPI3REF: Data Change Notification Callbacks
5219 **
5220 ** ^The sqlite3_update_hook() interface registers a callback function
@@ -5260,11 +5271,11 @@
5260 ** the first call on D.
5261 **
5262 ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
5263 ** interfaces.
5264 */
5265 SQLITE_API void *sqlite3_update_hook(
5266 sqlite3*,
5267 void(*)(void *,int ,char const *,char const *,sqlite3_int64),
5268 void*
5269 );
5270
@@ -5300,11 +5311,11 @@
5300 ** This interface is threadsafe on processors where writing a
5301 ** 32-bit integer is atomic.
5302 **
5303 ** See Also: [SQLite Shared-Cache Mode]
5304 */
5305 SQLITE_API int sqlite3_enable_shared_cache(int);
5306
5307 /*
5308 ** CAPI3REF: Attempt To Free Heap Memory
5309 **
5310 ** ^The sqlite3_release_memory() interface attempts to free N bytes
@@ -5316,11 +5327,11 @@
5316 ** ^The sqlite3_release_memory() routine is a no-op returning zero
5317 ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5318 **
5319 ** See also: [sqlite3_db_release_memory()]
5320 */
5321 SQLITE_API int sqlite3_release_memory(int);
5322
5323 /*
5324 ** CAPI3REF: Free Memory Used By A Database Connection
5325 **
5326 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
@@ -5329,11 +5340,11 @@
5329 ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
5330 ** omitted.
5331 **
5332 ** See also: [sqlite3_release_memory()]
5333 */
5334 SQLITE_API int sqlite3_db_release_memory(sqlite3*);
5335
5336 /*
5337 ** CAPI3REF: Impose A Limit On Heap Size
5338 **
5339 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
@@ -5381,11 +5392,11 @@
5381 ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5382 **
5383 ** The circumstances under which SQLite will enforce the soft heap limit may
5384 ** changes in future releases of SQLite.
5385 */
5386 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
5387
5388 /*
5389 ** CAPI3REF: Deprecated Soft Heap Limit Interface
5390 ** DEPRECATED
5391 **
@@ -5392,11 +5403,11 @@
5392 ** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
5393 ** interface. This routine is provided for historical compatibility
5394 ** only. All new applications should use the
5395 ** [sqlite3_soft_heap_limit64()] interface rather than this one.
5396 */
5397 SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
5398
5399
5400 /*
5401 ** CAPI3REF: Extract Metadata About A Column Of A Table
5402 **
@@ -5461,11 +5472,11 @@
5461 **
5462 ** ^This function causes all database schemas to be read from disk and
5463 ** parsed, if that has not already been done, and returns an error if
5464 ** any errors are encountered while loading the schema.
5465 */
5466 SQLITE_API int sqlite3_table_column_metadata(
5467 sqlite3 *db, /* Connection handle */
5468 const char *zDbName, /* Database name or NULL */
5469 const char *zTableName, /* Table name */
5470 const char *zColumnName, /* Column name */
5471 char const **pzDataType, /* OUTPUT: Declared data type */
@@ -5507,11 +5518,11 @@
5507 ** [sqlite3_enable_load_extension()] prior to calling this API,
5508 ** otherwise an error will be returned.
5509 **
5510 ** See also the [load_extension() SQL function].
5511 */
5512 SQLITE_API int sqlite3_load_extension(
5513 sqlite3 *db, /* Load the extension into this database connection */
5514 const char *zFile, /* Name of the shared library containing extension */
5515 const char *zProc, /* Entry point. Derived from zFile if 0 */
5516 char **pzErrMsg /* Put error message here if not 0 */
5517 );
@@ -5527,11 +5538,11 @@
5527 ** ^Extension loading is off by default.
5528 ** ^Call the sqlite3_enable_load_extension() routine with onoff==1
5529 ** to turn extension loading on and call it with onoff==0 to turn
5530 ** it back off again.
5531 */
5532 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
5533
5534 /*
5535 ** CAPI3REF: Automatically Load Statically Linked Extensions
5536 **
5537 ** ^This interface causes the xEntryPoint() function to be invoked for
@@ -5565,11 +5576,11 @@
5565 ** will be called more than once for each database connection that is opened.
5566 **
5567 ** See also: [sqlite3_reset_auto_extension()]
5568 ** and [sqlite3_cancel_auto_extension()]
5569 */
5570 SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
5571
5572 /*
5573 ** CAPI3REF: Cancel Automatic Extension Loading
5574 **
5575 ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5577,19 +5588,19 @@
5577 ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
5578 ** routine returns 1 if initialization routine X was successfully
5579 ** unregistered and it returns 0 if X was not on the list of initialization
5580 ** routines.
5581 */
5582 SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5583
5584 /*
5585 ** CAPI3REF: Reset Automatic Extension Loading
5586 **
5587 ** ^This interface disables all automatic extensions previously
5588 ** registered using [sqlite3_auto_extension()].
5589 */
5590 SQLITE_API void sqlite3_reset_auto_extension(void);
5591
5592 /*
5593 ** The interface to the virtual-table mechanism is currently considered
5594 ** to be experimental. The interface might change in incompatible ways.
5595 ** If this is a problem for you, do not use the interface at this time.
@@ -5788,17 +5799,17 @@
5788 ** be invoked if the call to sqlite3_create_module_v2() fails.
5789 ** ^The sqlite3_create_module()
5790 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
5791 ** destructor.
5792 */
5793 SQLITE_API int sqlite3_create_module(
5794 sqlite3 *db, /* SQLite connection to register module with */
5795 const char *zName, /* Name of the module */
5796 const sqlite3_module *p, /* Methods for the module */
5797 void *pClientData /* Client data for xCreate/xConnect */
5798 );
5799 SQLITE_API int sqlite3_create_module_v2(
5800 sqlite3 *db, /* SQLite connection to register module with */
5801 const char *zName, /* Name of the module */
5802 const sqlite3_module *p, /* Methods for the module */
5803 void *pClientData, /* Client data for xCreate/xConnect */
5804 void(*xDestroy)(void*) /* Module destructor function */
@@ -5822,11 +5833,11 @@
5822 ** is delivered up to the client application, the string will be automatically
5823 ** freed by sqlite3_free() and the zErrMsg field will be zeroed.
5824 */
5825 struct sqlite3_vtab {
5826 const sqlite3_module *pModule; /* The module for this virtual table */
5827 int nRef; /* NO LONGER USED */
5828 char *zErrMsg; /* Error message from sqlite3_mprintf() */
5829 /* Virtual table implementations will typically add additional fields */
5830 };
5831
5832 /*
@@ -5857,11 +5868,11 @@
5857 ** ^The [xCreate] and [xConnect] methods of a
5858 ** [virtual table module] call this interface
5859 ** to declare the format (the names and datatypes of the columns) of
5860 ** the virtual tables they implement.
5861 */
5862 SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
5863
5864 /*
5865 ** CAPI3REF: Overload A Function For A Virtual Table
5866 **
5867 ** ^(Virtual tables can provide alternative implementations of functions
@@ -5875,11 +5886,11 @@
5875 ** of the new function always causes an exception to be thrown. So
5876 ** the new function is not good for anything by itself. Its only
5877 ** purpose is to be a placeholder function that can be overloaded
5878 ** by a [virtual table].
5879 */
5880 SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
5881
5882 /*
5883 ** The interface to the virtual-table mechanism defined above (back up
5884 ** to a comment remarkably similar to this one) is currently considered
5885 ** to be experimental. The interface might change in incompatible ways.
@@ -5972,11 +5983,11 @@
5972 ** zero-filled blob to read or write using the incremental-blob interface.
5973 **
5974 ** To avoid a resource leak, every open [BLOB handle] should eventually
5975 ** be released by a call to [sqlite3_blob_close()].
5976 */
5977 SQLITE_API int sqlite3_blob_open(
5978 sqlite3*,
5979 const char *zDb,
5980 const char *zTable,
5981 const char *zColumn,
5982 sqlite3_int64 iRow,
@@ -6004,11 +6015,11 @@
6004 ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
6005 ** always returns zero.
6006 **
6007 ** ^This function sets the database handle error code and message.
6008 */
6009 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
6010
6011 /*
6012 ** CAPI3REF: Close A BLOB Handle
6013 **
6014 ** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
@@ -6026,11 +6037,11 @@
6026 ** with a null pointer (such as would be returned by a failed call to
6027 ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
6028 ** is passed a valid open blob handle, the values returned by the
6029 ** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
6030 */
6031 SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
6032
6033 /*
6034 ** CAPI3REF: Return The Size Of An Open BLOB
6035 **
6036 ** ^Returns the size in bytes of the BLOB accessible via the
@@ -6041,11 +6052,11 @@
6041 ** This routine only works on a [BLOB handle] which has been created
6042 ** by a prior successful call to [sqlite3_blob_open()] and which has not
6043 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
6044 ** to this routine results in undefined and probably undesirable behavior.
6045 */
6046 SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
6047
6048 /*
6049 ** CAPI3REF: Read Data From A BLOB Incrementally
6050 **
6051 ** ^(This function is used to read data from an open [BLOB handle] into a
@@ -6069,11 +6080,11 @@
6069 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
6070 ** to this routine results in undefined and probably undesirable behavior.
6071 **
6072 ** See also: [sqlite3_blob_write()].
6073 */
6074 SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
6075
6076 /*
6077 ** CAPI3REF: Write Data Into A BLOB Incrementally
6078 **
6079 ** ^(This function is used to write data into an open [BLOB handle] from a
@@ -6110,11 +6121,11 @@
6110 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
6111 ** to this routine results in undefined and probably undesirable behavior.
6112 **
6113 ** See also: [sqlite3_blob_read()].
6114 */
6115 SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
6116
6117 /*
6118 ** CAPI3REF: Virtual File System Objects
6119 **
6120 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
@@ -6141,13 +6152,13 @@
6141 **
6142 ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
6143 ** ^(If the default VFS is unregistered, another VFS is chosen as
6144 ** the default. The choice for the new VFS is arbitrary.)^
6145 */
6146 SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
6147 SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
6148 SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
6149
6150 /*
6151 ** CAPI3REF: Mutexes
6152 **
6153 ** The SQLite core uses these routines for thread
@@ -6256,15 +6267,15 @@
6256 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
6257 ** behave as no-ops.
6258 **
6259 ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
6260 */
6261 SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
6262 SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
6263 SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
6264 SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
6265 SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
6266
6267 /*
6268 ** CAPI3REF: Mutex Methods Object
6269 **
6270 ** An instance of this structure defines the low-level routines
@@ -6370,12 +6381,12 @@
6370 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
6371 ** the appropriate thing to do. The sqlite3_mutex_notheld()
6372 ** interface should also return 1 when given a NULL pointer.
6373 */
6374 #ifndef NDEBUG
6375 SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
6376 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
6377 #endif
6378
6379 /*
6380 ** CAPI3REF: Mutex Types
6381 **
@@ -6407,11 +6418,11 @@
6407 ** serializes access to the [database connection] given in the argument
6408 ** when the [threading mode] is Serialized.
6409 ** ^If the [threading mode] is Single-thread or Multi-thread then this
6410 ** routine returns a NULL pointer.
6411 */
6412 SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
6413
6414 /*
6415 ** CAPI3REF: Low-Level Control Of Database Files
6416 **
6417 ** ^The [sqlite3_file_control()] interface makes a direct call to the
@@ -6441,11 +6452,11 @@
6441 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
6442 ** xFileControl method.
6443 **
6444 ** See also: [SQLITE_FCNTL_LOCKSTATE]
6445 */
6446 SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
6447
6448 /*
6449 ** CAPI3REF: Testing Interface
6450 **
6451 ** ^The sqlite3_test_control() interface is used to read out internal
@@ -6460,11 +6471,11 @@
6460 ** The details of the operation codes, their meanings, the parameters
6461 ** they take, and what they do are all subject to change without notice.
6462 ** Unlike most of the SQLite API, this function is not guaranteed to
6463 ** operate consistently from one release to the next.
6464 */
6465 SQLITE_API int sqlite3_test_control(int op, ...);
6466
6467 /*
6468 ** CAPI3REF: Testing Interface Operation Codes
6469 **
6470 ** These constants are the valid operation code parameters used
@@ -6500,11 +6511,11 @@
6500 #define SQLITE_TESTCTRL_LAST 25
6501
6502 /*
6503 ** CAPI3REF: SQLite Runtime Status
6504 **
6505 ** ^This interface is used to retrieve runtime status information
6506 ** about the performance of SQLite, and optionally to reset various
6507 ** highwater marks. ^The first argument is an integer code for
6508 ** the specific parameter to measure. ^(Recognized integer codes
6509 ** are of the form [status parameters | SQLITE_STATUS_...].)^
6510 ** ^The current value of the parameter is returned into *pCurrent.
@@ -6514,23 +6525,26 @@
6514 ** value. For those parameters
6515 ** nothing is written into *pHighwater and the resetFlag is ignored.)^
6516 ** ^(Other parameters record only the highwater mark and not the current
6517 ** value. For these latter parameters nothing is written into *pCurrent.)^
6518 **
6519 ** ^The sqlite3_status() routine returns SQLITE_OK on success and a
6520 ** non-zero [error code] on failure.
6521 **
6522 ** This routine is threadsafe but is not atomic. This routine can be
6523 ** called while other threads are running the same or different SQLite
6524 ** interfaces. However the values returned in *pCurrent and
6525 ** *pHighwater reflect the status of SQLite at different points in time
6526 ** and it is possible that another thread might change the parameter
6527 ** in between the times when *pCurrent and *pHighwater are written.
6528 **
6529 ** See also: [sqlite3_db_status()]
6530 */
6531 SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
 
 
 
 
 
 
6532
6533
6534 /*
6535 ** CAPI3REF: Status Parameters
6536 ** KEYWORDS: {status parameters}
@@ -6644,11 +6658,11 @@
6644 ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
6645 ** non-zero [error code] on failure.
6646 **
6647 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
6648 */
6649 SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
6650
6651 /*
6652 ** CAPI3REF: Status Parameters for database connections
6653 ** KEYWORDS: {SQLITE_DBSTATUS options}
6654 **
@@ -6773,11 +6787,11 @@
6773 ** ^If the resetFlg is true, then the counter is reset to zero after this
6774 ** interface call returns.
6775 **
6776 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
6777 */
6778 SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
6779
6780 /*
6781 ** CAPI3REF: Status Parameters for prepared statements
6782 ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}
6783 **
@@ -7242,20 +7256,20 @@
7242 ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
7243 ** APIs are not strictly speaking threadsafe. If they are invoked at the
7244 ** same time as another thread is invoking sqlite3_backup_step() it is
7245 ** possible that they return invalid values.
7246 */
7247 SQLITE_API sqlite3_backup *sqlite3_backup_init(
7248 sqlite3 *pDest, /* Destination database handle */
7249 const char *zDestName, /* Destination database name */
7250 sqlite3 *pSource, /* Source database handle */
7251 const char *zSourceName /* Source database name */
7252 );
7253 SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
7254 SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
7255 SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
7256 SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
7257
7258 /*
7259 ** CAPI3REF: Unlock Notification
7260 **
7261 ** ^When running in shared-cache mode, a database operation may fail with
@@ -7367,11 +7381,11 @@
7367 ** by an sqlite3_step() call. ^(If there is a blocking connection, then the
7368 ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
7369 ** the special "DROP TABLE/INDEX" case, the extended error code is just
7370 ** SQLITE_LOCKED.)^
7371 */
7372 SQLITE_API int sqlite3_unlock_notify(
7373 sqlite3 *pBlocked, /* Waiting connection */
7374 void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
7375 void *pNotifyArg /* Argument to pass to xNotify */
7376 );
7377
@@ -7382,12 +7396,12 @@
7382 ** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
7383 ** and extensions to compare the contents of two buffers containing UTF-8
7384 ** strings in a case-independent fashion, using the same definition of "case
7385 ** independence" that SQLite uses internally when comparing identifiers.
7386 */
7387 SQLITE_API int sqlite3_stricmp(const char *, const char *);
7388 SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
7389
7390 /*
7391 ** CAPI3REF: String Globbing
7392 *
7393 ** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
@@ -7398,11 +7412,11 @@
7398 ** sensitive.
7399 **
7400 ** Note that this routine returns zero on a match and non-zero if the strings
7401 ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
7402 */
7403 SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
7404
7405 /*
7406 ** CAPI3REF: Error Logging Interface
7407 **
7408 ** ^The [sqlite3_log()] interface writes a message into the [error log]
@@ -7421,11 +7435,11 @@
7421 ** will not use dynamically allocated memory. The log message is stored in
7422 ** a fixed-length buffer on the stack. If the log message is longer than
7423 ** a few hundred characters, it will be truncated to the length of the
7424 ** buffer.
7425 */
7426 SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
7427
7428 /*
7429 ** CAPI3REF: Write-Ahead Log Commit Hook
7430 **
7431 ** ^The [sqlite3_wal_hook()] function is used to register a callback that
@@ -7456,11 +7470,11 @@
7456 ** previously registered write-ahead log callback. ^Note that the
7457 ** [sqlite3_wal_autocheckpoint()] interface and the
7458 ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
7459 ** those overwrite any prior [sqlite3_wal_hook()] settings.
7460 */
7461 SQLITE_API void *sqlite3_wal_hook(
7462 sqlite3*,
7463 int(*)(void *,sqlite3*,const char*,int),
7464 void*
7465 );
7466
@@ -7490,11 +7504,11 @@
7490 ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
7491 ** pages. The use of this interface
7492 ** is only necessary if the default setting is found to be suboptimal
7493 ** for a particular application.
7494 */
7495 SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
7496
7497 /*
7498 ** CAPI3REF: Checkpoint a database
7499 **
7500 ** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
@@ -7511,11 +7525,11 @@
7511 ** interface was added. This interface is retained for backwards
7512 ** compatibility and as a convenience for applications that need to manually
7513 ** start a callback but which do not need the full power (and corresponding
7514 ** complication) of [sqlite3_wal_checkpoint_v2()].
7515 */
7516 SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
7517
7518 /*
7519 ** CAPI3REF: Checkpoint a database
7520 **
7521 ** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
@@ -7604,11 +7618,11 @@
7604 ** [sqlite3_errcode()] and [sqlite3_errmsg()].
7605 **
7606 ** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
7607 ** from SQL.
7608 */
7609 SQLITE_API int sqlite3_wal_checkpoint_v2(
7610 sqlite3 *db, /* Database handle */
7611 const char *zDb, /* Name of attached database (or NULL) */
7612 int eMode, /* SQLITE_CHECKPOINT_* value */
7613 int *pnLog, /* OUT: Size of WAL log in frames */
7614 int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -7640,11 +7654,11 @@
7640 **
7641 ** At present, there is only one option that may be configured using
7642 ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
7643 ** may be added in the future.
7644 */
7645 SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
7646
7647 /*
7648 ** CAPI3REF: Virtual Table Configuration Options
7649 **
7650 ** These macros define the various options to the
@@ -7693,11 +7707,11 @@
7693 ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],
7694 ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode
7695 ** of the SQL statement that triggered the call to the [xUpdate] method of the
7696 ** [virtual table].
7697 */
7698 SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
7699
7700 /*
7701 ** CAPI3REF: Conflict resolution modes
7702 ** KEYWORDS: {conflict resolution mode}
7703 **
@@ -7797,11 +7811,11 @@
7797 ** as if the loop did not exist - it returns non-zero and leave the variable
7798 ** that pOut points to unchanged.
7799 **
7800 ** See also: [sqlite3_stmt_scanstatus_reset()]
7801 */
7802 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_scanstatus(
7803 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
7804 int idx, /* Index of loop to report on */
7805 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
7806 void *pOut /* Result written here */
7807 );
@@ -7812,11 +7826,11 @@
7812 ** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
7813 **
7814 ** This API is only available if the library is built with pre-processor
7815 ** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
7816 */
7817 SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
7818
7819
7820 /*
7821 ** Undo the hack that converts floating point types to integer for
7822 ** builds on processors without floating point support.
@@ -7867,11 +7881,11 @@
7867 ** Register a geometry callback named zGeom that can be used as part of an
7868 ** R-Tree geometry query as follows:
7869 **
7870 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
7871 */
7872 SQLITE_API int sqlite3_rtree_geometry_callback(
7873 sqlite3 *db,
7874 const char *zGeom,
7875 int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
7876 void *pContext
7877 );
@@ -7893,11 +7907,11 @@
7893 ** Register a 2nd-generation geometry callback named zScore that can be
7894 ** used as part of an R-Tree geometry query as follows:
7895 **
7896 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
7897 */
7898 SQLITE_API int sqlite3_rtree_query_callback(
7899 sqlite3 *db,
7900 const char *zQueryFunc,
7901 int (*xQueryFunc)(sqlite3_rtree_query_info*),
7902 void *pContext,
7903 void (*xDestructor)(void*)
@@ -8911,10 +8925,24 @@
8911 **
8912 ** 0.5 -> -10 0.1 -> -33 0.0625 -> -40
8913 */
8914 typedef INT16_TYPE LogEst;
8915
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8916 /*
8917 ** Macros to determine whether the machine is big or little endian,
8918 ** and whether or not that determination is run-time or compile-time.
8919 **
8920 ** For best performance, an attempt is made to guess at the byte-order
@@ -9123,12 +9151,12 @@
9123 */
9124 #ifdef SQLITE_OMIT_WSD
9125 #define SQLITE_WSD const
9126 #define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
9127 #define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
9128 SQLITE_API int sqlite3_wsd_init(int N, int J);
9129 SQLITE_API void *sqlite3_wsd_find(void *K, int L);
9130 #else
9131 #define SQLITE_WSD
9132 #define GLOBAL(t,v) v
9133 #define sqlite3GlobalConfig sqlite3Config
9134 #endif
@@ -9361,12 +9389,22 @@
9361 #define BTREE_DATA_VERSION 15 /* A virtual meta-value */
9362
9363 /*
9364 ** Values that may be OR'd together to form the second argument of an
9365 ** sqlite3BtreeCursorHints() call.
 
 
 
 
 
 
 
 
 
9366 */
9367 #define BTREE_BULKLOAD 0x00000001
 
9368
9369 SQLITE_PRIVATE int sqlite3BtreeCursor(
9370 Btree*, /* BTree containing table to open */
9371 int iTable, /* Index of root page */
9372 int wrFlag, /* 1 for writing. 0 for read-only */
@@ -9408,10 +9446,13 @@
9408 SQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
9409 SQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *);
9410 SQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *);
9411 SQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);
9412 SQLITE_PRIVATE void sqlite3BtreeCursorHints(BtCursor *, unsigned int mask);
 
 
 
9413 SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *pBt);
9414 SQLITE_PRIVATE int sqlite3HeaderSizeBtree(void);
9415
9416 #ifndef NDEBUG
9417 SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*);
@@ -10908,10 +10949,11 @@
10908 } init;
10909 int nVdbeActive; /* Number of VDBEs currently running */
10910 int nVdbeRead; /* Number of active VDBEs that read or write */
10911 int nVdbeWrite; /* Number of active VDBEs that read and write */
10912 int nVdbeExec; /* Number of nested calls to VdbeExec() */
 
10913 int nExtension; /* Number of loaded extensions */
10914 void **aExtension; /* Array of shared library handles */
10915 void (*xTrace)(void*,const char*); /* Trace function */
10916 void *pTraceArg; /* Argument to the trace function */
10917 void (*xProfile)(void*,const char*,u64); /* Profiling function */
@@ -12502,11 +12544,12 @@
12502 #define OPFLAG_APPEND 0x08 /* This is likely to be an append */
12503 #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
12504 #define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */
12505 #define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */
12506 #define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */
12507 #define OPFLAG_P2ISREG 0x02 /* P2 to OP_Open** is a register number */
 
12508 #define OPFLAG_PERMUTE 0x01 /* OP_Compare: use the permutation */
12509
12510 /*
12511 * Each trigger present in the database schema is stored as an instance of
12512 * struct Trigger.
@@ -12906,14 +12949,19 @@
12906 SQLITE_PRIVATE sqlite3_mutex *sqlite3MutexAlloc(int);
12907 SQLITE_PRIVATE int sqlite3MutexInit(void);
12908 SQLITE_PRIVATE int sqlite3MutexEnd(void);
12909 #endif
12910
12911 SQLITE_PRIVATE int sqlite3StatusValue(int);
12912 SQLITE_PRIVATE void sqlite3StatusAdd(int, int);
 
12913 SQLITE_PRIVATE void sqlite3StatusSet(int, int);
12914
 
 
 
 
12915 #ifndef SQLITE_OMIT_FLOATING_POINT
12916 SQLITE_PRIVATE int sqlite3IsNaN(double);
12917 #else
12918 # define sqlite3IsNaN(X) 0
12919 #endif
@@ -13289,11 +13337,11 @@
13289 SQLITE_PRIVATE const char *sqlite3ErrStr(int);
13290 SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);
13291 SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);
13292 SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);
13293 SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
13294 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*);
13295 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
13296 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
13297 SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
13298 SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *, const char *);
13299 SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);
@@ -13592,11 +13640,11 @@
13592 ** print I/O tracing messages.
13593 */
13594 #ifdef SQLITE_ENABLE_IOTRACE
13595 # define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; }
13596 SQLITE_PRIVATE void sqlite3VdbeIOTraceSql(Vdbe*);
13597 void (*sqlite3IoTrace)(const char*,...);
13598 #else
13599 # define IOTRACE(A)
13600 # define sqlite3VdbeIOTraceSql(X)
13601 #endif
13602
@@ -14305,11 +14353,11 @@
14305 ** was used and false if not.
14306 **
14307 ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
14308 ** is not required for a match.
14309 */
14310 SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
14311 int i, n;
14312
14313 #if SQLITE_ENABLE_API_ARMOR
14314 if( zOptName==0 ){
14315 (void)SQLITE_MISUSE_BKPT;
@@ -14333,11 +14381,11 @@
14333
14334 /*
14335 ** Return the N-th compile-time option string. If N is out of range,
14336 ** return a NULL pointer.
14337 */
14338 SQLITE_API const char *sqlite3_compileoption_get(int N){
14339 if( N>=0 && N<ArraySize(azCompileOpt) ){
14340 return azCompileOpt[N];
14341 }
14342 return 0;
14343 }
@@ -14676,18 +14724,10 @@
14676 ** An instance of the virtual machine. This structure contains the complete
14677 ** state of the virtual machine.
14678 **
14679 ** The "sqlite3_stmt" structure pointer that is returned by sqlite3_prepare()
14680 ** is really a pointer to an instance of this structure.
14681 **
14682 ** The Vdbe.inVtabMethod variable is set to non-zero for the duration of
14683 ** any virtual table method invocations made by the vdbe program. It is
14684 ** set to 2 for xDestroy method calls and 1 for all other methods. This
14685 ** variable is used for two purposes: to allow xDestroy methods to execute
14686 ** "DROP TABLE" statements and to prevent some nasty side effects of
14687 ** malloc failure when SQLite is invoked recursively by a virtual table
14688 ** method function.
14689 */
14690 struct Vdbe {
14691 sqlite3 *db; /* The database connection that owns this statement */
14692 Op *aOp; /* Space to hold the virtual machine's program */
14693 Mem *aMem; /* The memory locations */
@@ -14714,11 +14754,10 @@
14714 #endif
14715 u16 nResColumn; /* Number of columns in one row of the result set */
14716 u8 errorAction; /* Recovery action to do in case of an error */
14717 u8 minWriteFileFormat; /* Minimum file format for writable database files */
14718 bft explain:2; /* True if EXPLAIN present on SQL command */
14719 bft inVtabMethod:2; /* See comments above */
14720 bft changeCntOn:1; /* True to update the change-counter */
14721 bft expired:1; /* True if the VM needs to be recompiled */
14722 bft runOnlyOnce:1; /* Automatically expire on reset */
14723 bft usesStmtJournal:1; /* True if uses a statement journal */
14724 bft readOnly:1; /* True for statements that do not write */
@@ -14874,13 +14913,35 @@
14874 /*
14875 ** Variables in which to record status information.
14876 */
14877 typedef struct sqlite3StatType sqlite3StatType;
14878 static SQLITE_WSD struct sqlite3StatType {
14879 int nowValue[10]; /* Current value */
14880 int mxValue[10]; /* Maximum value */
 
 
 
 
 
14881 } sqlite3Stat = { {0,}, {0,} };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14882
14883
14884 /* The "wsdStat" macro will resolve to the status information
14885 ** state vector. If writable static data is unsupported on the target,
14886 ** we have to locate the state vector at run-time. In the more common
@@ -14894,70 +14955,116 @@
14894 # define wsdStatInit
14895 # define wsdStat sqlite3Stat
14896 #endif
14897
14898 /*
14899 ** Return the current value of a status parameter.
 
14900 */
14901 SQLITE_PRIVATE int sqlite3StatusValue(int op){
14902 wsdStatInit;
14903 assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
 
 
 
14904 return wsdStat.nowValue[op];
14905 }
14906
14907 /*
14908 ** Add N to the value of a status record. It is assumed that the
14909 ** caller holds appropriate locks.
 
 
 
 
 
 
 
14910 */
14911 SQLITE_PRIVATE void sqlite3StatusAdd(int op, int N){
14912 wsdStatInit;
14913 assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
 
 
 
14914 wsdStat.nowValue[op] += N;
14915 if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){
14916 wsdStat.mxValue[op] = wsdStat.nowValue[op];
14917 }
14918 }
 
 
 
 
 
 
 
 
 
14919
14920 /*
14921 ** Set the value of a status to X.
 
14922 */
14923 SQLITE_PRIVATE void sqlite3StatusSet(int op, int X){
14924 wsdStatInit;
14925 assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
 
 
 
14926 wsdStat.nowValue[op] = X;
14927 if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){
14928 wsdStat.mxValue[op] = wsdStat.nowValue[op];
14929 }
14930 }
14931
14932 /*
14933 ** Query status information.
14934 **
14935 ** This implementation assumes that reading or writing an aligned
14936 ** 32-bit integer is an atomic operation. If that assumption is not true,
14937 ** then this routine is not threadsafe.
14938 */
14939 SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
 
 
 
 
 
 
14940 wsdStatInit;
14941 if( op<0 || op>=ArraySize(wsdStat.nowValue) ){
14942 return SQLITE_MISUSE_BKPT;
14943 }
14944 #ifdef SQLITE_ENABLE_API_ARMOR
14945 if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;
14946 #endif
 
 
14947 *pCurrent = wsdStat.nowValue[op];
14948 *pHighwater = wsdStat.mxValue[op];
14949 if( resetFlag ){
14950 wsdStat.mxValue[op] = wsdStat.nowValue[op];
14951 }
 
 
14952 return SQLITE_OK;
 
 
 
 
 
 
 
 
 
 
 
 
 
14953 }
14954
14955 /*
14956 ** Query status information for a single database connection
14957 */
14958 SQLITE_API int sqlite3_db_status(
14959 sqlite3 *db, /* The database connection whose status is desired */
14960 int op, /* Status verb */
14961 int *pCurrent, /* Write current value here */
14962 int *pHighwater, /* Write high-water mark here */
14963 int resetFlag /* Reset high-water mark if true */
@@ -16577,11 +16684,11 @@
16577
16578 /*
16579 ** Locate a VFS by name. If no name is given, simply return the
16580 ** first VFS on the list.
16581 */
16582 SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){
16583 sqlite3_vfs *pVfs = 0;
16584 #if SQLITE_THREADSAFE
16585 sqlite3_mutex *mutex;
16586 #endif
16587 #ifndef SQLITE_OMIT_AUTOINIT
@@ -16623,11 +16730,11 @@
16623 /*
16624 ** Register a VFS with the system. It is harmless to register the same
16625 ** VFS multiple times. The new VFS becomes the default if makeDflt is
16626 ** true.
16627 */
16628 SQLITE_API int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
16629 MUTEX_LOGIC(sqlite3_mutex *mutex;)
16630 #ifndef SQLITE_OMIT_AUTOINIT
16631 int rc = sqlite3_initialize();
16632 if( rc ) return rc;
16633 #endif
@@ -16651,11 +16758,11 @@
16651 }
16652
16653 /*
16654 ** Unregister a VFS so that it is no longer accessible.
16655 */
16656 SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
16657 #if SQLITE_THREADSAFE
16658 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
16659 #endif
16660 sqlite3_mutex_enter(mutex);
16661 vfsUnlink(pVfs);
@@ -18987,11 +19094,11 @@
18987 }
18988
18989 /*
18990 ** Retrieve a pointer to a static mutex or allocate a new dynamic one.
18991 */
18992 SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int id){
18993 #ifndef SQLITE_OMIT_AUTOINIT
18994 if( id<=SQLITE_MUTEX_RECURSIVE && sqlite3_initialize() ) return 0;
18995 if( id>SQLITE_MUTEX_RECURSIVE && sqlite3MutexInit() ) return 0;
18996 #endif
18997 return sqlite3GlobalConfig.mutex.xMutexAlloc(id);
@@ -19006,31 +19113,31 @@
19006 }
19007
19008 /*
19009 ** Free a dynamic mutex.
19010 */
19011 SQLITE_API void sqlite3_mutex_free(sqlite3_mutex *p){
19012 if( p ){
19013 sqlite3GlobalConfig.mutex.xMutexFree(p);
19014 }
19015 }
19016
19017 /*
19018 ** Obtain the mutex p. If some other thread already has the mutex, block
19019 ** until it can be obtained.
19020 */
19021 SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex *p){
19022 if( p ){
19023 sqlite3GlobalConfig.mutex.xMutexEnter(p);
19024 }
19025 }
19026
19027 /*
19028 ** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another
19029 ** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.
19030 */
19031 SQLITE_API int sqlite3_mutex_try(sqlite3_mutex *p){
19032 int rc = SQLITE_OK;
19033 if( p ){
19034 return sqlite3GlobalConfig.mutex.xMutexTry(p);
19035 }
19036 return rc;
@@ -19040,11 +19147,11 @@
19040 ** The sqlite3_mutex_leave() routine exits a mutex that was previously
19041 ** entered by the same thread. The behavior is undefined if the mutex
19042 ** is not currently entered. If a NULL pointer is passed as an argument
19043 ** this function is a no-op.
19044 */
19045 SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex *p){
19046 if( p ){
19047 sqlite3GlobalConfig.mutex.xMutexLeave(p);
19048 }
19049 }
19050
@@ -19051,14 +19158,14 @@
19051 #ifndef NDEBUG
19052 /*
19053 ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are
19054 ** intended for use inside assert() statements.
19055 */
19056 SQLITE_API int sqlite3_mutex_held(sqlite3_mutex *p){
19057 return p==0 || sqlite3GlobalConfig.mutex.xMutexHeld(p);
19058 }
19059 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){
19060 return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
19061 }
19062 #endif
19063
19064 #endif /* !defined(SQLITE_MUTEX_OMIT) */
@@ -20050,12 +20157,12 @@
20050 ** of the sqlite3_initialize() and sqlite3_shutdown() processing, the
20051 ** "interlocked" magic used here is probably not strictly necessary.
20052 */
20053 static LONG SQLITE_WIN32_VOLATILE winMutex_lock = 0;
20054
20055 SQLITE_API int sqlite3_win32_is_nt(void); /* os_win.c */
20056 SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */
20057
20058 static int winMutexInit(void){
20059 /* The first to increment to 1 does actual initialization */
20060 if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){
20061 int i;
@@ -20347,11 +20454,11 @@
20347 /*
20348 ** Attempt to release up to n bytes of non-essential memory currently
20349 ** held by SQLite. An example of non-essential memory is memory used to
20350 ** cache database pages that are not currently in use.
20351 */
20352 SQLITE_API int sqlite3_release_memory(int n){
20353 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
20354 return sqlite3PcacheReleaseMemory(n);
20355 #else
20356 /* IMPLEMENTATION-OF: R-34391-24921 The sqlite3_release_memory() routine
20357 ** is a no-op returning zero if SQLite is not compiled with
@@ -20401,10 +20508,17 @@
20401 */
20402 int nearlyFull;
20403 } mem0 = { 0, 0, 0, 0, 0, 0, 0, 0 };
20404
20405 #define mem0 GLOBAL(struct Mem0Global, mem0)
 
 
 
 
 
 
 
20406
20407 /*
20408 ** This routine runs when the memory allocator sees that the
20409 ** total memory allocation is about to exceed the soft heap
20410 ** limit.
@@ -20424,11 +20538,11 @@
20424 static int sqlite3MemoryAlarm(
20425 void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
20426 void *pArg,
20427 sqlite3_int64 iThreshold
20428 ){
20429 int nUsed;
20430 sqlite3_mutex_enter(mem0.mutex);
20431 mem0.alarmCallback = xCallback;
20432 mem0.alarmArg = pArg;
20433 mem0.alarmThreshold = iThreshold;
20434 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
@@ -20440,11 +20554,11 @@
20440 #ifndef SQLITE_OMIT_DEPRECATED
20441 /*
20442 ** Deprecated external interface. Internal/core SQLite code
20443 ** should call sqlite3MemoryAlarm.
20444 */
20445 SQLITE_API int sqlite3_memory_alarm(
20446 void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
20447 void *pArg,
20448 sqlite3_int64 iThreshold
20449 ){
20450 return sqlite3MemoryAlarm(xCallback, pArg, iThreshold);
@@ -20453,11 +20567,11 @@
20453
20454 /*
20455 ** Set the soft heap-size limit for the library. Passing a zero or
20456 ** negative value indicates no limit.
20457 */
20458 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){
20459 sqlite3_int64 priorLimit;
20460 sqlite3_int64 excess;
20461 #ifndef SQLITE_OMIT_AUTOINIT
20462 int rc = sqlite3_initialize();
20463 if( rc ) return -1;
@@ -20473,19 +20587,20 @@
20473 }
20474 excess = sqlite3_memory_used() - n;
20475 if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff));
20476 return priorLimit;
20477 }
20478 SQLITE_API void sqlite3_soft_heap_limit(int n){
20479 if( n<0 ) n = 0;
20480 sqlite3_soft_heap_limit64(n);
20481 }
20482
20483 /*
20484 ** Initialize the memory allocation subsystem.
20485 */
20486 SQLITE_PRIVATE int sqlite3MallocInit(void){
 
20487 if( sqlite3GlobalConfig.m.xMalloc==0 ){
20488 sqlite3MemSetDefault();
20489 }
20490 memset(&mem0, 0, sizeof(mem0));
20491 if( sqlite3GlobalConfig.bCoreMutex ){
@@ -20517,11 +20632,13 @@
20517 || sqlite3GlobalConfig.nPage<1 ){
20518 sqlite3GlobalConfig.pPage = 0;
20519 sqlite3GlobalConfig.szPage = 0;
20520 sqlite3GlobalConfig.nPage = 0;
20521 }
20522 return sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
 
 
20523 }
20524
20525 /*
20526 ** Return true if the heap is currently under memory pressure - in other
20527 ** words if the amount of heap used is close to the limit set by
@@ -20542,11 +20659,11 @@
20542 }
20543
20544 /*
20545 ** Return the amount of memory currently checked out.
20546 */
20547 SQLITE_API sqlite3_int64 sqlite3_memory_used(void){
20548 int n, mx;
20549 sqlite3_int64 res;
20550 sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, 0);
20551 res = (sqlite3_int64)n; /* Work around bug in Borland C. Ticket #3216 */
20552 return res;
@@ -20555,11 +20672,11 @@
20555 /*
20556 ** Return the maximum amount of memory that has ever been
20557 ** checked out since either the beginning of this process
20558 ** or since the most recent reset.
20559 */
20560 SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag){
20561 int n, mx;
20562 sqlite3_int64 res;
20563 sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, resetFlag);
20564 res = (sqlite3_int64)mx; /* Work around bug in Borland C. Ticket #3216 */
20565 return res;
@@ -20593,11 +20710,11 @@
20593 void *p;
20594 assert( sqlite3_mutex_held(mem0.mutex) );
20595 nFull = sqlite3GlobalConfig.m.xRoundup(n);
20596 sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n);
20597 if( mem0.alarmCallback!=0 ){
20598 int nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
20599 if( nUsed >= mem0.alarmThreshold - nFull ){
20600 mem0.nearlyFull = 1;
20601 sqlite3MallocAlarm(nFull);
20602 }else{
20603 mem0.nearlyFull = 0;
@@ -20610,12 +20727,12 @@
20610 p = sqlite3GlobalConfig.m.xMalloc(nFull);
20611 }
20612 #endif
20613 if( p ){
20614 nFull = sqlite3MallocSize(p);
20615 sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull);
20616 sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, 1);
20617 }
20618 *pp = p;
20619 return nFull;
20620 }
20621
@@ -20646,17 +20763,17 @@
20646 /*
20647 ** This version of the memory allocation is for use by the application.
20648 ** First make sure the memory subsystem is initialized, then do the
20649 ** allocation.
20650 */
20651 SQLITE_API void *sqlite3_malloc(int n){
20652 #ifndef SQLITE_OMIT_AUTOINIT
20653 if( sqlite3_initialize() ) return 0;
20654 #endif
20655 return n<=0 ? 0 : sqlite3Malloc(n);
20656 }
20657 SQLITE_API void *sqlite3_malloc64(sqlite3_uint64 n){
20658 #ifndef SQLITE_OMIT_AUTOINIT
20659 if( sqlite3_initialize() ) return 0;
20660 #endif
20661 return sqlite3Malloc(n);
20662 }
@@ -20688,18 +20805,18 @@
20688 sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);
20689 if( mem0.nScratchFree && sqlite3GlobalConfig.szScratch>=n ){
20690 p = mem0.pScratchFree;
20691 mem0.pScratchFree = mem0.pScratchFree->pNext;
20692 mem0.nScratchFree--;
20693 sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1);
20694 sqlite3_mutex_leave(mem0.mutex);
20695 }else{
20696 sqlite3_mutex_leave(mem0.mutex);
20697 p = sqlite3Malloc(n);
20698 if( sqlite3GlobalConfig.bMemstat && p ){
20699 sqlite3_mutex_enter(mem0.mutex);
20700 sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, sqlite3MallocSize(p));
20701 sqlite3_mutex_leave(mem0.mutex);
20702 }
20703 sqlite3MemdebugSetType(p, MEMTYPE_SCRATCH);
20704 }
20705 assert( sqlite3_mutex_notheld(mem0.mutex) );
@@ -20736,23 +20853,23 @@
20736 sqlite3_mutex_enter(mem0.mutex);
20737 pSlot->pNext = mem0.pScratchFree;
20738 mem0.pScratchFree = pSlot;
20739 mem0.nScratchFree++;
20740 assert( mem0.nScratchFree <= (u32)sqlite3GlobalConfig.nScratch );
20741 sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1);
20742 sqlite3_mutex_leave(mem0.mutex);
20743 }else{
20744 /* Release memory back to the heap */
20745 assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) );
20746 assert( sqlite3MemdebugNoType(p, ~MEMTYPE_SCRATCH) );
20747 sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
20748 if( sqlite3GlobalConfig.bMemstat ){
20749 int iSize = sqlite3MallocSize(p);
20750 sqlite3_mutex_enter(mem0.mutex);
20751 sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize);
20752 sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize);
20753 sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1);
20754 sqlite3GlobalConfig.m.xFree(p);
20755 sqlite3_mutex_leave(mem0.mutex);
20756 }else{
20757 sqlite3GlobalConfig.m.xFree(p);
20758 }
@@ -20779,41 +20896,41 @@
20779 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
20780 return sqlite3GlobalConfig.m.xSize(p);
20781 }
20782 SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){
20783 if( db==0 ){
20784 assert( sqlite3MemdebugNoType(p, ~MEMTYPE_HEAP) );
20785 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
20786 return sqlite3MallocSize(p);
20787 }else{
20788 assert( sqlite3_mutex_held(db->mutex) );
20789 if( isLookaside(db, p) ){
20790 return db->lookaside.sz;
20791 }else{
20792 assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
20793 assert( sqlite3MemdebugNoType(p, ~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
20794 return sqlite3GlobalConfig.m.xSize(p);
20795 }
20796 }
20797 }
20798 SQLITE_API sqlite3_uint64 sqlite3_msize(void *p){
20799 assert( sqlite3MemdebugNoType(p, ~MEMTYPE_HEAP) );
20800 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
20801 return (sqlite3_uint64)sqlite3GlobalConfig.m.xSize(p);
20802 }
20803
20804 /*
20805 ** Free memory previously obtained from sqlite3Malloc().
20806 */
20807 SQLITE_API void sqlite3_free(void *p){
20808 if( p==0 ) return; /* IMP: R-49053-54554 */
20809 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
20810 assert( sqlite3MemdebugNoType(p, ~MEMTYPE_HEAP) );
20811 if( sqlite3GlobalConfig.bMemstat ){
20812 sqlite3_mutex_enter(mem0.mutex);
20813 sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -sqlite3MallocSize(p));
20814 sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1);
20815 sqlite3GlobalConfig.m.xFree(p);
20816 sqlite3_mutex_leave(mem0.mutex);
20817 }else{
20818 sqlite3GlobalConfig.m.xFree(p);
20819 }
@@ -20850,11 +20967,11 @@
20850 db->lookaside.nOut--;
20851 return;
20852 }
20853 }
20854 assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
20855 assert( sqlite3MemdebugNoType(p, ~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
20856 assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) );
20857 sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
20858 sqlite3_free(p);
20859 }
20860
@@ -20863,11 +20980,11 @@
20863 */
20864 SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, u64 nBytes){
20865 int nOld, nNew, nDiff;
20866 void *pNew;
20867 assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) );
20868 assert( sqlite3MemdebugNoType(pOld, ~MEMTYPE_HEAP) );
20869 if( pOld==0 ){
20870 return sqlite3Malloc(nBytes); /* IMP: R-04300-56712 */
20871 }
20872 if( nBytes==0 ){
20873 sqlite3_free(pOld); /* IMP: R-26507-47431 */
@@ -20897,11 +21014,11 @@
20897 sqlite3MallocAlarm((int)nBytes);
20898 pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
20899 }
20900 if( pNew ){
20901 nNew = sqlite3MallocSize(pNew);
20902 sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld);
20903 }
20904 sqlite3_mutex_leave(mem0.mutex);
20905 }else{
20906 pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
20907 }
@@ -20911,18 +21028,18 @@
20911
20912 /*
20913 ** The public interface to sqlite3Realloc. Make sure that the memory
20914 ** subsystem is initialized prior to invoking sqliteRealloc.
20915 */
20916 SQLITE_API void *sqlite3_realloc(void *pOld, int n){
20917 #ifndef SQLITE_OMIT_AUTOINIT
20918 if( sqlite3_initialize() ) return 0;
20919 #endif
20920 if( n<0 ) n = 0; /* IMP: R-26507-47431 */
20921 return sqlite3Realloc(pOld, n);
20922 }
20923 SQLITE_API void *sqlite3_realloc64(void *pOld, sqlite3_uint64 n){
20924 #ifndef SQLITE_OMIT_AUTOINIT
20925 if( sqlite3_initialize() ) return 0;
20926 #endif
20927 return sqlite3Realloc(pOld, n);
20928 }
@@ -21030,11 +21147,11 @@
21030 memcpy(pNew, p, db->lookaside.sz);
21031 sqlite3DbFree(db, p);
21032 }
21033 }else{
21034 assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
21035 assert( sqlite3MemdebugNoType(p, ~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
21036 sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
21037 pNew = sqlite3_realloc64(p, n);
21038 if( !pNew ){
21039 db->mallocFailed = 1;
21040 }
@@ -22084,11 +22201,11 @@
22084
22085 /*
22086 ** Print into memory obtained from sqlite3_malloc(). Omit the internal
22087 ** %-conversion extensions.
22088 */
22089 SQLITE_API char *sqlite3_vmprintf(const char *zFormat, va_list ap){
22090 char *z;
22091 char zBase[SQLITE_PRINT_BUF_SIZE];
22092 StrAccum acc;
22093
22094 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -22109,11 +22226,11 @@
22109
22110 /*
22111 ** Print into memory obtained from sqlite3_malloc()(). Omit the internal
22112 ** %-conversion extensions.
22113 */
22114 SQLITE_API char *sqlite3_mprintf(const char *zFormat, ...){
22115 va_list ap;
22116 char *z;
22117 #ifndef SQLITE_OMIT_AUTOINIT
22118 if( sqlite3_initialize() ) return 0;
22119 #endif
@@ -22134,11 +22251,11 @@
22134 ** this without breaking compatibility, so we just have to live with the
22135 ** mistake.
22136 **
22137 ** sqlite3_vsnprintf() is the varargs version.
22138 */
22139 SQLITE_API char *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){
22140 StrAccum acc;
22141 if( n<=0 ) return zBuf;
22142 #ifdef SQLITE_ENABLE_API_ARMOR
22143 if( zBuf==0 || zFormat==0 ) {
22144 (void)SQLITE_MISUSE_BKPT;
@@ -22149,11 +22266,11 @@
22149 sqlite3StrAccumInit(&acc, zBuf, n, 0);
22150 acc.useMalloc = 0;
22151 sqlite3VXPrintf(&acc, 0, zFormat, ap);
22152 return sqlite3StrAccumFinish(&acc);
22153 }
22154 SQLITE_API char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
22155 char *z;
22156 va_list ap;
22157 va_start(ap,zFormat);
22158 z = sqlite3_vsnprintf(n, zBuf, zFormat, ap);
22159 va_end(ap);
@@ -22181,11 +22298,11 @@
22181 }
22182
22183 /*
22184 ** Format and write a message to the log if logging is enabled.
22185 */
22186 SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...){
22187 va_list ap; /* Vararg list */
22188 if( sqlite3GlobalConfig.xLog ){
22189 va_start(ap, zFormat);
22190 renderLogMsg(iErrCode, zFormat, ap);
22191 va_end(ap);
@@ -22317,11 +22434,11 @@
22317 } sqlite3Prng;
22318
22319 /*
22320 ** Return N random bytes.
22321 */
22322 SQLITE_API void sqlite3_randomness(int N, void *pBuf){
22323 unsigned char t;
22324 unsigned char *zBuf = pBuf;
22325
22326 /* The "wsdPrng" macro will resolve to the pseudo-random number generator
22327 ** state vector. If writable static data is unsupported on the target,
@@ -23469,11 +23586,11 @@
23469 ** sqlite3_strnicmp() APIs allow applications and extensions to compare
23470 ** the contents of two buffers containing UTF-8 strings in a
23471 ** case-independent fashion, using the same definition of "case
23472 ** independence" that SQLite uses internally when comparing identifiers.
23473 */
23474 SQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){
23475 register unsigned char *a, *b;
23476 if( zLeft==0 ){
23477 return zRight ? -1 : 0;
23478 }else if( zRight==0 ){
23479 return 1;
@@ -23481,11 +23598,11 @@
23481 a = (unsigned char *)zLeft;
23482 b = (unsigned char *)zRight;
23483 while( *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }
23484 return UpperToLower[*a] - UpperToLower[*b];
23485 }
23486 SQLITE_API int sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){
23487 register unsigned char *a, *b;
23488 if( zLeft==0 ){
23489 return zRight ? -1 : 0;
23490 }else if( zRight==0 ){
23491 return 1;
@@ -25287,10 +25404,11 @@
25287 #define UNIXFILE_PSOW 0x10 /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */
25288 #define UNIXFILE_DELETE 0x20 /* Delete on close */
25289 #define UNIXFILE_URI 0x40 /* Filename might have query parameters */
25290 #define UNIXFILE_NOLOCK 0x80 /* Do no file locking */
25291 #define UNIXFILE_WARNED 0x0100 /* verifyDbFile() warnings issued */
 
25292
25293 /*
25294 ** Include code that is common to all os_*.c files
25295 */
25296 /************** Include os_common.h in the middle of os_unix.c ***************/
@@ -26782,11 +26900,11 @@
26782
26783 assert( pFile );
26784 OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (unix)\n", pFile->h,
26785 azFileLock(eFileLock), azFileLock(pFile->eFileLock),
26786 azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared,
26787 osGetpid()));
26788
26789 /* If there is already a lock of this type or more restrictive on the
26790 ** unixFile, do nothing. Don't use the end_lock: exit path, as
26791 ** unixEnterMutex() hasn't been called yet.
26792 */
@@ -26990,11 +27108,11 @@
26990 int rc = SQLITE_OK;
26991
26992 assert( pFile );
26993 OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (unix)\n", pFile->h, eFileLock,
26994 pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
26995 osGetpid()));
26996
26997 assert( eFileLock<=SHARED_LOCK );
26998 if( pFile->eFileLock<=eFileLock ){
26999 return SQLITE_OK;
27000 }
@@ -27417,11 +27535,11 @@
27417 char *zLockFile = (char *)pFile->lockingContext;
27418 int rc;
27419
27420 assert( pFile );
27421 OSTRACE(("UNLOCK %d %d was %d pid=%d (dotlock)\n", pFile->h, eFileLock,
27422 pFile->eFileLock, osGetpid()));
27423 assert( eFileLock<=SHARED_LOCK );
27424
27425 /* no-op if possible */
27426 if( pFile->eFileLock==eFileLock ){
27427 return SQLITE_OK;
@@ -27635,11 +27753,11 @@
27635 static int flockUnlock(sqlite3_file *id, int eFileLock) {
27636 unixFile *pFile = (unixFile*)id;
27637
27638 assert( pFile );
27639 OSTRACE(("UNLOCK %d %d was %d pid=%d (flock)\n", pFile->h, eFileLock,
27640 pFile->eFileLock, osGetpid()));
27641 assert( eFileLock<=SHARED_LOCK );
27642
27643 /* no-op if possible */
27644 if( pFile->eFileLock==eFileLock ){
27645 return SQLITE_OK;
@@ -27803,11 +27921,11 @@
27803 sem_t *pSem = pFile->pInode->pSem;
27804
27805 assert( pFile );
27806 assert( pSem );
27807 OSTRACE(("UNLOCK %d %d was %d pid=%d (sem)\n", pFile->h, eFileLock,
27808 pFile->eFileLock, osGetpid()));
27809 assert( eFileLock<=SHARED_LOCK );
27810
27811 /* no-op if possible */
27812 if( pFile->eFileLock==eFileLock ){
27813 return SQLITE_OK;
@@ -28017,11 +28135,11 @@
28017 afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;
28018
28019 assert( pFile );
28020 OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (afp)\n", pFile->h,
28021 azFileLock(eFileLock), azFileLock(pFile->eFileLock),
28022 azFileLock(pInode->eFileLock), pInode->nShared , osGetpid()));
28023
28024 /* If there is already a lock of this type or more restrictive on the
28025 ** unixFile, do nothing. Don't use the afp_end_lock: exit path, as
28026 ** unixEnterMutex() hasn't been called yet.
28027 */
@@ -28203,11 +28321,11 @@
28203 #endif
28204
28205 assert( pFile );
28206 OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock,
28207 pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
28208 osGetpid()));
28209
28210 assert( eFileLock<=SHARED_LOCK );
28211 if( pFile->eFileLock<=eFileLock ){
28212 return SQLITE_OK;
28213 }
@@ -29028,10 +29146,14 @@
29028 ** Information and control of an open file handle.
29029 */
29030 static int unixFileControl(sqlite3_file *id, int op, void *pArg){
29031 unixFile *pFile = (unixFile*)id;
29032 switch( op ){
 
 
 
 
29033 case SQLITE_FCNTL_LOCKSTATE: {
29034 *(int*)pArg = pFile->eFileLock;
29035 return SQLITE_OK;
29036 }
29037 case SQLITE_FCNTL_LAST_ERRNO: {
@@ -29337,37 +29459,42 @@
29337 **
29338 ** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking
29339 ** otherwise.
29340 */
29341 static int unixShmSystemLock(
29342 unixShmNode *pShmNode, /* Apply locks to this open shared-memory segment */
29343 int lockType, /* F_UNLCK, F_RDLCK, or F_WRLCK */
29344 int ofst, /* First byte of the locking range */
29345 int n /* Number of bytes to lock */
29346 ){
29347 struct flock f; /* The posix advisory locking structure */
29348 int rc = SQLITE_OK; /* Result code form fcntl() */
 
29349
29350 /* Access to the unixShmNode object is serialized by the caller */
 
29351 assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 );
29352
29353 /* Shared locks never span more than one byte */
29354 assert( n==1 || lockType!=F_RDLCK );
29355
29356 /* Locks are within range */
29357 assert( n>=1 && n<SQLITE_SHM_NLOCK );
29358
29359 if( pShmNode->h>=0 ){
 
29360 /* Initialize the locking parameters */
29361 memset(&f, 0, sizeof(f));
29362 f.l_type = lockType;
29363 f.l_whence = SEEK_SET;
29364 f.l_start = ofst;
29365 f.l_len = n;
29366
29367 rc = osFcntl(pShmNode->h, F_SETLK, &f);
 
29368 rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
 
29369 }
29370
29371 /* Update the global lock state and do debug tracing */
29372 #ifdef SQLITE_DEBUG
29373 { u16 mask;
@@ -29573,17 +29700,17 @@
29573
29574 /* Check to see if another process is holding the dead-man switch.
29575 ** If not, truncate the file to zero length.
29576 */
29577 rc = SQLITE_OK;
29578 if( unixShmSystemLock(pShmNode, F_WRLCK, UNIX_SHM_DMS, 1)==SQLITE_OK ){
29579 if( robust_ftruncate(pShmNode->h, 0) ){
29580 rc = unixLogError(SQLITE_IOERR_SHMOPEN, "ftruncate", zShmFilename);
29581 }
29582 }
29583 if( rc==SQLITE_OK ){
29584 rc = unixShmSystemLock(pShmNode, F_RDLCK, UNIX_SHM_DMS, 1);
29585 }
29586 if( rc ) goto shm_open_err;
29587 }
29588 }
29589
@@ -29811,11 +29938,11 @@
29811 allMask |= pX->sharedMask;
29812 }
29813
29814 /* Unlock the system-level locks */
29815 if( (mask & allMask)==0 ){
29816 rc = unixShmSystemLock(pShmNode, F_UNLCK, ofst+UNIX_SHM_BASE, n);
29817 }else{
29818 rc = SQLITE_OK;
29819 }
29820
29821 /* Undo the local locks */
@@ -29839,11 +29966,11 @@
29839 }
29840
29841 /* Get shared locks at the system level, if necessary */
29842 if( rc==SQLITE_OK ){
29843 if( (allShared & mask)==0 ){
29844 rc = unixShmSystemLock(pShmNode, F_RDLCK, ofst+UNIX_SHM_BASE, n);
29845 }else{
29846 rc = SQLITE_OK;
29847 }
29848 }
29849
@@ -29864,20 +29991,20 @@
29864
29865 /* Get the exclusive locks at the system level. Then if successful
29866 ** also mark the local connection as being locked.
29867 */
29868 if( rc==SQLITE_OK ){
29869 rc = unixShmSystemLock(pShmNode, F_WRLCK, ofst+UNIX_SHM_BASE, n);
29870 if( rc==SQLITE_OK ){
29871 assert( (p->sharedMask & mask)==0 );
29872 p->exclMask |= mask;
29873 }
29874 }
29875 }
29876 sqlite3_mutex_leave(pShmNode->mutex);
29877 OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n",
29878 p->id, osGetpid(), p->sharedMask, p->exclMask));
29879 return rc;
29880 }
29881
29882 /*
29883 ** Implement a memory barrier or memory fence on shared memory.
@@ -30968,12 +31095,12 @@
30968 /* Detect a pid change and reset the PRNG. There is a race condition
30969 ** here such that two or more threads all trying to open databases at
30970 ** the same instant might all reset the PRNG. But multiple resets
30971 ** are harmless.
30972 */
30973 if( randomnessPid!=osGetpid() ){
30974 randomnessPid = osGetpid();
30975 sqlite3_randomness(0,0);
30976 }
30977
30978 memset(p, 0, sizeof(unixFile));
30979
@@ -31360,11 +31487,11 @@
31360 ** When testing, initializing zBuf[] to zero is all we do. That means
31361 ** that we always use the same random number sequence. This makes the
31362 ** tests repeatable.
31363 */
31364 memset(zBuf, 0, nBuf);
31365 randomnessPid = osGetpid();
31366 #if !defined(SQLITE_TEST)
31367 {
31368 int fd, got;
31369 fd = robust_open("/dev/urandom", O_RDONLY, 0);
31370 if( fd<0 ){
@@ -31681,11 +31808,11 @@
31681 #else
31682 # ifdef _CS_DARWIN_USER_TEMP_DIR
31683 {
31684 if( !confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen) ){
31685 OSTRACE(("GETLOCKPATH failed %s errno=%d pid=%d\n",
31686 lPath, errno, osGetpid()));
31687 return SQLITE_IOERR_LOCK;
31688 }
31689 len = strlcat(lPath, "sqliteplocks", maxLen);
31690 }
31691 # else
@@ -31703,11 +31830,11 @@
31703 char c = dbPath[i];
31704 lPath[i+len] = (c=='/')?'_':c;
31705 }
31706 lPath[i+len]='\0';
31707 strlcat(lPath, ":auto:", maxLen);
31708 OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, osGetpid()));
31709 return SQLITE_OK;
31710 }
31711
31712 /*
31713 ** Creates the lock file and any missing directories in lockPath
@@ -31730,20 +31857,20 @@
31730 if( osMkdir(buf, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){
31731 int err=errno;
31732 if( err!=EEXIST ) {
31733 OSTRACE(("CREATELOCKPATH FAILED creating %s, "
31734 "'%s' proxy lock path=%s pid=%d\n",
31735 buf, strerror(err), lockPath, osGetpid()));
31736 return err;
31737 }
31738 }
31739 }
31740 start=i+1;
31741 }
31742 buf[i] = lockPath[i];
31743 }
31744 OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n", lockPath, osGetpid()));
31745 return 0;
31746 }
31747
31748 /*
31749 ** Create a new VFS file descriptor (stored in memory obtained from
@@ -32045,11 +32172,11 @@
32045 int tryOldLockPath = 0;
32046 int forceNewLockPath = 0;
32047
32048 OSTRACE(("TAKECONCH %d for %s pid=%d\n", conchFile->h,
32049 (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"),
32050 osGetpid()));
32051
32052 rc = proxyGetHostID(myHostID, &pError);
32053 if( (rc&0xff)==SQLITE_IOERR ){
32054 storeLastErrno(pFile, pError);
32055 goto end_takeconch;
@@ -32255,11 +32382,11 @@
32255
32256 pCtx = (proxyLockingContext *)pFile->lockingContext;
32257 conchFile = pCtx->conchFile;
32258 OSTRACE(("RELEASECONCH %d for %s pid=%d\n", conchFile->h,
32259 (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"),
32260 osGetpid()));
32261 if( pCtx->conchHeld>0 ){
32262 rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);
32263 }
32264 pCtx->conchHeld = 0;
32265 OSTRACE(("RELEASECONCH %d %s\n", conchFile->h,
@@ -32397,11 +32524,11 @@
32397 }else{
32398 lockPath=(char *)path;
32399 }
32400
32401 OSTRACE(("TRANSPROXY %d for %s pid=%d\n", pFile->h,
32402 (lockPath ? lockPath : ":auto:"), osGetpid()));
32403
32404 pCtx = sqlite3_malloc( sizeof(*pCtx) );
32405 if( pCtx==0 ){
32406 return SQLITE_NOMEM;
32407 }
@@ -32684,11 +32811,11 @@
32684 ** This routine is called once during SQLite initialization and by a
32685 ** single thread. The memory allocation and mutex subsystems have not
32686 ** necessarily been initialized when this routine is called, and so they
32687 ** should not be used.
32688 */
32689 SQLITE_API int sqlite3_os_init(void){
32690 /*
32691 ** The following macro defines an initializer for an sqlite3_vfs object.
32692 ** The name of the VFS is NAME. The pAppData is a pointer to a pointer
32693 ** to the "finder" function. (pAppData is a pointer to a pointer because
32694 ** silly C90 rules prohibit a void* from being cast to a function pointer
@@ -32783,11 +32910,11 @@
32783 **
32784 ** Some operating systems might need to do some cleanup in this routine,
32785 ** to release dynamically allocated objects. But not on unix.
32786 ** This routine is a no-op for unix.
32787 */
32788 SQLITE_API int sqlite3_os_end(void){
32789 return SQLITE_OK;
32790 }
32791
32792 #endif /* SQLITE_OS_UNIX */
32793
@@ -34175,11 +34302,11 @@
34175 ** compact it. Upon success, SQLITE_OK will be returned. Upon failure, one
34176 ** of SQLITE_NOMEM, SQLITE_ERROR, or SQLITE_NOTFOUND will be returned. The
34177 ** "pnLargest" argument, if non-zero, will be used to return the size of the
34178 ** largest committed free block in the heap, in bytes.
34179 */
34180 SQLITE_API int sqlite3_win32_compact_heap(LPUINT pnLargest){
34181 int rc = SQLITE_OK;
34182 UINT nLargest = 0;
34183 HANDLE hHeap;
34184
34185 winMemAssertMagic();
@@ -34215,11 +34342,11 @@
34215 ** If a Win32 native heap has been configured, this function will attempt to
34216 ** destroy and recreate it. If the Win32 native heap is not isolated and/or
34217 ** the sqlite3_memory_used() function does not return zero, SQLITE_BUSY will
34218 ** be returned and no changes will be made to the Win32 native heap.
34219 */
34220 SQLITE_API int sqlite3_win32_reset_heap(){
34221 int rc;
34222 MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
34223 MUTEX_LOGIC( sqlite3_mutex *pMem; ) /* The memsys static mutex */
34224 MUTEX_LOGIC( pMaster = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); )
34225 MUTEX_LOGIC( pMem = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); )
@@ -34260,11 +34387,11 @@
34260 /*
34261 ** This function outputs the specified (ANSI) string to the Win32 debugger
34262 ** (if available).
34263 */
34264
34265 SQLITE_API void sqlite3_win32_write_debug(const char *zBuf, int nBuf){
34266 char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE];
34267 int nMin = MIN(nBuf, (SQLITE_WIN32_DBG_BUF_SIZE - 1)); /* may be negative. */
34268 if( nMin<-1 ) nMin = -1; /* all negative values become -1. */
34269 assert( nMin==-1 || nMin==0 || nMin<SQLITE_WIN32_DBG_BUF_SIZE );
34270 #if defined(SQLITE_WIN32_HAS_ANSI)
@@ -34300,11 +34427,11 @@
34300 */
34301 #if SQLITE_OS_WINRT
34302 static HANDLE sleepObj = NULL;
34303 #endif
34304
34305 SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds){
34306 #if SQLITE_OS_WINRT
34307 if ( sleepObj==NULL ){
34308 sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET,
34309 SYNCHRONIZE);
34310 }
@@ -34349,11 +34476,11 @@
34349
34350 /*
34351 ** This function determines if the machine is running a version of Windows
34352 ** based on the NT kernel.
34353 */
34354 SQLITE_API int sqlite3_win32_is_nt(void){
34355 #if SQLITE_OS_WINRT
34356 /*
34357 ** NOTE: The WinRT sub-platform is always assumed to be based on the NT
34358 ** kernel.
34359 */
@@ -34703,11 +34830,11 @@
34703
34704 /*
34705 ** Convert multibyte character string to UTF-8. Space to hold the
34706 ** returned string is obtained from sqlite3_malloc().
34707 */
34708 SQLITE_API char *sqlite3_win32_mbcs_to_utf8(const char *zFilename){
34709 char *zFilenameUtf8;
34710 LPWSTR zTmpWide;
34711
34712 zTmpWide = winMbcsToUnicode(zFilename);
34713 if( zTmpWide==0 ){
@@ -34720,11 +34847,11 @@
34720
34721 /*
34722 ** Convert UTF-8 to multibyte character string. Space to hold the
34723 ** returned string is obtained from sqlite3_malloc().
34724 */
34725 SQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){
34726 char *zFilenameMbcs;
34727 LPWSTR zTmpWide;
34728
34729 zTmpWide = winUtf8ToUnicode(zFilename);
34730 if( zTmpWide==0 ){
@@ -34740,11 +34867,11 @@
34740 ** the provided arguments. The type argument must be 1 in order to set the
34741 ** data directory or 2 in order to set the temporary directory. The zValue
34742 ** argument is the name of the directory to use. The return value will be
34743 ** SQLITE_OK if successful.
34744 */
34745 SQLITE_API int sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){
34746 char **ppDirectory = 0;
34747 #ifndef SQLITE_OMIT_AUTOINIT
34748 int rc = sqlite3_initialize();
34749 if( rc ) return rc;
34750 #endif
@@ -34965,15 +35092,15 @@
34965 }
34966
34967 /*
34968 ** Log a I/O error retry episode.
34969 */
34970 static void winLogIoerr(int nRetry){
34971 if( nRetry ){
34972 sqlite3_log(SQLITE_IOERR,
34973 "delayed %dms for lock/sharing conflict",
34974 winIoerrRetryDelay*nRetry*(nRetry+1)/2
34975 );
34976 }
34977 }
34978
34979 #if SQLITE_OS_WINCE
@@ -35449,11 +35576,12 @@
35449 assert( id!=0 );
35450 #ifndef SQLITE_OMIT_WAL
35451 assert( pFile->pShm==0 );
35452 #endif
35453 assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
35454 OSTRACE(("CLOSE file=%p\n", pFile->h));
 
35455
35456 #if SQLITE_MAX_MMAP_SIZE>0
35457 winUnmapfile(pFile);
35458 #endif
35459
@@ -35478,11 +35606,12 @@
35478 #endif
35479 if( rc ){
35480 pFile->h = NULL;
35481 }
35482 OpenCounter(-1);
35483 OSTRACE(("CLOSE file=%p, rc=%s\n", pFile->h, rc ? "ok" : "failed"));
 
35484 return rc ? SQLITE_OK
35485 : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
35486 "winClose", pFile->zPath);
35487 }
35488
@@ -35506,20 +35635,22 @@
35506
35507 assert( id!=0 );
35508 assert( amt>0 );
35509 assert( offset>=0 );
35510 SimulateIOError(return SQLITE_IOERR_READ);
35511 OSTRACE(("READ file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
 
35512 pFile->h, pBuf, amt, offset, pFile->locktype));
35513
35514 #if SQLITE_MAX_MMAP_SIZE>0
35515 /* Deal with as much of this read request as possible by transfering
35516 ** data from the memory mapping using memcpy(). */
35517 if( offset<pFile->mmapSize ){
35518 if( offset+amt <= pFile->mmapSize ){
35519 memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);
35520 OSTRACE(("READ-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
 
35521 return SQLITE_OK;
35522 }else{
35523 int nCopy = (int)(pFile->mmapSize - offset);
35524 memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);
35525 pBuf = &((u8 *)pBuf)[nCopy];
@@ -35529,11 +35660,12 @@
35529 }
35530 #endif
35531
35532 #if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)
35533 if( winSeekFile(pFile, offset) ){
35534 OSTRACE(("READ file=%p, rc=SQLITE_FULL\n", pFile->h));
 
35535 return SQLITE_FULL;
35536 }
35537 while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
35538 #else
35539 memset(&overlapped, 0, sizeof(OVERLAPPED));
@@ -35543,23 +35675,26 @@
35543 osGetLastError()!=ERROR_HANDLE_EOF ){
35544 #endif
35545 DWORD lastErrno;
35546 if( winRetryIoerr(&nRetry, &lastErrno) ) continue;
35547 pFile->lastErrno = lastErrno;
35548 OSTRACE(("READ file=%p, rc=SQLITE_IOERR_READ\n", pFile->h));
 
35549 return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
35550 "winRead", pFile->zPath);
35551 }
35552 winLogIoerr(nRetry);
35553 if( nRead<(DWORD)amt ){
35554 /* Unread parts of the buffer must be zero-filled */
35555 memset(&((char*)pBuf)[nRead], 0, amt-nRead);
35556 OSTRACE(("READ file=%p, rc=SQLITE_IOERR_SHORT_READ\n", pFile->h));
 
35557 return SQLITE_IOERR_SHORT_READ;
35558 }
35559
35560 OSTRACE(("READ file=%p, rc=SQLITE_OK\n", pFile->h));
 
35561 return SQLITE_OK;
35562 }
35563
35564 /*
35565 ** Write data from a buffer into a file. Return SQLITE_OK on success
@@ -35578,20 +35713,22 @@
35578 assert( amt>0 );
35579 assert( pFile );
35580 SimulateIOError(return SQLITE_IOERR_WRITE);
35581 SimulateDiskfullError(return SQLITE_FULL);
35582
35583 OSTRACE(("WRITE file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
 
35584 pFile->h, pBuf, amt, offset, pFile->locktype));
35585
35586 #if SQLITE_MAX_MMAP_SIZE>0
35587 /* Deal with as much of this write request as possible by transfering
35588 ** data from the memory mapping using memcpy(). */
35589 if( offset<pFile->mmapSize ){
35590 if( offset+amt <= pFile->mmapSize ){
35591 memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);
35592 OSTRACE(("WRITE-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
 
35593 return SQLITE_OK;
35594 }else{
35595 int nCopy = (int)(pFile->mmapSize - offset);
35596 memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);
35597 pBuf = &((u8 *)pBuf)[nCopy];
@@ -35650,21 +35787,24 @@
35650 }
35651
35652 if( rc ){
35653 if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
35654 || ( pFile->lastErrno==ERROR_DISK_FULL )){
35655 OSTRACE(("WRITE file=%p, rc=SQLITE_FULL\n", pFile->h));
 
35656 return winLogError(SQLITE_FULL, pFile->lastErrno,
35657 "winWrite1", pFile->zPath);
35658 }
35659 OSTRACE(("WRITE file=%p, rc=SQLITE_IOERR_WRITE\n", pFile->h));
 
35660 return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,
35661 "winWrite2", pFile->zPath);
35662 }else{
35663 winLogIoerr(nRetry);
35664 }
35665 OSTRACE(("WRITE file=%p, rc=SQLITE_OK\n", pFile->h));
 
35666 return SQLITE_OK;
35667 }
35668
35669 /*
35670 ** Truncate an open file to a specified size
@@ -35674,12 +35814,12 @@
35674 int rc = SQLITE_OK; /* Return code for this function */
35675 DWORD lastErrno;
35676
35677 assert( pFile );
35678 SimulateIOError(return SQLITE_IOERR_TRUNCATE);
35679 OSTRACE(("TRUNCATE file=%p, size=%lld, lock=%d\n",
35680 pFile->h, nByte, pFile->locktype));
35681
35682 /* If the user has configured a chunk-size for this file, truncate the
35683 ** file so that it consists of an integer number of chunks (i.e. the
35684 ** actual file size after the operation may be larger than the requested
35685 ** size).
@@ -35707,11 +35847,12 @@
35707 if( pFile->pMapRegion && nByte<pFile->mmapSize ){
35708 pFile->mmapSize = nByte;
35709 }
35710 #endif
35711
35712 OSTRACE(("TRUNCATE file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
 
35713 return rc;
35714 }
35715
35716 #ifdef SQLITE_TEST
35717 /*
@@ -35752,12 +35893,13 @@
35752 /* Unix cannot, but some systems may return SQLITE_FULL from here. This
35753 ** line is to test that doing so does not cause any problems.
35754 */
35755 SimulateDiskfullError( return SQLITE_FULL );
35756
35757 OSTRACE(("SYNC file=%p, flags=%x, lock=%d\n",
35758 pFile->h, flags, pFile->locktype));
 
35759
35760 #ifndef SQLITE_TEST
35761 UNUSED_PARAMETER(flags);
35762 #else
35763 if( (flags&0x0F)==SQLITE_SYNC_FULL ){
@@ -35768,21 +35910,24 @@
35768
35769 /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a
35770 ** no-op
35771 */
35772 #ifdef SQLITE_NO_SYNC
35773 OSTRACE(("SYNC-NOP file=%p, rc=SQLITE_OK\n", pFile->h));
 
35774 return SQLITE_OK;
35775 #else
35776 rc = osFlushFileBuffers(pFile->h);
35777 SimulateIOError( rc=FALSE );
35778 if( rc ){
35779 OSTRACE(("SYNC file=%p, rc=SQLITE_OK\n", pFile->h));
 
35780 return SQLITE_OK;
35781 }else{
35782 pFile->lastErrno = osGetLastError();
35783 OSTRACE(("SYNC file=%p, rc=SQLITE_IOERR_FSYNC\n", pFile->h));
 
35784 return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,
35785 "winSync", pFile->zPath);
35786 }
35787 #endif
35788 }
@@ -37751,11 +37896,11 @@
37751 winRetryIoerr(&cnt, &lastErrno) ){
37752 /* Noop */
37753 }
37754 }
37755 #endif
37756 winLogIoerr(cnt);
37757
37758 OSTRACE(("OPEN file=%p, name=%s, access=%lx, rc=%s\n", h, zUtf8Name,
37759 dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
37760
37761 if( h==INVALID_HANDLE_VALUE ){
@@ -37935,11 +38080,11 @@
37935 }
37936 #endif
37937 if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
37938 rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename);
37939 }else{
37940 winLogIoerr(cnt);
37941 }
37942 sqlite3_free(zConverted);
37943 OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc)));
37944 return rc;
37945 }
@@ -37985,11 +38130,11 @@
37985 attr = INVALID_FILE_ATTRIBUTES;
37986 }else{
37987 attr = sAttrData.dwFileAttributes;
37988 }
37989 }else{
37990 winLogIoerr(cnt);
37991 if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){
37992 sqlite3_free(zConverted);
37993 return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess",
37994 zFilename);
37995 }else{
@@ -38500,11 +38645,11 @@
38500 }
38501
38502 /*
38503 ** Initialize and deinitialize the operating system interface.
38504 */
38505 SQLITE_API int sqlite3_os_init(void){
38506 static sqlite3_vfs winVfs = {
38507 3, /* iVersion */
38508 sizeof(winFile), /* szOsFile */
38509 SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
38510 0, /* pNext */
@@ -38575,11 +38720,11 @@
38575 #endif
38576
38577 return SQLITE_OK;
38578 }
38579
38580 SQLITE_API int sqlite3_os_end(void){
38581 #if SQLITE_OS_WINRT
38582 if( sleepObj!=NULL ){
38583 osCloseHandle(sleepObj);
38584 sleepObj = NULL;
38585 }
@@ -39866,20 +40011,20 @@
39866 ** in pcache1 need to be protected via mutex.
39867 */
39868 static void *pcache1Alloc(int nByte){
39869 void *p = 0;
39870 assert( sqlite3_mutex_notheld(pcache1.grp.mutex) );
39871 sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);
39872 if( nByte<=pcache1.szSlot ){
39873 sqlite3_mutex_enter(pcache1.mutex);
39874 p = (PgHdr1 *)pcache1.pFree;
39875 if( p ){
39876 pcache1.pFree = pcache1.pFree->pNext;
39877 pcache1.nFreeSlot--;
39878 pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;
39879 assert( pcache1.nFreeSlot>=0 );
39880 sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1);
 
39881 }
39882 sqlite3_mutex_leave(pcache1.mutex);
39883 }
39884 if( p==0 ){
39885 /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool. Get
@@ -39888,11 +40033,12 @@
39888 p = sqlite3Malloc(nByte);
39889 #ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
39890 if( p ){
39891 int sz = sqlite3MallocSize(p);
39892 sqlite3_mutex_enter(pcache1.mutex);
39893 sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);
 
39894 sqlite3_mutex_leave(pcache1.mutex);
39895 }
39896 #endif
39897 sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);
39898 }
@@ -39906,11 +40052,11 @@
39906 int nFreed = 0;
39907 if( p==0 ) return 0;
39908 if( p>=pcache1.pStart && p<pcache1.pEnd ){
39909 PgFreeslot *pSlot;
39910 sqlite3_mutex_enter(pcache1.mutex);
39911 sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, -1);
39912 pSlot = (PgFreeslot*)p;
39913 pSlot->pNext = pcache1.pFree;
39914 pcache1.pFree = pSlot;
39915 pcache1.nFreeSlot++;
39916 pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;
@@ -39920,11 +40066,11 @@
39920 assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );
39921 sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
39922 nFreed = sqlite3MallocSize(p);
39923 #ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
39924 sqlite3_mutex_enter(pcache1.mutex);
39925 sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -nFreed);
39926 sqlite3_mutex_leave(pcache1.mutex);
39927 #endif
39928 sqlite3_free(p);
39929 }
39930 return nFreed;
@@ -40656,10 +40802,18 @@
40656
40657 /*
40658 ** Return the size of the header on each page of this PCACHE implementation.
40659 */
40660 SQLITE_PRIVATE int sqlite3HeaderSizePcache1(void){ return ROUND8(sizeof(PgHdr1)); }
 
 
 
 
 
 
 
 
40661
40662 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
40663 /*
40664 ** This function is called to free superfluous dynamically allocated memory
40665 ** held by the pager system. Memory in use by any SQLite pager allocated
@@ -49429,13 +49583,14 @@
49429 if( pWal->exclusiveMode ) return;
49430 (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,
49431 SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED);
49432 WALTRACE(("WAL%p: release SHARED-%s\n", pWal, walLockName(lockIdx)));
49433 }
49434 static int walLockExclusive(Wal *pWal, int lockIdx, int n){
49435 int rc;
49436 if( pWal->exclusiveMode ) return SQLITE_OK;
 
49437 rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,
49438 SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE);
49439 WALTRACE(("WAL%p: acquire EXCLUSIVE-%s cnt=%d %s\n", pWal,
49440 walLockName(lockIdx), n, rc ? "failed" : "ok"));
49441 VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )
@@ -49717,11 +49872,11 @@
49717 assert( WAL_ALL_BUT_WRITE==WAL_WRITE_LOCK+1 );
49718 assert( WAL_CKPT_LOCK==WAL_ALL_BUT_WRITE );
49719 assert( pWal->writeLock );
49720 iLock = WAL_ALL_BUT_WRITE + pWal->ckptLock;
49721 nLock = SQLITE_SHM_NLOCK - iLock;
49722 rc = walLockExclusive(pWal, iLock, nLock);
49723 if( rc ){
49724 return rc;
49725 }
49726 WALTRACE(("WAL%p: recovery begin...\n", pWal));
49727
@@ -50251,11 +50406,11 @@
50251 int lockIdx, /* Offset of first byte to lock */
50252 int n /* Number of bytes to lock */
50253 ){
50254 int rc;
50255 do {
50256 rc = walLockExclusive(pWal, lockIdx, n);
50257 }while( xBusy && rc==SQLITE_BUSY && xBusy(pBusyArg) );
50258 return rc;
50259 }
50260
50261 /*
@@ -50684,11 +50839,11 @@
50684 if( pWal->readOnly & WAL_SHM_RDONLY ){
50685 if( SQLITE_OK==(rc = walLockShared(pWal, WAL_WRITE_LOCK)) ){
50686 walUnlockShared(pWal, WAL_WRITE_LOCK);
50687 rc = SQLITE_READONLY_RECOVERY;
50688 }
50689 }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1)) ){
50690 pWal->writeLock = 1;
50691 if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){
50692 badHdr = walIndexTryHdr(pWal, pChanged);
50693 if( badHdr ){
50694 /* If the wal-index header is still malformed even while holding
@@ -50890,11 +51045,11 @@
50890 {
50891 if( (pWal->readOnly & WAL_SHM_RDONLY)==0
50892 && (mxReadMark<pWal->hdr.mxFrame || mxI==0)
50893 ){
50894 for(i=1; i<WAL_NREADER; i++){
50895 rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
50896 if( rc==SQLITE_OK ){
50897 mxReadMark = pInfo->aReadMark[i] = pWal->hdr.mxFrame;
50898 mxI = i;
50899 walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
50900 break;
@@ -51146,11 +51301,11 @@
51146 }
51147
51148 /* Only one writer allowed at a time. Get the write lock. Return
51149 ** SQLITE_BUSY if unable.
51150 */
51151 rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1);
51152 if( rc ){
51153 return rc;
51154 }
51155 pWal->writeLock = 1;
51156
@@ -51291,11 +51446,11 @@
51291 volatile WalCkptInfo *pInfo = walCkptInfo(pWal);
51292 assert( pInfo->nBackfill==pWal->hdr.mxFrame );
51293 if( pInfo->nBackfill>0 ){
51294 u32 salt1;
51295 sqlite3_randomness(4, &salt1);
51296 rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
51297 if( rc==SQLITE_OK ){
51298 /* If all readers are using WAL_READ_LOCK(0) (in other words if no
51299 ** readers are currently using the WAL), then the transactions
51300 ** frames will overwrite the start of the existing log. Update the
51301 ** wal-index header to reflect this.
@@ -51616,11 +51771,11 @@
51616 if( pWal->readOnly ) return SQLITE_READONLY;
51617 WALTRACE(("WAL%p: checkpoint begins\n", pWal));
51618
51619 /* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive
51620 ** "checkpoint" lock on the database file. */
51621 rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);
51622 if( rc ){
51623 /* EVIDENCE-OF: R-10421-19736 If any other process is running a
51624 ** checkpoint operation at the same time, the lock cannot be obtained and
51625 ** SQLITE_BUSY is returned.
51626 ** EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured,
@@ -52618,10 +52773,11 @@
52618
52619 /*
52620 ** Exit the recursive mutex on a Btree.
52621 */
52622 SQLITE_PRIVATE void sqlite3BtreeLeave(Btree *p){
 
52623 if( p->sharable ){
52624 assert( p->wantToLock>0 );
52625 p->wantToLock--;
52626 if( p->wantToLock==0 ){
52627 unlockBtreeMutex(p);
@@ -52865,11 +53021,11 @@
52865 **
52866 ** This routine has no effect on existing database connections.
52867 ** The shared cache setting effects only future calls to
52868 ** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2().
52869 */
52870 SQLITE_API int sqlite3_enable_shared_cache(int enable){
52871 sqlite3GlobalConfig.sharedCacheEnabled = enable;
52872 return SQLITE_OK;
52873 }
52874 #endif
52875
@@ -53379,14 +53535,19 @@
53379 ** prior to calling this routine.
53380 */
53381 static int saveCursorPosition(BtCursor *pCur){
53382 int rc;
53383
53384 assert( CURSOR_VALID==pCur->eState );
53385 assert( 0==pCur->pKey );
53386 assert( cursorHoldsMutex(pCur) );
53387
 
 
 
 
 
53388 rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
53389 assert( rc==SQLITE_OK ); /* KeySize() cannot fail */
53390
53391 /* If this is an intKey table, then the above call to BtreeKeySize()
53392 ** stores the integer key in pCur->nKey. In this case this value is
@@ -53453,11 +53614,11 @@
53453 Pgno iRoot, /* Only save cursor with this iRoot. Save all if zero */
53454 BtCursor *pExcept /* Do not save this cursor */
53455 ){
53456 do{
53457 if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){
53458 if( p->eState==CURSOR_VALID ){
53459 int rc = saveCursorPosition(p);
53460 if( SQLITE_OK!=rc ){
53461 return rc;
53462 }
53463 }else{
@@ -53525,21 +53686,23 @@
53525 ** at most one effective restoreCursorPosition() call after each
53526 ** saveCursorPosition().
53527 */
53528 static int btreeRestoreCursorPosition(BtCursor *pCur){
53529 int rc;
 
53530 assert( cursorHoldsMutex(pCur) );
53531 assert( pCur->eState>=CURSOR_REQUIRESEEK );
53532 if( pCur->eState==CURSOR_FAULT ){
53533 return pCur->skipNext;
53534 }
53535 pCur->eState = CURSOR_INVALID;
53536 rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &pCur->skipNext);
53537 if( rc==SQLITE_OK ){
53538 sqlite3_free(pCur->pKey);
53539 pCur->pKey = 0;
53540 assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
 
53541 if( pCur->skipNext && pCur->eState==CURSOR_VALID ){
53542 pCur->eState = CURSOR_SKIPNEXT;
53543 }
53544 }
53545 return rc;
@@ -53587,13 +53750,14 @@
53587 rc = restoreCursorPosition(pCur);
53588 if( rc ){
53589 *pDifferentRow = 1;
53590 return rc;
53591 }
53592 if( pCur->eState!=CURSOR_VALID || NEVER(pCur->skipNext!=0) ){
53593 *pDifferentRow = 1;
53594 }else{
 
53595 *pDifferentRow = 0;
53596 }
53597 return SQLITE_OK;
53598 }
53599
@@ -54796,12 +54960,12 @@
54796 /*
54797 ** The following asserts make sure that structures used by the btree are
54798 ** the right size. This is to guard against size changes that result
54799 ** when compiling on a different architecture.
54800 */
54801 assert( sizeof(i64)==8 || sizeof(i64)==4 );
54802 assert( sizeof(u64)==8 || sizeof(u64)==4 );
54803 assert( sizeof(u32)==4 );
54804 assert( sizeof(u16)==2 );
54805 assert( sizeof(Pgno)==4 );
54806
54807 pBt = sqlite3MallocZero( sizeof(*pBt) );
@@ -56404,11 +56568,11 @@
56404 if( pBtree ){
56405 sqlite3BtreeEnter(pBtree);
56406 for(p=pBtree->pBt->pCursor; p; p=p->pNext){
56407 int i;
56408 if( writeOnly && (p->curFlags & BTCF_WriteFlag)==0 ){
56409 if( p->eState==CURSOR_VALID ){
56410 rc = saveCursorPosition(p);
56411 if( rc!=SQLITE_OK ){
56412 (void)sqlite3BtreeTripAllCursors(pBtree, rc, 0);
56413 break;
56414 }
@@ -56810,10 +56974,12 @@
56810 ** to return an integer result code for historical reasons.
56811 */
56812 SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
56813 assert( cursorHoldsMutex(pCur) );
56814 assert( pCur->eState==CURSOR_VALID );
 
 
56815 assert( pCur->apPage[pCur->iPage]->intKeyLeaf==1 );
56816 getCellInfo(pCur);
56817 *pSize = pCur->info.nPayload;
56818 return SQLITE_OK;
56819 }
@@ -57288,19 +57454,21 @@
57288 return SQLITE_CORRUPT_BKPT;
57289 }
57290 return SQLITE_OK;
57291 }
57292
57293 #if 0
57294 /*
57295 ** Page pParent is an internal (non-leaf) tree page. This function
57296 ** asserts that page number iChild is the left-child if the iIdx'th
57297 ** cell in page pParent. Or, if iIdx is equal to the total number of
57298 ** cells in pParent, that page number iChild is the right-child of
57299 ** the page.
57300 */
57301 static void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){
 
 
57302 assert( iIdx<=pParent->nCell );
57303 if( iIdx==pParent->nCell ){
57304 assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild );
57305 }else{
57306 assert( get4byte(findCell(pParent, iIdx))==iChild );
@@ -57321,23 +57489,15 @@
57321 static void moveToParent(BtCursor *pCur){
57322 assert( cursorHoldsMutex(pCur) );
57323 assert( pCur->eState==CURSOR_VALID );
57324 assert( pCur->iPage>0 );
57325 assert( pCur->apPage[pCur->iPage] );
57326
57327 /* UPDATE: It is actually possible for the condition tested by the assert
57328 ** below to be untrue if the database file is corrupt. This can occur if
57329 ** one cursor has modified page pParent while a reference to it is held
57330 ** by a second cursor. Which can only happen if a single page is linked
57331 ** into more than one b-tree structure in a corrupt database. */
57332 #if 0
57333 assertParentIndex(
57334 pCur->apPage[pCur->iPage-1],
57335 pCur->aiIdx[pCur->iPage-1],
57336 pCur->apPage[pCur->iPage]->pgno
57337 );
57338 #endif
57339 testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell );
57340
57341 releasePage(pCur->apPage[pCur->iPage]);
57342 pCur->iPage--;
57343 pCur->info.nSize = 0;
@@ -60259,11 +60419,12 @@
60259 ** the previous call, as the overflow cell data will have been
60260 ** copied either into the body of a database page or into the new
60261 ** pSpace buffer passed to the latter call to balance_nonroot().
60262 */
60263 u8 *pSpace = sqlite3PageMalloc(pCur->pBt->pageSize);
60264 rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1, pCur->hints);
 
60265 if( pFree ){
60266 /* If pFree is not NULL, it points to the pSpace buffer used
60267 ** by a previous call to balance_nonroot(). Its contents are
60268 ** now stored either on real database pages or within the
60269 ** new pSpace buffer, so it may be safely freed here. */
@@ -60280,10 +60441,11 @@
60280 pPage->nOverflow = 0;
60281
60282 /* The next iteration of the do-loop balances the parent page. */
60283 releasePage(pPage);
60284 pCur->iPage--;
 
60285 }
60286 }while( rc==SQLITE_OK );
60287
60288 if( pFree ){
60289 sqlite3PageFree(pFree);
@@ -60751,29 +60913,32 @@
60751 int rc;
60752 unsigned char *pCell;
60753 int i;
60754 int hdr;
60755 u16 szCell;
 
60756
60757 assert( sqlite3_mutex_held(pBt->mutex) );
60758 if( pgno>btreePagecount(pBt) ){
60759 return SQLITE_CORRUPT_BKPT;
60760 }
60761
60762 rc = getAndInitPage(pBt, pgno, &pPage, 0);
60763 if( rc ) return rc;
 
 
60764 hdr = pPage->hdrOffset;
60765 for(i=0; i<pPage->nCell; i++){
60766 pCell = findCell(pPage, i);
60767 if( !pPage->leaf ){
60768 rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
60769 if( rc ) goto cleardatabasepage_out;
60770 }
60771 rc = clearCell(pPage, pCell, &szCell);
60772 if( rc ) goto cleardatabasepage_out;
60773 }
60774 if( !pPage->leaf ){
60775 rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
60776 if( rc ) goto cleardatabasepage_out;
60777 }else if( pnChange ){
60778 assert( pPage->intKey );
60779 *pnChange += pPage->nCell;
@@ -61922,17 +62087,26 @@
61922 pBt->btsFlags &= ~BTS_NO_WAL;
61923 return rc;
61924 }
61925
61926 /*
61927 ** set the mask of hint flags for cursor pCsr. Currently the only valid
61928 ** values are 0 and BTREE_BULKLOAD.
61929 */
61930 SQLITE_PRIVATE void sqlite3BtreeCursorHints(BtCursor *pCsr, unsigned int mask){
61931 assert( mask==BTREE_BULKLOAD || mask==0 );
61932 pCsr->hints = mask;
61933 }
 
 
 
 
 
 
 
 
 
 
61934
61935 /*
61936 ** Return true if the given Btree is read-only.
61937 */
61938 SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *p){
@@ -62088,11 +62262,11 @@
62088 ** a pointer to the new sqlite3_backup object.
62089 **
62090 ** If an error occurs, NULL is returned and an error code and error message
62091 ** stored in database handle pDestDb.
62092 */
62093 SQLITE_API sqlite3_backup *sqlite3_backup_init(
62094 sqlite3* pDestDb, /* Database to write to */
62095 const char *zDestDb, /* Name of database within pDestDb */
62096 sqlite3* pSrcDb, /* Database connection to read from */
62097 const char *zSrcDb /* Name of database within pSrcDb */
62098 ){
@@ -62296,11 +62470,11 @@
62296 }
62297
62298 /*
62299 ** Copy nPage pages from the source b-tree to the destination.
62300 */
62301 SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){
62302 int rc;
62303 int destMode; /* Destination journal mode */
62304 int pgszSrc = 0; /* Source page size */
62305 int pgszDest = 0; /* Destination page size */
62306
@@ -62541,11 +62715,11 @@
62541 }
62542
62543 /*
62544 ** Release all resources associated with an sqlite3_backup* handle.
62545 */
62546 SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p){
62547 sqlite3_backup **pp; /* Ptr to head of pagers backup list */
62548 sqlite3 *pSrcDb; /* Source database connection */
62549 int rc; /* Value to return */
62550
62551 /* Enter the mutexes */
@@ -62593,11 +62767,11 @@
62593
62594 /*
62595 ** Return the number of pages still to be backed up as of the most recent
62596 ** call to sqlite3_backup_step().
62597 */
62598 SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p){
62599 #ifdef SQLITE_ENABLE_API_ARMOR
62600 if( p==0 ){
62601 (void)SQLITE_MISUSE_BKPT;
62602 return 0;
62603 }
@@ -62607,11 +62781,11 @@
62607
62608 /*
62609 ** Return the total number of pages in the source database as of the most
62610 ** recent call to sqlite3_backup_step().
62611 */
62612 SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p){
62613 #ifdef SQLITE_ENABLE_API_ARMOR
62614 if( p==0 ){
62615 (void)SQLITE_MISUSE_BKPT;
62616 return 0;
62617 }
@@ -63822,11 +63996,11 @@
63822 ** by calling sqlite3ValueNew().
63823 **
63824 ** Otherwise, if the second argument is non-zero, then this function is
63825 ** being called indirectly by sqlite3Stat4ProbeSetValue(). If it has not
63826 ** already been allocated, allocate the UnpackedRecord structure that
63827 ** that function will return to its caller here. Then return a pointer
63828 ** an sqlite3_value within the UnpackedRecord.a[] array.
63829 */
63830 static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){
63831 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
63832 if( p ){
@@ -63866,10 +64040,117 @@
63866 UNUSED_PARAMETER(p);
63867 #endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
63868 return sqlite3ValueNew(db);
63869 }
63870
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63871 /*
63872 ** Extract a value from the supplied expression in the manner described
63873 ** above sqlite3ValueFromExpr(). Allocate the sqlite3_value object
63874 ** using valueNew().
63875 **
@@ -63897,10 +64178,16 @@
63897 *ppVal = 0;
63898 return SQLITE_OK;
63899 }
63900 while( (op = pExpr->op)==TK_UPLUS ) pExpr = pExpr->pLeft;
63901 if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
 
 
 
 
 
 
63902
63903 if( op==TK_CAST ){
63904 u8 aff = sqlite3AffinityType(pExpr->u.zToken,0);
63905 rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx);
63906 testcase( rc!=SQLITE_OK );
@@ -63973,10 +64260,16 @@
63973 assert( zVal[nVal]=='\'' );
63974 sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,
63975 0, SQLITE_DYNAMIC);
63976 }
63977 #endif
 
 
 
 
 
 
63978
63979 *ppVal = pVal;
63980 return rc;
63981
63982 no_mem:
@@ -64363,11 +64656,11 @@
64363 }
64364
64365 /*
64366 ** Return the SQL associated with a prepared statement
64367 */
64368 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt){
64369 Vdbe *p = (Vdbe *)pStmt;
64370 return (p && p->isPrepareV2) ? p->zSql : 0;
64371 }
64372
64373 /*
@@ -65426,11 +65719,11 @@
65426 break;
65427 }
65428 #ifndef SQLITE_OMIT_VIRTUALTABLE
65429 case P4_VTAB: {
65430 sqlite3_vtab *pVtab = pOp->p4.pVtab->pVtab;
65431 sqlite3_snprintf(nTemp, zTemp, "vtab:%p:%p", pVtab, pVtab->pModule);
65432 break;
65433 }
65434 #endif
65435 case P4_INTARRAY: {
65436 sqlite3_snprintf(nTemp, zTemp, "intarray");
@@ -66090,13 +66383,13 @@
66090 }
66091 #ifndef SQLITE_OMIT_VIRTUALTABLE
66092 else if( pCx->pVtabCursor ){
66093 sqlite3_vtab_cursor *pVtabCursor = pCx->pVtabCursor;
66094 const sqlite3_module *pModule = pVtabCursor->pVtab->pModule;
66095 p->inVtabMethod = 1;
 
66096 pModule->xClose(pVtabCursor);
66097 p->inVtabMethod = 0;
66098 }
66099 #endif
66100 }
66101
66102 /*
@@ -66451,11 +66744,11 @@
66451
66452 /* Delete the master journal file. This commits the transaction. After
66453 ** doing this the directory is synced again before any individual
66454 ** transaction files are deleted.
66455 */
66456 rc = sqlite3OsDelete(pVfs, zMaster, 1);
66457 sqlite3DbFree(db, zMaster);
66458 zMaster = 0;
66459 if( rc ){
66460 return rc;
66461 }
@@ -68519,11 +68812,11 @@
68519 ** execution environment changes in a way that would alter the program
68520 ** that sqlite3_prepare() generates. For example, if new functions or
68521 ** collating sequences are registered or if an authorizer function is
68522 ** added or changed.
68523 */
68524 SQLITE_API int sqlite3_expired(sqlite3_stmt *pStmt){
68525 Vdbe *p = (Vdbe*)pStmt;
68526 return p==0 || p->expired;
68527 }
68528 #endif
68529
@@ -68556,11 +68849,11 @@
68556 ** machine.
68557 **
68558 ** This routine sets the error code and string returned by
68559 ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
68560 */
68561 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt){
68562 int rc;
68563 if( pStmt==0 ){
68564 /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL
68565 ** pointer is a harmless no-op. */
68566 rc = SQLITE_OK;
@@ -68582,11 +68875,11 @@
68582 ** the prior execution is returned.
68583 **
68584 ** This routine sets the error code and string returned by
68585 ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
68586 */
68587 SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt){
68588 int rc;
68589 if( pStmt==0 ){
68590 rc = SQLITE_OK;
68591 }else{
68592 Vdbe *v = (Vdbe*)pStmt;
@@ -68601,11 +68894,11 @@
68601 }
68602
68603 /*
68604 ** Set all the parameters in the compiled SQL statement to NULL.
68605 */
68606 SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *pStmt){
68607 int i;
68608 int rc = SQLITE_OK;
68609 Vdbe *p = (Vdbe*)pStmt;
68610 #if SQLITE_THREADSAFE
68611 sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex;
@@ -68625,54 +68918,54 @@
68625
68626 /**************************** sqlite3_value_ *******************************
68627 ** The following routines extract information from a Mem or sqlite3_value
68628 ** structure.
68629 */
68630 SQLITE_API const void *sqlite3_value_blob(sqlite3_value *pVal){
68631 Mem *p = (Mem*)pVal;
68632 if( p->flags & (MEM_Blob|MEM_Str) ){
68633 sqlite3VdbeMemExpandBlob(p);
68634 p->flags |= MEM_Blob;
68635 return p->n ? p->z : 0;
68636 }else{
68637 return sqlite3_value_text(pVal);
68638 }
68639 }
68640 SQLITE_API int sqlite3_value_bytes(sqlite3_value *pVal){
68641 return sqlite3ValueBytes(pVal, SQLITE_UTF8);
68642 }
68643 SQLITE_API int sqlite3_value_bytes16(sqlite3_value *pVal){
68644 return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE);
68645 }
68646 SQLITE_API double sqlite3_value_double(sqlite3_value *pVal){
68647 return sqlite3VdbeRealValue((Mem*)pVal);
68648 }
68649 SQLITE_API int sqlite3_value_int(sqlite3_value *pVal){
68650 return (int)sqlite3VdbeIntValue((Mem*)pVal);
68651 }
68652 SQLITE_API sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){
68653 return sqlite3VdbeIntValue((Mem*)pVal);
68654 }
68655 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
68656 return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
68657 }
68658 #ifndef SQLITE_OMIT_UTF16
68659 SQLITE_API const void *sqlite3_value_text16(sqlite3_value* pVal){
68660 return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE);
68661 }
68662 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value *pVal){
68663 return sqlite3ValueText(pVal, SQLITE_UTF16BE);
68664 }
68665 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value *pVal){
68666 return sqlite3ValueText(pVal, SQLITE_UTF16LE);
68667 }
68668 #endif /* SQLITE_OMIT_UTF16 */
68669 /* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five
68670 ** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating
68671 ** point number string BLOB NULL
68672 */
68673 SQLITE_API int sqlite3_value_type(sqlite3_value* pVal){
68674 static const u8 aType[] = {
68675 SQLITE_BLOB, /* 0x00 */
68676 SQLITE_NULL, /* 0x01 */
68677 SQLITE_TEXT, /* 0x02 */
68678 SQLITE_NULL, /* 0x03 */
@@ -68744,21 +69037,21 @@
68744 xDel((void*)p);
68745 }
68746 if( pCtx ) sqlite3_result_error_toobig(pCtx);
68747 return SQLITE_TOOBIG;
68748 }
68749 SQLITE_API void sqlite3_result_blob(
68750 sqlite3_context *pCtx,
68751 const void *z,
68752 int n,
68753 void (*xDel)(void *)
68754 ){
68755 assert( n>=0 );
68756 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68757 setResultStrOrError(pCtx, z, n, 0, xDel);
68758 }
68759 SQLITE_API void sqlite3_result_blob64(
68760 sqlite3_context *pCtx,
68761 const void *z,
68762 sqlite3_uint64 n,
68763 void (*xDel)(void *)
68764 ){
@@ -68768,50 +69061,50 @@
68768 (void)invokeValueDestructor(z, xDel, pCtx);
68769 }else{
68770 setResultStrOrError(pCtx, z, (int)n, 0, xDel);
68771 }
68772 }
68773 SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){
68774 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68775 sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);
68776 }
68777 SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
68778 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68779 pCtx->isError = SQLITE_ERROR;
68780 pCtx->fErrorOrAux = 1;
68781 sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);
68782 }
68783 #ifndef SQLITE_OMIT_UTF16
68784 SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
68785 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68786 pCtx->isError = SQLITE_ERROR;
68787 pCtx->fErrorOrAux = 1;
68788 sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);
68789 }
68790 #endif
68791 SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){
68792 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68793 sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal);
68794 }
68795 SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
68796 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68797 sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);
68798 }
68799 SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){
68800 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68801 sqlite3VdbeMemSetNull(pCtx->pOut);
68802 }
68803 SQLITE_API void sqlite3_result_text(
68804 sqlite3_context *pCtx,
68805 const char *z,
68806 int n,
68807 void (*xDel)(void *)
68808 ){
68809 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68810 setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);
68811 }
68812 SQLITE_API void sqlite3_result_text64(
68813 sqlite3_context *pCtx,
68814 const char *z,
68815 sqlite3_uint64 n,
68816 void (*xDel)(void *),
68817 unsigned char enc
@@ -68824,69 +69117,69 @@
68824 }else{
68825 setResultStrOrError(pCtx, z, (int)n, enc, xDel);
68826 }
68827 }
68828 #ifndef SQLITE_OMIT_UTF16
68829 SQLITE_API void sqlite3_result_text16(
68830 sqlite3_context *pCtx,
68831 const void *z,
68832 int n,
68833 void (*xDel)(void *)
68834 ){
68835 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68836 setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel);
68837 }
68838 SQLITE_API void sqlite3_result_text16be(
68839 sqlite3_context *pCtx,
68840 const void *z,
68841 int n,
68842 void (*xDel)(void *)
68843 ){
68844 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68845 setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel);
68846 }
68847 SQLITE_API void sqlite3_result_text16le(
68848 sqlite3_context *pCtx,
68849 const void *z,
68850 int n,
68851 void (*xDel)(void *)
68852 ){
68853 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68854 setResultStrOrError(pCtx, z, n, SQLITE_UTF16LE, xDel);
68855 }
68856 #endif /* SQLITE_OMIT_UTF16 */
68857 SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){
68858 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68859 sqlite3VdbeMemCopy(pCtx->pOut, pValue);
68860 }
68861 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){
68862 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68863 sqlite3VdbeMemSetZeroBlob(pCtx->pOut, n);
68864 }
68865 SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
68866 pCtx->isError = errCode;
68867 pCtx->fErrorOrAux = 1;
68868 #ifdef SQLITE_DEBUG
68869 pCtx->pVdbe->rcApp = errCode;
68870 #endif
68871 if( pCtx->pOut->flags & MEM_Null ){
68872 sqlite3VdbeMemSetStr(pCtx->pOut, sqlite3ErrStr(errCode), -1,
68873 SQLITE_UTF8, SQLITE_STATIC);
68874 }
68875 }
68876
68877 /* Force an SQLITE_TOOBIG error. */
68878 SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){
68879 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68880 pCtx->isError = SQLITE_TOOBIG;
68881 pCtx->fErrorOrAux = 1;
68882 sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1,
68883 SQLITE_UTF8, SQLITE_STATIC);
68884 }
68885
68886 /* An SQLITE_NOMEM error. */
68887 SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){
68888 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
68889 sqlite3VdbeMemSetNull(pCtx->pOut);
68890 pCtx->isError = SQLITE_NOMEM;
68891 pCtx->fErrorOrAux = 1;
68892 pCtx->pOut->db->mallocFailed = 1;
@@ -69055,11 +69348,11 @@
69055 /*
69056 ** This is the top-level implementation of sqlite3_step(). Call
69057 ** sqlite3Step() to do most of the work. If a schema error occurs,
69058 ** call sqlite3Reprepare() and try again.
69059 */
69060 SQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){
69061 int rc = SQLITE_OK; /* Result from sqlite3Step() */
69062 int rc2 = SQLITE_OK; /* Result from sqlite3Reprepare() */
69063 Vdbe *v = (Vdbe*)pStmt; /* the prepared statement */
69064 int cnt = 0; /* Counter to prevent infinite loop of reprepares */
69065 sqlite3 *db; /* The database connection */
@@ -69106,11 +69399,11 @@
69106
69107 /*
69108 ** Extract the user data from a sqlite3_context structure and return a
69109 ** pointer to it.
69110 */
69111 SQLITE_API void *sqlite3_user_data(sqlite3_context *p){
69112 assert( p && p->pFunc );
69113 return p->pFunc->pUserData;
69114 }
69115
69116 /*
@@ -69121,26 +69414,36 @@
69121 ** returns a copy of the pointer to the database connection (the 1st
69122 ** parameter) of the sqlite3_create_function() and
69123 ** sqlite3_create_function16() routines that originally registered the
69124 ** application defined function.
69125 */
69126 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){
69127 assert( p && p->pFunc );
69128 return p->pOut->db;
69129 }
69130
69131 /*
69132 ** Return the current time for a statement
 
 
 
 
69133 */
69134 SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){
69135 Vdbe *v = p->pVdbe;
69136 int rc;
69137 if( v->iCurrentTime==0 ){
69138 rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, &v->iCurrentTime);
69139 if( rc ) v->iCurrentTime = 0;
 
 
 
 
 
 
 
69140 }
69141 return v->iCurrentTime;
69142 }
69143
69144 /*
69145 ** The following is the implementation of an SQL function that always
69146 ** fails with an error message stating that the function is used in the
@@ -69187,11 +69490,11 @@
69187 /*
69188 ** Allocate or return the aggregate context for a user function. A new
69189 ** context is allocated on the first call. Subsequent calls return the
69190 ** same context that was returned on prior calls.
69191 */
69192 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
69193 assert( p && p->pFunc && p->pFunc->xStep );
69194 assert( sqlite3_mutex_held(p->pOut->db->mutex) );
69195 testcase( nByte<0 );
69196 if( (p->pMem->flags & MEM_Agg)==0 ){
69197 return createAggContext(p, nByte);
@@ -69202,14 +69505,19 @@
69202
69203 /*
69204 ** Return the auxiliary data pointer, if any, for the iArg'th argument to
69205 ** the user-function defined by pCtx.
69206 */
69207 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
69208 AuxData *pAuxData;
69209
69210 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
 
 
 
 
 
69211 for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
69212 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
69213 }
69214
69215 return (pAuxData ? pAuxData->pAux : 0);
@@ -69218,11 +69526,11 @@
69218 /*
69219 ** Set the auxiliary data pointer and delete function, for the iArg'th
69220 ** argument to the user-function defined by pCtx. Any previous value is
69221 ** deleted by calling the delete function specified when it was set.
69222 */
69223 SQLITE_API void sqlite3_set_auxdata(
69224 sqlite3_context *pCtx,
69225 int iArg,
69226 void *pAux,
69227 void (*xDelete)(void*)
69228 ){
@@ -69229,10 +69537,15 @@
69229 AuxData *pAuxData;
69230 Vdbe *pVdbe = pCtx->pVdbe;
69231
69232 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69233 if( iArg<0 ) goto failed;
 
 
 
 
 
69234
69235 for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
69236 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
69237 }
69238 if( pAuxData==0 ){
@@ -69268,29 +69581,29 @@
69268 ** This function is deprecated. Do not use it for new code. It is
69269 ** provide only to avoid breaking legacy code. New aggregate function
69270 ** implementations should keep their own counts within their aggregate
69271 ** context.
69272 */
69273 SQLITE_API int sqlite3_aggregate_count(sqlite3_context *p){
69274 assert( p && p->pMem && p->pFunc && p->pFunc->xStep );
69275 return p->pMem->n;
69276 }
69277 #endif
69278
69279 /*
69280 ** Return the number of columns in the result set for the statement pStmt.
69281 */
69282 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt){
69283 Vdbe *pVm = (Vdbe *)pStmt;
69284 return pVm ? pVm->nResColumn : 0;
69285 }
69286
69287 /*
69288 ** Return the number of values available from the current row of the
69289 ** currently executing statement pStmt.
69290 */
69291 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt){
69292 Vdbe *pVm = (Vdbe *)pStmt;
69293 if( pVm==0 || pVm->pResultSet==0 ) return 0;
69294 return pVm->nResColumn;
69295 }
69296
@@ -69388,67 +69701,67 @@
69388
69389 /**************************** sqlite3_column_ *******************************
69390 ** The following routines are used to access elements of the current row
69391 ** in the result set.
69392 */
69393 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt *pStmt, int i){
69394 const void *val;
69395 val = sqlite3_value_blob( columnMem(pStmt,i) );
69396 /* Even though there is no encoding conversion, value_blob() might
69397 ** need to call malloc() to expand the result of a zeroblob()
69398 ** expression.
69399 */
69400 columnMallocFailure(pStmt);
69401 return val;
69402 }
69403 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){
69404 int val = sqlite3_value_bytes( columnMem(pStmt,i) );
69405 columnMallocFailure(pStmt);
69406 return val;
69407 }
69408 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){
69409 int val = sqlite3_value_bytes16( columnMem(pStmt,i) );
69410 columnMallocFailure(pStmt);
69411 return val;
69412 }
69413 SQLITE_API double sqlite3_column_double(sqlite3_stmt *pStmt, int i){
69414 double val = sqlite3_value_double( columnMem(pStmt,i) );
69415 columnMallocFailure(pStmt);
69416 return val;
69417 }
69418 SQLITE_API int sqlite3_column_int(sqlite3_stmt *pStmt, int i){
69419 int val = sqlite3_value_int( columnMem(pStmt,i) );
69420 columnMallocFailure(pStmt);
69421 return val;
69422 }
69423 SQLITE_API sqlite_int64 sqlite3_column_int64(sqlite3_stmt *pStmt, int i){
69424 sqlite_int64 val = sqlite3_value_int64( columnMem(pStmt,i) );
69425 columnMallocFailure(pStmt);
69426 return val;
69427 }
69428 SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt *pStmt, int i){
69429 const unsigned char *val = sqlite3_value_text( columnMem(pStmt,i) );
69430 columnMallocFailure(pStmt);
69431 return val;
69432 }
69433 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt *pStmt, int i){
69434 Mem *pOut = columnMem(pStmt, i);
69435 if( pOut->flags&MEM_Static ){
69436 pOut->flags &= ~MEM_Static;
69437 pOut->flags |= MEM_Ephem;
69438 }
69439 columnMallocFailure(pStmt);
69440 return (sqlite3_value *)pOut;
69441 }
69442 #ifndef SQLITE_OMIT_UTF16
69443 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt *pStmt, int i){
69444 const void *val = sqlite3_value_text16( columnMem(pStmt,i) );
69445 columnMallocFailure(pStmt);
69446 return val;
69447 }
69448 #endif /* SQLITE_OMIT_UTF16 */
69449 SQLITE_API int sqlite3_column_type(sqlite3_stmt *pStmt, int i){
69450 int iType = sqlite3_value_type( columnMem(pStmt,i) );
69451 columnMallocFailure(pStmt);
69452 return iType;
69453 }
69454
@@ -69508,16 +69821,16 @@
69508
69509 /*
69510 ** Return the name of the Nth column of the result set returned by SQL
69511 ** statement pStmt.
69512 */
69513 SQLITE_API const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){
69514 return columnName(
69515 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_NAME);
69516 }
69517 #ifndef SQLITE_OMIT_UTF16
69518 SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
69519 return columnName(
69520 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_NAME);
69521 }
69522 #endif
69523
@@ -69533,16 +69846,16 @@
69533 #ifndef SQLITE_OMIT_DECLTYPE
69534 /*
69535 ** Return the column declaration type (if applicable) of the 'i'th column
69536 ** of the result set of SQL statement pStmt.
69537 */
69538 SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){
69539 return columnName(
69540 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DECLTYPE);
69541 }
69542 #ifndef SQLITE_OMIT_UTF16
69543 SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
69544 return columnName(
69545 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DECLTYPE);
69546 }
69547 #endif /* SQLITE_OMIT_UTF16 */
69548 #endif /* SQLITE_OMIT_DECLTYPE */
@@ -69551,16 +69864,16 @@
69551 /*
69552 ** Return the name of the database from which a result column derives.
69553 ** NULL is returned if the result column is an expression or constant or
69554 ** anything else which is not an unambiguous reference to a database column.
69555 */
69556 SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){
69557 return columnName(
69558 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DATABASE);
69559 }
69560 #ifndef SQLITE_OMIT_UTF16
69561 SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){
69562 return columnName(
69563 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DATABASE);
69564 }
69565 #endif /* SQLITE_OMIT_UTF16 */
69566
@@ -69567,16 +69880,16 @@
69567 /*
69568 ** Return the name of the table from which a result column derives.
69569 ** NULL is returned if the result column is an expression or constant or
69570 ** anything else which is not an unambiguous reference to a database column.
69571 */
69572 SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){
69573 return columnName(
69574 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_TABLE);
69575 }
69576 #ifndef SQLITE_OMIT_UTF16
69577 SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){
69578 return columnName(
69579 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_TABLE);
69580 }
69581 #endif /* SQLITE_OMIT_UTF16 */
69582
@@ -69583,16 +69896,16 @@
69583 /*
69584 ** Return the name of the table column from which a result column derives.
69585 ** NULL is returned if the result column is an expression or constant or
69586 ** anything else which is not an unambiguous reference to a database column.
69587 */
69588 SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){
69589 return columnName(
69590 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_COLUMN);
69591 }
69592 #ifndef SQLITE_OMIT_UTF16
69593 SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){
69594 return columnName(
69595 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN);
69596 }
69597 #endif /* SQLITE_OMIT_UTF16 */
69598 #endif /* SQLITE_ENABLE_COLUMN_METADATA */
@@ -69689,20 +70002,20 @@
69689
69690
69691 /*
69692 ** Bind a blob value to an SQL statement variable.
69693 */
69694 SQLITE_API int sqlite3_bind_blob(
69695 sqlite3_stmt *pStmt,
69696 int i,
69697 const void *zData,
69698 int nData,
69699 void (*xDel)(void*)
69700 ){
69701 return bindText(pStmt, i, zData, nData, xDel, 0);
69702 }
69703 SQLITE_API int sqlite3_bind_blob64(
69704 sqlite3_stmt *pStmt,
69705 int i,
69706 const void *zData,
69707 sqlite3_uint64 nData,
69708 void (*xDel)(void*)
@@ -69712,52 +70025,52 @@
69712 return invokeValueDestructor(zData, xDel, 0);
69713 }else{
69714 return bindText(pStmt, i, zData, (int)nData, xDel, 0);
69715 }
69716 }
69717 SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
69718 int rc;
69719 Vdbe *p = (Vdbe *)pStmt;
69720 rc = vdbeUnbind(p, i);
69721 if( rc==SQLITE_OK ){
69722 sqlite3VdbeMemSetDouble(&p->aVar[i-1], rValue);
69723 sqlite3_mutex_leave(p->db->mutex);
69724 }
69725 return rc;
69726 }
69727 SQLITE_API int sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){
69728 return sqlite3_bind_int64(p, i, (i64)iValue);
69729 }
69730 SQLITE_API int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){
69731 int rc;
69732 Vdbe *p = (Vdbe *)pStmt;
69733 rc = vdbeUnbind(p, i);
69734 if( rc==SQLITE_OK ){
69735 sqlite3VdbeMemSetInt64(&p->aVar[i-1], iValue);
69736 sqlite3_mutex_leave(p->db->mutex);
69737 }
69738 return rc;
69739 }
69740 SQLITE_API int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
69741 int rc;
69742 Vdbe *p = (Vdbe*)pStmt;
69743 rc = vdbeUnbind(p, i);
69744 if( rc==SQLITE_OK ){
69745 sqlite3_mutex_leave(p->db->mutex);
69746 }
69747 return rc;
69748 }
69749 SQLITE_API int sqlite3_bind_text(
69750 sqlite3_stmt *pStmt,
69751 int i,
69752 const char *zData,
69753 int nData,
69754 void (*xDel)(void*)
69755 ){
69756 return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);
69757 }
69758 SQLITE_API int sqlite3_bind_text64(
69759 sqlite3_stmt *pStmt,
69760 int i,
69761 const char *zData,
69762 sqlite3_uint64 nData,
69763 void (*xDel)(void*),
@@ -69770,21 +70083,21 @@
69770 if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
69771 return bindText(pStmt, i, zData, (int)nData, xDel, enc);
69772 }
69773 }
69774 #ifndef SQLITE_OMIT_UTF16
69775 SQLITE_API int sqlite3_bind_text16(
69776 sqlite3_stmt *pStmt,
69777 int i,
69778 const void *zData,
69779 int nData,
69780 void (*xDel)(void*)
69781 ){
69782 return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);
69783 }
69784 #endif /* SQLITE_OMIT_UTF16 */
69785 SQLITE_API int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
69786 int rc;
69787 switch( sqlite3_value_type((sqlite3_value*)pValue) ){
69788 case SQLITE_INTEGER: {
69789 rc = sqlite3_bind_int64(pStmt, i, pValue->u.i);
69790 break;
@@ -69811,11 +70124,11 @@
69811 break;
69812 }
69813 }
69814 return rc;
69815 }
69816 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
69817 int rc;
69818 Vdbe *p = (Vdbe *)pStmt;
69819 rc = vdbeUnbind(p, i);
69820 if( rc==SQLITE_OK ){
69821 sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n);
@@ -69826,11 +70139,11 @@
69826
69827 /*
69828 ** Return the number of wildcards that can be potentially bound to.
69829 ** This routine is added to support DBD::SQLite.
69830 */
69831 SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){
69832 Vdbe *p = (Vdbe*)pStmt;
69833 return p ? p->nVar : 0;
69834 }
69835
69836 /*
@@ -69837,11 +70150,11 @@
69837 ** Return the name of a wildcard parameter. Return NULL if the index
69838 ** is out of range or if the wildcard is unnamed.
69839 **
69840 ** The result is always UTF-8.
69841 */
69842 SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){
69843 Vdbe *p = (Vdbe*)pStmt;
69844 if( p==0 || i<1 || i>p->nzVar ){
69845 return 0;
69846 }
69847 return p->azVar[i-1];
@@ -69865,11 +70178,11 @@
69865 }
69866 }
69867 }
69868 return 0;
69869 }
69870 SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){
69871 return sqlite3VdbeParameterIndex((Vdbe*)pStmt, zName, sqlite3Strlen30(zName));
69872 }
69873
69874 /*
69875 ** Transfer all bindings from the first statement over to the second.
@@ -69899,11 +70212,11 @@
69899 **
69900 ** If the two statements contain a different number of bindings, then
69901 ** an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise
69902 ** SQLITE_OK is returned.
69903 */
69904 SQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
69905 Vdbe *pFrom = (Vdbe*)pFromStmt;
69906 Vdbe *pTo = (Vdbe*)pToStmt;
69907 if( pFrom->nVar!=pTo->nVar ){
69908 return SQLITE_ERROR;
69909 }
@@ -69921,26 +70234,26 @@
69921 ** Return the sqlite3* database handle to which the prepared statement given
69922 ** in the argument belongs. This is the same database handle that was
69923 ** the first argument to the sqlite3_prepare() that was used to create
69924 ** the statement in the first place.
69925 */
69926 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt *pStmt){
69927 return pStmt ? ((Vdbe*)pStmt)->db : 0;
69928 }
69929
69930 /*
69931 ** Return true if the prepared statement is guaranteed to not modify the
69932 ** database.
69933 */
69934 SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt){
69935 return pStmt ? ((Vdbe*)pStmt)->readOnly : 1;
69936 }
69937
69938 /*
69939 ** Return true if the prepared statement is in need of being reset.
69940 */
69941 SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *pStmt){
69942 Vdbe *v = (Vdbe*)pStmt;
69943 return v!=0 && v->pc>=0 && v->magic==VDBE_MAGIC_RUN;
69944 }
69945
69946 /*
@@ -69947,11 +70260,11 @@
69947 ** Return a pointer to the next prepared statement after pStmt associated
69948 ** with database connection pDb. If pStmt is NULL, return the first
69949 ** prepared statement for the database connection. Return NULL if there
69950 ** are no more.
69951 */
69952 SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){
69953 sqlite3_stmt *pNext;
69954 #ifdef SQLITE_ENABLE_API_ARMOR
69955 if( !sqlite3SafetyCheckOk(pDb) ){
69956 (void)SQLITE_MISUSE_BKPT;
69957 return 0;
@@ -69968,11 +70281,11 @@
69968 }
69969
69970 /*
69971 ** Return the value of a status counter for a prepared statement
69972 */
69973 SQLITE_API int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
69974 Vdbe *pVdbe = (Vdbe*)pStmt;
69975 u32 v;
69976 #ifdef SQLITE_ENABLE_API_ARMOR
69977 if( !pStmt ){
69978 (void)SQLITE_MISUSE_BKPT;
@@ -69986,11 +70299,11 @@
69986
69987 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
69988 /*
69989 ** Return status data for a single loop within query pStmt.
69990 */
69991 SQLITE_API int sqlite3_stmt_scanstatus(
69992 sqlite3_stmt *pStmt, /* Prepared statement being queried */
69993 int idx, /* Index of loop to report on */
69994 int iScanStatusOp, /* Which metric to return */
69995 void *pOut /* OUT: Write the answer here */
69996 ){
@@ -70045,11 +70358,11 @@
70045 }
70046
70047 /*
70048 ** Zero all counters associated with the sqlite3_stmt_scanstatus() data.
70049 */
70050 SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){
70051 Vdbe *p = (Vdbe*)pStmt;
70052 memset(p->anExec, 0, p->nOp * sizeof(i64));
70053 }
70054 #endif /* SQLITE_ENABLE_STMT_SCANSTATUS */
70055
@@ -70544,11 +70857,11 @@
70544 ** Try to convert the type of a function argument or a result column
70545 ** into a numeric representation. Use either INTEGER or REAL whichever
70546 ** is appropriate. But only do the conversion if it is possible without
70547 ** loss of information and return the revised type of the argument.
70548 */
70549 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){
70550 int eType = sqlite3_value_type(pVal);
70551 if( eType==SQLITE_TEXT ){
70552 Mem *pMem = (Mem*)pVal;
70553 applyNumericAffinity(pMem, 0);
70554 eType = sqlite3_value_type(pVal);
@@ -71845,11 +72158,11 @@
71845 ** max() aggregate will set to 1 if the current row is not the minimum or
71846 ** maximum. The P1 register is initialized to 0 by this instruction.
71847 **
71848 ** The interface used by the implementation of the aforementioned functions
71849 ** to retrieve the collation sequence set by this opcode is not available
71850 ** publicly, only to user functions defined in func.c.
71851 */
71852 case OP_CollSeq: {
71853 assert( pOp->p4type==P4_COLLSEQ );
71854 if( pOp->p1 ){
71855 sqlite3VdbeMemSetInt64(&aMem[pOp->p1], 0);
@@ -73563,35 +73876,33 @@
73563 ** cursors or a single read/write cursor but not both.
73564 **
73565 ** See also OpenRead.
73566 */
73567 case OP_ReopenIdx: {
73568 VdbeCursor *pCur;
73569
73570 assert( pOp->p5==0 );
73571 assert( pOp->p4type==P4_KEYINFO );
73572 pCur = p->apCsr[pOp->p1];
73573 if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){
73574 assert( pCur->iDb==pOp->p3 ); /* Guaranteed by the code generator */
73575 break;
73576 }
73577 /* If the cursor is not currently open or is open on a different
73578 ** index, then fall through into OP_OpenRead to force a reopen */
73579 }
73580 case OP_OpenRead:
73581 case OP_OpenWrite: {
73582 int nField;
73583 KeyInfo *pKeyInfo;
73584 int p2;
73585 int iDb;
73586 int wrFlag;
73587 Btree *pX;
73588 VdbeCursor *pCur;
73589 Db *pDb;
73590
73591 assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR))==pOp->p5 );
73592 assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 );
 
 
 
 
 
 
 
 
 
 
 
 
73593 assert( p->bIsReader );
73594 assert( pOp->opcode==OP_OpenRead || pOp->opcode==OP_ReopenIdx
73595 || p->readOnly==0 );
73596
73597 if( p->expired ){
@@ -73650,18 +73961,21 @@
73650 pCur->nullRow = 1;
73651 pCur->isOrdered = 1;
73652 pCur->pgnoRoot = p2;
73653 rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur->pCursor);
73654 pCur->pKeyInfo = pKeyInfo;
73655 assert( OPFLAG_BULKCSR==BTREE_BULKLOAD );
73656 sqlite3BtreeCursorHints(pCur->pCursor, (pOp->p5 & OPFLAG_BULKCSR));
73657
73658 /* Set the VdbeCursor.isTable variable. Previous versions of
73659 ** SQLite used to check if the root-page flags were sane at this point
73660 ** and report database corruption if they were not, but this check has
73661 ** since moved into the btree layer. */
73662 pCur->isTable = pOp->p4type!=P4_KEYINFO;
 
 
 
 
 
 
73663 break;
73664 }
73665
73666 /* Opcode: OpenEphemeral P1 P2 * P4 P5
73667 ** Synopsis: nColumn=P2
@@ -73918,10 +74232,26 @@
73918 oc = pOp->opcode;
73919 pC->nullRow = 0;
73920 #ifdef SQLITE_DEBUG
73921 pC->seekOp = pOp->opcode;
73922 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73923 if( pC->isTable ){
73924 /* The input value in P3 might be of any type: integer, real, string,
73925 ** blob, or NULL. But it needs to be an integer before we can do
73926 ** the seek, so convert it. */
73927 pIn3 = &aMem[pOp->p3];
@@ -75257,34 +75587,19 @@
75257 **
75258 ** See also: Clear
75259 */
75260 case OP_Destroy: { /* out2-prerelease */
75261 int iMoved;
75262 int iCnt;
75263 Vdbe *pVdbe;
75264 int iDb;
75265
75266 assert( p->readOnly==0 );
75267 #ifndef SQLITE_OMIT_VIRTUALTABLE
75268 iCnt = 0;
75269 for(pVdbe=db->pVdbe; pVdbe; pVdbe = pVdbe->pNext){
75270 if( pVdbe->magic==VDBE_MAGIC_RUN && pVdbe->bIsReader
75271 && pVdbe->inVtabMethod<2 && pVdbe->pc>=0
75272 ){
75273 iCnt++;
75274 }
75275 }
75276 #else
75277 iCnt = db->nVdbeRead;
75278 #endif
75279 pOut->flags = MEM_Null;
75280 if( iCnt>1 ){
75281 rc = SQLITE_LOCKED;
75282 p->errorAction = OE_Abort;
75283 }else{
75284 iDb = pOp->p3;
75285 assert( iCnt==1 );
75286 assert( DbMaskTest(p->btreeMask, iDb) );
75287 iMoved = 0; /* Not needed. Only to silence a warning. */
75288 rc = sqlite3BtreeDropTable(db->aDb[iDb].pBt, pOp->p1, &iMoved);
75289 pOut->flags = MEM_Int;
75290 pOut->u.i = iMoved;
@@ -76337,17 +76652,33 @@
76337 break;
76338 }
76339 #endif /* SQLITE_OMIT_VIRTUALTABLE */
76340
76341 #ifndef SQLITE_OMIT_VIRTUALTABLE
76342 /* Opcode: VCreate P1 * * P4 *
76343 **
76344 ** P4 is the name of a virtual table in database P1. Call the xCreate method
76345 ** for that table.
76346 */
76347 case OP_VCreate: {
76348 rc = sqlite3VtabCallCreate(db, pOp->p1, pOp->p4.z, &p->zErrMsg);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76349 break;
76350 }
76351 #endif /* SQLITE_OMIT_VIRTUALTABLE */
76352
76353 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -76355,13 +76686,13 @@
76355 **
76356 ** P4 is the name of a virtual table in database P1. Call the xDestroy method
76357 ** of that table.
76358 */
76359 case OP_VDestroy: {
76360 p->inVtabMethod = 2;
76361 rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z);
76362 p->inVtabMethod = 0;
76363 break;
76364 }
76365 #endif /* SQLITE_OMIT_VIRTUALTABLE */
76366
76367 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -76373,18 +76704,21 @@
76373 */
76374 case OP_VOpen: {
76375 VdbeCursor *pCur;
76376 sqlite3_vtab_cursor *pVtabCursor;
76377 sqlite3_vtab *pVtab;
76378 sqlite3_module *pModule;
76379
76380 assert( p->bIsReader );
76381 pCur = 0;
76382 pVtabCursor = 0;
76383 pVtab = pOp->p4.pVtab->pVtab;
76384 pModule = (sqlite3_module *)pVtab->pModule;
76385 assert(pVtab && pModule);
 
 
 
76386 rc = pModule->xOpen(pVtab, &pVtabCursor);
76387 sqlite3VtabImportErrmsg(p, pVtab);
76388 if( SQLITE_OK==rc ){
76389 /* Initialize sqlite3_vtab_cursor base class */
76390 pVtabCursor->pVtab = pVtab;
@@ -76391,10 +76725,11 @@
76391
76392 /* Initialize vdbe cursor object */
76393 pCur = allocateCursor(p, pOp->p1, 0, -1, 0);
76394 if( pCur ){
76395 pCur->pVtabCursor = pVtabCursor;
 
76396 }else{
76397 db->mallocFailed = 1;
76398 pModule->xClose(pVtabCursor);
76399 }
76400 }
@@ -76456,13 +76791,11 @@
76456 apArg = p->apArg;
76457 for(i = 0; i<nArg; i++){
76458 apArg[i] = &pArgc[i+1];
76459 }
76460
76461 p->inVtabMethod = 1;
76462 rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg);
76463 p->inVtabMethod = 0;
76464 sqlite3VtabImportErrmsg(p, pVtab);
76465 if( rc==SQLITE_OK ){
76466 res = pModule->xEof(pVtabCursor);
76467 }
76468 VdbeBranchTaken(res!=0,2);
@@ -76548,13 +76881,11 @@
76548 ** underlying implementation to return an error if one occurs during
76549 ** xNext(). Instead, if an error occurs, true is returned (indicating that
76550 ** data is available) and the error code returned when xColumn or
76551 ** some other method is next invoked on the save virtual table cursor.
76552 */
76553 p->inVtabMethod = 1;
76554 rc = pModule->xNext(pCur->pVtabCursor);
76555 p->inVtabMethod = 0;
76556 sqlite3VtabImportErrmsg(p, pVtab);
76557 if( rc==SQLITE_OK ){
76558 res = pModule->xEof(pCur->pVtabCursor);
76559 }
76560 VdbeBranchTaken(!res,2);
@@ -76625,11 +76956,11 @@
76625 ** P5 is the error actions (OE_Replace, OE_Fail, OE_Ignore, etc) to
76626 ** apply in the case of a constraint failure on an insert or update.
76627 */
76628 case OP_VUpdate: {
76629 sqlite3_vtab *pVtab;
76630 sqlite3_module *pModule;
76631 int nArg;
76632 int i;
76633 sqlite_int64 rowid;
76634 Mem **apArg;
76635 Mem *pX;
@@ -76637,11 +76968,15 @@
76637 assert( pOp->p2==1 || pOp->p5==OE_Fail || pOp->p5==OE_Rollback
76638 || pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace
76639 );
76640 assert( p->readOnly==0 );
76641 pVtab = pOp->p4.pVtab->pVtab;
76642 pModule = (sqlite3_module *)pVtab->pModule;
 
 
 
 
76643 nArg = pOp->p2;
76644 assert( pOp->p4type==P4_VTAB );
76645 if( ALWAYS(pModule->xUpdate) ){
76646 u8 vtabOnConflict = db->vtabOnConflict;
76647 apArg = p->apArg;
@@ -76984,11 +77319,11 @@
76984 }
76985
76986 /*
76987 ** Open a blob handle.
76988 */
76989 SQLITE_API int sqlite3_blob_open(
76990 sqlite3* db, /* The database connection */
76991 const char *zDb, /* The attached database containing the blob */
76992 const char *zTable, /* The table containing the blob */
76993 const char *zColumn, /* The column containing the blob */
76994 sqlite_int64 iRow, /* The row containing the glob */
@@ -77221,11 +77556,11 @@
77221
77222 /*
77223 ** Close a blob handle that was previously created using
77224 ** sqlite3_blob_open().
77225 */
77226 SQLITE_API int sqlite3_blob_close(sqlite3_blob *pBlob){
77227 Incrblob *p = (Incrblob *)pBlob;
77228 int rc;
77229 sqlite3 *db;
77230
77231 if( p ){
@@ -77290,28 +77625,28 @@
77290 }
77291
77292 /*
77293 ** Read data from a blob handle.
77294 */
77295 SQLITE_API int sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){
77296 return blobReadWrite(pBlob, z, n, iOffset, sqlite3BtreeData);
77297 }
77298
77299 /*
77300 ** Write data to a blob handle.
77301 */
77302 SQLITE_API int sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){
77303 return blobReadWrite(pBlob, (void *)z, n, iOffset, sqlite3BtreePutData);
77304 }
77305
77306 /*
77307 ** Query a blob handle for the size of the data.
77308 **
77309 ** The Incrblob.nByte field is fixed for the lifetime of the Incrblob
77310 ** so no mutex is required for access.
77311 */
77312 SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *pBlob){
77313 Incrblob *p = (Incrblob *)pBlob;
77314 return (p && p->pStmt) ? p->nByte : 0;
77315 }
77316
77317 /*
@@ -77322,11 +77657,11 @@
77322 ** contain a blob or text value, then an error code is returned and the
77323 ** database handle error code and message set. If this happens, then all
77324 ** subsequent calls to sqlite3_blob_xxx() functions (except blob_close())
77325 ** immediately return SQLITE_ABORT.
77326 */
77327 SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
77328 int rc;
77329 Incrblob *p = (Incrblob *)pBlob;
77330 sqlite3 *db;
77331
77332 if( p==0 ) return SQLITE_MISUSE_BKPT;
@@ -78507,10 +78842,11 @@
78507 sqlite3 *db, /* Database handle doing sort */
78508 i64 nExtend, /* Attempt to extend file to this size */
78509 sqlite3_file **ppFd
78510 ){
78511 int rc;
 
78512 rc = sqlite3OsOpenMalloc(db->pVfs, 0, ppFd,
78513 SQLITE_OPEN_TEMP_JOURNAL |
78514 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |
78515 SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE, &rc
78516 );
@@ -82098,14 +82434,15 @@
82098 ** and the pExpr parameter is returned unchanged.
82099 */
82100 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(
82101 Parse *pParse, /* Parsing context */
82102 Expr *pExpr, /* Add the "COLLATE" clause to this expression */
82103 const Token *pCollName /* Name of collating sequence */
 
82104 ){
82105 if( pCollName->n>0 ){
82106 Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, 1);
82107 if( pNew ){
82108 pNew->pLeft = pExpr;
82109 pNew->flags |= EP_Collate|EP_Skip;
82110 pExpr = pNew;
82111 }
@@ -82115,11 +82452,11 @@
82115 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse *pParse, Expr *pExpr, const char *zC){
82116 Token s;
82117 assert( zC!=0 );
82118 s.z = zC;
82119 s.n = sqlite3Strlen30(s.z);
82120 return sqlite3ExprAddCollateToken(pParse, pExpr, &s);
82121 }
82122
82123 /*
82124 ** Skip over any TK_COLLATE or TK_AS operators and any unlikely()
82125 ** or likelihood() function at the root of an expression.
@@ -82425,10 +82762,11 @@
82425 **
82426 ** Also propagate all EP_Propagate flags from the Expr.x.pList into
82427 ** Expr.flags.
82428 */
82429 SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){
 
82430 exprSetHeight(p);
82431 sqlite3ExprCheckHeight(pParse, p->nHeight);
82432 }
82433
82434 /*
@@ -87139,11 +87477,14 @@
87139 /* Ensure the default expression is something that sqlite3ValueFromExpr()
87140 ** can handle (i.e. not CURRENT_TIME etc.)
87141 */
87142 if( pDflt ){
87143 sqlite3_value *pVal = 0;
87144 if( sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal) ){
 
 
 
87145 db->mallocFailed = 1;
87146 return;
87147 }
87148 if( !pVal ){
87149 sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default");
@@ -89824,11 +90165,11 @@
89824 ** and attempts to write the column will be ignored.
89825 **
89826 ** Setting the auth function to NULL disables this hook. The default
89827 ** setting of the auth function is NULL.
89828 */
89829 SQLITE_API int sqlite3_set_authorizer(
89830 sqlite3 *db,
89831 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
89832 void *pArg
89833 ){
89834 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -93202,10 +93543,11 @@
93202 }
93203 if( pIdx->onError==OE_Default ){
93204 pIdx->onError = pIndex->onError;
93205 }
93206 }
 
93207 goto exit_create_index;
93208 }
93209 }
93210 }
93211
@@ -95661,11 +96003,13 @@
95661
95662 /*
95663 ** Return the collating function associated with a function.
95664 */
95665 static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){
95666 VdbeOp *pOp = &context->pVdbe->aOp[context->iOp-1];
 
 
95667 assert( pOp->opcode==OP_CollSeq );
95668 assert( pOp->p4type==P4_COLLSEQ );
95669 return pOp->p4.pColl;
95670 }
95671
@@ -96399,11 +96743,11 @@
96399 }
96400
96401 /*
96402 ** The sqlite3_strglob() interface.
96403 */
96404 SQLITE_API int sqlite3_strglob(const char *zGlobPattern, const char *zString){
96405 return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, 0)==0;
96406 }
96407
96408 /*
96409 ** Count the number of times that the LIKE operator (or GLOB which is
@@ -100894,11 +101238,11 @@
100894 ** If the SQL is a query, then for each row in the query result
100895 ** the xCallback() function is called. pArg becomes the first
100896 ** argument to xCallback(). If xCallback=NULL then no callback
100897 ** is invoked, even for queries.
100898 */
100899 SQLITE_API int sqlite3_exec(
100900 sqlite3 *db, /* The database on which the SQL executes */
100901 const char *zSql, /* The SQL to be executed */
100902 sqlite3_callback xCallback, /* Invoke this callback routine */
100903 void *pArg, /* First argument to xCallback() */
100904 char **pzErrMsg /* Write error messages here */
@@ -102089,11 +102433,11 @@
102089 db->aExtension = aHandle;
102090
102091 db->aExtension[db->nExtension++] = handle;
102092 return SQLITE_OK;
102093 }
102094 SQLITE_API int sqlite3_load_extension(
102095 sqlite3 *db, /* Load the extension into this database connection */
102096 const char *zFile, /* Name of the shared library containing extension */
102097 const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
102098 char **pzErrMsg /* Put error message here if not 0 */
102099 ){
@@ -102120,11 +102464,11 @@
102120
102121 /*
102122 ** Enable or disable extension loading. Extension loading is disabled by
102123 ** default so as not to open security holes in older applications.
102124 */
102125 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){
102126 sqlite3_mutex_enter(db->mutex);
102127 if( onoff ){
102128 db->flags |= SQLITE_LoadExtension;
102129 }else{
102130 db->flags &= ~SQLITE_LoadExtension;
@@ -102177,11 +102521,11 @@
102177
102178 /*
102179 ** Register a statically linked extension that is automatically
102180 ** loaded by every new database connection.
102181 */
102182 SQLITE_API int sqlite3_auto_extension(void (*xInit)(void)){
102183 int rc = SQLITE_OK;
102184 #ifndef SQLITE_OMIT_AUTOINIT
102185 rc = sqlite3_initialize();
102186 if( rc ){
102187 return rc;
@@ -102222,11 +102566,11 @@
102222 ** routine is a no-op.
102223 **
102224 ** Return 1 if xInit was found on the list and removed. Return 0 if xInit
102225 ** was not on the list.
102226 */
102227 SQLITE_API int sqlite3_cancel_auto_extension(void (*xInit)(void)){
102228 #if SQLITE_THREADSAFE
102229 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
102230 #endif
102231 int i;
102232 int n = 0;
@@ -102245,11 +102589,11 @@
102245 }
102246
102247 /*
102248 ** Reset the automatic extension loading mechanism.
102249 */
102250 SQLITE_API void sqlite3_reset_auto_extension(void){
102251 #ifndef SQLITE_OMIT_AUTOINIT
102252 if( sqlite3_initialize()==SQLITE_OK )
102253 #endif
102254 {
102255 #if SQLITE_THREADSAFE
@@ -105525,11 +105869,11 @@
105525 ** and so if a schema change occurs, SQLITE_SCHEMA is returned by
105526 ** sqlite3_step(). In the new version, the original SQL text is retained
105527 ** and the statement is automatically recompiled if an schema change
105528 ** occurs.
105529 */
105530 SQLITE_API int sqlite3_prepare(
105531 sqlite3 *db, /* Database handle. */
105532 const char *zSql, /* UTF-8 encoded SQL statement. */
105533 int nBytes, /* Length of zSql in bytes. */
105534 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105535 const char **pzTail /* OUT: End of parsed string */
@@ -105537,11 +105881,11 @@
105537 int rc;
105538 rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,0,ppStmt,pzTail);
105539 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
105540 return rc;
105541 }
105542 SQLITE_API int sqlite3_prepare_v2(
105543 sqlite3 *db, /* Database handle. */
105544 const char *zSql, /* UTF-8 encoded SQL statement. */
105545 int nBytes, /* Length of zSql in bytes. */
105546 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105547 const char **pzTail /* OUT: End of parsed string */
@@ -105613,11 +105957,11 @@
105613 ** and so if a schema change occurs, SQLITE_SCHEMA is returned by
105614 ** sqlite3_step(). In the new version, the original SQL text is retained
105615 ** and the statement is automatically recompiled if an schema change
105616 ** occurs.
105617 */
105618 SQLITE_API int sqlite3_prepare16(
105619 sqlite3 *db, /* Database handle. */
105620 const void *zSql, /* UTF-16 encoded SQL statement. */
105621 int nBytes, /* Length of zSql in bytes. */
105622 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105623 const void **pzTail /* OUT: End of parsed string */
@@ -105625,11 +105969,11 @@
105625 int rc;
105626 rc = sqlite3Prepare16(db,zSql,nBytes,0,ppStmt,pzTail);
105627 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
105628 return rc;
105629 }
105630 SQLITE_API int sqlite3_prepare16_v2(
105631 sqlite3 *db, /* Database handle. */
105632 const void *zSql, /* UTF-16 encoded SQL statement. */
105633 int nBytes, /* Length of zSql in bytes. */
105634 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105635 const void **pzTail /* OUT: End of parsed string */
@@ -109678,11 +110022,11 @@
109678 sqlite3WalkSelect(pWalker, bMayRecursive ? pSel->pPrior : pSel);
109679
109680 for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior);
109681 pEList = pLeft->pEList;
109682 if( pCte->pCols ){
109683 if( pEList->nExpr!=pCte->pCols->nExpr ){
109684 sqlite3ErrorMsg(pParse, "table %s has %d values for %d columns",
109685 pCte->zName, pEList->nExpr, pCte->pCols->nExpr
109686 );
109687 pParse->pWith = pSavedWith;
109688 return SQLITE_ERROR;
@@ -111361,11 +111705,11 @@
111361 ** The result that is written to ***pazResult is held in memory obtained
111362 ** from malloc(). But the caller cannot free this memory directly.
111363 ** Instead, the entire table should be passed to sqlite3_free_table() when
111364 ** the calling procedure is finished using it.
111365 */
111366 SQLITE_API int sqlite3_get_table(
111367 sqlite3 *db, /* The database on which the SQL executes */
111368 const char *zSql, /* The SQL to be executed */
111369 char ***pazResult, /* Write the result table here */
111370 int *pnRow, /* Write the number of rows in the result here */
111371 int *pnColumn, /* Write the number of columns of result here */
@@ -111430,11 +111774,11 @@
111430 }
111431
111432 /*
111433 ** This routine frees the space the sqlite3_get_table() malloced.
111434 */
111435 SQLITE_API void sqlite3_free_table(
111436 char **azResult /* Result returned from sqlite3_get_table() */
111437 ){
111438 if( azResult ){
111439 int i, n;
111440 azResult--;
@@ -113790,11 +114134,11 @@
113790
113791
113792 /*
113793 ** External API function used to create a new virtual-table module.
113794 */
113795 SQLITE_API int sqlite3_create_module(
113796 sqlite3 *db, /* Database in which module is registered */
113797 const char *zName, /* Name assigned to this module */
113798 const sqlite3_module *pModule, /* The definition of the module */
113799 void *pAux /* Context pointer for xCreate/xConnect */
113800 ){
@@ -113805,11 +114149,11 @@
113805 }
113806
113807 /*
113808 ** External API function used to create a new virtual-table module.
113809 */
113810 SQLITE_API int sqlite3_create_module_v2(
113811 sqlite3 *db, /* Database in which module is registered */
113812 const char *zName, /* Name assigned to this module */
113813 const sqlite3_module *pModule, /* The definition of the module */
113814 void *pAux, /* Context pointer for xCreate/xConnect */
113815 void (*xDestroy)(void *) /* Module destructor function */
@@ -114104,10 +114448,11 @@
114104 */
114105 if( !db->init.busy ){
114106 char *zStmt;
114107 char *zWhere;
114108 int iDb;
 
114109 Vdbe *v;
114110
114111 /* Compute the complete text of the CREATE VIRTUAL TABLE statement */
114112 if( pEnd ){
114113 pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n;
@@ -114138,12 +114483,14 @@
114138 sqlite3ChangeCookie(pParse, iDb);
114139
114140 sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
114141 zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
114142 sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
114143 sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0,
114144 pTab->zName, sqlite3Strlen30(pTab->zName) + 1);
 
 
114145 }
114146
114147 /* If we are rereading the sqlite_master table create the in-memory
114148 ** record of the table. The xConnect() method is not called until
114149 ** the first time the virtual table is used in an SQL statement. This
@@ -114417,11 +114764,11 @@
114417 /*
114418 ** This function is used to set the schema of a virtual table. It is only
114419 ** valid to call this function from within the xCreate() or xConnect() of a
114420 ** virtual table module.
114421 */
114422 SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
114423 Parse *pParse;
114424
114425 int rc = SQLITE_OK;
114426 Table *pTab;
114427 char *zErr = 0;
@@ -114492,15 +114839,19 @@
114492 int rc = SQLITE_OK;
114493 Table *pTab;
114494
114495 pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
114496 if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){
114497 VTable *p = vtabDisconnectAll(db, pTab);
114498
114499 assert( rc==SQLITE_OK );
 
 
 
 
 
114500 rc = p->pMod->pModule->xDestroy(p->pVtab);
114501
114502 /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */
114503 if( rc==SQLITE_OK ){
114504 assert( pTab->pVTable==p && p->pNext==0 );
114505 p->pVtab = 0;
114506 pTab->pVTable = 0;
@@ -114781,11 +115132,11 @@
114781 ** table update operation currently in progress.
114782 **
114783 ** The results of this routine are undefined unless it is called from
114784 ** within an xUpdate method.
114785 */
114786 SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *db){
114787 static const unsigned char aMap[] = {
114788 SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE
114789 };
114790 #ifdef SQLITE_ENABLE_API_ARMOR
114791 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -114799,11 +115150,11 @@
114799 /*
114800 ** Call from within the xCreate() or xConnect() methods to provide
114801 ** the SQLite core with additional information about the behavior
114802 ** of the virtual table being implemented.
114803 */
114804 SQLITE_API int sqlite3_vtab_config(sqlite3 *db, int op, ...){
114805 va_list ap;
114806 int rc = SQLITE_OK;
114807
114808 #ifdef SQLITE_ENABLE_API_ARMOR
114809 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -116078,10 +116429,83 @@
116078 static void markTermAsChild(WhereClause *pWC, int iChild, int iParent){
116079 pWC->a[iChild].iParent = iParent;
116080 pWC->a[iChild].truthProb = pWC->a[iParent].truthProb;
116081 pWC->a[iParent].nChild++;
116082 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116083
116084 #if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)
116085 /*
116086 ** Analyze a term that consists of two or more OR-connected
116087 ** subterms. So in:
@@ -116103,10 +116527,11 @@
116103 ** (A) t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5
116104 ** (B) x=expr1 OR expr2=x OR x=expr3
116105 ** (C) t1.x=t2.y OR (t1.x=t2.z AND t1.y=15)
116106 ** (D) x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*')
116107 ** (E) (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6)
 
116108 **
116109 ** CASE 1:
116110 **
116111 ** If all subterms are of the form T.C=expr for some single column of C and
116112 ** a single table T (as shown in example B above) then create a new virtual
@@ -116118,10 +116543,20 @@
116118 ** then create a new virtual term like this:
116119 **
116120 ** x IN (expr1,expr2,expr3)
116121 **
116122 ** CASE 2:
 
 
 
 
 
 
 
 
 
 
116123 **
116124 ** If all subterms are indexable by a single table T, then set
116125 **
116126 ** WhereTerm.eOperator = WO_OR
116127 ** WhereTerm.u.pOrInfo->indexable |= the cursor number for table T
@@ -116245,15 +116680,29 @@
116245 }
116246 }
116247 }
116248
116249 /*
116250 ** Record the set of tables that satisfy case 2. The set might be
116251 ** empty.
116252 */
116253 pOrInfo->indexable = indexable;
116254 pTerm->eOperator = indexable==0 ? 0 : WO_OR;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116255
116256 /*
116257 ** chngToIN holds a set of tables that *might* satisfy case 1. But
116258 ** we have to do some additional checking to see if case 1 really
116259 ** is satisfied.
@@ -116380,11 +116829,11 @@
116380 pTerm = &pWC->a[idxTerm];
116381 markTermAsChild(pWC, idxNew, idxTerm);
116382 }else{
116383 sqlite3ExprListDelete(db, pList);
116384 }
116385 pTerm->eOperator = WO_NOOP; /* case 1 trumps case 2 */
116386 }
116387 }
116388 }
116389 #endif /* !SQLITE_OMIT_OR_OPTIMIZATION && !SQLITE_OMIT_SUBQUERY */
116390
@@ -116575,11 +117024,11 @@
116575 Expr *pStr2; /* Copy of pStr1 - RHS of LIKE/GLOB operator */
116576 Expr *pNewExpr1;
116577 Expr *pNewExpr2;
116578 int idxNew1;
116579 int idxNew2;
116580 Token sCollSeqName; /* Name of collating sequence */
116581 const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC;
116582
116583 pLeft = pExpr->x.pList->a[1].pExpr;
116584 pStr2 = sqlite3ExprDup(db, pStr1, 0);
116585
@@ -116611,23 +117060,22 @@
116611 if( c=='A'-1 ) isComplete = 0;
116612 c = sqlite3UpperToLower[c];
116613 }
116614 *pC = c + 1;
116615 }
116616 sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
116617 sCollSeqName.n = 6;
116618 pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);
116619 pNewExpr1 = sqlite3PExpr(pParse, TK_GE,
116620 sqlite3ExprAddCollateToken(pParse,pNewExpr1,&sCollSeqName),
116621 pStr1, 0);
116622 transferJoinMarkings(pNewExpr1, pExpr);
116623 idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags);
116624 testcase( idxNew1==0 );
116625 exprAnalyze(pSrc, pWC, idxNew1);
116626 pNewExpr2 = sqlite3ExprDup(db, pLeft, 0);
116627 pNewExpr2 = sqlite3PExpr(pParse, TK_LT,
116628 sqlite3ExprAddCollateToken(pParse,pNewExpr2,&sCollSeqName),
116629 pStr2, 0);
116630 transferJoinMarkings(pNewExpr2, pExpr);
116631 idxNew2 = whereClauseInsert(pWC, pNewExpr2, wtFlags);
116632 testcase( idxNew2==0 );
116633 exprAnalyze(pSrc, pWC, idxNew2);
@@ -117240,15 +117688,18 @@
117240 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
117241 /*
117242 ** Estimate the location of a particular key among all keys in an
117243 ** index. Store the results in aStat as follows:
117244 **
117245 ** aStat[0] Est. number of rows less than pVal
117246 ** aStat[1] Est. number of rows equal to pVal
117247 **
117248 ** Return the index of the sample that is the smallest sample that
117249 ** is greater than or equal to pRec.
 
 
 
117250 */
117251 static int whereKeyStats(
117252 Parse *pParse, /* Database connection */
117253 Index *pIdx, /* Index to consider domain of */
117254 UnpackedRecord *pRec, /* Vector of values to consider */
@@ -117255,71 +117706,162 @@
117255 int roundUp, /* Round up if true. Round down if false */
117256 tRowcnt *aStat /* OUT: stats written here */
117257 ){
117258 IndexSample *aSample = pIdx->aSample;
117259 int iCol; /* Index of required stats in anEq[] etc. */
 
 
117260 int iMin = 0; /* Smallest sample not yet tested */
117261 int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
117262 int iTest; /* Next sample to test */
117263 int res; /* Result of comparison operation */
 
 
117264
117265 #ifndef SQLITE_DEBUG
117266 UNUSED_PARAMETER( pParse );
117267 #endif
117268 assert( pRec!=0 );
117269 iCol = pRec->nField - 1;
117270 assert( pIdx->nSample>0 );
117271 assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117272 do{
117273 iTest = (iMin+i)/2;
117274 res = sqlite3VdbeRecordCompare(aSample[iTest].n, aSample[iTest].p, pRec);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117275 if( res<0 ){
 
 
 
 
117276 iMin = iTest+1;
 
117277 }else{
117278 i = iTest;
 
117279 }
117280 }while( res && iMin<i );
 
117281
117282 #ifdef SQLITE_DEBUG
117283 /* The following assert statements check that the binary search code
117284 ** above found the right answer. This block serves no purpose other
117285 ** than to invoke the asserts. */
117286 if( res==0 ){
117287 /* If (res==0) is true, then sample $i must be equal to pRec */
117288 assert( i<pIdx->nSample );
117289 assert( 0==sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)
117290 || pParse->db->mallocFailed );
117291 }else{
117292 /* Otherwise, pRec must be smaller than sample $i and larger than
117293 ** sample ($i-1). */
117294 assert( i==pIdx->nSample
117295 || sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)>0
117296 || pParse->db->mallocFailed );
117297 assert( i==0
117298 || sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0
117299 || pParse->db->mallocFailed );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117300 }
117301 #endif /* ifdef SQLITE_DEBUG */
117302
117303 /* At this point, aSample[i] is the first sample that is greater than
117304 ** or equal to pVal. Or if i==pIdx->nSample, then all samples are less
117305 ** than pVal. If aSample[i]==pVal, then res==0.
117306 */
117307 if( res==0 ){
 
 
117308 aStat[0] = aSample[i].anLt[iCol];
117309 aStat[1] = aSample[i].anEq[iCol];
117310 }else{
117311 tRowcnt iLower, iUpper, iGap;
117312 if( i==0 ){
117313 iLower = 0;
117314 iUpper = aSample[0].anLt[iCol];
 
 
117315 }else{
117316 i64 nRow0 = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]);
117317 iUpper = i>=pIdx->nSample ? nRow0 : aSample[i].anLt[iCol];
117318 iLower = aSample[i-1].anEq[iCol] + aSample[i-1].anLt[iCol];
117319 }
117320 aStat[1] = pIdx->aAvgEq[iCol];
117321 if( iLower>=iUpper ){
117322 iGap = 0;
117323 }else{
117324 iGap = iUpper - iLower;
117325 }
@@ -117327,11 +117869,15 @@
117327 iGap = (iGap*2)/3;
117328 }else{
117329 iGap = iGap/3;
117330 }
117331 aStat[0] = iLower + iGap;
 
117332 }
 
 
 
117333 return i;
117334 }
117335 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
117336
117337 /*
@@ -118322,25 +118868,33 @@
118322 #else
118323 # define addScanStatus(a, b, c, d) ((void)d)
118324 #endif
118325
118326 /*
118327 ** Look at the last instruction coded. If that instruction is OP_String8
118328 ** and if pLoop->iLikeRepCntr is non-zero, then change the P3 to be
118329 ** pLoop->iLikeRepCntr and set P5.
118330 **
118331 ** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range
118332 ** expression: "x>='ABC' AND x<'abd'". But this requires that the range
118333 ** scan loop run twice, once for strings and a second time for BLOBs.
118334 ** The OP_String opcodes on the second pass convert the upper and lower
118335 ** bound string contants to blobs. This routine makes the necessary changes
118336 ** to the OP_String opcodes for that to happen.
118337 */
118338 static void whereLikeOptimizationStringFixup(Vdbe *v, WhereLevel *pLevel){
118339 VdbeOp *pOp;
118340 pOp = sqlite3VdbeGetOp(v, -1);
118341 if( pLevel->iLikeRepCntr && pOp->opcode==OP_String8 ){
 
 
 
 
 
 
 
 
118342 pOp->p3 = pLevel->iLikeRepCntr;
118343 pOp->p5 = 1;
118344 }
118345 }
118346
@@ -118670,18 +119224,20 @@
118670 */
118671 j = nEq;
118672 if( pLoop->wsFlags & WHERE_BTM_LIMIT ){
118673 pRangeStart = pLoop->aLTerm[j++];
118674 nExtraReg = 1;
 
 
 
118675 }
118676 if( pLoop->wsFlags & WHERE_TOP_LIMIT ){
118677 pRangeEnd = pLoop->aLTerm[j++];
118678 nExtraReg = 1;
118679 if( pRangeStart
118680 && (pRangeStart->wtFlags & TERM_LIKEOPT)!=0
118681 && (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0
118682 ){
118683 pLevel->iLikeRepCntr = ++pParse->nMem;
118684 testcase( bRev );
118685 testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC );
118686 sqlite3VdbeAddOp2(v, OP_Integer,
118687 bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC),
@@ -118729,11 +119285,11 @@
118729 /* Seek the index cursor to the start of the range. */
118730 nConstraint = nEq;
118731 if( pRangeStart ){
118732 Expr *pRight = pRangeStart->pExpr->pRight;
118733 sqlite3ExprCode(pParse, pRight, regBase+nEq);
118734 whereLikeOptimizationStringFixup(v, pLevel);
118735 if( (pRangeStart->wtFlags & TERM_VNULL)==0
118736 && sqlite3ExprCanBeNull(pRight)
118737 ){
118738 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
118739 VdbeCoverage(v);
@@ -118775,11 +119331,11 @@
118775 nConstraint = nEq;
118776 if( pRangeEnd ){
118777 Expr *pRight = pRangeEnd->pExpr->pRight;
118778 sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
118779 sqlite3ExprCode(pParse, pRight, regBase+nEq);
118780 whereLikeOptimizationStringFixup(v, pLevel);
118781 if( (pRangeEnd->wtFlags & TERM_VNULL)==0
118782 && sqlite3ExprCanBeNull(pRight)
118783 ){
118784 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
118785 VdbeCoverage(v);
@@ -119852,10 +120408,14 @@
119852 ){
119853 continue; /* ignore IS [NOT] NULL constraints on NOT NULL columns */
119854 }
119855 if( pTerm->prereqRight & pNew->maskSelf ) continue;
119856
 
 
 
 
119857 pNew->wsFlags = saved_wsFlags;
119858 pNew->u.btree.nEq = saved_nEq;
119859 pNew->nLTerm = saved_nLTerm;
119860 if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
119861 pNew->aLTerm[pNew->nLTerm++] = pTerm;
@@ -119895,10 +120455,21 @@
119895 testcase( eOp & WO_GT );
119896 testcase( eOp & WO_GE );
119897 pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT;
119898 pBtm = pTerm;
119899 pTop = 0;
 
 
 
 
 
 
 
 
 
 
 
119900 }else{
119901 assert( eOp & (WO_LT|WO_LE) );
119902 testcase( eOp & WO_LT );
119903 testcase( eOp & WO_LE );
119904 pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_TOP_LIMIT;
@@ -121089,14 +121660,14 @@
121089 assert( aSortCost==0 || &pSpace[nSpace]==(char*)&aSortCost[nOrderBy] );
121090 assert( aSortCost!=0 || &pSpace[nSpace]==(char*)pX );
121091
121092 /* Seed the search with a single WherePath containing zero WhereLoops.
121093 **
121094 ** TUNING: Do not let the number of iterations go above 25. If the cost
121095 ** of computing an automatic index is not paid back within the first 25
121096 ** rows, then do not use the automatic index. */
121097 aFrom[0].nRow = MIN(pParse->nQueryLoop, 46); assert( 46==sqlite3LogEst(25) );
121098 nFrom = 1;
121099 assert( aFrom[0].isOrdered==0 );
121100 if( nOrderBy ){
121101 /* If nLoop is zero, then there are no FROM terms in the query. Since
121102 ** in this case the query may return a maximum of one row, the results
@@ -121890,10 +122461,16 @@
121890 assert( pIx->pSchema==pTab->pSchema );
121891 assert( iIndexCur>=0 );
121892 if( op ){
121893 sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb);
121894 sqlite3VdbeSetP4KeyInfo(pParse, pIx);
 
 
 
 
 
 
121895 VdbeComment((v, "%s", pIx->zName));
121896 }
121897 }
121898 if( iDb>=0 ) sqlite3CodeVerifySchema(pParse, iDb);
121899 notReady &= ~getMask(&pWInfo->sMaskSet, pTabItem->iCursor);
@@ -124891,11 +125468,11 @@
124891 spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
124892 }
124893 break;
124894 case 193: /* expr ::= expr COLLATE ID|STRING */
124895 {
124896 yygotominor.yy346.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0);
124897 yygotominor.yy346.zStart = yymsp[-2].minor.yy346.zStart;
124898 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
124899 }
124900 break;
124901 case 194: /* expr ::= CAST LP expr AS typetoken RP */
@@ -125171,20 +125748,20 @@
125171 case 241: /* uniqueflag ::= */
125172 {yygotominor.yy328 = OE_None;}
125173 break;
125174 case 244: /* idxlist ::= idxlist COMMA nm collate sortorder */
125175 {
125176 Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0);
125177 yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, p);
125178 sqlite3ExprListSetName(pParse,yygotominor.yy14,&yymsp[-2].minor.yy0,1);
125179 sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
125180 if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
125181 }
125182 break;
125183 case 245: /* idxlist ::= nm collate sortorder */
125184 {
125185 Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0);
125186 yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, p);
125187 sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
125188 sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
125189 if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
125190 }
@@ -126439,13 +127016,15 @@
126439 pParse->zTail = &zSql[i];
126440 }
126441 sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);
126442 }
126443 #ifdef YYTRACKMAXSTACKDEPTH
 
126444 sqlite3StatusSet(SQLITE_STATUS_PARSER_STACK,
126445 sqlite3ParserStackPeak(pEngine)
126446 );
 
126447 #endif /* YYDEBUG */
126448 sqlite3ParserFree(pEngine, sqlite3_free);
126449 db->lookaside.bEnabled = enableLookaside;
126450 if( db->mallocFailed ){
126451 pParse->rc = SQLITE_NOMEM;
@@ -126605,11 +127184,11 @@
126605 **
126606 ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
126607 ** to recognize the end of a trigger can be omitted. All we have to do
126608 ** is look for a semicolon that is not part of an string or comment.
126609 */
126610 SQLITE_API int sqlite3_complete(const char *zSql){
126611 u8 state = 0; /* Current state, using numbers defined in header comment */
126612 u8 token; /* Value of the next token */
126613
126614 #ifndef SQLITE_OMIT_TRIGGER
126615 /* A complex statement machine used to detect the end of a CREATE TRIGGER
@@ -126770,11 +127349,11 @@
126770 /*
126771 ** This routine is the same as the sqlite3_complete() routine described
126772 ** above, except that the parameter is required to be UTF-16 encoded, not
126773 ** UTF-8.
126774 */
126775 SQLITE_API int sqlite3_complete16(const void *zSql){
126776 sqlite3_value *pVal;
126777 char const *zSql8;
126778 int rc = SQLITE_NOMEM;
126779
126780 #ifndef SQLITE_OMIT_AUTOINIT
@@ -126920,37 +127499,37 @@
126920 #endif
126921
126922 /* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns
126923 ** a pointer to the to the sqlite3_version[] string constant.
126924 */
126925 SQLITE_API const char *sqlite3_libversion(void){ return sqlite3_version; }
126926
126927 /* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a
126928 ** pointer to a string constant whose value is the same as the
126929 ** SQLITE_SOURCE_ID C preprocessor macro.
126930 */
126931 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
126932
126933 /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function
126934 ** returns an integer equal to SQLITE_VERSION_NUMBER.
126935 */
126936 SQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
126937
126938 /* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns
126939 ** zero if and only if SQLite was compiled with mutexing code omitted due to
126940 ** the SQLITE_THREADSAFE compile-time option being set to 0.
126941 */
126942 SQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
126943
126944 #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
126945 /*
126946 ** If the following function pointer is not NULL and if
126947 ** SQLITE_ENABLE_IOTRACE is enabled, then messages describing
126948 ** I/O active are written using this function. These messages
126949 ** are intended for debugging activity only.
126950 */
126951 /* not-private */ void (*sqlite3IoTrace)(const char*, ...) = 0;
126952 #endif
126953
126954 /*
126955 ** If the following global variable points to a string which is the
126956 ** name of a directory, then that directory will be used to store
@@ -126998,11 +127577,11 @@
126998 ** call by X completes.
126999 **
127000 ** * Recursive calls to this routine from thread X return immediately
127001 ** without blocking.
127002 */
127003 SQLITE_API int sqlite3_initialize(void){
127004 MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
127005 int rc; /* Result code */
127006 #ifdef SQLITE_EXTRA_INIT
127007 int bRunExtraInit = 0; /* Extra initialization needed */
127008 #endif
@@ -127011,10 +127590,15 @@
127011 rc = sqlite3_wsd_init(4096, 24);
127012 if( rc!=SQLITE_OK ){
127013 return rc;
127014 }
127015 #endif
 
 
 
 
 
127016
127017 /* If SQLite is already completely initialized, then this call
127018 ** to sqlite3_initialize() should be a no-op. But the initialization
127019 ** must be complete. So isInit must not be set until the very end
127020 ** of this routine.
@@ -127154,11 +127738,11 @@
127154 ** while any part of SQLite is otherwise in use in any thread. This
127155 ** routine is not threadsafe. But it is safe to invoke this routine
127156 ** on when SQLite is already shut down. If SQLite is already shut down
127157 ** when this routine is invoked, then this routine is a harmless no-op.
127158 */
127159 SQLITE_API int sqlite3_shutdown(void){
127160 #ifdef SQLITE_OMIT_WSD
127161 int rc = sqlite3_wsd_init(4096, 24);
127162 if( rc!=SQLITE_OK ){
127163 return rc;
127164 }
@@ -127208,11 +127792,11 @@
127208 ** This routine should only be called when there are no outstanding
127209 ** database connections or memory allocations. This routine is not
127210 ** threadsafe. Failure to heed these warnings can lead to unpredictable
127211 ** behavior.
127212 */
127213 SQLITE_API int sqlite3_config(int op, ...){
127214 va_list ap;
127215 int rc = SQLITE_OK;
127216
127217 /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while
127218 ** the SQLite library is in use. */
@@ -127565,11 +128149,11 @@
127565 }
127566
127567 /*
127568 ** Return the mutex associated with a database connection.
127569 */
127570 SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3 *db){
127571 #ifdef SQLITE_ENABLE_API_ARMOR
127572 if( !sqlite3SafetyCheckOk(db) ){
127573 (void)SQLITE_MISUSE_BKPT;
127574 return 0;
127575 }
@@ -127579,11 +128163,11 @@
127579
127580 /*
127581 ** Free up as much memory as we can from the given database
127582 ** connection.
127583 */
127584 SQLITE_API int sqlite3_db_release_memory(sqlite3 *db){
127585 int i;
127586
127587 #ifdef SQLITE_ENABLE_API_ARMOR
127588 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
127589 #endif
@@ -127602,11 +128186,11 @@
127602 }
127603
127604 /*
127605 ** Configuration settings for an individual database connection
127606 */
127607 SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){
127608 va_list ap;
127609 int rc;
127610 va_start(ap, op);
127611 switch( op ){
127612 case SQLITE_DBCONFIG_LOOKASIDE: {
@@ -127721,11 +128305,11 @@
127721 }
127722
127723 /*
127724 ** Return the ROWID of the most recent insert
127725 */
127726 SQLITE_API sqlite_int64 sqlite3_last_insert_rowid(sqlite3 *db){
127727 #ifdef SQLITE_ENABLE_API_ARMOR
127728 if( !sqlite3SafetyCheckOk(db) ){
127729 (void)SQLITE_MISUSE_BKPT;
127730 return 0;
127731 }
@@ -127734,11 +128318,11 @@
127734 }
127735
127736 /*
127737 ** Return the number of changes in the most recent call to sqlite3_exec().
127738 */
127739 SQLITE_API int sqlite3_changes(sqlite3 *db){
127740 #ifdef SQLITE_ENABLE_API_ARMOR
127741 if( !sqlite3SafetyCheckOk(db) ){
127742 (void)SQLITE_MISUSE_BKPT;
127743 return 0;
127744 }
@@ -127747,11 +128331,11 @@
127747 }
127748
127749 /*
127750 ** Return the number of changes since the database handle was opened.
127751 */
127752 SQLITE_API int sqlite3_total_changes(sqlite3 *db){
127753 #ifdef SQLITE_ENABLE_API_ARMOR
127754 if( !sqlite3SafetyCheckOk(db) ){
127755 (void)SQLITE_MISUSE_BKPT;
127756 return 0;
127757 }
@@ -127889,12 +128473,12 @@
127889 ** statements or unfinished sqlite3_backups. The sqlite3_close_v2()
127890 ** version forces the connection to become a zombie if there are
127891 ** unclosed resources, and arranges for deallocation when the last
127892 ** prepare statement or sqlite3_backup closes.
127893 */
127894 SQLITE_API int sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); }
127895 SQLITE_API int sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); }
127896
127897
127898 /*
127899 ** Close the mutex on database connection db.
127900 **
@@ -128297,11 +128881,11 @@
128297
128298 /*
128299 ** This routine sets the busy callback for an Sqlite database to the
128300 ** given callback function with the given argument.
128301 */
128302 SQLITE_API int sqlite3_busy_handler(
128303 sqlite3 *db,
128304 int (*xBusy)(void*,int),
128305 void *pArg
128306 ){
128307 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -128320,11 +128904,11 @@
128320 /*
128321 ** This routine sets the progress callback for an Sqlite database to the
128322 ** given callback function with the given argument. The progress callback will
128323 ** be invoked every nOps opcodes.
128324 */
128325 SQLITE_API void sqlite3_progress_handler(
128326 sqlite3 *db,
128327 int nOps,
128328 int (*xProgress)(void*),
128329 void *pArg
128330 ){
@@ -128351,11 +128935,11 @@
128351
128352 /*
128353 ** This routine installs a default busy handler that waits for the
128354 ** specified number of milliseconds before returning 0.
128355 */
128356 SQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){
128357 #ifdef SQLITE_ENABLE_API_ARMOR
128358 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
128359 #endif
128360 if( ms>0 ){
128361 sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)db);
@@ -128367,11 +128951,11 @@
128367 }
128368
128369 /*
128370 ** Cause any pending operation to stop at its earliest opportunity.
128371 */
128372 SQLITE_API void sqlite3_interrupt(sqlite3 *db){
128373 #ifdef SQLITE_ENABLE_API_ARMOR
128374 if( !sqlite3SafetyCheckOk(db) ){
128375 (void)SQLITE_MISUSE_BKPT;
128376 return;
128377 }
@@ -128484,11 +129068,11 @@
128484 }
128485
128486 /*
128487 ** Create new user functions.
128488 */
128489 SQLITE_API int sqlite3_create_function(
128490 sqlite3 *db,
128491 const char *zFunc,
128492 int nArg,
128493 int enc,
128494 void *p,
@@ -128498,11 +129082,11 @@
128498 ){
128499 return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xFunc, xStep,
128500 xFinal, 0);
128501 }
128502
128503 SQLITE_API int sqlite3_create_function_v2(
128504 sqlite3 *db,
128505 const char *zFunc,
128506 int nArg,
128507 int enc,
128508 void *p,
@@ -128541,11 +129125,11 @@
128541 sqlite3_mutex_leave(db->mutex);
128542 return rc;
128543 }
128544
128545 #ifndef SQLITE_OMIT_UTF16
128546 SQLITE_API int sqlite3_create_function16(
128547 sqlite3 *db,
128548 const void *zFunctionName,
128549 int nArg,
128550 int eTextRep,
128551 void *p,
@@ -128581,11 +129165,11 @@
128581 ** When virtual tables intend to provide an overloaded function, they
128582 ** should call this routine to make sure the global function exists.
128583 ** A global function must exist in order for name resolution to work
128584 ** properly.
128585 */
128586 SQLITE_API int sqlite3_overload_function(
128587 sqlite3 *db,
128588 const char *zName,
128589 int nArg
128590 ){
128591 int nName = sqlite3Strlen30(zName);
@@ -128613,11 +129197,11 @@
128613 **
128614 ** A NULL trace function means that no tracing is executes. A non-NULL
128615 ** trace is a pointer to a function that is invoked at the start of each
128616 ** SQL statement.
128617 */
128618 SQLITE_API void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
128619 void *pOld;
128620
128621 #ifdef SQLITE_ENABLE_API_ARMOR
128622 if( !sqlite3SafetyCheckOk(db) ){
128623 (void)SQLITE_MISUSE_BKPT;
@@ -128637,11 +129221,11 @@
128637 **
128638 ** A NULL profile function means that no profiling is executes. A non-NULL
128639 ** profile is a pointer to a function that is invoked at the conclusion of
128640 ** each SQL statement that is run.
128641 */
128642 SQLITE_API void *sqlite3_profile(
128643 sqlite3 *db,
128644 void (*xProfile)(void*,const char*,sqlite_uint64),
128645 void *pArg
128646 ){
128647 void *pOld;
@@ -128664,11 +129248,11 @@
128664 /*
128665 ** Register a function to be invoked when a transaction commits.
128666 ** If the invoked function returns non-zero, then the commit becomes a
128667 ** rollback.
128668 */
128669 SQLITE_API void *sqlite3_commit_hook(
128670 sqlite3 *db, /* Attach the hook to this database */
128671 int (*xCallback)(void*), /* Function to invoke on each commit */
128672 void *pArg /* Argument to the function */
128673 ){
128674 void *pOld;
@@ -128689,11 +129273,11 @@
128689
128690 /*
128691 ** Register a callback to be invoked each time a row is updated,
128692 ** inserted or deleted using this database connection.
128693 */
128694 SQLITE_API void *sqlite3_update_hook(
128695 sqlite3 *db, /* Attach the hook to this database */
128696 void (*xCallback)(void*,int,char const *,char const *,sqlite_int64),
128697 void *pArg /* Argument to the function */
128698 ){
128699 void *pRet;
@@ -128714,11 +129298,11 @@
128714
128715 /*
128716 ** Register a callback to be invoked each time a transaction is rolled
128717 ** back by this database connection.
128718 */
128719 SQLITE_API void *sqlite3_rollback_hook(
128720 sqlite3 *db, /* Attach the hook to this database */
128721 void (*xCallback)(void*), /* Callback function */
128722 void *pArg /* Argument to the function */
128723 ){
128724 void *pRet;
@@ -128768,11 +129352,11 @@
128768 ** The callback registered by this function replaces any existing callback
128769 ** registered using sqlite3_wal_hook(). Likewise, registering a callback
128770 ** using sqlite3_wal_hook() disables the automatic checkpoint mechanism
128771 ** configured by this function.
128772 */
128773 SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
128774 #ifdef SQLITE_OMIT_WAL
128775 UNUSED_PARAMETER(db);
128776 UNUSED_PARAMETER(nFrame);
128777 #else
128778 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -128789,11 +129373,11 @@
128789
128790 /*
128791 ** Register a callback to be invoked each time a transaction is written
128792 ** into the write-ahead-log by this database connection.
128793 */
128794 SQLITE_API void *sqlite3_wal_hook(
128795 sqlite3 *db, /* Attach the hook to this db handle */
128796 int(*xCallback)(void *, sqlite3*, const char*, int),
128797 void *pArg /* First argument passed to xCallback() */
128798 ){
128799 #ifndef SQLITE_OMIT_WAL
@@ -128816,11 +129400,11 @@
128816 }
128817
128818 /*
128819 ** Checkpoint database zDb.
128820 */
128821 SQLITE_API int sqlite3_wal_checkpoint_v2(
128822 sqlite3 *db, /* Database handle */
128823 const char *zDb, /* Name of attached database (or NULL) */
128824 int eMode, /* SQLITE_CHECKPOINT_* value */
128825 int *pnLog, /* OUT: Size of WAL log in frames */
128826 int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -128871,11 +129455,11 @@
128871 /*
128872 ** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points
128873 ** to contains a zero-length string, all attached databases are
128874 ** checkpointed.
128875 */
128876 SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
128877 /* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to
128878 ** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */
128879 return sqlite3_wal_checkpoint_v2(db,zDb,SQLITE_CHECKPOINT_PASSIVE,0,0);
128880 }
128881
@@ -128960,11 +129544,11 @@
128960
128961 /*
128962 ** Return UTF-8 encoded English language explanation of the most recent
128963 ** error.
128964 */
128965 SQLITE_API const char *sqlite3_errmsg(sqlite3 *db){
128966 const char *z;
128967 if( !db ){
128968 return sqlite3ErrStr(SQLITE_NOMEM);
128969 }
128970 if( !sqlite3SafetyCheckSickOrOk(db) ){
@@ -128988,11 +129572,11 @@
128988 #ifndef SQLITE_OMIT_UTF16
128989 /*
128990 ** Return UTF-16 encoded English language explanation of the most recent
128991 ** error.
128992 */
128993 SQLITE_API const void *sqlite3_errmsg16(sqlite3 *db){
128994 static const u16 outOfMem[] = {
128995 'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
128996 };
128997 static const u16 misuse[] = {
128998 'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ',
@@ -129033,20 +129617,20 @@
129033
129034 /*
129035 ** Return the most recent error code generated by an SQLite routine. If NULL is
129036 ** passed to this function, we assume a malloc() failed during sqlite3_open().
129037 */
129038 SQLITE_API int sqlite3_errcode(sqlite3 *db){
129039 if( db && !sqlite3SafetyCheckSickOrOk(db) ){
129040 return SQLITE_MISUSE_BKPT;
129041 }
129042 if( !db || db->mallocFailed ){
129043 return SQLITE_NOMEM;
129044 }
129045 return db->errCode & db->errMask;
129046 }
129047 SQLITE_API int sqlite3_extended_errcode(sqlite3 *db){
129048 if( db && !sqlite3SafetyCheckSickOrOk(db) ){
129049 return SQLITE_MISUSE_BKPT;
129050 }
129051 if( !db || db->mallocFailed ){
129052 return SQLITE_NOMEM;
@@ -129057,11 +129641,11 @@
129057 /*
129058 ** Return a string that describes the kind of error specified in the
129059 ** argument. For now, this simply calls the internal sqlite3ErrStr()
129060 ** function.
129061 */
129062 SQLITE_API const char *sqlite3_errstr(int rc){
129063 return sqlite3ErrStr(rc);
129064 }
129065
129066 /*
129067 ** Create a new collating function for database "db". The name is zName
@@ -129205,11 +129789,11 @@
129205 **
129206 ** A new lower limit does not shrink existing constructs.
129207 ** It merely prevents new constructs that exceed the limit
129208 ** from forming.
129209 */
129210 SQLITE_API int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
129211 int oldLimit;
129212
129213 #ifdef SQLITE_ENABLE_API_ARMOR
129214 if( !sqlite3SafetyCheckOk(db) ){
129215 (void)SQLITE_MISUSE_BKPT;
@@ -129790,18 +130374,18 @@
129790 }
129791
129792 /*
129793 ** Open a new database handle.
129794 */
129795 SQLITE_API int sqlite3_open(
129796 const char *zFilename,
129797 sqlite3 **ppDb
129798 ){
129799 return openDatabase(zFilename, ppDb,
129800 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
129801 }
129802 SQLITE_API int sqlite3_open_v2(
129803 const char *filename, /* Database filename (UTF-8) */
129804 sqlite3 **ppDb, /* OUT: SQLite db handle */
129805 int flags, /* Flags */
129806 const char *zVfs /* Name of VFS module to use */
129807 ){
@@ -129810,11 +130394,11 @@
129810
129811 #ifndef SQLITE_OMIT_UTF16
129812 /*
129813 ** Open a new database handle.
129814 */
129815 SQLITE_API int sqlite3_open16(
129816 const void *zFilename,
129817 sqlite3 **ppDb
129818 ){
129819 char const *zFilename8; /* zFilename encoded in UTF-8 instead of UTF-16 */
129820 sqlite3_value *pVal;
@@ -129849,11 +130433,11 @@
129849 #endif /* SQLITE_OMIT_UTF16 */
129850
129851 /*
129852 ** Register a new collation sequence with the database handle db.
129853 */
129854 SQLITE_API int sqlite3_create_collation(
129855 sqlite3* db,
129856 const char *zName,
129857 int enc,
129858 void* pCtx,
129859 int(*xCompare)(void*,int,const void*,int,const void*)
@@ -129862,11 +130446,11 @@
129862 }
129863
129864 /*
129865 ** Register a new collation sequence with the database handle db.
129866 */
129867 SQLITE_API int sqlite3_create_collation_v2(
129868 sqlite3* db,
129869 const char *zName,
129870 int enc,
129871 void* pCtx,
129872 int(*xCompare)(void*,int,const void*,int,const void*),
@@ -129887,11 +130471,11 @@
129887
129888 #ifndef SQLITE_OMIT_UTF16
129889 /*
129890 ** Register a new collation sequence with the database handle db.
129891 */
129892 SQLITE_API int sqlite3_create_collation16(
129893 sqlite3* db,
129894 const void *zName,
129895 int enc,
129896 void* pCtx,
129897 int(*xCompare)(void*,int,const void*,int,const void*)
@@ -129917,11 +130501,11 @@
129917
129918 /*
129919 ** Register a collation sequence factory callback with the database handle
129920 ** db. Replace any previously installed collation sequence factory.
129921 */
129922 SQLITE_API int sqlite3_collation_needed(
129923 sqlite3 *db,
129924 void *pCollNeededArg,
129925 void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*)
129926 ){
129927 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -129938,11 +130522,11 @@
129938 #ifndef SQLITE_OMIT_UTF16
129939 /*
129940 ** Register a collation sequence factory callback with the database handle
129941 ** db. Replace any previously installed collation sequence factory.
129942 */
129943 SQLITE_API int sqlite3_collation_needed16(
129944 sqlite3 *db,
129945 void *pCollNeededArg,
129946 void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*)
129947 ){
129948 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -129960,11 +130544,11 @@
129960 #ifndef SQLITE_OMIT_DEPRECATED
129961 /*
129962 ** This function is now an anachronism. It used to be used to recover from a
129963 ** malloc() failure, but SQLite now does this automatically.
129964 */
129965 SQLITE_API int sqlite3_global_recover(void){
129966 return SQLITE_OK;
129967 }
129968 #endif
129969
129970 /*
@@ -129971,11 +130555,11 @@
129971 ** Test to see whether or not the database connection is in autocommit
129972 ** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on
129973 ** by default. Autocommit is disabled by a BEGIN statement and reenabled
129974 ** by the next COMMIT or ROLLBACK.
129975 */
129976 SQLITE_API int sqlite3_get_autocommit(sqlite3 *db){
129977 #ifdef SQLITE_ENABLE_API_ARMOR
129978 if( !sqlite3SafetyCheckOk(db) ){
129979 (void)SQLITE_MISUSE_BKPT;
129980 return 0;
129981 }
@@ -130023,19 +130607,19 @@
130023 ** data for this thread has been deallocated.
130024 **
130025 ** SQLite no longer uses thread-specific data so this routine is now a
130026 ** no-op. It is retained for historical compatibility.
130027 */
130028 SQLITE_API void sqlite3_thread_cleanup(void){
130029 }
130030 #endif
130031
130032 /*
130033 ** Return meta information about a specific column of a database table.
130034 ** See comment in sqlite3.h (sqlite.h.in) for details.
130035 */
130036 SQLITE_API int sqlite3_table_column_metadata(
130037 sqlite3 *db, /* Connection handle */
130038 const char *zDbName, /* Database name or NULL */
130039 const char *zTableName, /* Table name */
130040 const char *zColumnName, /* Column name */
130041 char const **pzDataType, /* OUTPUT: Declared data type */
@@ -130149,11 +130733,11 @@
130149 }
130150
130151 /*
130152 ** Sleep for a little while. Return the amount of time slept.
130153 */
130154 SQLITE_API int sqlite3_sleep(int ms){
130155 sqlite3_vfs *pVfs;
130156 int rc;
130157 pVfs = sqlite3_vfs_find(0);
130158 if( pVfs==0 ) return 0;
130159
@@ -130165,11 +130749,11 @@
130165 }
130166
130167 /*
130168 ** Enable or disable the extended result codes.
130169 */
130170 SQLITE_API int sqlite3_extended_result_codes(sqlite3 *db, int onoff){
130171 #ifdef SQLITE_ENABLE_API_ARMOR
130172 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
130173 #endif
130174 sqlite3_mutex_enter(db->mutex);
130175 db->errMask = onoff ? 0xffffffff : 0xff;
@@ -130178,11 +130762,11 @@
130178 }
130179
130180 /*
130181 ** Invoke the xFileControl method on a particular database.
130182 */
130183 SQLITE_API int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){
130184 int rc = SQLITE_ERROR;
130185 Btree *pBtree;
130186
130187 #ifdef SQLITE_ENABLE_API_ARMOR
130188 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -130212,11 +130796,11 @@
130212 }
130213
130214 /*
130215 ** Interface to the testing logic.
130216 */
130217 SQLITE_API int sqlite3_test_control(int op, ...){
130218 int rc = 0;
130219 #ifndef SQLITE_OMIT_BUILTIN_TEST
130220 va_list ap;
130221 va_start(ap, op);
130222 switch( op ){
@@ -130555,11 +131139,11 @@
130555 ** method of a VFS implementation. The zParam argument is the name of the
130556 ** query parameter we seek. This routine returns the value of the zParam
130557 ** parameter if it exists. If the parameter does not exist, this routine
130558 ** returns a NULL pointer.
130559 */
130560 SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){
130561 if( zFilename==0 || zParam==0 ) return 0;
130562 zFilename += sqlite3Strlen30(zFilename) + 1;
130563 while( zFilename[0] ){
130564 int x = strcmp(zFilename, zParam);
130565 zFilename += sqlite3Strlen30(zFilename) + 1;
@@ -130570,20 +131154,20 @@
130570 }
130571
130572 /*
130573 ** Return a boolean value for a query parameter.
130574 */
130575 SQLITE_API int sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){
130576 const char *z = sqlite3_uri_parameter(zFilename, zParam);
130577 bDflt = bDflt!=0;
130578 return z ? sqlite3GetBoolean(z, bDflt) : bDflt;
130579 }
130580
130581 /*
130582 ** Return a 64-bit integer value for a query parameter.
130583 */
130584 SQLITE_API sqlite3_int64 sqlite3_uri_int64(
130585 const char *zFilename, /* Filename as passed to xOpen */
130586 const char *zParam, /* URI parameter sought */
130587 sqlite3_int64 bDflt /* return if parameter is missing */
130588 ){
130589 const char *z = sqlite3_uri_parameter(zFilename, zParam);
@@ -130611,11 +131195,11 @@
130611
130612 /*
130613 ** Return the filename of the database associated with a database
130614 ** connection.
130615 */
130616 SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){
130617 Btree *pBt;
130618 #ifdef SQLITE_ENABLE_API_ARMOR
130619 if( !sqlite3SafetyCheckOk(db) ){
130620 (void)SQLITE_MISUSE_BKPT;
130621 return 0;
@@ -130627,11 +131211,11 @@
130627
130628 /*
130629 ** Return 1 if database is read-only or 0 if read/write. Return -1 if
130630 ** no such database exists.
130631 */
130632 SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){
130633 Btree *pBt;
130634 #ifdef SQLITE_ENABLE_API_ARMOR
130635 if( !sqlite3SafetyCheckOk(db) ){
130636 (void)SQLITE_MISUSE_BKPT;
130637 return -1;
@@ -130786,11 +131370,11 @@
130786 **
130787 ** Each call to this routine overrides any prior callbacks registered
130788 ** on the same "db". If xNotify==0 then any prior callbacks are immediately
130789 ** cancelled.
130790 */
130791 SQLITE_API int sqlite3_unlock_notify(
130792 sqlite3 *db,
130793 void (*xNotify)(void **, int),
130794 void *pArg
130795 ){
130796 int rc = SQLITE_OK;
@@ -132766,15 +133350,20 @@
132766 ** the output value undefined. Otherwise SQLITE_OK is returned.
132767 **
132768 ** This function is used when parsing the "prefix=" FTS4 parameter.
132769 */
132770 static int fts3GobbleInt(const char **pp, int *pnOut){
 
132771 const char *p; /* Iterator pointer */
132772 int nInt = 0; /* Output value */
132773
132774 for(p=*pp; p[0]>='0' && p[0]<='9'; p++){
132775 nInt = nInt * 10 + (p[0] - '0');
 
 
 
 
132776 }
132777 if( p==*pp ) return SQLITE_ERROR;
132778 *pnOut = nInt;
132779 *pp = p;
132780 return SQLITE_OK;
@@ -132813,27 +133402,33 @@
132813 }
132814 }
132815
132816 aIndex = sqlite3_malloc(sizeof(struct Fts3Index) * nIndex);
132817 *apIndex = aIndex;
132818 *pnIndex = nIndex;
132819 if( !aIndex ){
132820 return SQLITE_NOMEM;
132821 }
132822
132823 memset(aIndex, 0, sizeof(struct Fts3Index) * nIndex);
132824 if( zParam ){
132825 const char *p = zParam;
132826 int i;
132827 for(i=1; i<nIndex; i++){
132828 int nPrefix;
132829 if( fts3GobbleInt(&p, &nPrefix) ) return SQLITE_ERROR;
132830 aIndex[i].nPrefix = nPrefix;
 
 
 
 
 
 
132831 p++;
132832 }
132833 }
132834
 
132835 return SQLITE_OK;
132836 }
132837
132838 /*
132839 ** This function is called when initializing an FTS4 table that uses the
@@ -132953,11 +133548,11 @@
132953 int nName; /* Bytes required to hold table name */
132954 int isFts4 = (argv[0][3]=='4'); /* True for FTS4, false for FTS3 */
132955 const char **aCol; /* Array of column names */
132956 sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
132957
132958 int nIndex; /* Size of aIndex[] array */
132959 struct Fts3Index *aIndex = 0; /* Array of indexes for this table */
132960
132961 /* The results of parsing supported FTS4 key=value options: */
132962 int bNoDocsize = 0; /* True to omit %_docsize table */
132963 int bDescIdx = 0; /* True to store descending indexes */
@@ -137641,11 +138236,11 @@
137641 ** Initialize API pointer table, if required.
137642 */
137643 #ifdef _WIN32
137644 __declspec(dllexport)
137645 #endif
137646 SQLITE_API int sqlite3_fts3_init(
137647 sqlite3 *db,
137648 char **pzErrMsg,
137649 const sqlite3_api_routines *pApi
137650 ){
137651 SQLITE_EXTENSION_INIT2(pApi)
@@ -140609,11 +141204,11 @@
140609 nName = sqlite3_value_bytes(argv[0])+1;
140610
140611 if( argc==2 ){
140612 void *pOld;
140613 int n = sqlite3_value_bytes(argv[1]);
140614 if( n!=sizeof(pPtr) ){
140615 sqlite3_result_error(context, "argument type mismatch", -1);
140616 return;
140617 }
140618 pPtr = *(void **)sqlite3_value_blob(argv[1]);
140619 pOld = sqlite3Fts3HashInsert(pHash, (void *)zName, nName, pPtr);
@@ -140620,11 +141215,13 @@
140620 if( pOld==pPtr ){
140621 sqlite3_result_error(context, "out of memory", -1);
140622 return;
140623 }
140624 }else{
140625 pPtr = sqlite3Fts3HashFind(pHash, zName, nName);
 
 
140626 if( !pPtr ){
140627 char *zErr = sqlite3_mprintf("unknown tokenizer: %s", zName);
140628 sqlite3_result_error(context, zErr, -1);
140629 sqlite3_free(zErr);
140630 return;
@@ -140701,10 +141298,14 @@
140701 zCopy = sqlite3_mprintf("%s", zArg);
140702 if( !zCopy ) return SQLITE_NOMEM;
140703 zEnd = &zCopy[strlen(zCopy)];
140704
140705 z = (char *)sqlite3Fts3NextToken(zCopy, &n);
 
 
 
 
140706 z[n] = '\0';
140707 sqlite3Fts3Dequote(z);
140708
140709 m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash,z,(int)strlen(z)+1);
140710 if( !m ){
@@ -143346,11 +143947,14 @@
143346 /*
143347 ** This is a comparison function used as a qsort() callback when sorting
143348 ** an array of pending terms by term. This occurs as part of flushing
143349 ** the contents of the pending-terms hash table to the database.
143350 */
143351 static int fts3CompareElemByTerm(const void *lhs, const void *rhs){
 
 
 
143352 char *z1 = fts3HashKey(*(Fts3HashElem **)lhs);
143353 char *z2 = fts3HashKey(*(Fts3HashElem **)rhs);
143354 int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs);
143355 int n2 = fts3HashKeysize(*(Fts3HashElem **)rhs);
143356
@@ -153079,11 +153683,11 @@
153079 }
153080
153081 /*
153082 ** Register a new geometry function for use with the r-tree MATCH operator.
153083 */
153084 SQLITE_API int sqlite3_rtree_geometry_callback(
153085 sqlite3 *db, /* Register SQL function on this connection */
153086 const char *zGeom, /* Name of the new SQL function */
153087 int (*xGeom)(sqlite3_rtree_geometry*,int,RtreeDValue*,int*), /* Callback */
153088 void *pContext /* Extra data associated with the callback */
153089 ){
@@ -153103,11 +153707,11 @@
153103
153104 /*
153105 ** Register a new 2nd-generation geometry function for use with the
153106 ** r-tree MATCH operator.
153107 */
153108 SQLITE_API int sqlite3_rtree_query_callback(
153109 sqlite3 *db, /* Register SQL function on this connection */
153110 const char *zQueryFunc, /* Name of new SQL function */
153111 int (*xQueryFunc)(sqlite3_rtree_query_info*), /* Callback */
153112 void *pContext, /* Extra data passed into the callback */
153113 void (*xDestructor)(void*) /* Destructor for the extra data */
@@ -153128,11 +153732,11 @@
153128
153129 #if !SQLITE_CORE
153130 #ifdef _WIN32
153131 __declspec(dllexport)
153132 #endif
153133 SQLITE_API int sqlite3_rtree_init(
153134 sqlite3 *db,
153135 char **pzErrMsg,
153136 const sqlite3_api_routines *pApi
153137 ){
153138 SQLITE_EXTENSION_INIT2(pApi)
@@ -153633,11 +154237,11 @@
153633
153634 #if !SQLITE_CORE
153635 #ifdef _WIN32
153636 __declspec(dllexport)
153637 #endif
153638 SQLITE_API int sqlite3_icu_init(
153639 sqlite3 *db,
153640 char **pzErrMsg,
153641 const sqlite3_api_routines *pApi
153642 ){
153643 SQLITE_EXTENSION_INIT2(pApi)
153644
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -20,13 +20,10 @@
20 #define SQLITE_CORE 1
21 #define SQLITE_AMALGAMATION 1
22 #ifndef SQLITE_PRIVATE
23 # define SQLITE_PRIVATE static
24 #endif
 
 
 
25 /************** Begin file sqliteInt.h ***************************************/
26 /*
27 ** 2001 September 15
28 **
29 ** The author disclaims copyright to this source code. In place of
@@ -250,20 +247,24 @@
247 extern "C" {
248 #endif
249
250
251 /*
252 ** Provide the ability to override linkage features of the interface.
253 */
254 #ifndef SQLITE_EXTERN
255 # define SQLITE_EXTERN extern
256 #endif
 
257 #ifndef SQLITE_API
258 # define SQLITE_API
259 #endif
260 #ifndef SQLITE_CDECL
261 # define SQLITE_CDECL
262 #endif
263 #ifndef SQLITE_STDCALL
264 # define SQLITE_STDCALL
265 #endif
266
267 /*
268 ** These no-op macros are used in front of interfaces to mark those
269 ** interfaces as either deprecated or experimental. New applications
270 ** should not use deprecated interfaces - they are supported for backwards
@@ -316,11 +317,11 @@
317 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
318 ** [sqlite_version()] and [sqlite_source_id()].
319 */
320 #define SQLITE_VERSION "3.8.9"
321 #define SQLITE_VERSION_NUMBER 3008009
322 #define SQLITE_SOURCE_ID "2015-03-30 23:43:56 395bb3e677a6551b06ba96fc58c393132b93d1e8"
323
324 /*
325 ** CAPI3REF: Run-Time Library Version Numbers
326 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
327 **
@@ -349,13 +350,13 @@
350 ** [SQLITE_SOURCE_ID] C preprocessor macro.
351 **
352 ** See also: [sqlite_version()] and [sqlite_source_id()].
353 */
354 SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
355 SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void);
356 SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void);
357 SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void);
358
359 /*
360 ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
361 **
362 ** ^The sqlite3_compileoption_used() function returns 0 or 1
@@ -376,12 +377,12 @@
377 **
378 ** See also: SQL functions [sqlite_compileoption_used()] and
379 ** [sqlite_compileoption_get()] and the [compile_options pragma].
380 */
381 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
382 SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName);
383 SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N);
384 #endif
385
386 /*
387 ** CAPI3REF: Test To See If The Library Is Threadsafe
388 **
@@ -416,11 +417,11 @@
417 ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
418 ** is unchanged by calls to sqlite3_config().)^
419 **
420 ** See the [threading mode] documentation for additional information.
421 */
422 SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void);
423
424 /*
425 ** CAPI3REF: Database Connection Handle
426 ** KEYWORDS: {database connection} {database connections}
427 **
@@ -512,12 +513,12 @@
513 ** from [sqlite3_open()], [sqlite3_open16()], or
514 ** [sqlite3_open_v2()], and not previously closed.
515 ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
516 ** argument is a harmless no-op.
517 */
518 SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*);
519 SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*);
520
521 /*
522 ** The type for a callback function.
523 ** This is legacy and deprecated. It is included for historical
524 ** compatibility and is not documented.
@@ -583,11 +584,11 @@
584 ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
585 ** <li> The application must not modify the SQL statement text passed into
586 ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
587 ** </ul>
588 */
589 SQLITE_API int SQLITE_STDCALL sqlite3_exec(
590 sqlite3*, /* An open database */
591 const char *sql, /* SQL to be evaluated */
592 int (*callback)(void*,int,char**,char**), /* Callback function */
593 void *, /* 1st argument to callback */
594 char **errmsg /* Error msg written here */
@@ -1157,10 +1158,17 @@
1158 ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
1159 ** opcode causes the xFileControl method to swap the file handle with the one
1160 ** pointed to by the pArg argument. This capability is used during testing
1161 ** and only needs to be supported when SQLITE_TEST is defined.
1162 **
1163 ** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
1164 ** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
1165 ** be advantageous to block on the next WAL lock if the lock is not immediately
1166 ** available. The WAL subsystem issues this signal during rare
1167 ** circumstances in order to fix a problem with priority inversion.
1168 ** Applications should <em>not</em> use this file-control.
1169 **
1170 ** </ul>
1171 */
1172 #define SQLITE_FCNTL_LOCKSTATE 1
1173 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
1174 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
@@ -1181,10 +1189,11 @@
1189 #define SQLITE_FCNTL_TRACE 19
1190 #define SQLITE_FCNTL_HAS_MOVED 20
1191 #define SQLITE_FCNTL_SYNC 21
1192 #define SQLITE_FCNTL_COMMIT_PHASETWO 22
1193 #define SQLITE_FCNTL_WIN32_SET_HANDLE 23
1194 #define SQLITE_FCNTL_WAL_BLOCK 24
1195
1196 /* deprecated names */
1197 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
1198 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1199 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -1535,14 +1544,14 @@
1544 ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
1545 ** implementation of sqlite3_os_init() or sqlite3_os_end()
1546 ** must return [SQLITE_OK] on success and some other [error code] upon
1547 ** failure.
1548 */
1549 SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void);
1550 SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void);
1551 SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void);
1552 SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void);
1553
1554 /*
1555 ** CAPI3REF: Configuring The SQLite Library
1556 **
1557 ** The sqlite3_config() interface is used to make global configuration
@@ -1569,11 +1578,11 @@
1578 **
1579 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1580 ** ^If the option is unknown or SQLite is unable to set the option
1581 ** then this routine returns a non-zero [error code].
1582 */
1583 SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...);
1584
1585 /*
1586 ** CAPI3REF: Configure database connections
1587 **
1588 ** The sqlite3_db_config() interface is used to make configuration
@@ -1587,11 +1596,11 @@
1596 ** Subsequent arguments vary depending on the configuration verb.
1597 **
1598 ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
1599 ** the call is considered successful.
1600 */
1601 SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...);
1602
1603 /*
1604 ** CAPI3REF: Memory Allocation Routines
1605 **
1606 ** An instance of this object defines the interface between SQLite
@@ -1747,11 +1756,11 @@
1756 ** disabled, the following SQLite interfaces become non-operational:
1757 ** <ul>
1758 ** <li> [sqlite3_memory_used()]
1759 ** <li> [sqlite3_memory_highwater()]
1760 ** <li> [sqlite3_soft_heap_limit64()]
1761 ** <li> [sqlite3_status64()]
1762 ** </ul>)^
1763 ** ^Memory allocation statistics are enabled by default unless SQLite is
1764 ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
1765 ** allocation statistics are disabled by default.
1766 ** </dd>
@@ -2075,11 +2084,11 @@
2084 **
2085 ** ^The sqlite3_extended_result_codes() routine enables or disables the
2086 ** [extended result codes] feature of SQLite. ^The extended result
2087 ** codes are disabled by default for historical compatibility.
2088 */
2089 SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff);
2090
2091 /*
2092 ** CAPI3REF: Last Insert Rowid
2093 **
2094 ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
@@ -2126,11 +2135,11 @@
2135 ** function is running and thus changes the last insert [rowid],
2136 ** then the value returned by [sqlite3_last_insert_rowid()] is
2137 ** unpredictable and might not equal either the old or the new
2138 ** last insert [rowid].
2139 */
2140 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*);
2141
2142 /*
2143 ** CAPI3REF: Count The Number Of Rows Modified
2144 **
2145 ** ^This function returns the number of rows modified, inserted or
@@ -2178,11 +2187,11 @@
2187 **
2188 ** If a separate thread makes changes on the same database connection
2189 ** while [sqlite3_changes()] is running then the value returned
2190 ** is unpredictable and not meaningful.
2191 */
2192 SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*);
2193
2194 /*
2195 ** CAPI3REF: Total Number Of Rows Modified
2196 **
2197 ** ^This function returns the total number of rows inserted, modified or
@@ -2201,11 +2210,11 @@
2210 **
2211 ** If a separate thread makes changes on the same database connection
2212 ** while [sqlite3_total_changes()] is running then the value
2213 ** returned is unpredictable and not meaningful.
2214 */
2215 SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*);
2216
2217 /*
2218 ** CAPI3REF: Interrupt A Long-Running Query
2219 **
2220 ** ^This function causes any pending database operation to abort and
@@ -2240,11 +2249,11 @@
2249 ** that are started after the sqlite3_interrupt() call returns.
2250 **
2251 ** If the database connection closes while [sqlite3_interrupt()]
2252 ** is running then bad things will likely happen.
2253 */
2254 SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*);
2255
2256 /*
2257 ** CAPI3REF: Determine If An SQL Statement Is Complete
2258 **
2259 ** These routines are useful during command-line input to determine if the
@@ -2275,12 +2284,12 @@
2284 ** UTF-8 string.
2285 **
2286 ** The input to [sqlite3_complete16()] must be a zero-terminated
2287 ** UTF-16 string in native byte order.
2288 */
2289 SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql);
2290 SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
2291
2292 /*
2293 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
2294 ** KEYWORDS: {busy-handler callback} {busy handler}
2295 **
@@ -2336,11 +2345,11 @@
2345 ** result in undefined behavior.
2346 **
2347 ** A busy handler must not close the database connection
2348 ** or [prepared statement] that invoked the busy handler.
2349 */
2350 SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2351
2352 /*
2353 ** CAPI3REF: Set A Busy Timeout
2354 **
2355 ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
@@ -2358,11 +2367,11 @@
2367 ** was defined (using [sqlite3_busy_handler()]) prior to calling
2368 ** this routine, that other busy handler is cleared.)^
2369 **
2370 ** See also: [PRAGMA busy_timeout]
2371 */
2372 SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms);
2373
2374 /*
2375 ** CAPI3REF: Convenience Routines For Running Queries
2376 **
2377 ** This is a legacy interface that is preserved for backwards compatibility.
@@ -2432,19 +2441,19 @@
2441 ** interface defined here. As a consequence, errors that occur in the
2442 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
2443 ** reflected in subsequent calls to [sqlite3_errcode()] or
2444 ** [sqlite3_errmsg()].
2445 */
2446 SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
2447 sqlite3 *db, /* An open database */
2448 const char *zSql, /* SQL to be evaluated */
2449 char ***pazResult, /* Results of the query */
2450 int *pnRow, /* Number of result rows written here */
2451 int *pnColumn, /* Number of result columns written here */
2452 char **pzErrmsg /* Error msg written here */
2453 );
2454 SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result);
2455
2456 /*
2457 ** CAPI3REF: Formatted String Printing Functions
2458 **
2459 ** These routines are work-alikes of the "printf()" family of functions
@@ -2546,14 +2555,14 @@
2555 **
2556 ** ^(The "%z" formatting option works like "%s" but with the
2557 ** addition that after the string has been read and copied into
2558 ** the result, [sqlite3_free()] is called on the input string.)^
2559 */
2560 SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...);
2561 SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list);
2562 SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...);
2563 SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list);
2564
2565 /*
2566 ** CAPI3REF: Memory Allocation Subsystem
2567 **
2568 ** The SQLite core uses these three routines for all of its own
@@ -2639,16 +2648,16 @@
2648 **
2649 ** The application must not read or write any part of
2650 ** a block of memory after it has been released using
2651 ** [sqlite3_free()] or [sqlite3_realloc()].
2652 */
2653 SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int);
2654 SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64);
2655 SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int);
2656 SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64);
2657 SQLITE_API void SQLITE_STDCALL sqlite3_free(void*);
2658 SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*);
2659
2660 /*
2661 ** CAPI3REF: Memory Allocator Statistics
2662 **
2663 ** SQLite provides these two interfaces for reporting on the status
@@ -2669,12 +2678,12 @@
2678 ** [sqlite3_memory_used()] if and only if the parameter to
2679 ** [sqlite3_memory_highwater()] is true. ^The value returned
2680 ** by [sqlite3_memory_highwater(1)] is the high-water mark
2681 ** prior to the reset.
2682 */
2683 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void);
2684 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag);
2685
2686 /*
2687 ** CAPI3REF: Pseudo-Random Number Generator
2688 **
2689 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
@@ -2693,11 +2702,11 @@
2702 ** ^If the previous call to this routine had an N of 1 or more and a
2703 ** non-NULL P then the pseudo-randomness is generated
2704 ** internally and without recourse to the [sqlite3_vfs] xRandomness
2705 ** method.
2706 */
2707 SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P);
2708
2709 /*
2710 ** CAPI3REF: Compile-Time Authorization Callbacks
2711 **
2712 ** ^This routine registers an authorizer callback with a particular
@@ -2775,11 +2784,11 @@
2784 ** [sqlite3_prepare()] or its variants. Authorization is not
2785 ** performed during statement evaluation in [sqlite3_step()], unless
2786 ** as stated in the previous paragraph, sqlite3_step() invokes
2787 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
2788 */
2789 SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
2790 sqlite3*,
2791 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2792 void *pUserData
2793 );
2794
@@ -2879,12 +2888,12 @@
2888 ** digits in the time are meaningless. Future versions of SQLite
2889 ** might provide greater resolution on the profiler callback. The
2890 ** sqlite3_profile() function is considered experimental and is
2891 ** subject to change in future versions of SQLite.
2892 */
2893 SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2894 SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
2895 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2896
2897 /*
2898 ** CAPI3REF: Query Progress Callbacks
2899 **
@@ -2914,11 +2923,11 @@
2923 ** the database connection that invoked the progress handler.
2924 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2925 ** database connections for the meaning of "modify" in this paragraph.
2926 **
2927 */
2928 SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2929
2930 /*
2931 ** CAPI3REF: Opening A New Database Connection
2932 **
2933 ** ^These routines open an SQLite database file as specified by the
@@ -3142,19 +3151,19 @@
3151 ** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various
3152 ** features that require the use of temporary files may fail.
3153 **
3154 ** See also: [sqlite3_temp_directory]
3155 */
3156 SQLITE_API int SQLITE_STDCALL sqlite3_open(
3157 const char *filename, /* Database filename (UTF-8) */
3158 sqlite3 **ppDb /* OUT: SQLite db handle */
3159 );
3160 SQLITE_API int SQLITE_STDCALL sqlite3_open16(
3161 const void *filename, /* Database filename (UTF-16) */
3162 sqlite3 **ppDb /* OUT: SQLite db handle */
3163 );
3164 SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
3165 const char *filename, /* Database filename (UTF-8) */
3166 sqlite3 **ppDb, /* OUT: SQLite db handle */
3167 int flags, /* Flags */
3168 const char *zVfs /* Name of VFS module to use */
3169 );
@@ -3196,23 +3205,25 @@
3205 ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
3206 ** is not a database file pathname pointer that SQLite passed into the xOpen
3207 ** VFS method, then the behavior of this routine is undefined and probably
3208 ** undesirable.
3209 */
3210 SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3211 SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3212 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3213
3214
3215 /*
3216 ** CAPI3REF: Error Codes And Messages
3217 **
3218 ** ^If the most recent sqlite3_* API call associated with
3219 ** [database connection] D failed, then the sqlite3_errcode(D) interface
3220 ** returns the numeric [result code] or [extended result code] for that
3221 ** API call.
3222 ** If the most recent API call was successful,
3223 ** then the return value from sqlite3_errcode() is undefined.
3224 ** ^The sqlite3_extended_errcode()
3225 ** interface is the same except that it always returns the
3226 ** [extended result code] even when extended result codes are
3227 ** disabled.
3228 **
3229 ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -3239,15 +3250,15 @@
3250 **
3251 ** If an interface fails with SQLITE_MISUSE, that means the interface
3252 ** was invoked incorrectly by the application. In that case, the
3253 ** error code and message may or may not be set.
3254 */
3255 SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db);
3256 SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db);
3257 SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*);
3258 SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*);
3259 SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int);
3260
3261 /*
3262 ** CAPI3REF: SQL Statement Object
3263 ** KEYWORDS: {prepared statement} {prepared statements}
3264 **
@@ -3310,11 +3321,11 @@
3321 ** created by an untrusted script can be contained using the
3322 ** [max_page_count] [PRAGMA].
3323 **
3324 ** New run-time limit categories may be added in future releases.
3325 */
3326 SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal);
3327
3328 /*
3329 ** CAPI3REF: Run-Time Limit Categories
3330 ** KEYWORDS: {limit category} {*limit categories}
3331 **
@@ -3460,32 +3471,32 @@
3471 ** or [GLOB] operator or if the parameter is compared to an indexed column
3472 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3473 ** </li>
3474 ** </ol>
3475 */
3476 SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
3477 sqlite3 *db, /* Database handle */
3478 const char *zSql, /* SQL statement, UTF-8 encoded */
3479 int nByte, /* Maximum length of zSql in bytes. */
3480 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3481 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3482 );
3483 SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
3484 sqlite3 *db, /* Database handle */
3485 const char *zSql, /* SQL statement, UTF-8 encoded */
3486 int nByte, /* Maximum length of zSql in bytes. */
3487 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3488 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3489 );
3490 SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
3491 sqlite3 *db, /* Database handle */
3492 const void *zSql, /* SQL statement, UTF-16 encoded */
3493 int nByte, /* Maximum length of zSql in bytes. */
3494 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3495 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3496 );
3497 SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
3498 sqlite3 *db, /* Database handle */
3499 const void *zSql, /* SQL statement, UTF-16 encoded */
3500 int nByte, /* Maximum length of zSql in bytes. */
3501 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3502 const void **pzTail /* OUT: Pointer to unused portion of zSql */
@@ -3496,11 +3507,11 @@
3507 **
3508 ** ^This interface can be used to retrieve a saved copy of the original
3509 ** SQL text used to create a [prepared statement] if that statement was
3510 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3511 */
3512 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
3513
3514 /*
3515 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3516 **
3517 ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
@@ -3527,11 +3538,11 @@
3538 ** database. ^The [ATTACH] and [DETACH] statements also cause
3539 ** sqlite3_stmt_readonly() to return true since, while those statements
3540 ** change the configuration of a database connection, they do not make
3541 ** changes to the content of the database files on disk.
3542 */
3543 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
3544
3545 /*
3546 ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
3547 **
3548 ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
@@ -3546,11 +3557,11 @@
3557 ** to locate all prepared statements associated with a database
3558 ** connection that are in need of being reset. This can be used,
3559 ** for example, in diagnostic routines to search for prepared
3560 ** statements that are holding a transaction open.
3561 */
3562 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*);
3563
3564 /*
3565 ** CAPI3REF: Dynamically Typed Value Object
3566 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
3567 **
@@ -3707,23 +3718,23 @@
3718 ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
3719 **
3720 ** See also: [sqlite3_bind_parameter_count()],
3721 ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
3722 */
3723 SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3724 SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
3725 void(*)(void*));
3726 SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double);
3727 SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int);
3728 SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3729 SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int);
3730 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3731 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3732 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3733 void(*)(void*), unsigned char encoding);
3734 SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3735 SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3736
3737 /*
3738 ** CAPI3REF: Number Of SQL Parameters
3739 **
3740 ** ^This routine can be used to find the number of [SQL parameters]
@@ -3739,11 +3750,11 @@
3750 **
3751 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3752 ** [sqlite3_bind_parameter_name()], and
3753 ** [sqlite3_bind_parameter_index()].
3754 */
3755 SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*);
3756
3757 /*
3758 ** CAPI3REF: Name Of A Host Parameter
3759 **
3760 ** ^The sqlite3_bind_parameter_name(P,N) interface returns
@@ -3766,11 +3777,11 @@
3777 **
3778 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3779 ** [sqlite3_bind_parameter_count()], and
3780 ** [sqlite3_bind_parameter_index()].
3781 */
3782 SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3783
3784 /*
3785 ** CAPI3REF: Index Of A Parameter With A Given Name
3786 **
3787 ** ^Return the index of an SQL parameter given its name. ^The
@@ -3782,20 +3793,20 @@
3793 **
3794 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3795 ** [sqlite3_bind_parameter_count()], and
3796 ** [sqlite3_bind_parameter_index()].
3797 */
3798 SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3799
3800 /*
3801 ** CAPI3REF: Reset All Bindings On A Prepared Statement
3802 **
3803 ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
3804 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
3805 ** ^Use this routine to reset all host parameters to NULL.
3806 */
3807 SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*);
3808
3809 /*
3810 ** CAPI3REF: Number Of Columns In A Result Set
3811 **
3812 ** ^Return the number of columns in the result set returned by the
@@ -3802,11 +3813,11 @@
3813 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
3814 ** statement that does not return data (for example an [UPDATE]).
3815 **
3816 ** See also: [sqlite3_data_count()]
3817 */
3818 SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt);
3819
3820 /*
3821 ** CAPI3REF: Column Names In A Result Set
3822 **
3823 ** ^These routines return the name assigned to a particular column
@@ -3830,12 +3841,12 @@
3841 ** ^The name of a result column is the value of the "AS" clause for
3842 ** that column, if there is an AS clause. If there is no AS clause
3843 ** then the name of the column is unspecified and may change from
3844 ** one release of SQLite to the next.
3845 */
3846 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N);
3847 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N);
3848
3849 /*
3850 ** CAPI3REF: Source Of Data In A Query Result
3851 **
3852 ** ^These routines provide a means to determine the database, table, and
@@ -3878,16 +3889,16 @@
3889 ** If two or more threads call one or more
3890 ** [sqlite3_column_database_name | column metadata interfaces]
3891 ** for the same [prepared statement] and result column
3892 ** at the same time then the results are undefined.
3893 */
3894 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int);
3895 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int);
3896 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int);
3897 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int);
3898 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int);
3899 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int);
3900
3901 /*
3902 ** CAPI3REF: Declared Datatype Of A Query Result
3903 **
3904 ** ^(The first parameter is a [prepared statement].
@@ -3914,12 +3925,12 @@
3925 ** data stored in that column is of the declared type. SQLite is
3926 ** strongly typed, but the typing is dynamic not static. ^Type
3927 ** is associated with individual values, not with the containers
3928 ** used to hold those values.
3929 */
3930 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int);
3931 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int);
3932
3933 /*
3934 ** CAPI3REF: Evaluate An SQL Statement
3935 **
3936 ** After a [prepared statement] has been prepared using either
@@ -3994,11 +4005,11 @@
4005 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
4006 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
4007 ** then the more specific [error codes] are returned directly
4008 ** by sqlite3_step(). The use of the "v2" interface is recommended.
4009 */
4010 SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*);
4011
4012 /*
4013 ** CAPI3REF: Number of columns in a result set
4014 **
4015 ** ^The sqlite3_data_count(P) interface returns the number of columns in the
@@ -4014,11 +4025,11 @@
4025 ** where it always returns zero since each step of that multi-step
4026 ** pragma returns 0 columns of data.
4027 **
4028 ** See also: [sqlite3_column_count()]
4029 */
4030 SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt);
4031
4032 /*
4033 ** CAPI3REF: Fundamental Datatypes
4034 ** KEYWORDS: SQLITE_TEXT
4035 **
@@ -4210,20 +4221,20 @@
4221 ** of these routines, a default value is returned. The default value
4222 ** is either the integer 0, the floating point number 0.0, or a NULL
4223 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
4224 ** [SQLITE_NOMEM].)^
4225 */
4226 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol);
4227 SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4228 SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4229 SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol);
4230 SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol);
4231 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol);
4232 SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol);
4233 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol);
4234 SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol);
4235 SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol);
4236
4237 /*
4238 ** CAPI3REF: Destroy A Prepared Statement Object
4239 **
4240 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
@@ -4246,11 +4257,11 @@
4257 ** resource leaks. It is a grievous error for the application to try to use
4258 ** a prepared statement after it has been finalized. Any use of a prepared
4259 ** statement after it has been finalized can result in undefined and
4260 ** undesirable behavior such as segfaults and heap corruption.
4261 */
4262 SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt);
4263
4264 /*
4265 ** CAPI3REF: Reset A Prepared Statement Object
4266 **
4267 ** The sqlite3_reset() function is called to reset a [prepared statement]
@@ -4272,11 +4283,11 @@
4283 ** [sqlite3_reset(S)] returns an appropriate [error code].
4284 **
4285 ** ^The [sqlite3_reset(S)] interface does not change the values
4286 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
4287 */
4288 SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt);
4289
4290 /*
4291 ** CAPI3REF: Create Or Redefine SQL Functions
4292 ** KEYWORDS: {function creation routines}
4293 ** KEYWORDS: {application-defined SQL function}
@@ -4371,31 +4382,31 @@
4382 ** ^An application-defined function is permitted to call other
4383 ** SQLite interfaces. However, such calls must not
4384 ** close the database connection nor finalize or reset the prepared
4385 ** statement in which the function is running.
4386 */
4387 SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
4388 sqlite3 *db,
4389 const char *zFunctionName,
4390 int nArg,
4391 int eTextRep,
4392 void *pApp,
4393 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4394 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4395 void (*xFinal)(sqlite3_context*)
4396 );
4397 SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
4398 sqlite3 *db,
4399 const void *zFunctionName,
4400 int nArg,
4401 int eTextRep,
4402 void *pApp,
4403 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4404 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4405 void (*xFinal)(sqlite3_context*)
4406 );
4407 SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
4408 sqlite3 *db,
4409 const char *zFunctionName,
4410 int nArg,
4411 int eTextRep,
4412 void *pApp,
@@ -4437,16 +4448,16 @@
4448 ** to be supported. However, new applications should avoid
4449 ** the use of these functions. To encourage programmers to avoid
4450 ** these functions, we will not explain what they do.
4451 */
4452 #ifndef SQLITE_OMIT_DEPRECATED
4453 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*);
4454 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*);
4455 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4456 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void);
4457 SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void);
4458 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4459 void*,sqlite3_int64);
4460 #endif
4461
4462 /*
4463 ** CAPI3REF: Obtaining SQL Function Parameter Values
@@ -4491,22 +4502,22 @@
4502 ** or [sqlite3_value_text16()].
4503 **
4504 ** These routines must be called from the same thread as
4505 ** the SQL function that supplied the [sqlite3_value*] parameters.
4506 */
4507 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*);
4508 SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*);
4509 SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*);
4510 SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*);
4511 SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*);
4512 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*);
4513 SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*);
4514 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*);
4515 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*);
4516 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*);
4517 SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*);
4518 SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*);
4519
4520 /*
4521 ** CAPI3REF: Obtain Aggregate Function Context
4522 **
4523 ** Implementations of aggregate SQL functions use this
@@ -4546,11 +4557,11 @@
4557 ** function.
4558 **
4559 ** This routine must be called from the same thread in which
4560 ** the aggregate SQL function is running.
4561 */
4562 SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes);
4563
4564 /*
4565 ** CAPI3REF: User Data For Functions
4566 **
4567 ** ^The sqlite3_user_data() interface returns a copy of
@@ -4560,11 +4571,11 @@
4571 ** registered the application defined function.
4572 **
4573 ** This routine must be called from the same thread in which
4574 ** the application-defined function is running.
4575 */
4576 SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*);
4577
4578 /*
4579 ** CAPI3REF: Database Connection For Functions
4580 **
4581 ** ^The sqlite3_context_db_handle() interface returns a copy of
@@ -4571,11 +4582,11 @@
4582 ** the pointer to the [database connection] (the 1st parameter)
4583 ** of the [sqlite3_create_function()]
4584 ** and [sqlite3_create_function16()] routines that originally
4585 ** registered the application defined function.
4586 */
4587 SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
4588
4589 /*
4590 ** CAPI3REF: Function Auxiliary Data
4591 **
4592 ** These functions may be used by (non-aggregate) SQL functions to
@@ -4623,12 +4634,12 @@
4634 ** values and [parameters] and expressions composed from the same.)^
4635 **
4636 ** These routines must be called from the same thread in which
4637 ** the SQL function is running.
4638 */
4639 SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N);
4640 SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
4641
4642
4643 /*
4644 ** CAPI3REF: Constants Defining Special Destructor Behavior
4645 **
@@ -4759,30 +4770,30 @@
4770 **
4771 ** If these routines are called from within the different thread
4772 ** than the one containing the application-defined function that received
4773 ** the [sqlite3_context] pointer, the results are undefined.
4774 */
4775 SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4776 SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*,
4777 sqlite3_uint64,void(*)(void*));
4778 SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double);
4779 SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int);
4780 SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int);
4781 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*);
4782 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*);
4783 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int);
4784 SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int);
4785 SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4786 SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*);
4787 SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4788 SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
4789 void(*)(void*), unsigned char encoding);
4790 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4791 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4792 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4793 SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4794 SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n);
4795
4796 /*
4797 ** CAPI3REF: Define New Collating Sequences
4798 **
4799 ** ^These functions add, remove, or modify a [collation] associated
@@ -4859,26 +4870,26 @@
4870 ** is unfortunate but cannot be changed without breaking backwards
4871 ** compatibility.
4872 **
4873 ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
4874 */
4875 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
4876 sqlite3*,
4877 const char *zName,
4878 int eTextRep,
4879 void *pArg,
4880 int(*xCompare)(void*,int,const void*,int,const void*)
4881 );
4882 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
4883 sqlite3*,
4884 const char *zName,
4885 int eTextRep,
4886 void *pArg,
4887 int(*xCompare)(void*,int,const void*,int,const void*),
4888 void(*xDestroy)(void*)
4889 );
4890 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
4891 sqlite3*,
4892 const void *zName,
4893 int eTextRep,
4894 void *pArg,
4895 int(*xCompare)(void*,int,const void*,int,const void*)
@@ -4908,16 +4919,16 @@
4919 **
4920 ** The callback function should register the desired collation using
4921 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
4922 ** [sqlite3_create_collation_v2()].
4923 */
4924 SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
4925 sqlite3*,
4926 void*,
4927 void(*)(void*,sqlite3*,int eTextRep,const char*)
4928 );
4929 SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
4930 sqlite3*,
4931 void*,
4932 void(*)(void*,sqlite3*,int eTextRep,const void*)
4933 );
4934
@@ -4927,15 +4938,15 @@
4938 ** called right after sqlite3_open().
4939 **
4940 ** The code to implement this API is not available in the public release
4941 ** of SQLite.
4942 */
4943 SQLITE_API int SQLITE_STDCALL sqlite3_key(
4944 sqlite3 *db, /* Database to be rekeyed */
4945 const void *pKey, int nKey /* The key */
4946 );
4947 SQLITE_API int SQLITE_STDCALL sqlite3_key_v2(
4948 sqlite3 *db, /* Database to be rekeyed */
4949 const char *zDbName, /* Name of the database */
4950 const void *pKey, int nKey /* The key */
4951 );
4952
@@ -4945,35 +4956,35 @@
4956 ** database is decrypted.
4957 **
4958 ** The code to implement this API is not available in the public release
4959 ** of SQLite.
4960 */
4961 SQLITE_API int SQLITE_STDCALL sqlite3_rekey(
4962 sqlite3 *db, /* Database to be rekeyed */
4963 const void *pKey, int nKey /* The new key */
4964 );
4965 SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2(
4966 sqlite3 *db, /* Database to be rekeyed */
4967 const char *zDbName, /* Name of the database */
4968 const void *pKey, int nKey /* The new key */
4969 );
4970
4971 /*
4972 ** Specify the activation key for a SEE database. Unless
4973 ** activated, none of the SEE routines will work.
4974 */
4975 SQLITE_API void SQLITE_STDCALL sqlite3_activate_see(
4976 const char *zPassPhrase /* Activation phrase */
4977 );
4978 #endif
4979
4980 #ifdef SQLITE_ENABLE_CEROD
4981 /*
4982 ** Specify the activation key for a CEROD database. Unless
4983 ** activated, none of the CEROD routines will work.
4984 */
4985 SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod(
4986 const char *zPassPhrase /* Activation phrase */
4987 );
4988 #endif
4989
4990 /*
@@ -4991,11 +5002,11 @@
5002 ** method of the default [sqlite3_vfs] object. If the xSleep() method
5003 ** of the default VFS is not implemented correctly, or not implemented at
5004 ** all, then the behavior of sqlite3_sleep() may deviate from the description
5005 ** in the previous paragraphs.
5006 */
5007 SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int);
5008
5009 /*
5010 ** CAPI3REF: Name Of The Folder Holding Temporary Files
5011 **
5012 ** ^(If this global variable is made to point to a string which is
@@ -5109,11 +5120,11 @@
5120 **
5121 ** If another thread changes the autocommit status of the database
5122 ** connection while this routine is running, then the return value
5123 ** is undefined.
5124 */
5125 SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*);
5126
5127 /*
5128 ** CAPI3REF: Find The Database Handle Of A Prepared Statement
5129 **
5130 ** ^The sqlite3_db_handle interface returns the [database connection] handle
@@ -5121,11 +5132,11 @@
5132 ** returned by sqlite3_db_handle is the same [database connection]
5133 ** that was the first argument
5134 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
5135 ** create the statement in the first place.
5136 */
5137 SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*);
5138
5139 /*
5140 ** CAPI3REF: Return The Filename For A Database Connection
5141 **
5142 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
@@ -5137,20 +5148,20 @@
5148 ** ^The filename returned by this function is the output of the
5149 ** xFullPathname method of the [VFS]. ^In other words, the filename
5150 ** will be an absolute pathname, even if the filename used
5151 ** to open the database originally was a URI or relative pathname.
5152 */
5153 SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName);
5154
5155 /*
5156 ** CAPI3REF: Determine if a database is read-only
5157 **
5158 ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
5159 ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
5160 ** the name of a database on connection D.
5161 */
5162 SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
5163
5164 /*
5165 ** CAPI3REF: Find the next prepared statement
5166 **
5167 ** ^This interface returns a pointer to the next [prepared statement] after
@@ -5161,11 +5172,11 @@
5172 **
5173 ** The [database connection] pointer D in a call to
5174 ** [sqlite3_next_stmt(D,S)] must refer to an open database
5175 ** connection and in particular must not be a NULL pointer.
5176 */
5177 SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
5178
5179 /*
5180 ** CAPI3REF: Commit And Rollback Notification Callbacks
5181 **
5182 ** ^The sqlite3_commit_hook() interface registers a callback
@@ -5209,12 +5220,12 @@
5220 ** ^The rollback callback is not invoked if a transaction is
5221 ** automatically rolled back because the database connection is closed.
5222 **
5223 ** See also the [sqlite3_update_hook()] interface.
5224 */
5225 SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5226 SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
5227
5228 /*
5229 ** CAPI3REF: Data Change Notification Callbacks
5230 **
5231 ** ^The sqlite3_update_hook() interface registers a callback function
@@ -5260,11 +5271,11 @@
5271 ** the first call on D.
5272 **
5273 ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
5274 ** interfaces.
5275 */
5276 SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
5277 sqlite3*,
5278 void(*)(void *,int ,char const *,char const *,sqlite3_int64),
5279 void*
5280 );
5281
@@ -5300,11 +5311,11 @@
5311 ** This interface is threadsafe on processors where writing a
5312 ** 32-bit integer is atomic.
5313 **
5314 ** See Also: [SQLite Shared-Cache Mode]
5315 */
5316 SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int);
5317
5318 /*
5319 ** CAPI3REF: Attempt To Free Heap Memory
5320 **
5321 ** ^The sqlite3_release_memory() interface attempts to free N bytes
@@ -5316,11 +5327,11 @@
5327 ** ^The sqlite3_release_memory() routine is a no-op returning zero
5328 ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5329 **
5330 ** See also: [sqlite3_db_release_memory()]
5331 */
5332 SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int);
5333
5334 /*
5335 ** CAPI3REF: Free Memory Used By A Database Connection
5336 **
5337 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
@@ -5329,11 +5340,11 @@
5340 ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
5341 ** omitted.
5342 **
5343 ** See also: [sqlite3_release_memory()]
5344 */
5345 SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*);
5346
5347 /*
5348 ** CAPI3REF: Impose A Limit On Heap Size
5349 **
5350 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
@@ -5381,11 +5392,11 @@
5392 ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5393 **
5394 ** The circumstances under which SQLite will enforce the soft heap limit may
5395 ** changes in future releases of SQLite.
5396 */
5397 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N);
5398
5399 /*
5400 ** CAPI3REF: Deprecated Soft Heap Limit Interface
5401 ** DEPRECATED
5402 **
@@ -5392,11 +5403,11 @@
5403 ** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
5404 ** interface. This routine is provided for historical compatibility
5405 ** only. All new applications should use the
5406 ** [sqlite3_soft_heap_limit64()] interface rather than this one.
5407 */
5408 SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
5409
5410
5411 /*
5412 ** CAPI3REF: Extract Metadata About A Column Of A Table
5413 **
@@ -5461,11 +5472,11 @@
5472 **
5473 ** ^This function causes all database schemas to be read from disk and
5474 ** parsed, if that has not already been done, and returns an error if
5475 ** any errors are encountered while loading the schema.
5476 */
5477 SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
5478 sqlite3 *db, /* Connection handle */
5479 const char *zDbName, /* Database name or NULL */
5480 const char *zTableName, /* Table name */
5481 const char *zColumnName, /* Column name */
5482 char const **pzDataType, /* OUTPUT: Declared data type */
@@ -5507,11 +5518,11 @@
5518 ** [sqlite3_enable_load_extension()] prior to calling this API,
5519 ** otherwise an error will be returned.
5520 **
5521 ** See also the [load_extension() SQL function].
5522 */
5523 SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
5524 sqlite3 *db, /* Load the extension into this database connection */
5525 const char *zFile, /* Name of the shared library containing extension */
5526 const char *zProc, /* Entry point. Derived from zFile if 0 */
5527 char **pzErrMsg /* Put error message here if not 0 */
5528 );
@@ -5527,11 +5538,11 @@
5538 ** ^Extension loading is off by default.
5539 ** ^Call the sqlite3_enable_load_extension() routine with onoff==1
5540 ** to turn extension loading on and call it with onoff==0 to turn
5541 ** it back off again.
5542 */
5543 SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
5544
5545 /*
5546 ** CAPI3REF: Automatically Load Statically Linked Extensions
5547 **
5548 ** ^This interface causes the xEntryPoint() function to be invoked for
@@ -5565,11 +5576,11 @@
5576 ** will be called more than once for each database connection that is opened.
5577 **
5578 ** See also: [sqlite3_reset_auto_extension()]
5579 ** and [sqlite3_cancel_auto_extension()]
5580 */
5581 SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
5582
5583 /*
5584 ** CAPI3REF: Cancel Automatic Extension Loading
5585 **
5586 ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5577,19 +5588,19 @@
5588 ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
5589 ** routine returns 1 if initialization routine X was successfully
5590 ** unregistered and it returns 0 if X was not on the list of initialization
5591 ** routines.
5592 */
5593 SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5594
5595 /*
5596 ** CAPI3REF: Reset Automatic Extension Loading
5597 **
5598 ** ^This interface disables all automatic extensions previously
5599 ** registered using [sqlite3_auto_extension()].
5600 */
5601 SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void);
5602
5603 /*
5604 ** The interface to the virtual-table mechanism is currently considered
5605 ** to be experimental. The interface might change in incompatible ways.
5606 ** If this is a problem for you, do not use the interface at this time.
@@ -5788,17 +5799,17 @@
5799 ** be invoked if the call to sqlite3_create_module_v2() fails.
5800 ** ^The sqlite3_create_module()
5801 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
5802 ** destructor.
5803 */
5804 SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
5805 sqlite3 *db, /* SQLite connection to register module with */
5806 const char *zName, /* Name of the module */
5807 const sqlite3_module *p, /* Methods for the module */
5808 void *pClientData /* Client data for xCreate/xConnect */
5809 );
5810 SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
5811 sqlite3 *db, /* SQLite connection to register module with */
5812 const char *zName, /* Name of the module */
5813 const sqlite3_module *p, /* Methods for the module */
5814 void *pClientData, /* Client data for xCreate/xConnect */
5815 void(*xDestroy)(void*) /* Module destructor function */
@@ -5822,11 +5833,11 @@
5833 ** is delivered up to the client application, the string will be automatically
5834 ** freed by sqlite3_free() and the zErrMsg field will be zeroed.
5835 */
5836 struct sqlite3_vtab {
5837 const sqlite3_module *pModule; /* The module for this virtual table */
5838 int nRef; /* Number of open cursors */
5839 char *zErrMsg; /* Error message from sqlite3_mprintf() */
5840 /* Virtual table implementations will typically add additional fields */
5841 };
5842
5843 /*
@@ -5857,11 +5868,11 @@
5868 ** ^The [xCreate] and [xConnect] methods of a
5869 ** [virtual table module] call this interface
5870 ** to declare the format (the names and datatypes of the columns) of
5871 ** the virtual tables they implement.
5872 */
5873 SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL);
5874
5875 /*
5876 ** CAPI3REF: Overload A Function For A Virtual Table
5877 **
5878 ** ^(Virtual tables can provide alternative implementations of functions
@@ -5875,11 +5886,11 @@
5886 ** of the new function always causes an exception to be thrown. So
5887 ** the new function is not good for anything by itself. Its only
5888 ** purpose is to be a placeholder function that can be overloaded
5889 ** by a [virtual table].
5890 */
5891 SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
5892
5893 /*
5894 ** The interface to the virtual-table mechanism defined above (back up
5895 ** to a comment remarkably similar to this one) is currently considered
5896 ** to be experimental. The interface might change in incompatible ways.
@@ -5972,11 +5983,11 @@
5983 ** zero-filled blob to read or write using the incremental-blob interface.
5984 **
5985 ** To avoid a resource leak, every open [BLOB handle] should eventually
5986 ** be released by a call to [sqlite3_blob_close()].
5987 */
5988 SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
5989 sqlite3*,
5990 const char *zDb,
5991 const char *zTable,
5992 const char *zColumn,
5993 sqlite3_int64 iRow,
@@ -6004,11 +6015,11 @@
6015 ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
6016 ** always returns zero.
6017 **
6018 ** ^This function sets the database handle error code and message.
6019 */
6020 SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
6021
6022 /*
6023 ** CAPI3REF: Close A BLOB Handle
6024 **
6025 ** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
@@ -6026,11 +6037,11 @@
6037 ** with a null pointer (such as would be returned by a failed call to
6038 ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
6039 ** is passed a valid open blob handle, the values returned by the
6040 ** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
6041 */
6042 SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *);
6043
6044 /*
6045 ** CAPI3REF: Return The Size Of An Open BLOB
6046 **
6047 ** ^Returns the size in bytes of the BLOB accessible via the
@@ -6041,11 +6052,11 @@
6052 ** This routine only works on a [BLOB handle] which has been created
6053 ** by a prior successful call to [sqlite3_blob_open()] and which has not
6054 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
6055 ** to this routine results in undefined and probably undesirable behavior.
6056 */
6057 SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *);
6058
6059 /*
6060 ** CAPI3REF: Read Data From A BLOB Incrementally
6061 **
6062 ** ^(This function is used to read data from an open [BLOB handle] into a
@@ -6069,11 +6080,11 @@
6080 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
6081 ** to this routine results in undefined and probably undesirable behavior.
6082 **
6083 ** See also: [sqlite3_blob_write()].
6084 */
6085 SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
6086
6087 /*
6088 ** CAPI3REF: Write Data Into A BLOB Incrementally
6089 **
6090 ** ^(This function is used to write data into an open [BLOB handle] from a
@@ -6110,11 +6121,11 @@
6121 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
6122 ** to this routine results in undefined and probably undesirable behavior.
6123 **
6124 ** See also: [sqlite3_blob_read()].
6125 */
6126 SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
6127
6128 /*
6129 ** CAPI3REF: Virtual File System Objects
6130 **
6131 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
@@ -6141,13 +6152,13 @@
6152 **
6153 ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
6154 ** ^(If the default VFS is unregistered, another VFS is chosen as
6155 ** the default. The choice for the new VFS is arbitrary.)^
6156 */
6157 SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName);
6158 SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
6159 SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*);
6160
6161 /*
6162 ** CAPI3REF: Mutexes
6163 **
6164 ** The SQLite core uses these routines for thread
@@ -6256,15 +6267,15 @@
6267 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
6268 ** behave as no-ops.
6269 **
6270 ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
6271 */
6272 SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int);
6273 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*);
6274 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*);
6275 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*);
6276 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*);
6277
6278 /*
6279 ** CAPI3REF: Mutex Methods Object
6280 **
6281 ** An instance of this structure defines the low-level routines
@@ -6370,12 +6381,12 @@
6381 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
6382 ** the appropriate thing to do. The sqlite3_mutex_notheld()
6383 ** interface should also return 1 when given a NULL pointer.
6384 */
6385 #ifndef NDEBUG
6386 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*);
6387 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*);
6388 #endif
6389
6390 /*
6391 ** CAPI3REF: Mutex Types
6392 **
@@ -6407,11 +6418,11 @@
6418 ** serializes access to the [database connection] given in the argument
6419 ** when the [threading mode] is Serialized.
6420 ** ^If the [threading mode] is Single-thread or Multi-thread then this
6421 ** routine returns a NULL pointer.
6422 */
6423 SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*);
6424
6425 /*
6426 ** CAPI3REF: Low-Level Control Of Database Files
6427 **
6428 ** ^The [sqlite3_file_control()] interface makes a direct call to the
@@ -6441,11 +6452,11 @@
6452 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
6453 ** xFileControl method.
6454 **
6455 ** See also: [SQLITE_FCNTL_LOCKSTATE]
6456 */
6457 SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
6458
6459 /*
6460 ** CAPI3REF: Testing Interface
6461 **
6462 ** ^The sqlite3_test_control() interface is used to read out internal
@@ -6460,11 +6471,11 @@
6471 ** The details of the operation codes, their meanings, the parameters
6472 ** they take, and what they do are all subject to change without notice.
6473 ** Unlike most of the SQLite API, this function is not guaranteed to
6474 ** operate consistently from one release to the next.
6475 */
6476 SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...);
6477
6478 /*
6479 ** CAPI3REF: Testing Interface Operation Codes
6480 **
6481 ** These constants are the valid operation code parameters used
@@ -6500,11 +6511,11 @@
6511 #define SQLITE_TESTCTRL_LAST 25
6512
6513 /*
6514 ** CAPI3REF: SQLite Runtime Status
6515 **
6516 ** ^These interfaces are used to retrieve runtime status information
6517 ** about the performance of SQLite, and optionally to reset various
6518 ** highwater marks. ^The first argument is an integer code for
6519 ** the specific parameter to measure. ^(Recognized integer codes
6520 ** are of the form [status parameters | SQLITE_STATUS_...].)^
6521 ** ^The current value of the parameter is returned into *pCurrent.
@@ -6514,23 +6525,26 @@
6525 ** value. For those parameters
6526 ** nothing is written into *pHighwater and the resetFlag is ignored.)^
6527 ** ^(Other parameters record only the highwater mark and not the current
6528 ** value. For these latter parameters nothing is written into *pCurrent.)^
6529 **
6530 ** ^The sqlite3_status() and sqlite3_status64() routines return
6531 ** SQLITE_OK on success and a non-zero [error code] on failure.
6532 **
6533 ** If either the current value or the highwater mark is too large to
6534 ** be represented by a 32-bit integer, then the values returned by
6535 ** sqlite3_status() are undefined.
 
 
 
6536 **
6537 ** See also: [sqlite3_db_status()]
6538 */
6539 SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6540 SQLITE_API int SQLITE_STDCALL sqlite3_status64(
6541 int op,
6542 sqlite3_int64 *pCurrent,
6543 sqlite3_int64 *pHighwater,
6544 int resetFlag
6545 );
6546
6547
6548 /*
6549 ** CAPI3REF: Status Parameters
6550 ** KEYWORDS: {status parameters}
@@ -6644,11 +6658,11 @@
6658 ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
6659 ** non-zero [error code] on failure.
6660 **
6661 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
6662 */
6663 SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
6664
6665 /*
6666 ** CAPI3REF: Status Parameters for database connections
6667 ** KEYWORDS: {SQLITE_DBSTATUS options}
6668 **
@@ -6773,11 +6787,11 @@
6787 ** ^If the resetFlg is true, then the counter is reset to zero after this
6788 ** interface call returns.
6789 **
6790 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
6791 */
6792 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
6793
6794 /*
6795 ** CAPI3REF: Status Parameters for prepared statements
6796 ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}
6797 **
@@ -7242,20 +7256,20 @@
7256 ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
7257 ** APIs are not strictly speaking threadsafe. If they are invoked at the
7258 ** same time as another thread is invoking sqlite3_backup_step() it is
7259 ** possible that they return invalid values.
7260 */
7261 SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
7262 sqlite3 *pDest, /* Destination database handle */
7263 const char *zDestName, /* Destination database name */
7264 sqlite3 *pSource, /* Source database handle */
7265 const char *zSourceName /* Source database name */
7266 );
7267 SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage);
7268 SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p);
7269 SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p);
7270 SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p);
7271
7272 /*
7273 ** CAPI3REF: Unlock Notification
7274 **
7275 ** ^When running in shared-cache mode, a database operation may fail with
@@ -7367,11 +7381,11 @@
7381 ** by an sqlite3_step() call. ^(If there is a blocking connection, then the
7382 ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
7383 ** the special "DROP TABLE/INDEX" case, the extended error code is just
7384 ** SQLITE_LOCKED.)^
7385 */
7386 SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
7387 sqlite3 *pBlocked, /* Waiting connection */
7388 void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
7389 void *pNotifyArg /* Argument to pass to xNotify */
7390 );
7391
@@ -7382,12 +7396,12 @@
7396 ** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
7397 ** and extensions to compare the contents of two buffers containing UTF-8
7398 ** strings in a case-independent fashion, using the same definition of "case
7399 ** independence" that SQLite uses internally when comparing identifiers.
7400 */
7401 SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *);
7402 SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
7403
7404 /*
7405 ** CAPI3REF: String Globbing
7406 *
7407 ** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
@@ -7398,11 +7412,11 @@
7412 ** sensitive.
7413 **
7414 ** Note that this routine returns zero on a match and non-zero if the strings
7415 ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
7416 */
7417 SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
7418
7419 /*
7420 ** CAPI3REF: Error Logging Interface
7421 **
7422 ** ^The [sqlite3_log()] interface writes a message into the [error log]
@@ -7421,11 +7435,11 @@
7435 ** will not use dynamically allocated memory. The log message is stored in
7436 ** a fixed-length buffer on the stack. If the log message is longer than
7437 ** a few hundred characters, it will be truncated to the length of the
7438 ** buffer.
7439 */
7440 SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...);
7441
7442 /*
7443 ** CAPI3REF: Write-Ahead Log Commit Hook
7444 **
7445 ** ^The [sqlite3_wal_hook()] function is used to register a callback that
@@ -7456,11 +7470,11 @@
7470 ** previously registered write-ahead log callback. ^Note that the
7471 ** [sqlite3_wal_autocheckpoint()] interface and the
7472 ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
7473 ** those overwrite any prior [sqlite3_wal_hook()] settings.
7474 */
7475 SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
7476 sqlite3*,
7477 int(*)(void *,sqlite3*,const char*,int),
7478 void*
7479 );
7480
@@ -7490,11 +7504,11 @@
7504 ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
7505 ** pages. The use of this interface
7506 ** is only necessary if the default setting is found to be suboptimal
7507 ** for a particular application.
7508 */
7509 SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
7510
7511 /*
7512 ** CAPI3REF: Checkpoint a database
7513 **
7514 ** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
@@ -7511,11 +7525,11 @@
7525 ** interface was added. This interface is retained for backwards
7526 ** compatibility and as a convenience for applications that need to manually
7527 ** start a callback but which do not need the full power (and corresponding
7528 ** complication) of [sqlite3_wal_checkpoint_v2()].
7529 */
7530 SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
7531
7532 /*
7533 ** CAPI3REF: Checkpoint a database
7534 **
7535 ** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
@@ -7604,11 +7618,11 @@
7618 ** [sqlite3_errcode()] and [sqlite3_errmsg()].
7619 **
7620 ** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
7621 ** from SQL.
7622 */
7623 SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
7624 sqlite3 *db, /* Database handle */
7625 const char *zDb, /* Name of attached database (or NULL) */
7626 int eMode, /* SQLITE_CHECKPOINT_* value */
7627 int *pnLog, /* OUT: Size of WAL log in frames */
7628 int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -7640,11 +7654,11 @@
7654 **
7655 ** At present, there is only one option that may be configured using
7656 ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
7657 ** may be added in the future.
7658 */
7659 SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...);
7660
7661 /*
7662 ** CAPI3REF: Virtual Table Configuration Options
7663 **
7664 ** These macros define the various options to the
@@ -7693,11 +7707,11 @@
7707 ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],
7708 ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode
7709 ** of the SQL statement that triggered the call to the [xUpdate] method of the
7710 ** [virtual table].
7711 */
7712 SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *);
7713
7714 /*
7715 ** CAPI3REF: Conflict resolution modes
7716 ** KEYWORDS: {conflict resolution mode}
7717 **
@@ -7797,11 +7811,11 @@
7811 ** as if the loop did not exist - it returns non-zero and leave the variable
7812 ** that pOut points to unchanged.
7813 **
7814 ** See also: [sqlite3_stmt_scanstatus_reset()]
7815 */
7816 SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_stmt_scanstatus(
7817 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
7818 int idx, /* Index of loop to report on */
7819 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
7820 void *pOut /* Result written here */
7821 );
@@ -7812,11 +7826,11 @@
7826 ** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
7827 **
7828 ** This API is only available if the library is built with pre-processor
7829 ** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
7830 */
7831 SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
7832
7833
7834 /*
7835 ** Undo the hack that converts floating point types to integer for
7836 ** builds on processors without floating point support.
@@ -7867,11 +7881,11 @@
7881 ** Register a geometry callback named zGeom that can be used as part of an
7882 ** R-Tree geometry query as follows:
7883 **
7884 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
7885 */
7886 SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
7887 sqlite3 *db,
7888 const char *zGeom,
7889 int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
7890 void *pContext
7891 );
@@ -7893,11 +7907,11 @@
7907 ** Register a 2nd-generation geometry callback named zScore that can be
7908 ** used as part of an R-Tree geometry query as follows:
7909 **
7910 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
7911 */
7912 SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
7913 sqlite3 *db,
7914 const char *zQueryFunc,
7915 int (*xQueryFunc)(sqlite3_rtree_query_info*),
7916 void *pContext,
7917 void (*xDestructor)(void*)
@@ -8911,10 +8925,24 @@
8925 **
8926 ** 0.5 -> -10 0.1 -> -33 0.0625 -> -40
8927 */
8928 typedef INT16_TYPE LogEst;
8929
8930 /*
8931 ** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer
8932 */
8933 #ifndef SQLITE_PTRSIZE
8934 # if defined(__SIZEOF_POINTER__)
8935 # define SQLITE_PTRSIZE __SIZEOF_POINTER__
8936 # elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \
8937 defined(_M_ARM) || defined(__arm__) || defined(__x86)
8938 # define SQLITE_PTRSIZE 4
8939 # else
8940 # define SQLITE_PTRSIZE 8
8941 # endif
8942 #endif
8943
8944 /*
8945 ** Macros to determine whether the machine is big or little endian,
8946 ** and whether or not that determination is run-time or compile-time.
8947 **
8948 ** For best performance, an attempt is made to guess at the byte-order
@@ -9123,12 +9151,12 @@
9151 */
9152 #ifdef SQLITE_OMIT_WSD
9153 #define SQLITE_WSD const
9154 #define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
9155 #define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
9156 SQLITE_API int SQLITE_STDCALL sqlite3_wsd_init(int N, int J);
9157 SQLITE_API void *SQLITE_STDCALL sqlite3_wsd_find(void *K, int L);
9158 #else
9159 #define SQLITE_WSD
9160 #define GLOBAL(t,v) v
9161 #define sqlite3GlobalConfig sqlite3Config
9162 #endif
@@ -9361,12 +9389,22 @@
9389 #define BTREE_DATA_VERSION 15 /* A virtual meta-value */
9390
9391 /*
9392 ** Values that may be OR'd together to form the second argument of an
9393 ** sqlite3BtreeCursorHints() call.
9394 **
9395 ** The BTREE_BULKLOAD flag is set on index cursors when the index is going
9396 ** to be filled with content that is already in sorted order.
9397 **
9398 ** The BTREE_SEEK_EQ flag is set on cursors that will get OP_SeekGE or
9399 ** OP_SeekLE opcodes for a range search, but where the range of entries
9400 ** selected will all have the same key. In other words, the cursor will
9401 ** be used only for equality key searches.
9402 **
9403 */
9404 #define BTREE_BULKLOAD 0x00000001 /* Used to full index in sorted order */
9405 #define BTREE_SEEK_EQ 0x00000002 /* EQ seeks only - no range seeks */
9406
9407 SQLITE_PRIVATE int sqlite3BtreeCursor(
9408 Btree*, /* BTree containing table to open */
9409 int iTable, /* Index of root page */
9410 int wrFlag, /* 1 for writing. 0 for read-only */
@@ -9408,10 +9446,13 @@
9446 SQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
9447 SQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *);
9448 SQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *);
9449 SQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);
9450 SQLITE_PRIVATE void sqlite3BtreeCursorHints(BtCursor *, unsigned int mask);
9451 #ifdef SQLITE_DEBUG
9452 SQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor*, unsigned int mask);
9453 #endif
9454 SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *pBt);
9455 SQLITE_PRIVATE int sqlite3HeaderSizeBtree(void);
9456
9457 #ifndef NDEBUG
9458 SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*);
@@ -10908,10 +10949,11 @@
10949 } init;
10950 int nVdbeActive; /* Number of VDBEs currently running */
10951 int nVdbeRead; /* Number of active VDBEs that read or write */
10952 int nVdbeWrite; /* Number of active VDBEs that read and write */
10953 int nVdbeExec; /* Number of nested calls to VdbeExec() */
10954 int nVDestroy; /* Number of active OP_VDestroy operations */
10955 int nExtension; /* Number of loaded extensions */
10956 void **aExtension; /* Array of shared library handles */
10957 void (*xTrace)(void*,const char*); /* Trace function */
10958 void *pTraceArg; /* Argument to the trace function */
10959 void (*xProfile)(void*,const char*,u64); /* Profiling function */
@@ -12502,11 +12544,12 @@
12544 #define OPFLAG_APPEND 0x08 /* This is likely to be an append */
12545 #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
12546 #define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */
12547 #define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */
12548 #define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */
12549 #define OPFLAG_SEEKEQ 0x02 /* OP_Open** cursor uses EQ seek only */
12550 #define OPFLAG_P2ISREG 0x04 /* P2 to OP_Open** is a register number */
12551 #define OPFLAG_PERMUTE 0x01 /* OP_Compare: use the permutation */
12552
12553 /*
12554 * Each trigger present in the database schema is stored as an instance of
12555 * struct Trigger.
@@ -12906,14 +12949,19 @@
12949 SQLITE_PRIVATE sqlite3_mutex *sqlite3MutexAlloc(int);
12950 SQLITE_PRIVATE int sqlite3MutexInit(void);
12951 SQLITE_PRIVATE int sqlite3MutexEnd(void);
12952 #endif
12953
12954 SQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int);
12955 SQLITE_PRIVATE void sqlite3StatusUp(int, int);
12956 SQLITE_PRIVATE void sqlite3StatusDown(int, int);
12957 SQLITE_PRIVATE void sqlite3StatusSet(int, int);
12958
12959 /* Access to mutexes used by sqlite3_status() */
12960 SQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void);
12961 SQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void);
12962
12963 #ifndef SQLITE_OMIT_FLOATING_POINT
12964 SQLITE_PRIVATE int sqlite3IsNaN(double);
12965 #else
12966 # define sqlite3IsNaN(X) 0
12967 #endif
@@ -13289,11 +13337,11 @@
13337 SQLITE_PRIVATE const char *sqlite3ErrStr(int);
13338 SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);
13339 SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);
13340 SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);
13341 SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
13342 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
13343 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
13344 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
13345 SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
13346 SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *, const char *);
13347 SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);
@@ -13592,11 +13640,11 @@
13640 ** print I/O tracing messages.
13641 */
13642 #ifdef SQLITE_ENABLE_IOTRACE
13643 # define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; }
13644 SQLITE_PRIVATE void sqlite3VdbeIOTraceSql(Vdbe*);
13645 SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);
13646 #else
13647 # define IOTRACE(A)
13648 # define sqlite3VdbeIOTraceSql(X)
13649 #endif
13650
@@ -14305,11 +14353,11 @@
14353 ** was used and false if not.
14354 **
14355 ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
14356 ** is not required for a match.
14357 */
14358 SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName){
14359 int i, n;
14360
14361 #if SQLITE_ENABLE_API_ARMOR
14362 if( zOptName==0 ){
14363 (void)SQLITE_MISUSE_BKPT;
@@ -14333,11 +14381,11 @@
14381
14382 /*
14383 ** Return the N-th compile-time option string. If N is out of range,
14384 ** return a NULL pointer.
14385 */
14386 SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N){
14387 if( N>=0 && N<ArraySize(azCompileOpt) ){
14388 return azCompileOpt[N];
14389 }
14390 return 0;
14391 }
@@ -14676,18 +14724,10 @@
14724 ** An instance of the virtual machine. This structure contains the complete
14725 ** state of the virtual machine.
14726 **
14727 ** The "sqlite3_stmt" structure pointer that is returned by sqlite3_prepare()
14728 ** is really a pointer to an instance of this structure.
 
 
 
 
 
 
 
 
14729 */
14730 struct Vdbe {
14731 sqlite3 *db; /* The database connection that owns this statement */
14732 Op *aOp; /* Space to hold the virtual machine's program */
14733 Mem *aMem; /* The memory locations */
@@ -14714,11 +14754,10 @@
14754 #endif
14755 u16 nResColumn; /* Number of columns in one row of the result set */
14756 u8 errorAction; /* Recovery action to do in case of an error */
14757 u8 minWriteFileFormat; /* Minimum file format for writable database files */
14758 bft explain:2; /* True if EXPLAIN present on SQL command */
 
14759 bft changeCntOn:1; /* True to update the change-counter */
14760 bft expired:1; /* True if the VM needs to be recompiled */
14761 bft runOnlyOnce:1; /* Automatically expire on reset */
14762 bft usesStmtJournal:1; /* True if uses a statement journal */
14763 bft readOnly:1; /* True for statements that do not write */
@@ -14874,13 +14913,35 @@
14913 /*
14914 ** Variables in which to record status information.
14915 */
14916 typedef struct sqlite3StatType sqlite3StatType;
14917 static SQLITE_WSD struct sqlite3StatType {
14918 #if SQLITE_PTRSIZE>4
14919 sqlite3_int64 nowValue[10]; /* Current value */
14920 sqlite3_int64 mxValue[10]; /* Maximum value */
14921 #else
14922 u32 nowValue[10]; /* Current value */
14923 u32 mxValue[10]; /* Maximum value */
14924 #endif
14925 } sqlite3Stat = { {0,}, {0,} };
14926
14927 /*
14928 ** Elements of sqlite3Stat[] are protected by either the memory allocator
14929 ** mutex, or by the pcache1 mutex. The following array determines which.
14930 */
14931 static const char statMutex[] = {
14932 0, /* SQLITE_STATUS_MEMORY_USED */
14933 1, /* SQLITE_STATUS_PAGECACHE_USED */
14934 1, /* SQLITE_STATUS_PAGECACHE_OVERFLOW */
14935 0, /* SQLITE_STATUS_SCRATCH_USED */
14936 0, /* SQLITE_STATUS_SCRATCH_OVERFLOW */
14937 0, /* SQLITE_STATUS_MALLOC_SIZE */
14938 0, /* SQLITE_STATUS_PARSER_STACK */
14939 1, /* SQLITE_STATUS_PAGECACHE_SIZE */
14940 0, /* SQLITE_STATUS_SCRATCH_SIZE */
14941 0, /* SQLITE_STATUS_MALLOC_COUNT */
14942 };
14943
14944
14945 /* The "wsdStat" macro will resolve to the status information
14946 ** state vector. If writable static data is unsupported on the target,
14947 ** we have to locate the state vector at run-time. In the more common
@@ -14894,70 +14955,116 @@
14955 # define wsdStatInit
14956 # define wsdStat sqlite3Stat
14957 #endif
14958
14959 /*
14960 ** Return the current value of a status parameter. The caller must
14961 ** be holding the appropriate mutex.
14962 */
14963 SQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int op){
14964 wsdStatInit;
14965 assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
14966 assert( op>=0 && op<ArraySize(statMutex) );
14967 assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()
14968 : sqlite3MallocMutex()) );
14969 return wsdStat.nowValue[op];
14970 }
14971
14972 /*
14973 ** Add N to the value of a status record. The caller must hold the
14974 ** appropriate mutex. (Locking is checked by assert()).
14975 **
14976 ** The StatusUp() routine can accept positive or negative values for N.
14977 ** The value of N is added to the current status value and the high-water
14978 ** mark is adjusted if necessary.
14979 **
14980 ** The StatusDown() routine lowers the current value by N. The highwater
14981 ** mark is unchanged. N must be non-negative for StatusDown().
14982 */
14983 SQLITE_PRIVATE void sqlite3StatusUp(int op, int N){
14984 wsdStatInit;
14985 assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
14986 assert( op>=0 && op<ArraySize(statMutex) );
14987 assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()
14988 : sqlite3MallocMutex()) );
14989 wsdStat.nowValue[op] += N;
14990 if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){
14991 wsdStat.mxValue[op] = wsdStat.nowValue[op];
14992 }
14993 }
14994 SQLITE_PRIVATE void sqlite3StatusDown(int op, int N){
14995 wsdStatInit;
14996 assert( N>=0 );
14997 assert( op>=0 && op<ArraySize(statMutex) );
14998 assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()
14999 : sqlite3MallocMutex()) );
15000 assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
15001 wsdStat.nowValue[op] -= N;
15002 }
15003
15004 /*
15005 ** Set the value of a status to X. The highwater mark is adjusted if
15006 ** necessary. The caller must hold the appropriate mutex.
15007 */
15008 SQLITE_PRIVATE void sqlite3StatusSet(int op, int X){
15009 wsdStatInit;
15010 assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
15011 assert( op>=0 && op<ArraySize(statMutex) );
15012 assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()
15013 : sqlite3MallocMutex()) );
15014 wsdStat.nowValue[op] = X;
15015 if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){
15016 wsdStat.mxValue[op] = wsdStat.nowValue[op];
15017 }
15018 }
15019
15020 /*
15021 ** Query status information.
 
 
 
 
15022 */
15023 SQLITE_API int SQLITE_STDCALL sqlite3_status64(
15024 int op,
15025 sqlite3_int64 *pCurrent,
15026 sqlite3_int64 *pHighwater,
15027 int resetFlag
15028 ){
15029 sqlite3_mutex *pMutex;
15030 wsdStatInit;
15031 if( op<0 || op>=ArraySize(wsdStat.nowValue) ){
15032 return SQLITE_MISUSE_BKPT;
15033 }
15034 #ifdef SQLITE_ENABLE_API_ARMOR
15035 if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;
15036 #endif
15037 pMutex = statMutex[op] ? sqlite3Pcache1Mutex() : sqlite3MallocMutex();
15038 sqlite3_mutex_enter(pMutex);
15039 *pCurrent = wsdStat.nowValue[op];
15040 *pHighwater = wsdStat.mxValue[op];
15041 if( resetFlag ){
15042 wsdStat.mxValue[op] = wsdStat.nowValue[op];
15043 }
15044 sqlite3_mutex_leave(pMutex);
15045 (void)pMutex; /* Prevent warning when SQLITE_THREADSAFE=0 */
15046 return SQLITE_OK;
15047 }
15048 SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
15049 sqlite3_int64 iCur, iHwtr;
15050 int rc;
15051 #ifdef SQLITE_ENABLE_API_ARMOR
15052 if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;
15053 #endif
15054 rc = sqlite3_status64(op, &iCur, &iHwtr, resetFlag);
15055 if( rc==0 ){
15056 *pCurrent = (int)iCur;
15057 *pHighwater = (int)iHwtr;
15058 }
15059 return rc;
15060 }
15061
15062 /*
15063 ** Query status information for a single database connection
15064 */
15065 SQLITE_API int SQLITE_STDCALL sqlite3_db_status(
15066 sqlite3 *db, /* The database connection whose status is desired */
15067 int op, /* Status verb */
15068 int *pCurrent, /* Write current value here */
15069 int *pHighwater, /* Write high-water mark here */
15070 int resetFlag /* Reset high-water mark if true */
@@ -16577,11 +16684,11 @@
16684
16685 /*
16686 ** Locate a VFS by name. If no name is given, simply return the
16687 ** first VFS on the list.
16688 */
16689 SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfs){
16690 sqlite3_vfs *pVfs = 0;
16691 #if SQLITE_THREADSAFE
16692 sqlite3_mutex *mutex;
16693 #endif
16694 #ifndef SQLITE_OMIT_AUTOINIT
@@ -16623,11 +16730,11 @@
16730 /*
16731 ** Register a VFS with the system. It is harmless to register the same
16732 ** VFS multiple times. The new VFS becomes the default if makeDflt is
16733 ** true.
16734 */
16735 SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
16736 MUTEX_LOGIC(sqlite3_mutex *mutex;)
16737 #ifndef SQLITE_OMIT_AUTOINIT
16738 int rc = sqlite3_initialize();
16739 if( rc ) return rc;
16740 #endif
@@ -16651,11 +16758,11 @@
16758 }
16759
16760 /*
16761 ** Unregister a VFS so that it is no longer accessible.
16762 */
16763 SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
16764 #if SQLITE_THREADSAFE
16765 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
16766 #endif
16767 sqlite3_mutex_enter(mutex);
16768 vfsUnlink(pVfs);
@@ -18987,11 +19094,11 @@
19094 }
19095
19096 /*
19097 ** Retrieve a pointer to a static mutex or allocate a new dynamic one.
19098 */
19099 SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int id){
19100 #ifndef SQLITE_OMIT_AUTOINIT
19101 if( id<=SQLITE_MUTEX_RECURSIVE && sqlite3_initialize() ) return 0;
19102 if( id>SQLITE_MUTEX_RECURSIVE && sqlite3MutexInit() ) return 0;
19103 #endif
19104 return sqlite3GlobalConfig.mutex.xMutexAlloc(id);
@@ -19006,31 +19113,31 @@
19113 }
19114
19115 /*
19116 ** Free a dynamic mutex.
19117 */
19118 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex *p){
19119 if( p ){
19120 sqlite3GlobalConfig.mutex.xMutexFree(p);
19121 }
19122 }
19123
19124 /*
19125 ** Obtain the mutex p. If some other thread already has the mutex, block
19126 ** until it can be obtained.
19127 */
19128 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex *p){
19129 if( p ){
19130 sqlite3GlobalConfig.mutex.xMutexEnter(p);
19131 }
19132 }
19133
19134 /*
19135 ** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another
19136 ** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.
19137 */
19138 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex *p){
19139 int rc = SQLITE_OK;
19140 if( p ){
19141 return sqlite3GlobalConfig.mutex.xMutexTry(p);
19142 }
19143 return rc;
@@ -19040,11 +19147,11 @@
19147 ** The sqlite3_mutex_leave() routine exits a mutex that was previously
19148 ** entered by the same thread. The behavior is undefined if the mutex
19149 ** is not currently entered. If a NULL pointer is passed as an argument
19150 ** this function is a no-op.
19151 */
19152 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex *p){
19153 if( p ){
19154 sqlite3GlobalConfig.mutex.xMutexLeave(p);
19155 }
19156 }
19157
@@ -19051,14 +19158,14 @@
19158 #ifndef NDEBUG
19159 /*
19160 ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are
19161 ** intended for use inside assert() statements.
19162 */
19163 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex *p){
19164 return p==0 || sqlite3GlobalConfig.mutex.xMutexHeld(p);
19165 }
19166 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex *p){
19167 return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
19168 }
19169 #endif
19170
19171 #endif /* !defined(SQLITE_MUTEX_OMIT) */
@@ -20050,12 +20157,12 @@
20157 ** of the sqlite3_initialize() and sqlite3_shutdown() processing, the
20158 ** "interlocked" magic used here is probably not strictly necessary.
20159 */
20160 static LONG SQLITE_WIN32_VOLATILE winMutex_lock = 0;
20161
20162 SQLITE_API int SQLITE_STDCALL sqlite3_win32_is_nt(void); /* os_win.c */
20163 SQLITE_API void SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */
20164
20165 static int winMutexInit(void){
20166 /* The first to increment to 1 does actual initialization */
20167 if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){
20168 int i;
@@ -20347,11 +20454,11 @@
20454 /*
20455 ** Attempt to release up to n bytes of non-essential memory currently
20456 ** held by SQLite. An example of non-essential memory is memory used to
20457 ** cache database pages that are not currently in use.
20458 */
20459 SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int n){
20460 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
20461 return sqlite3PcacheReleaseMemory(n);
20462 #else
20463 /* IMPLEMENTATION-OF: R-34391-24921 The sqlite3_release_memory() routine
20464 ** is a no-op returning zero if SQLite is not compiled with
@@ -20401,10 +20508,17 @@
20508 */
20509 int nearlyFull;
20510 } mem0 = { 0, 0, 0, 0, 0, 0, 0, 0 };
20511
20512 #define mem0 GLOBAL(struct Mem0Global, mem0)
20513
20514 /*
20515 ** Return the memory allocator mutex. sqlite3_status() needs it.
20516 */
20517 SQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void){
20518 return mem0.mutex;
20519 }
20520
20521 /*
20522 ** This routine runs when the memory allocator sees that the
20523 ** total memory allocation is about to exceed the soft heap
20524 ** limit.
@@ -20424,11 +20538,11 @@
20538 static int sqlite3MemoryAlarm(
20539 void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
20540 void *pArg,
20541 sqlite3_int64 iThreshold
20542 ){
20543 sqlite3_int64 nUsed;
20544 sqlite3_mutex_enter(mem0.mutex);
20545 mem0.alarmCallback = xCallback;
20546 mem0.alarmArg = pArg;
20547 mem0.alarmThreshold = iThreshold;
20548 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
@@ -20440,11 +20554,11 @@
20554 #ifndef SQLITE_OMIT_DEPRECATED
20555 /*
20556 ** Deprecated external interface. Internal/core SQLite code
20557 ** should call sqlite3MemoryAlarm.
20558 */
20559 SQLITE_API int SQLITE_STDCALL sqlite3_memory_alarm(
20560 void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
20561 void *pArg,
20562 sqlite3_int64 iThreshold
20563 ){
20564 return sqlite3MemoryAlarm(xCallback, pArg, iThreshold);
@@ -20453,11 +20567,11 @@
20567
20568 /*
20569 ** Set the soft heap-size limit for the library. Passing a zero or
20570 ** negative value indicates no limit.
20571 */
20572 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 n){
20573 sqlite3_int64 priorLimit;
20574 sqlite3_int64 excess;
20575 #ifndef SQLITE_OMIT_AUTOINIT
20576 int rc = sqlite3_initialize();
20577 if( rc ) return -1;
@@ -20473,19 +20587,20 @@
20587 }
20588 excess = sqlite3_memory_used() - n;
20589 if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff));
20590 return priorLimit;
20591 }
20592 SQLITE_API void SQLITE_STDCALL sqlite3_soft_heap_limit(int n){
20593 if( n<0 ) n = 0;
20594 sqlite3_soft_heap_limit64(n);
20595 }
20596
20597 /*
20598 ** Initialize the memory allocation subsystem.
20599 */
20600 SQLITE_PRIVATE int sqlite3MallocInit(void){
20601 int rc;
20602 if( sqlite3GlobalConfig.m.xMalloc==0 ){
20603 sqlite3MemSetDefault();
20604 }
20605 memset(&mem0, 0, sizeof(mem0));
20606 if( sqlite3GlobalConfig.bCoreMutex ){
@@ -20517,11 +20632,13 @@
20632 || sqlite3GlobalConfig.nPage<1 ){
20633 sqlite3GlobalConfig.pPage = 0;
20634 sqlite3GlobalConfig.szPage = 0;
20635 sqlite3GlobalConfig.nPage = 0;
20636 }
20637 rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
20638 if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));
20639 return rc;
20640 }
20641
20642 /*
20643 ** Return true if the heap is currently under memory pressure - in other
20644 ** words if the amount of heap used is close to the limit set by
@@ -20542,11 +20659,11 @@
20659 }
20660
20661 /*
20662 ** Return the amount of memory currently checked out.
20663 */
20664 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void){
20665 int n, mx;
20666 sqlite3_int64 res;
20667 sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, 0);
20668 res = (sqlite3_int64)n; /* Work around bug in Borland C. Ticket #3216 */
20669 return res;
@@ -20555,11 +20672,11 @@
20672 /*
20673 ** Return the maximum amount of memory that has ever been
20674 ** checked out since either the beginning of this process
20675 ** or since the most recent reset.
20676 */
20677 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag){
20678 int n, mx;
20679 sqlite3_int64 res;
20680 sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, resetFlag);
20681 res = (sqlite3_int64)mx; /* Work around bug in Borland C. Ticket #3216 */
20682 return res;
@@ -20593,11 +20710,11 @@
20710 void *p;
20711 assert( sqlite3_mutex_held(mem0.mutex) );
20712 nFull = sqlite3GlobalConfig.m.xRoundup(n);
20713 sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n);
20714 if( mem0.alarmCallback!=0 ){
20715 sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
20716 if( nUsed >= mem0.alarmThreshold - nFull ){
20717 mem0.nearlyFull = 1;
20718 sqlite3MallocAlarm(nFull);
20719 }else{
20720 mem0.nearlyFull = 0;
@@ -20610,12 +20727,12 @@
20727 p = sqlite3GlobalConfig.m.xMalloc(nFull);
20728 }
20729 #endif
20730 if( p ){
20731 nFull = sqlite3MallocSize(p);
20732 sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nFull);
20733 sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1);
20734 }
20735 *pp = p;
20736 return nFull;
20737 }
20738
@@ -20646,17 +20763,17 @@
20763 /*
20764 ** This version of the memory allocation is for use by the application.
20765 ** First make sure the memory subsystem is initialized, then do the
20766 ** allocation.
20767 */
20768 SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int n){
20769 #ifndef SQLITE_OMIT_AUTOINIT
20770 if( sqlite3_initialize() ) return 0;
20771 #endif
20772 return n<=0 ? 0 : sqlite3Malloc(n);
20773 }
20774 SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64 n){
20775 #ifndef SQLITE_OMIT_AUTOINIT
20776 if( sqlite3_initialize() ) return 0;
20777 #endif
20778 return sqlite3Malloc(n);
20779 }
@@ -20688,18 +20805,18 @@
20805 sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);
20806 if( mem0.nScratchFree && sqlite3GlobalConfig.szScratch>=n ){
20807 p = mem0.pScratchFree;
20808 mem0.pScratchFree = mem0.pScratchFree->pNext;
20809 mem0.nScratchFree--;
20810 sqlite3StatusUp(SQLITE_STATUS_SCRATCH_USED, 1);
20811 sqlite3_mutex_leave(mem0.mutex);
20812 }else{
20813 sqlite3_mutex_leave(mem0.mutex);
20814 p = sqlite3Malloc(n);
20815 if( sqlite3GlobalConfig.bMemstat && p ){
20816 sqlite3_mutex_enter(mem0.mutex);
20817 sqlite3StatusUp(SQLITE_STATUS_SCRATCH_OVERFLOW, sqlite3MallocSize(p));
20818 sqlite3_mutex_leave(mem0.mutex);
20819 }
20820 sqlite3MemdebugSetType(p, MEMTYPE_SCRATCH);
20821 }
20822 assert( sqlite3_mutex_notheld(mem0.mutex) );
@@ -20736,23 +20853,23 @@
20853 sqlite3_mutex_enter(mem0.mutex);
20854 pSlot->pNext = mem0.pScratchFree;
20855 mem0.pScratchFree = pSlot;
20856 mem0.nScratchFree++;
20857 assert( mem0.nScratchFree <= (u32)sqlite3GlobalConfig.nScratch );
20858 sqlite3StatusDown(SQLITE_STATUS_SCRATCH_USED, 1);
20859 sqlite3_mutex_leave(mem0.mutex);
20860 }else{
20861 /* Release memory back to the heap */
20862 assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) );
20863 assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_SCRATCH) );
20864 sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
20865 if( sqlite3GlobalConfig.bMemstat ){
20866 int iSize = sqlite3MallocSize(p);
20867 sqlite3_mutex_enter(mem0.mutex);
20868 sqlite3StatusDown(SQLITE_STATUS_SCRATCH_OVERFLOW, iSize);
20869 sqlite3StatusDown(SQLITE_STATUS_MEMORY_USED, iSize);
20870 sqlite3StatusDown(SQLITE_STATUS_MALLOC_COUNT, 1);
20871 sqlite3GlobalConfig.m.xFree(p);
20872 sqlite3_mutex_leave(mem0.mutex);
20873 }else{
20874 sqlite3GlobalConfig.m.xFree(p);
20875 }
@@ -20779,41 +20896,41 @@
20896 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
20897 return sqlite3GlobalConfig.m.xSize(p);
20898 }
20899 SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){
20900 if( db==0 ){
20901 assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
20902 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
20903 return sqlite3MallocSize(p);
20904 }else{
20905 assert( sqlite3_mutex_held(db->mutex) );
20906 if( isLookaside(db, p) ){
20907 return db->lookaside.sz;
20908 }else{
20909 assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
20910 assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
20911 return sqlite3GlobalConfig.m.xSize(p);
20912 }
20913 }
20914 }
20915 SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void *p){
20916 assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
20917 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
20918 return (sqlite3_uint64)sqlite3GlobalConfig.m.xSize(p);
20919 }
20920
20921 /*
20922 ** Free memory previously obtained from sqlite3Malloc().
20923 */
20924 SQLITE_API void SQLITE_STDCALL sqlite3_free(void *p){
20925 if( p==0 ) return; /* IMP: R-49053-54554 */
20926 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
20927 assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
20928 if( sqlite3GlobalConfig.bMemstat ){
20929 sqlite3_mutex_enter(mem0.mutex);
20930 sqlite3StatusDown(SQLITE_STATUS_MEMORY_USED, sqlite3MallocSize(p));
20931 sqlite3StatusDown(SQLITE_STATUS_MALLOC_COUNT, 1);
20932 sqlite3GlobalConfig.m.xFree(p);
20933 sqlite3_mutex_leave(mem0.mutex);
20934 }else{
20935 sqlite3GlobalConfig.m.xFree(p);
20936 }
@@ -20850,11 +20967,11 @@
20967 db->lookaside.nOut--;
20968 return;
20969 }
20970 }
20971 assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
20972 assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
20973 assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) );
20974 sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
20975 sqlite3_free(p);
20976 }
20977
@@ -20863,11 +20980,11 @@
20980 */
20981 SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, u64 nBytes){
20982 int nOld, nNew, nDiff;
20983 void *pNew;
20984 assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) );
20985 assert( sqlite3MemdebugNoType(pOld, (u8)~MEMTYPE_HEAP) );
20986 if( pOld==0 ){
20987 return sqlite3Malloc(nBytes); /* IMP: R-04300-56712 */
20988 }
20989 if( nBytes==0 ){
20990 sqlite3_free(pOld); /* IMP: R-26507-47431 */
@@ -20897,11 +21014,11 @@
21014 sqlite3MallocAlarm((int)nBytes);
21015 pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
21016 }
21017 if( pNew ){
21018 nNew = sqlite3MallocSize(pNew);
21019 sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nNew-nOld);
21020 }
21021 sqlite3_mutex_leave(mem0.mutex);
21022 }else{
21023 pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
21024 }
@@ -20911,18 +21028,18 @@
21028
21029 /*
21030 ** The public interface to sqlite3Realloc. Make sure that the memory
21031 ** subsystem is initialized prior to invoking sqliteRealloc.
21032 */
21033 SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void *pOld, int n){
21034 #ifndef SQLITE_OMIT_AUTOINIT
21035 if( sqlite3_initialize() ) return 0;
21036 #endif
21037 if( n<0 ) n = 0; /* IMP: R-26507-47431 */
21038 return sqlite3Realloc(pOld, n);
21039 }
21040 SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void *pOld, sqlite3_uint64 n){
21041 #ifndef SQLITE_OMIT_AUTOINIT
21042 if( sqlite3_initialize() ) return 0;
21043 #endif
21044 return sqlite3Realloc(pOld, n);
21045 }
@@ -21030,11 +21147,11 @@
21147 memcpy(pNew, p, db->lookaside.sz);
21148 sqlite3DbFree(db, p);
21149 }
21150 }else{
21151 assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
21152 assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
21153 sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
21154 pNew = sqlite3_realloc64(p, n);
21155 if( !pNew ){
21156 db->mallocFailed = 1;
21157 }
@@ -22084,11 +22201,11 @@
22201
22202 /*
22203 ** Print into memory obtained from sqlite3_malloc(). Omit the internal
22204 ** %-conversion extensions.
22205 */
22206 SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char *zFormat, va_list ap){
22207 char *z;
22208 char zBase[SQLITE_PRINT_BUF_SIZE];
22209 StrAccum acc;
22210
22211 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -22109,11 +22226,11 @@
22226
22227 /*
22228 ** Print into memory obtained from sqlite3_malloc()(). Omit the internal
22229 ** %-conversion extensions.
22230 */
22231 SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char *zFormat, ...){
22232 va_list ap;
22233 char *z;
22234 #ifndef SQLITE_OMIT_AUTOINIT
22235 if( sqlite3_initialize() ) return 0;
22236 #endif
@@ -22134,11 +22251,11 @@
22251 ** this without breaking compatibility, so we just have to live with the
22252 ** mistake.
22253 **
22254 ** sqlite3_vsnprintf() is the varargs version.
22255 */
22256 SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){
22257 StrAccum acc;
22258 if( n<=0 ) return zBuf;
22259 #ifdef SQLITE_ENABLE_API_ARMOR
22260 if( zBuf==0 || zFormat==0 ) {
22261 (void)SQLITE_MISUSE_BKPT;
@@ -22149,11 +22266,11 @@
22266 sqlite3StrAccumInit(&acc, zBuf, n, 0);
22267 acc.useMalloc = 0;
22268 sqlite3VXPrintf(&acc, 0, zFormat, ap);
22269 return sqlite3StrAccumFinish(&acc);
22270 }
22271 SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
22272 char *z;
22273 va_list ap;
22274 va_start(ap,zFormat);
22275 z = sqlite3_vsnprintf(n, zBuf, zFormat, ap);
22276 va_end(ap);
@@ -22181,11 +22298,11 @@
22298 }
22299
22300 /*
22301 ** Format and write a message to the log if logging is enabled.
22302 */
22303 SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...){
22304 va_list ap; /* Vararg list */
22305 if( sqlite3GlobalConfig.xLog ){
22306 va_start(ap, zFormat);
22307 renderLogMsg(iErrCode, zFormat, ap);
22308 va_end(ap);
@@ -22317,11 +22434,11 @@
22434 } sqlite3Prng;
22435
22436 /*
22437 ** Return N random bytes.
22438 */
22439 SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *pBuf){
22440 unsigned char t;
22441 unsigned char *zBuf = pBuf;
22442
22443 /* The "wsdPrng" macro will resolve to the pseudo-random number generator
22444 ** state vector. If writable static data is unsupported on the target,
@@ -23469,11 +23586,11 @@
23586 ** sqlite3_strnicmp() APIs allow applications and extensions to compare
23587 ** the contents of two buffers containing UTF-8 strings in a
23588 ** case-independent fashion, using the same definition of "case
23589 ** independence" that SQLite uses internally when comparing identifiers.
23590 */
23591 SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *zLeft, const char *zRight){
23592 register unsigned char *a, *b;
23593 if( zLeft==0 ){
23594 return zRight ? -1 : 0;
23595 }else if( zRight==0 ){
23596 return 1;
@@ -23481,11 +23598,11 @@
23598 a = (unsigned char *)zLeft;
23599 b = (unsigned char *)zRight;
23600 while( *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }
23601 return UpperToLower[*a] - UpperToLower[*b];
23602 }
23603 SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){
23604 register unsigned char *a, *b;
23605 if( zLeft==0 ){
23606 return zRight ? -1 : 0;
23607 }else if( zRight==0 ){
23608 return 1;
@@ -25287,10 +25404,11 @@
25404 #define UNIXFILE_PSOW 0x10 /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */
25405 #define UNIXFILE_DELETE 0x20 /* Delete on close */
25406 #define UNIXFILE_URI 0x40 /* Filename might have query parameters */
25407 #define UNIXFILE_NOLOCK 0x80 /* Do no file locking */
25408 #define UNIXFILE_WARNED 0x0100 /* verifyDbFile() warnings issued */
25409 #define UNIXFILE_BLOCK 0x0200 /* Next SHM lock might block */
25410
25411 /*
25412 ** Include code that is common to all os_*.c files
25413 */
25414 /************** Include os_common.h in the middle of os_unix.c ***************/
@@ -26782,11 +26900,11 @@
26900
26901 assert( pFile );
26902 OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (unix)\n", pFile->h,
26903 azFileLock(eFileLock), azFileLock(pFile->eFileLock),
26904 azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared,
26905 osGetpid(0)));
26906
26907 /* If there is already a lock of this type or more restrictive on the
26908 ** unixFile, do nothing. Don't use the end_lock: exit path, as
26909 ** unixEnterMutex() hasn't been called yet.
26910 */
@@ -26990,11 +27108,11 @@
27108 int rc = SQLITE_OK;
27109
27110 assert( pFile );
27111 OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (unix)\n", pFile->h, eFileLock,
27112 pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
27113 osGetpid(0)));
27114
27115 assert( eFileLock<=SHARED_LOCK );
27116 if( pFile->eFileLock<=eFileLock ){
27117 return SQLITE_OK;
27118 }
@@ -27417,11 +27535,11 @@
27535 char *zLockFile = (char *)pFile->lockingContext;
27536 int rc;
27537
27538 assert( pFile );
27539 OSTRACE(("UNLOCK %d %d was %d pid=%d (dotlock)\n", pFile->h, eFileLock,
27540 pFile->eFileLock, osGetpid(0)));
27541 assert( eFileLock<=SHARED_LOCK );
27542
27543 /* no-op if possible */
27544 if( pFile->eFileLock==eFileLock ){
27545 return SQLITE_OK;
@@ -27635,11 +27753,11 @@
27753 static int flockUnlock(sqlite3_file *id, int eFileLock) {
27754 unixFile *pFile = (unixFile*)id;
27755
27756 assert( pFile );
27757 OSTRACE(("UNLOCK %d %d was %d pid=%d (flock)\n", pFile->h, eFileLock,
27758 pFile->eFileLock, osGetpid(0)));
27759 assert( eFileLock<=SHARED_LOCK );
27760
27761 /* no-op if possible */
27762 if( pFile->eFileLock==eFileLock ){
27763 return SQLITE_OK;
@@ -27803,11 +27921,11 @@
27921 sem_t *pSem = pFile->pInode->pSem;
27922
27923 assert( pFile );
27924 assert( pSem );
27925 OSTRACE(("UNLOCK %d %d was %d pid=%d (sem)\n", pFile->h, eFileLock,
27926 pFile->eFileLock, osGetpid(0)));
27927 assert( eFileLock<=SHARED_LOCK );
27928
27929 /* no-op if possible */
27930 if( pFile->eFileLock==eFileLock ){
27931 return SQLITE_OK;
@@ -28017,11 +28135,11 @@
28135 afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;
28136
28137 assert( pFile );
28138 OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (afp)\n", pFile->h,
28139 azFileLock(eFileLock), azFileLock(pFile->eFileLock),
28140 azFileLock(pInode->eFileLock), pInode->nShared , osGetpid(0)));
28141
28142 /* If there is already a lock of this type or more restrictive on the
28143 ** unixFile, do nothing. Don't use the afp_end_lock: exit path, as
28144 ** unixEnterMutex() hasn't been called yet.
28145 */
@@ -28203,11 +28321,11 @@
28321 #endif
28322
28323 assert( pFile );
28324 OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock,
28325 pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
28326 osGetpid(0)));
28327
28328 assert( eFileLock<=SHARED_LOCK );
28329 if( pFile->eFileLock<=eFileLock ){
28330 return SQLITE_OK;
28331 }
@@ -29028,10 +29146,14 @@
29146 ** Information and control of an open file handle.
29147 */
29148 static int unixFileControl(sqlite3_file *id, int op, void *pArg){
29149 unixFile *pFile = (unixFile*)id;
29150 switch( op ){
29151 case SQLITE_FCNTL_WAL_BLOCK: {
29152 pFile->ctrlFlags |= UNIXFILE_BLOCK;
29153 return SQLITE_OK;
29154 }
29155 case SQLITE_FCNTL_LOCKSTATE: {
29156 *(int*)pArg = pFile->eFileLock;
29157 return SQLITE_OK;
29158 }
29159 case SQLITE_FCNTL_LAST_ERRNO: {
@@ -29337,37 +29459,42 @@
29459 **
29460 ** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking
29461 ** otherwise.
29462 */
29463 static int unixShmSystemLock(
29464 unixFile *pFile, /* Open connection to the WAL file */
29465 int lockType, /* F_UNLCK, F_RDLCK, or F_WRLCK */
29466 int ofst, /* First byte of the locking range */
29467 int n /* Number of bytes to lock */
29468 ){
29469 unixShmNode *pShmNode; /* Apply locks to this open shared-memory segment */
29470 struct flock f; /* The posix advisory locking structure */
29471 int rc = SQLITE_OK; /* Result code form fcntl() */
29472
29473 /* Access to the unixShmNode object is serialized by the caller */
29474 pShmNode = pFile->pInode->pShmNode;
29475 assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 );
29476
29477 /* Shared locks never span more than one byte */
29478 assert( n==1 || lockType!=F_RDLCK );
29479
29480 /* Locks are within range */
29481 assert( n>=1 && n<SQLITE_SHM_NLOCK );
29482
29483 if( pShmNode->h>=0 ){
29484 int lkType;
29485 /* Initialize the locking parameters */
29486 memset(&f, 0, sizeof(f));
29487 f.l_type = lockType;
29488 f.l_whence = SEEK_SET;
29489 f.l_start = ofst;
29490 f.l_len = n;
29491
29492 lkType = (pFile->ctrlFlags & UNIXFILE_BLOCK)!=0 ? F_SETLKW : F_SETLK;
29493 rc = osFcntl(pShmNode->h, lkType, &f);
29494 rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
29495 pFile->ctrlFlags &= ~UNIXFILE_BLOCK;
29496 }
29497
29498 /* Update the global lock state and do debug tracing */
29499 #ifdef SQLITE_DEBUG
29500 { u16 mask;
@@ -29573,17 +29700,17 @@
29700
29701 /* Check to see if another process is holding the dead-man switch.
29702 ** If not, truncate the file to zero length.
29703 */
29704 rc = SQLITE_OK;
29705 if( unixShmSystemLock(pDbFd, F_WRLCK, UNIX_SHM_DMS, 1)==SQLITE_OK ){
29706 if( robust_ftruncate(pShmNode->h, 0) ){
29707 rc = unixLogError(SQLITE_IOERR_SHMOPEN, "ftruncate", zShmFilename);
29708 }
29709 }
29710 if( rc==SQLITE_OK ){
29711 rc = unixShmSystemLock(pDbFd, F_RDLCK, UNIX_SHM_DMS, 1);
29712 }
29713 if( rc ) goto shm_open_err;
29714 }
29715 }
29716
@@ -29811,11 +29938,11 @@
29938 allMask |= pX->sharedMask;
29939 }
29940
29941 /* Unlock the system-level locks */
29942 if( (mask & allMask)==0 ){
29943 rc = unixShmSystemLock(pDbFd, F_UNLCK, ofst+UNIX_SHM_BASE, n);
29944 }else{
29945 rc = SQLITE_OK;
29946 }
29947
29948 /* Undo the local locks */
@@ -29839,11 +29966,11 @@
29966 }
29967
29968 /* Get shared locks at the system level, if necessary */
29969 if( rc==SQLITE_OK ){
29970 if( (allShared & mask)==0 ){
29971 rc = unixShmSystemLock(pDbFd, F_RDLCK, ofst+UNIX_SHM_BASE, n);
29972 }else{
29973 rc = SQLITE_OK;
29974 }
29975 }
29976
@@ -29864,20 +29991,20 @@
29991
29992 /* Get the exclusive locks at the system level. Then if successful
29993 ** also mark the local connection as being locked.
29994 */
29995 if( rc==SQLITE_OK ){
29996 rc = unixShmSystemLock(pDbFd, F_WRLCK, ofst+UNIX_SHM_BASE, n);
29997 if( rc==SQLITE_OK ){
29998 assert( (p->sharedMask & mask)==0 );
29999 p->exclMask |= mask;
30000 }
30001 }
30002 }
30003 sqlite3_mutex_leave(pShmNode->mutex);
30004 OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n",
30005 p->id, osGetpid(0), p->sharedMask, p->exclMask));
30006 return rc;
30007 }
30008
30009 /*
30010 ** Implement a memory barrier or memory fence on shared memory.
@@ -30968,12 +31095,12 @@
31095 /* Detect a pid change and reset the PRNG. There is a race condition
31096 ** here such that two or more threads all trying to open databases at
31097 ** the same instant might all reset the PRNG. But multiple resets
31098 ** are harmless.
31099 */
31100 if( randomnessPid!=osGetpid(0) ){
31101 randomnessPid = osGetpid(0);
31102 sqlite3_randomness(0,0);
31103 }
31104
31105 memset(p, 0, sizeof(unixFile));
31106
@@ -31360,11 +31487,11 @@
31487 ** When testing, initializing zBuf[] to zero is all we do. That means
31488 ** that we always use the same random number sequence. This makes the
31489 ** tests repeatable.
31490 */
31491 memset(zBuf, 0, nBuf);
31492 randomnessPid = osGetpid(0);
31493 #if !defined(SQLITE_TEST)
31494 {
31495 int fd, got;
31496 fd = robust_open("/dev/urandom", O_RDONLY, 0);
31497 if( fd<0 ){
@@ -31681,11 +31808,11 @@
31808 #else
31809 # ifdef _CS_DARWIN_USER_TEMP_DIR
31810 {
31811 if( !confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen) ){
31812 OSTRACE(("GETLOCKPATH failed %s errno=%d pid=%d\n",
31813 lPath, errno, osGetpid(0)));
31814 return SQLITE_IOERR_LOCK;
31815 }
31816 len = strlcat(lPath, "sqliteplocks", maxLen);
31817 }
31818 # else
@@ -31703,11 +31830,11 @@
31830 char c = dbPath[i];
31831 lPath[i+len] = (c=='/')?'_':c;
31832 }
31833 lPath[i+len]='\0';
31834 strlcat(lPath, ":auto:", maxLen);
31835 OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, osGetpid(0)));
31836 return SQLITE_OK;
31837 }
31838
31839 /*
31840 ** Creates the lock file and any missing directories in lockPath
@@ -31730,20 +31857,20 @@
31857 if( osMkdir(buf, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){
31858 int err=errno;
31859 if( err!=EEXIST ) {
31860 OSTRACE(("CREATELOCKPATH FAILED creating %s, "
31861 "'%s' proxy lock path=%s pid=%d\n",
31862 buf, strerror(err), lockPath, osGetpid(0)));
31863 return err;
31864 }
31865 }
31866 }
31867 start=i+1;
31868 }
31869 buf[i] = lockPath[i];
31870 }
31871 OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n", lockPath, osGetpid(0)));
31872 return 0;
31873 }
31874
31875 /*
31876 ** Create a new VFS file descriptor (stored in memory obtained from
@@ -32045,11 +32172,11 @@
32172 int tryOldLockPath = 0;
32173 int forceNewLockPath = 0;
32174
32175 OSTRACE(("TAKECONCH %d for %s pid=%d\n", conchFile->h,
32176 (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"),
32177 osGetpid(0)));
32178
32179 rc = proxyGetHostID(myHostID, &pError);
32180 if( (rc&0xff)==SQLITE_IOERR ){
32181 storeLastErrno(pFile, pError);
32182 goto end_takeconch;
@@ -32255,11 +32382,11 @@
32382
32383 pCtx = (proxyLockingContext *)pFile->lockingContext;
32384 conchFile = pCtx->conchFile;
32385 OSTRACE(("RELEASECONCH %d for %s pid=%d\n", conchFile->h,
32386 (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"),
32387 osGetpid(0)));
32388 if( pCtx->conchHeld>0 ){
32389 rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);
32390 }
32391 pCtx->conchHeld = 0;
32392 OSTRACE(("RELEASECONCH %d %s\n", conchFile->h,
@@ -32397,11 +32524,11 @@
32524 }else{
32525 lockPath=(char *)path;
32526 }
32527
32528 OSTRACE(("TRANSPROXY %d for %s pid=%d\n", pFile->h,
32529 (lockPath ? lockPath : ":auto:"), osGetpid(0)));
32530
32531 pCtx = sqlite3_malloc( sizeof(*pCtx) );
32532 if( pCtx==0 ){
32533 return SQLITE_NOMEM;
32534 }
@@ -32684,11 +32811,11 @@
32811 ** This routine is called once during SQLite initialization and by a
32812 ** single thread. The memory allocation and mutex subsystems have not
32813 ** necessarily been initialized when this routine is called, and so they
32814 ** should not be used.
32815 */
32816 SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
32817 /*
32818 ** The following macro defines an initializer for an sqlite3_vfs object.
32819 ** The name of the VFS is NAME. The pAppData is a pointer to a pointer
32820 ** to the "finder" function. (pAppData is a pointer to a pointer because
32821 ** silly C90 rules prohibit a void* from being cast to a function pointer
@@ -32783,11 +32910,11 @@
32910 **
32911 ** Some operating systems might need to do some cleanup in this routine,
32912 ** to release dynamically allocated objects. But not on unix.
32913 ** This routine is a no-op for unix.
32914 */
32915 SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
32916 return SQLITE_OK;
32917 }
32918
32919 #endif /* SQLITE_OS_UNIX */
32920
@@ -34175,11 +34302,11 @@
34302 ** compact it. Upon success, SQLITE_OK will be returned. Upon failure, one
34303 ** of SQLITE_NOMEM, SQLITE_ERROR, or SQLITE_NOTFOUND will be returned. The
34304 ** "pnLargest" argument, if non-zero, will be used to return the size of the
34305 ** largest committed free block in the heap, in bytes.
34306 */
34307 SQLITE_API int SQLITE_STDCALL sqlite3_win32_compact_heap(LPUINT pnLargest){
34308 int rc = SQLITE_OK;
34309 UINT nLargest = 0;
34310 HANDLE hHeap;
34311
34312 winMemAssertMagic();
@@ -34215,11 +34342,11 @@
34342 ** If a Win32 native heap has been configured, this function will attempt to
34343 ** destroy and recreate it. If the Win32 native heap is not isolated and/or
34344 ** the sqlite3_memory_used() function does not return zero, SQLITE_BUSY will
34345 ** be returned and no changes will be made to the Win32 native heap.
34346 */
34347 SQLITE_API int SQLITE_STDCALL sqlite3_win32_reset_heap(){
34348 int rc;
34349 MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
34350 MUTEX_LOGIC( sqlite3_mutex *pMem; ) /* The memsys static mutex */
34351 MUTEX_LOGIC( pMaster = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); )
34352 MUTEX_LOGIC( pMem = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); )
@@ -34260,11 +34387,11 @@
34387 /*
34388 ** This function outputs the specified (ANSI) string to the Win32 debugger
34389 ** (if available).
34390 */
34391
34392 SQLITE_API void SQLITE_STDCALL sqlite3_win32_write_debug(const char *zBuf, int nBuf){
34393 char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE];
34394 int nMin = MIN(nBuf, (SQLITE_WIN32_DBG_BUF_SIZE - 1)); /* may be negative. */
34395 if( nMin<-1 ) nMin = -1; /* all negative values become -1. */
34396 assert( nMin==-1 || nMin==0 || nMin<SQLITE_WIN32_DBG_BUF_SIZE );
34397 #if defined(SQLITE_WIN32_HAS_ANSI)
@@ -34300,11 +34427,11 @@
34427 */
34428 #if SQLITE_OS_WINRT
34429 static HANDLE sleepObj = NULL;
34430 #endif
34431
34432 SQLITE_API void SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds){
34433 #if SQLITE_OS_WINRT
34434 if ( sleepObj==NULL ){
34435 sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET,
34436 SYNCHRONIZE);
34437 }
@@ -34349,11 +34476,11 @@
34476
34477 /*
34478 ** This function determines if the machine is running a version of Windows
34479 ** based on the NT kernel.
34480 */
34481 SQLITE_API int SQLITE_STDCALL sqlite3_win32_is_nt(void){
34482 #if SQLITE_OS_WINRT
34483 /*
34484 ** NOTE: The WinRT sub-platform is always assumed to be based on the NT
34485 ** kernel.
34486 */
@@ -34703,11 +34830,11 @@
34830
34831 /*
34832 ** Convert multibyte character string to UTF-8. Space to hold the
34833 ** returned string is obtained from sqlite3_malloc().
34834 */
34835 SQLITE_API char *SQLITE_STDCALL sqlite3_win32_mbcs_to_utf8(const char *zFilename){
34836 char *zFilenameUtf8;
34837 LPWSTR zTmpWide;
34838
34839 zTmpWide = winMbcsToUnicode(zFilename);
34840 if( zTmpWide==0 ){
@@ -34720,11 +34847,11 @@
34847
34848 /*
34849 ** Convert UTF-8 to multibyte character string. Space to hold the
34850 ** returned string is obtained from sqlite3_malloc().
34851 */
34852 SQLITE_API char *SQLITE_STDCALL sqlite3_win32_utf8_to_mbcs(const char *zFilename){
34853 char *zFilenameMbcs;
34854 LPWSTR zTmpWide;
34855
34856 zTmpWide = winUtf8ToUnicode(zFilename);
34857 if( zTmpWide==0 ){
@@ -34740,11 +34867,11 @@
34867 ** the provided arguments. The type argument must be 1 in order to set the
34868 ** data directory or 2 in order to set the temporary directory. The zValue
34869 ** argument is the name of the directory to use. The return value will be
34870 ** SQLITE_OK if successful.
34871 */
34872 SQLITE_API int SQLITE_STDCALL sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){
34873 char **ppDirectory = 0;
34874 #ifndef SQLITE_OMIT_AUTOINIT
34875 int rc = sqlite3_initialize();
34876 if( rc ) return rc;
34877 #endif
@@ -34965,15 +35092,15 @@
35092 }
35093
35094 /*
35095 ** Log a I/O error retry episode.
35096 */
35097 static void winLogIoerr(int nRetry, int lineno){
35098 if( nRetry ){
35099 sqlite3_log(SQLITE_IOERR,
35100 "delayed %dms for lock/sharing conflict at line %d",
35101 winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno
35102 );
35103 }
35104 }
35105
35106 #if SQLITE_OS_WINCE
@@ -35449,11 +35576,12 @@
35576 assert( id!=0 );
35577 #ifndef SQLITE_OMIT_WAL
35578 assert( pFile->pShm==0 );
35579 #endif
35580 assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
35581 OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p\n",
35582 osGetCurrentProcessId(), pFile, pFile->h));
35583
35584 #if SQLITE_MAX_MMAP_SIZE>0
35585 winUnmapfile(pFile);
35586 #endif
35587
@@ -35478,11 +35606,12 @@
35606 #endif
35607 if( rc ){
35608 pFile->h = NULL;
35609 }
35610 OpenCounter(-1);
35611 OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p, rc=%s\n",
35612 osGetCurrentProcessId(), pFile, pFile->h, rc ? "ok" : "failed"));
35613 return rc ? SQLITE_OK
35614 : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
35615 "winClose", pFile->zPath);
35616 }
35617
@@ -35506,20 +35635,22 @@
35635
35636 assert( id!=0 );
35637 assert( amt>0 );
35638 assert( offset>=0 );
35639 SimulateIOError(return SQLITE_IOERR_READ);
35640 OSTRACE(("READ pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
35641 "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
35642 pFile->h, pBuf, amt, offset, pFile->locktype));
35643
35644 #if SQLITE_MAX_MMAP_SIZE>0
35645 /* Deal with as much of this read request as possible by transfering
35646 ** data from the memory mapping using memcpy(). */
35647 if( offset<pFile->mmapSize ){
35648 if( offset+amt <= pFile->mmapSize ){
35649 memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);
35650 OSTRACE(("READ-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35651 osGetCurrentProcessId(), pFile, pFile->h));
35652 return SQLITE_OK;
35653 }else{
35654 int nCopy = (int)(pFile->mmapSize - offset);
35655 memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);
35656 pBuf = &((u8 *)pBuf)[nCopy];
@@ -35529,11 +35660,12 @@
35660 }
35661 #endif
35662
35663 #if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)
35664 if( winSeekFile(pFile, offset) ){
35665 OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n",
35666 osGetCurrentProcessId(), pFile, pFile->h));
35667 return SQLITE_FULL;
35668 }
35669 while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
35670 #else
35671 memset(&overlapped, 0, sizeof(OVERLAPPED));
@@ -35543,23 +35675,26 @@
35675 osGetLastError()!=ERROR_HANDLE_EOF ){
35676 #endif
35677 DWORD lastErrno;
35678 if( winRetryIoerr(&nRetry, &lastErrno) ) continue;
35679 pFile->lastErrno = lastErrno;
35680 OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_READ\n",
35681 osGetCurrentProcessId(), pFile, pFile->h));
35682 return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
35683 "winRead", pFile->zPath);
35684 }
35685 winLogIoerr(nRetry, __LINE__);
35686 if( nRead<(DWORD)amt ){
35687 /* Unread parts of the buffer must be zero-filled */
35688 memset(&((char*)pBuf)[nRead], 0, amt-nRead);
35689 OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_SHORT_READ\n",
35690 osGetCurrentProcessId(), pFile, pFile->h));
35691 return SQLITE_IOERR_SHORT_READ;
35692 }
35693
35694 OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35695 osGetCurrentProcessId(), pFile, pFile->h));
35696 return SQLITE_OK;
35697 }
35698
35699 /*
35700 ** Write data from a buffer into a file. Return SQLITE_OK on success
@@ -35578,20 +35713,22 @@
35713 assert( amt>0 );
35714 assert( pFile );
35715 SimulateIOError(return SQLITE_IOERR_WRITE);
35716 SimulateDiskfullError(return SQLITE_FULL);
35717
35718 OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
35719 "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
35720 pFile->h, pBuf, amt, offset, pFile->locktype));
35721
35722 #if SQLITE_MAX_MMAP_SIZE>0
35723 /* Deal with as much of this write request as possible by transfering
35724 ** data from the memory mapping using memcpy(). */
35725 if( offset<pFile->mmapSize ){
35726 if( offset+amt <= pFile->mmapSize ){
35727 memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);
35728 OSTRACE(("WRITE-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35729 osGetCurrentProcessId(), pFile, pFile->h));
35730 return SQLITE_OK;
35731 }else{
35732 int nCopy = (int)(pFile->mmapSize - offset);
35733 memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);
35734 pBuf = &((u8 *)pBuf)[nCopy];
@@ -35650,21 +35787,24 @@
35787 }
35788
35789 if( rc ){
35790 if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
35791 || ( pFile->lastErrno==ERROR_DISK_FULL )){
35792 OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n",
35793 osGetCurrentProcessId(), pFile, pFile->h));
35794 return winLogError(SQLITE_FULL, pFile->lastErrno,
35795 "winWrite1", pFile->zPath);
35796 }
35797 OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_WRITE\n",
35798 osGetCurrentProcessId(), pFile, pFile->h));
35799 return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,
35800 "winWrite2", pFile->zPath);
35801 }else{
35802 winLogIoerr(nRetry, __LINE__);
35803 }
35804 OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35805 osGetCurrentProcessId(), pFile, pFile->h));
35806 return SQLITE_OK;
35807 }
35808
35809 /*
35810 ** Truncate an open file to a specified size
@@ -35674,12 +35814,12 @@
35814 int rc = SQLITE_OK; /* Return code for this function */
35815 DWORD lastErrno;
35816
35817 assert( pFile );
35818 SimulateIOError(return SQLITE_IOERR_TRUNCATE);
35819 OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\n",
35820 osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype));
35821
35822 /* If the user has configured a chunk-size for this file, truncate the
35823 ** file so that it consists of an integer number of chunks (i.e. the
35824 ** actual file size after the operation may be larger than the requested
35825 ** size).
@@ -35707,11 +35847,12 @@
35847 if( pFile->pMapRegion && nByte<pFile->mmapSize ){
35848 pFile->mmapSize = nByte;
35849 }
35850 #endif
35851
35852 OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, rc=%s\n",
35853 osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc)));
35854 return rc;
35855 }
35856
35857 #ifdef SQLITE_TEST
35858 /*
@@ -35752,12 +35893,13 @@
35893 /* Unix cannot, but some systems may return SQLITE_FULL from here. This
35894 ** line is to test that doing so does not cause any problems.
35895 */
35896 SimulateDiskfullError( return SQLITE_FULL );
35897
35898 OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, flags=%x, lock=%d\n",
35899 osGetCurrentProcessId(), pFile, pFile->h, flags,
35900 pFile->locktype));
35901
35902 #ifndef SQLITE_TEST
35903 UNUSED_PARAMETER(flags);
35904 #else
35905 if( (flags&0x0F)==SQLITE_SYNC_FULL ){
@@ -35768,21 +35910,24 @@
35910
35911 /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a
35912 ** no-op
35913 */
35914 #ifdef SQLITE_NO_SYNC
35915 OSTRACE(("SYNC-NOP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35916 osGetCurrentProcessId(), pFile, pFile->h));
35917 return SQLITE_OK;
35918 #else
35919 rc = osFlushFileBuffers(pFile->h);
35920 SimulateIOError( rc=FALSE );
35921 if( rc ){
35922 OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35923 osGetCurrentProcessId(), pFile, pFile->h));
35924 return SQLITE_OK;
35925 }else{
35926 pFile->lastErrno = osGetLastError();
35927 OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_FSYNC\n",
35928 osGetCurrentProcessId(), pFile, pFile->h));
35929 return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,
35930 "winSync", pFile->zPath);
35931 }
35932 #endif
35933 }
@@ -37751,11 +37896,11 @@
37896 winRetryIoerr(&cnt, &lastErrno) ){
37897 /* Noop */
37898 }
37899 }
37900 #endif
37901 winLogIoerr(cnt, __LINE__);
37902
37903 OSTRACE(("OPEN file=%p, name=%s, access=%lx, rc=%s\n", h, zUtf8Name,
37904 dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
37905
37906 if( h==INVALID_HANDLE_VALUE ){
@@ -37935,11 +38080,11 @@
38080 }
38081 #endif
38082 if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
38083 rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename);
38084 }else{
38085 winLogIoerr(cnt, __LINE__);
38086 }
38087 sqlite3_free(zConverted);
38088 OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc)));
38089 return rc;
38090 }
@@ -37985,11 +38130,11 @@
38130 attr = INVALID_FILE_ATTRIBUTES;
38131 }else{
38132 attr = sAttrData.dwFileAttributes;
38133 }
38134 }else{
38135 winLogIoerr(cnt, __LINE__);
38136 if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){
38137 sqlite3_free(zConverted);
38138 return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess",
38139 zFilename);
38140 }else{
@@ -38500,11 +38645,11 @@
38645 }
38646
38647 /*
38648 ** Initialize and deinitialize the operating system interface.
38649 */
38650 SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
38651 static sqlite3_vfs winVfs = {
38652 3, /* iVersion */
38653 sizeof(winFile), /* szOsFile */
38654 SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
38655 0, /* pNext */
@@ -38575,11 +38720,11 @@
38720 #endif
38721
38722 return SQLITE_OK;
38723 }
38724
38725 SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
38726 #if SQLITE_OS_WINRT
38727 if( sleepObj!=NULL ){
38728 osCloseHandle(sleepObj);
38729 sleepObj = NULL;
38730 }
@@ -39866,20 +40011,20 @@
40011 ** in pcache1 need to be protected via mutex.
40012 */
40013 static void *pcache1Alloc(int nByte){
40014 void *p = 0;
40015 assert( sqlite3_mutex_notheld(pcache1.grp.mutex) );
 
40016 if( nByte<=pcache1.szSlot ){
40017 sqlite3_mutex_enter(pcache1.mutex);
40018 p = (PgHdr1 *)pcache1.pFree;
40019 if( p ){
40020 pcache1.pFree = pcache1.pFree->pNext;
40021 pcache1.nFreeSlot--;
40022 pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;
40023 assert( pcache1.nFreeSlot>=0 );
40024 sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);
40025 sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_USED, 1);
40026 }
40027 sqlite3_mutex_leave(pcache1.mutex);
40028 }
40029 if( p==0 ){
40030 /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool. Get
@@ -39888,11 +40033,12 @@
40033 p = sqlite3Malloc(nByte);
40034 #ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
40035 if( p ){
40036 int sz = sqlite3MallocSize(p);
40037 sqlite3_mutex_enter(pcache1.mutex);
40038 sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);
40039 sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);
40040 sqlite3_mutex_leave(pcache1.mutex);
40041 }
40042 #endif
40043 sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);
40044 }
@@ -39906,11 +40052,11 @@
40052 int nFreed = 0;
40053 if( p==0 ) return 0;
40054 if( p>=pcache1.pStart && p<pcache1.pEnd ){
40055 PgFreeslot *pSlot;
40056 sqlite3_mutex_enter(pcache1.mutex);
40057 sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_USED, 1);
40058 pSlot = (PgFreeslot*)p;
40059 pSlot->pNext = pcache1.pFree;
40060 pcache1.pFree = pSlot;
40061 pcache1.nFreeSlot++;
40062 pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;
@@ -39920,11 +40066,11 @@
40066 assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );
40067 sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
40068 nFreed = sqlite3MallocSize(p);
40069 #ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
40070 sqlite3_mutex_enter(pcache1.mutex);
40071 sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_OVERFLOW, nFreed);
40072 sqlite3_mutex_leave(pcache1.mutex);
40073 #endif
40074 sqlite3_free(p);
40075 }
40076 return nFreed;
@@ -40656,10 +40802,18 @@
40802
40803 /*
40804 ** Return the size of the header on each page of this PCACHE implementation.
40805 */
40806 SQLITE_PRIVATE int sqlite3HeaderSizePcache1(void){ return ROUND8(sizeof(PgHdr1)); }
40807
40808 /*
40809 ** Return the global mutex used by this PCACHE implementation. The
40810 ** sqlite3_status() routine needs access to this mutex.
40811 */
40812 SQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void){
40813 return pcache1.mutex;
40814 }
40815
40816 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
40817 /*
40818 ** This function is called to free superfluous dynamically allocated memory
40819 ** held by the pager system. Memory in use by any SQLite pager allocated
@@ -49429,13 +49583,14 @@
49583 if( pWal->exclusiveMode ) return;
49584 (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,
49585 SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED);
49586 WALTRACE(("WAL%p: release SHARED-%s\n", pWal, walLockName(lockIdx)));
49587 }
49588 static int walLockExclusive(Wal *pWal, int lockIdx, int n, int fBlock){
49589 int rc;
49590 if( pWal->exclusiveMode ) return SQLITE_OK;
49591 if( fBlock ) sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_WAL_BLOCK, 0);
49592 rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,
49593 SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE);
49594 WALTRACE(("WAL%p: acquire EXCLUSIVE-%s cnt=%d %s\n", pWal,
49595 walLockName(lockIdx), n, rc ? "failed" : "ok"));
49596 VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )
@@ -49717,11 +49872,11 @@
49872 assert( WAL_ALL_BUT_WRITE==WAL_WRITE_LOCK+1 );
49873 assert( WAL_CKPT_LOCK==WAL_ALL_BUT_WRITE );
49874 assert( pWal->writeLock );
49875 iLock = WAL_ALL_BUT_WRITE + pWal->ckptLock;
49876 nLock = SQLITE_SHM_NLOCK - iLock;
49877 rc = walLockExclusive(pWal, iLock, nLock, 0);
49878 if( rc ){
49879 return rc;
49880 }
49881 WALTRACE(("WAL%p: recovery begin...\n", pWal));
49882
@@ -50251,11 +50406,11 @@
50406 int lockIdx, /* Offset of first byte to lock */
50407 int n /* Number of bytes to lock */
50408 ){
50409 int rc;
50410 do {
50411 rc = walLockExclusive(pWal, lockIdx, n, 0);
50412 }while( xBusy && rc==SQLITE_BUSY && xBusy(pBusyArg) );
50413 return rc;
50414 }
50415
50416 /*
@@ -50684,11 +50839,11 @@
50839 if( pWal->readOnly & WAL_SHM_RDONLY ){
50840 if( SQLITE_OK==(rc = walLockShared(pWal, WAL_WRITE_LOCK)) ){
50841 walUnlockShared(pWal, WAL_WRITE_LOCK);
50842 rc = SQLITE_READONLY_RECOVERY;
50843 }
50844 }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1, 1)) ){
50845 pWal->writeLock = 1;
50846 if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){
50847 badHdr = walIndexTryHdr(pWal, pChanged);
50848 if( badHdr ){
50849 /* If the wal-index header is still malformed even while holding
@@ -50890,11 +51045,11 @@
51045 {
51046 if( (pWal->readOnly & WAL_SHM_RDONLY)==0
51047 && (mxReadMark<pWal->hdr.mxFrame || mxI==0)
51048 ){
51049 for(i=1; i<WAL_NREADER; i++){
51050 rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1, 0);
51051 if( rc==SQLITE_OK ){
51052 mxReadMark = pInfo->aReadMark[i] = pWal->hdr.mxFrame;
51053 mxI = i;
51054 walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
51055 break;
@@ -51146,11 +51301,11 @@
51301 }
51302
51303 /* Only one writer allowed at a time. Get the write lock. Return
51304 ** SQLITE_BUSY if unable.
51305 */
51306 rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1, 0);
51307 if( rc ){
51308 return rc;
51309 }
51310 pWal->writeLock = 1;
51311
@@ -51291,11 +51446,11 @@
51446 volatile WalCkptInfo *pInfo = walCkptInfo(pWal);
51447 assert( pInfo->nBackfill==pWal->hdr.mxFrame );
51448 if( pInfo->nBackfill>0 ){
51449 u32 salt1;
51450 sqlite3_randomness(4, &salt1);
51451 rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1, 0);
51452 if( rc==SQLITE_OK ){
51453 /* If all readers are using WAL_READ_LOCK(0) (in other words if no
51454 ** readers are currently using the WAL), then the transactions
51455 ** frames will overwrite the start of the existing log. Update the
51456 ** wal-index header to reflect this.
@@ -51616,11 +51771,11 @@
51771 if( pWal->readOnly ) return SQLITE_READONLY;
51772 WALTRACE(("WAL%p: checkpoint begins\n", pWal));
51773
51774 /* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive
51775 ** "checkpoint" lock on the database file. */
51776 rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1, 0);
51777 if( rc ){
51778 /* EVIDENCE-OF: R-10421-19736 If any other process is running a
51779 ** checkpoint operation at the same time, the lock cannot be obtained and
51780 ** SQLITE_BUSY is returned.
51781 ** EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured,
@@ -52618,10 +52773,11 @@
52773
52774 /*
52775 ** Exit the recursive mutex on a Btree.
52776 */
52777 SQLITE_PRIVATE void sqlite3BtreeLeave(Btree *p){
52778 assert( sqlite3_mutex_held(p->db->mutex) );
52779 if( p->sharable ){
52780 assert( p->wantToLock>0 );
52781 p->wantToLock--;
52782 if( p->wantToLock==0 ){
52783 unlockBtreeMutex(p);
@@ -52865,11 +53021,11 @@
53021 **
53022 ** This routine has no effect on existing database connections.
53023 ** The shared cache setting effects only future calls to
53024 ** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2().
53025 */
53026 SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int enable){
53027 sqlite3GlobalConfig.sharedCacheEnabled = enable;
53028 return SQLITE_OK;
53029 }
53030 #endif
53031
@@ -53379,14 +53535,19 @@
53535 ** prior to calling this routine.
53536 */
53537 static int saveCursorPosition(BtCursor *pCur){
53538 int rc;
53539
53540 assert( CURSOR_VALID==pCur->eState || CURSOR_SKIPNEXT==pCur->eState );
53541 assert( 0==pCur->pKey );
53542 assert( cursorHoldsMutex(pCur) );
53543
53544 if( pCur->eState==CURSOR_SKIPNEXT ){
53545 pCur->eState = CURSOR_VALID;
53546 }else{
53547 pCur->skipNext = 0;
53548 }
53549 rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
53550 assert( rc==SQLITE_OK ); /* KeySize() cannot fail */
53551
53552 /* If this is an intKey table, then the above call to BtreeKeySize()
53553 ** stores the integer key in pCur->nKey. In this case this value is
@@ -53453,11 +53614,11 @@
53614 Pgno iRoot, /* Only save cursor with this iRoot. Save all if zero */
53615 BtCursor *pExcept /* Do not save this cursor */
53616 ){
53617 do{
53618 if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){
53619 if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){
53620 int rc = saveCursorPosition(p);
53621 if( SQLITE_OK!=rc ){
53622 return rc;
53623 }
53624 }else{
@@ -53525,21 +53686,23 @@
53686 ** at most one effective restoreCursorPosition() call after each
53687 ** saveCursorPosition().
53688 */
53689 static int btreeRestoreCursorPosition(BtCursor *pCur){
53690 int rc;
53691 int skipNext;
53692 assert( cursorHoldsMutex(pCur) );
53693 assert( pCur->eState>=CURSOR_REQUIRESEEK );
53694 if( pCur->eState==CURSOR_FAULT ){
53695 return pCur->skipNext;
53696 }
53697 pCur->eState = CURSOR_INVALID;
53698 rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext);
53699 if( rc==SQLITE_OK ){
53700 sqlite3_free(pCur->pKey);
53701 pCur->pKey = 0;
53702 assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
53703 pCur->skipNext |= skipNext;
53704 if( pCur->skipNext && pCur->eState==CURSOR_VALID ){
53705 pCur->eState = CURSOR_SKIPNEXT;
53706 }
53707 }
53708 return rc;
@@ -53587,13 +53750,14 @@
53750 rc = restoreCursorPosition(pCur);
53751 if( rc ){
53752 *pDifferentRow = 1;
53753 return rc;
53754 }
53755 if( pCur->eState!=CURSOR_VALID ){
53756 *pDifferentRow = 1;
53757 }else{
53758 assert( pCur->skipNext==0 );
53759 *pDifferentRow = 0;
53760 }
53761 return SQLITE_OK;
53762 }
53763
@@ -54796,12 +54960,12 @@
54960 /*
54961 ** The following asserts make sure that structures used by the btree are
54962 ** the right size. This is to guard against size changes that result
54963 ** when compiling on a different architecture.
54964 */
54965 assert( sizeof(i64)==8 );
54966 assert( sizeof(u64)==8 );
54967 assert( sizeof(u32)==4 );
54968 assert( sizeof(u16)==2 );
54969 assert( sizeof(Pgno)==4 );
54970
54971 pBt = sqlite3MallocZero( sizeof(*pBt) );
@@ -56404,11 +56568,11 @@
56568 if( pBtree ){
56569 sqlite3BtreeEnter(pBtree);
56570 for(p=pBtree->pBt->pCursor; p; p=p->pNext){
56571 int i;
56572 if( writeOnly && (p->curFlags & BTCF_WriteFlag)==0 ){
56573 if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){
56574 rc = saveCursorPosition(p);
56575 if( rc!=SQLITE_OK ){
56576 (void)sqlite3BtreeTripAllCursors(pBtree, rc, 0);
56577 break;
56578 }
@@ -56810,10 +56974,12 @@
56974 ** to return an integer result code for historical reasons.
56975 */
56976 SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
56977 assert( cursorHoldsMutex(pCur) );
56978 assert( pCur->eState==CURSOR_VALID );
56979 assert( pCur->iPage>=0 );
56980 assert( pCur->iPage<BTCURSOR_MAX_DEPTH );
56981 assert( pCur->apPage[pCur->iPage]->intKeyLeaf==1 );
56982 getCellInfo(pCur);
56983 *pSize = pCur->info.nPayload;
56984 return SQLITE_OK;
56985 }
@@ -57288,19 +57454,21 @@
57454 return SQLITE_CORRUPT_BKPT;
57455 }
57456 return SQLITE_OK;
57457 }
57458
57459 #if SQLITE_DEBUG
57460 /*
57461 ** Page pParent is an internal (non-leaf) tree page. This function
57462 ** asserts that page number iChild is the left-child if the iIdx'th
57463 ** cell in page pParent. Or, if iIdx is equal to the total number of
57464 ** cells in pParent, that page number iChild is the right-child of
57465 ** the page.
57466 */
57467 static void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){
57468 if( CORRUPT_DB ) return; /* The conditions tested below might not be true
57469 ** in a corrupt database */
57470 assert( iIdx<=pParent->nCell );
57471 if( iIdx==pParent->nCell ){
57472 assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild );
57473 }else{
57474 assert( get4byte(findCell(pParent, iIdx))==iChild );
@@ -57321,23 +57489,15 @@
57489 static void moveToParent(BtCursor *pCur){
57490 assert( cursorHoldsMutex(pCur) );
57491 assert( pCur->eState==CURSOR_VALID );
57492 assert( pCur->iPage>0 );
57493 assert( pCur->apPage[pCur->iPage] );
 
 
 
 
 
 
 
57494 assertParentIndex(
57495 pCur->apPage[pCur->iPage-1],
57496 pCur->aiIdx[pCur->iPage-1],
57497 pCur->apPage[pCur->iPage]->pgno
57498 );
 
57499 testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell );
57500
57501 releasePage(pCur->apPage[pCur->iPage]);
57502 pCur->iPage--;
57503 pCur->info.nSize = 0;
@@ -60259,11 +60419,12 @@
60419 ** the previous call, as the overflow cell data will have been
60420 ** copied either into the body of a database page or into the new
60421 ** pSpace buffer passed to the latter call to balance_nonroot().
60422 */
60423 u8 *pSpace = sqlite3PageMalloc(pCur->pBt->pageSize);
60424 rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1,
60425 pCur->hints&BTREE_BULKLOAD);
60426 if( pFree ){
60427 /* If pFree is not NULL, it points to the pSpace buffer used
60428 ** by a previous call to balance_nonroot(). Its contents are
60429 ** now stored either on real database pages or within the
60430 ** new pSpace buffer, so it may be safely freed here. */
@@ -60280,10 +60441,11 @@
60441 pPage->nOverflow = 0;
60442
60443 /* The next iteration of the do-loop balances the parent page. */
60444 releasePage(pPage);
60445 pCur->iPage--;
60446 assert( pCur->iPage>=0 );
60447 }
60448 }while( rc==SQLITE_OK );
60449
60450 if( pFree ){
60451 sqlite3PageFree(pFree);
@@ -60751,29 +60913,32 @@
60913 int rc;
60914 unsigned char *pCell;
60915 int i;
60916 int hdr;
60917 u16 szCell;
60918 u8 hasChildren;
60919
60920 assert( sqlite3_mutex_held(pBt->mutex) );
60921 if( pgno>btreePagecount(pBt) ){
60922 return SQLITE_CORRUPT_BKPT;
60923 }
60924
60925 rc = getAndInitPage(pBt, pgno, &pPage, 0);
60926 if( rc ) return rc;
60927 hasChildren = !pPage->leaf;
60928 pPage->leaf = 1; /* Block looping if the database is corrupt */
60929 hdr = pPage->hdrOffset;
60930 for(i=0; i<pPage->nCell; i++){
60931 pCell = findCell(pPage, i);
60932 if( hasChildren ){
60933 rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
60934 if( rc ) goto cleardatabasepage_out;
60935 }
60936 rc = clearCell(pPage, pCell, &szCell);
60937 if( rc ) goto cleardatabasepage_out;
60938 }
60939 if( hasChildren ){
60940 rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
60941 if( rc ) goto cleardatabasepage_out;
60942 }else if( pnChange ){
60943 assert( pPage->intKey );
60944 *pnChange += pPage->nCell;
@@ -61922,17 +62087,26 @@
62087 pBt->btsFlags &= ~BTS_NO_WAL;
62088 return rc;
62089 }
62090
62091 /*
62092 ** set the mask of hint flags for cursor pCsr.
 
62093 */
62094 SQLITE_PRIVATE void sqlite3BtreeCursorHints(BtCursor *pCsr, unsigned int mask){
62095 assert( mask==BTREE_BULKLOAD || mask==BTREE_SEEK_EQ || mask==0 );
62096 pCsr->hints = mask;
62097 }
62098
62099 #ifdef SQLITE_DEBUG
62100 /*
62101 ** Return true if the cursor has a hint specified. This routine is
62102 ** only used from within assert() statements
62103 */
62104 SQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor *pCsr, unsigned int mask){
62105 return (pCsr->hints & mask)!=0;
62106 }
62107 #endif
62108
62109 /*
62110 ** Return true if the given Btree is read-only.
62111 */
62112 SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *p){
@@ -62088,11 +62262,11 @@
62262 ** a pointer to the new sqlite3_backup object.
62263 **
62264 ** If an error occurs, NULL is returned and an error code and error message
62265 ** stored in database handle pDestDb.
62266 */
62267 SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
62268 sqlite3* pDestDb, /* Database to write to */
62269 const char *zDestDb, /* Name of database within pDestDb */
62270 sqlite3* pSrcDb, /* Database connection to read from */
62271 const char *zSrcDb /* Name of database within pSrcDb */
62272 ){
@@ -62296,11 +62470,11 @@
62470 }
62471
62472 /*
62473 ** Copy nPage pages from the source b-tree to the destination.
62474 */
62475 SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage){
62476 int rc;
62477 int destMode; /* Destination journal mode */
62478 int pgszSrc = 0; /* Source page size */
62479 int pgszDest = 0; /* Destination page size */
62480
@@ -62541,11 +62715,11 @@
62715 }
62716
62717 /*
62718 ** Release all resources associated with an sqlite3_backup* handle.
62719 */
62720 SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p){
62721 sqlite3_backup **pp; /* Ptr to head of pagers backup list */
62722 sqlite3 *pSrcDb; /* Source database connection */
62723 int rc; /* Value to return */
62724
62725 /* Enter the mutexes */
@@ -62593,11 +62767,11 @@
62767
62768 /*
62769 ** Return the number of pages still to be backed up as of the most recent
62770 ** call to sqlite3_backup_step().
62771 */
62772 SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p){
62773 #ifdef SQLITE_ENABLE_API_ARMOR
62774 if( p==0 ){
62775 (void)SQLITE_MISUSE_BKPT;
62776 return 0;
62777 }
@@ -62607,11 +62781,11 @@
62781
62782 /*
62783 ** Return the total number of pages in the source database as of the most
62784 ** recent call to sqlite3_backup_step().
62785 */
62786 SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p){
62787 #ifdef SQLITE_ENABLE_API_ARMOR
62788 if( p==0 ){
62789 (void)SQLITE_MISUSE_BKPT;
62790 return 0;
62791 }
@@ -63822,11 +63996,11 @@
63996 ** by calling sqlite3ValueNew().
63997 **
63998 ** Otherwise, if the second argument is non-zero, then this function is
63999 ** being called indirectly by sqlite3Stat4ProbeSetValue(). If it has not
64000 ** already been allocated, allocate the UnpackedRecord structure that
64001 ** that function will return to its caller here. Then return a pointer to
64002 ** an sqlite3_value within the UnpackedRecord.a[] array.
64003 */
64004 static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){
64005 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
64006 if( p ){
@@ -63866,10 +64040,117 @@
64040 UNUSED_PARAMETER(p);
64041 #endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
64042 return sqlite3ValueNew(db);
64043 }
64044
64045 /*
64046 ** The expression object indicated by the second argument is guaranteed
64047 ** to be a scalar SQL function. If
64048 **
64049 ** * all function arguments are SQL literals,
64050 ** * the SQLITE_FUNC_CONSTANT function flag is set, and
64051 ** * the SQLITE_FUNC_NEEDCOLL function flag is not set,
64052 **
64053 ** then this routine attempts to invoke the SQL function. Assuming no
64054 ** error occurs, output parameter (*ppVal) is set to point to a value
64055 ** object containing the result before returning SQLITE_OK.
64056 **
64057 ** Affinity aff is applied to the result of the function before returning.
64058 ** If the result is a text value, the sqlite3_value object uses encoding
64059 ** enc.
64060 **
64061 ** If the conditions above are not met, this function returns SQLITE_OK
64062 ** and sets (*ppVal) to NULL. Or, if an error occurs, (*ppVal) is set to
64063 ** NULL and an SQLite error code returned.
64064 */
64065 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
64066 static int valueFromFunction(
64067 sqlite3 *db, /* The database connection */
64068 Expr *p, /* The expression to evaluate */
64069 u8 enc, /* Encoding to use */
64070 u8 aff, /* Affinity to use */
64071 sqlite3_value **ppVal, /* Write the new value here */
64072 struct ValueNewStat4Ctx *pCtx /* Second argument for valueNew() */
64073 ){
64074 sqlite3_context ctx; /* Context object for function invocation */
64075 sqlite3_value **apVal = 0; /* Function arguments */
64076 int nVal = 0; /* Size of apVal[] array */
64077 FuncDef *pFunc = 0; /* Function definition */
64078 sqlite3_value *pVal = 0; /* New value */
64079 int rc = SQLITE_OK; /* Return code */
64080 int nName; /* Size of function name in bytes */
64081 ExprList *pList = 0; /* Function arguments */
64082 int i; /* Iterator variable */
64083
64084 assert( pCtx!=0 );
64085 assert( (p->flags & EP_TokenOnly)==0 );
64086 pList = p->x.pList;
64087 if( pList ) nVal = pList->nExpr;
64088 nName = sqlite3Strlen30(p->u.zToken);
64089 pFunc = sqlite3FindFunction(db, p->u.zToken, nName, nVal, enc, 0);
64090 assert( pFunc );
64091 if( (pFunc->funcFlags & SQLITE_FUNC_CONSTANT)==0
64092 || (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)
64093 ){
64094 return SQLITE_OK;
64095 }
64096
64097 if( pList ){
64098 apVal = (sqlite3_value**)sqlite3DbMallocZero(db, sizeof(apVal[0]) * nVal);
64099 if( apVal==0 ){
64100 rc = SQLITE_NOMEM;
64101 goto value_from_function_out;
64102 }
64103 for(i=0; i<nVal; i++){
64104 rc = sqlite3ValueFromExpr(db, pList->a[i].pExpr, enc, aff, &apVal[i]);
64105 if( apVal[i]==0 || rc!=SQLITE_OK ) goto value_from_function_out;
64106 }
64107 }
64108
64109 pVal = valueNew(db, pCtx);
64110 if( pVal==0 ){
64111 rc = SQLITE_NOMEM;
64112 goto value_from_function_out;
64113 }
64114
64115 assert( pCtx->pParse->rc==SQLITE_OK );
64116 memset(&ctx, 0, sizeof(ctx));
64117 ctx.pOut = pVal;
64118 ctx.pFunc = pFunc;
64119 pFunc->xFunc(&ctx, nVal, apVal);
64120 if( ctx.isError ){
64121 rc = ctx.isError;
64122 sqlite3ErrorMsg(pCtx->pParse, "%s", sqlite3_value_text(pVal));
64123 }else{
64124 sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8);
64125 assert( rc==SQLITE_OK );
64126 rc = sqlite3VdbeChangeEncoding(pVal, enc);
64127 if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){
64128 rc = SQLITE_TOOBIG;
64129 pCtx->pParse->nErr++;
64130 }
64131 }
64132 pCtx->pParse->rc = rc;
64133
64134 value_from_function_out:
64135 if( rc!=SQLITE_OK ){
64136 pVal = 0;
64137 }
64138 if( apVal ){
64139 for(i=0; i<nVal; i++){
64140 sqlite3ValueFree(apVal[i]);
64141 }
64142 sqlite3DbFree(db, apVal);
64143 }
64144
64145 *ppVal = pVal;
64146 return rc;
64147 }
64148 #else
64149 # define valueFromFunction(a,b,c,d,e,f) SQLITE_OK
64150 #endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
64151
64152 /*
64153 ** Extract a value from the supplied expression in the manner described
64154 ** above sqlite3ValueFromExpr(). Allocate the sqlite3_value object
64155 ** using valueNew().
64156 **
@@ -63897,10 +64178,16 @@
64178 *ppVal = 0;
64179 return SQLITE_OK;
64180 }
64181 while( (op = pExpr->op)==TK_UPLUS ) pExpr = pExpr->pLeft;
64182 if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
64183
64184 /* Compressed expressions only appear when parsing the DEFAULT clause
64185 ** on a table column definition, and hence only when pCtx==0. This
64186 ** check ensures that an EP_TokenOnly expression is never passed down
64187 ** into valueFromFunction(). */
64188 assert( (pExpr->flags & EP_TokenOnly)==0 || pCtx==0 );
64189
64190 if( op==TK_CAST ){
64191 u8 aff = sqlite3AffinityType(pExpr->u.zToken,0);
64192 rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx);
64193 testcase( rc!=SQLITE_OK );
@@ -63973,10 +64260,16 @@
64260 assert( zVal[nVal]=='\'' );
64261 sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,
64262 0, SQLITE_DYNAMIC);
64263 }
64264 #endif
64265
64266 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
64267 else if( op==TK_FUNCTION && pCtx!=0 ){
64268 rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);
64269 }
64270 #endif
64271
64272 *ppVal = pVal;
64273 return rc;
64274
64275 no_mem:
@@ -64363,11 +64656,11 @@
64656 }
64657
64658 /*
64659 ** Return the SQL associated with a prepared statement
64660 */
64661 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){
64662 Vdbe *p = (Vdbe *)pStmt;
64663 return (p && p->isPrepareV2) ? p->zSql : 0;
64664 }
64665
64666 /*
@@ -65426,11 +65719,11 @@
65719 break;
65720 }
65721 #ifndef SQLITE_OMIT_VIRTUALTABLE
65722 case P4_VTAB: {
65723 sqlite3_vtab *pVtab = pOp->p4.pVtab->pVtab;
65724 sqlite3_snprintf(nTemp, zTemp, "vtab:%p", pVtab);
65725 break;
65726 }
65727 #endif
65728 case P4_INTARRAY: {
65729 sqlite3_snprintf(nTemp, zTemp, "intarray");
@@ -66090,13 +66383,13 @@
66383 }
66384 #ifndef SQLITE_OMIT_VIRTUALTABLE
66385 else if( pCx->pVtabCursor ){
66386 sqlite3_vtab_cursor *pVtabCursor = pCx->pVtabCursor;
66387 const sqlite3_module *pModule = pVtabCursor->pVtab->pModule;
66388 assert( pVtabCursor->pVtab->nRef>0 );
66389 pVtabCursor->pVtab->nRef--;
66390 pModule->xClose(pVtabCursor);
 
66391 }
66392 #endif
66393 }
66394
66395 /*
@@ -66451,11 +66744,11 @@
66744
66745 /* Delete the master journal file. This commits the transaction. After
66746 ** doing this the directory is synced again before any individual
66747 ** transaction files are deleted.
66748 */
66749 rc = sqlite3OsDelete(pVfs, zMaster, needSync);
66750 sqlite3DbFree(db, zMaster);
66751 zMaster = 0;
66752 if( rc ){
66753 return rc;
66754 }
@@ -68519,11 +68812,11 @@
68812 ** execution environment changes in a way that would alter the program
68813 ** that sqlite3_prepare() generates. For example, if new functions or
68814 ** collating sequences are registered or if an authorizer function is
68815 ** added or changed.
68816 */
68817 SQLITE_API int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt *pStmt){
68818 Vdbe *p = (Vdbe*)pStmt;
68819 return p==0 || p->expired;
68820 }
68821 #endif
68822
@@ -68556,11 +68849,11 @@
68849 ** machine.
68850 **
68851 ** This routine sets the error code and string returned by
68852 ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
68853 */
68854 SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt){
68855 int rc;
68856 if( pStmt==0 ){
68857 /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL
68858 ** pointer is a harmless no-op. */
68859 rc = SQLITE_OK;
@@ -68582,11 +68875,11 @@
68875 ** the prior execution is returned.
68876 **
68877 ** This routine sets the error code and string returned by
68878 ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
68879 */
68880 SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt){
68881 int rc;
68882 if( pStmt==0 ){
68883 rc = SQLITE_OK;
68884 }else{
68885 Vdbe *v = (Vdbe*)pStmt;
@@ -68601,11 +68894,11 @@
68894 }
68895
68896 /*
68897 ** Set all the parameters in the compiled SQL statement to NULL.
68898 */
68899 SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt *pStmt){
68900 int i;
68901 int rc = SQLITE_OK;
68902 Vdbe *p = (Vdbe*)pStmt;
68903 #if SQLITE_THREADSAFE
68904 sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex;
@@ -68625,54 +68918,54 @@
68918
68919 /**************************** sqlite3_value_ *******************************
68920 ** The following routines extract information from a Mem or sqlite3_value
68921 ** structure.
68922 */
68923 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value *pVal){
68924 Mem *p = (Mem*)pVal;
68925 if( p->flags & (MEM_Blob|MEM_Str) ){
68926 sqlite3VdbeMemExpandBlob(p);
68927 p->flags |= MEM_Blob;
68928 return p->n ? p->z : 0;
68929 }else{
68930 return sqlite3_value_text(pVal);
68931 }
68932 }
68933 SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value *pVal){
68934 return sqlite3ValueBytes(pVal, SQLITE_UTF8);
68935 }
68936 SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value *pVal){
68937 return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE);
68938 }
68939 SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value *pVal){
68940 return sqlite3VdbeRealValue((Mem*)pVal);
68941 }
68942 SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value *pVal){
68943 return (int)sqlite3VdbeIntValue((Mem*)pVal);
68944 }
68945 SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value *pVal){
68946 return sqlite3VdbeIntValue((Mem*)pVal);
68947 }
68948 SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value *pVal){
68949 return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
68950 }
68951 #ifndef SQLITE_OMIT_UTF16
68952 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value* pVal){
68953 return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE);
68954 }
68955 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value *pVal){
68956 return sqlite3ValueText(pVal, SQLITE_UTF16BE);
68957 }
68958 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value *pVal){
68959 return sqlite3ValueText(pVal, SQLITE_UTF16LE);
68960 }
68961 #endif /* SQLITE_OMIT_UTF16 */
68962 /* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five
68963 ** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating
68964 ** point number string BLOB NULL
68965 */
68966 SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value* pVal){
68967 static const u8 aType[] = {
68968 SQLITE_BLOB, /* 0x00 */
68969 SQLITE_NULL, /* 0x01 */
68970 SQLITE_TEXT, /* 0x02 */
68971 SQLITE_NULL, /* 0x03 */
@@ -68744,21 +69037,21 @@
69037 xDel((void*)p);
69038 }
69039 if( pCtx ) sqlite3_result_error_toobig(pCtx);
69040 return SQLITE_TOOBIG;
69041 }
69042 SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(
69043 sqlite3_context *pCtx,
69044 const void *z,
69045 int n,
69046 void (*xDel)(void *)
69047 ){
69048 assert( n>=0 );
69049 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69050 setResultStrOrError(pCtx, z, n, 0, xDel);
69051 }
69052 SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(
69053 sqlite3_context *pCtx,
69054 const void *z,
69055 sqlite3_uint64 n,
69056 void (*xDel)(void *)
69057 ){
@@ -68768,50 +69061,50 @@
69061 (void)invokeValueDestructor(z, xDel, pCtx);
69062 }else{
69063 setResultStrOrError(pCtx, z, (int)n, 0, xDel);
69064 }
69065 }
69066 SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context *pCtx, double rVal){
69067 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69068 sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);
69069 }
69070 SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
69071 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69072 pCtx->isError = SQLITE_ERROR;
69073 pCtx->fErrorOrAux = 1;
69074 sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);
69075 }
69076 #ifndef SQLITE_OMIT_UTF16
69077 SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
69078 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69079 pCtx->isError = SQLITE_ERROR;
69080 pCtx->fErrorOrAux = 1;
69081 sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);
69082 }
69083 #endif
69084 SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context *pCtx, int iVal){
69085 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69086 sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal);
69087 }
69088 SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
69089 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69090 sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);
69091 }
69092 SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context *pCtx){
69093 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69094 sqlite3VdbeMemSetNull(pCtx->pOut);
69095 }
69096 SQLITE_API void SQLITE_STDCALL sqlite3_result_text(
69097 sqlite3_context *pCtx,
69098 const char *z,
69099 int n,
69100 void (*xDel)(void *)
69101 ){
69102 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69103 setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);
69104 }
69105 SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(
69106 sqlite3_context *pCtx,
69107 const char *z,
69108 sqlite3_uint64 n,
69109 void (*xDel)(void *),
69110 unsigned char enc
@@ -68824,69 +69117,69 @@
69117 }else{
69118 setResultStrOrError(pCtx, z, (int)n, enc, xDel);
69119 }
69120 }
69121 #ifndef SQLITE_OMIT_UTF16
69122 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(
69123 sqlite3_context *pCtx,
69124 const void *z,
69125 int n,
69126 void (*xDel)(void *)
69127 ){
69128 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69129 setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel);
69130 }
69131 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(
69132 sqlite3_context *pCtx,
69133 const void *z,
69134 int n,
69135 void (*xDel)(void *)
69136 ){
69137 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69138 setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel);
69139 }
69140 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(
69141 sqlite3_context *pCtx,
69142 const void *z,
69143 int n,
69144 void (*xDel)(void *)
69145 ){
69146 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69147 setResultStrOrError(pCtx, z, n, SQLITE_UTF16LE, xDel);
69148 }
69149 #endif /* SQLITE_OMIT_UTF16 */
69150 SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){
69151 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69152 sqlite3VdbeMemCopy(pCtx->pOut, pValue);
69153 }
69154 SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){
69155 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69156 sqlite3VdbeMemSetZeroBlob(pCtx->pOut, n);
69157 }
69158 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
69159 pCtx->isError = errCode;
69160 pCtx->fErrorOrAux = 1;
69161 #ifdef SQLITE_DEBUG
69162 if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode;
69163 #endif
69164 if( pCtx->pOut->flags & MEM_Null ){
69165 sqlite3VdbeMemSetStr(pCtx->pOut, sqlite3ErrStr(errCode), -1,
69166 SQLITE_UTF8, SQLITE_STATIC);
69167 }
69168 }
69169
69170 /* Force an SQLITE_TOOBIG error. */
69171 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context *pCtx){
69172 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69173 pCtx->isError = SQLITE_TOOBIG;
69174 pCtx->fErrorOrAux = 1;
69175 sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1,
69176 SQLITE_UTF8, SQLITE_STATIC);
69177 }
69178
69179 /* An SQLITE_NOMEM error. */
69180 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context *pCtx){
69181 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69182 sqlite3VdbeMemSetNull(pCtx->pOut);
69183 pCtx->isError = SQLITE_NOMEM;
69184 pCtx->fErrorOrAux = 1;
69185 pCtx->pOut->db->mallocFailed = 1;
@@ -69055,11 +69348,11 @@
69348 /*
69349 ** This is the top-level implementation of sqlite3_step(). Call
69350 ** sqlite3Step() to do most of the work. If a schema error occurs,
69351 ** call sqlite3Reprepare() and try again.
69352 */
69353 SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt *pStmt){
69354 int rc = SQLITE_OK; /* Result from sqlite3Step() */
69355 int rc2 = SQLITE_OK; /* Result from sqlite3Reprepare() */
69356 Vdbe *v = (Vdbe*)pStmt; /* the prepared statement */
69357 int cnt = 0; /* Counter to prevent infinite loop of reprepares */
69358 sqlite3 *db; /* The database connection */
@@ -69106,11 +69399,11 @@
69399
69400 /*
69401 ** Extract the user data from a sqlite3_context structure and return a
69402 ** pointer to it.
69403 */
69404 SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context *p){
69405 assert( p && p->pFunc );
69406 return p->pFunc->pUserData;
69407 }
69408
69409 /*
@@ -69121,26 +69414,36 @@
69414 ** returns a copy of the pointer to the database connection (the 1st
69415 ** parameter) of the sqlite3_create_function() and
69416 ** sqlite3_create_function16() routines that originally registered the
69417 ** application defined function.
69418 */
69419 SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context *p){
69420 assert( p && p->pFunc );
69421 return p->pOut->db;
69422 }
69423
69424 /*
69425 ** Return the current time for a statement. If the current time
69426 ** is requested more than once within the same run of a single prepared
69427 ** statement, the exact same time is returned for each invocation regardless
69428 ** of the amount of time that elapses between invocations. In other words,
69429 ** the time returned is always the time of the first call.
69430 */
69431 SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){
 
69432 int rc;
69433 #ifndef SQLITE_ENABLE_STAT3_OR_STAT4
69434 sqlite3_int64 *piTime = &p->pVdbe->iCurrentTime;
69435 assert( p->pVdbe!=0 );
69436 #else
69437 sqlite3_int64 iTime = 0;
69438 sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;
69439 #endif
69440 if( *piTime==0 ){
69441 rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime);
69442 if( rc ) *piTime = 0;
69443 }
69444 return *piTime;
69445 }
69446
69447 /*
69448 ** The following is the implementation of an SQL function that always
69449 ** fails with an error message stating that the function is used in the
@@ -69187,11 +69490,11 @@
69490 /*
69491 ** Allocate or return the aggregate context for a user function. A new
69492 ** context is allocated on the first call. Subsequent calls return the
69493 ** same context that was returned on prior calls.
69494 */
69495 SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context *p, int nByte){
69496 assert( p && p->pFunc && p->pFunc->xStep );
69497 assert( sqlite3_mutex_held(p->pOut->db->mutex) );
69498 testcase( nByte<0 );
69499 if( (p->pMem->flags & MEM_Agg)==0 ){
69500 return createAggContext(p, nByte);
@@ -69202,14 +69505,19 @@
69505
69506 /*
69507 ** Return the auxiliary data pointer, if any, for the iArg'th argument to
69508 ** the user-function defined by pCtx.
69509 */
69510 SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
69511 AuxData *pAuxData;
69512
69513 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69514 #if SQLITE_ENABLE_STAT3_OR_STAT4
69515 if( pCtx->pVdbe==0 ) return 0;
69516 #else
69517 assert( pCtx->pVdbe!=0 );
69518 #endif
69519 for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
69520 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
69521 }
69522
69523 return (pAuxData ? pAuxData->pAux : 0);
@@ -69218,11 +69526,11 @@
69526 /*
69527 ** Set the auxiliary data pointer and delete function, for the iArg'th
69528 ** argument to the user-function defined by pCtx. Any previous value is
69529 ** deleted by calling the delete function specified when it was set.
69530 */
69531 SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(
69532 sqlite3_context *pCtx,
69533 int iArg,
69534 void *pAux,
69535 void (*xDelete)(void*)
69536 ){
@@ -69229,10 +69537,15 @@
69537 AuxData *pAuxData;
69538 Vdbe *pVdbe = pCtx->pVdbe;
69539
69540 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69541 if( iArg<0 ) goto failed;
69542 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
69543 if( pVdbe==0 ) goto failed;
69544 #else
69545 assert( pVdbe!=0 );
69546 #endif
69547
69548 for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
69549 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
69550 }
69551 if( pAuxData==0 ){
@@ -69268,29 +69581,29 @@
69581 ** This function is deprecated. Do not use it for new code. It is
69582 ** provide only to avoid breaking legacy code. New aggregate function
69583 ** implementations should keep their own counts within their aggregate
69584 ** context.
69585 */
69586 SQLITE_API int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context *p){
69587 assert( p && p->pMem && p->pFunc && p->pFunc->xStep );
69588 return p->pMem->n;
69589 }
69590 #endif
69591
69592 /*
69593 ** Return the number of columns in the result set for the statement pStmt.
69594 */
69595 SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt){
69596 Vdbe *pVm = (Vdbe *)pStmt;
69597 return pVm ? pVm->nResColumn : 0;
69598 }
69599
69600 /*
69601 ** Return the number of values available from the current row of the
69602 ** currently executing statement pStmt.
69603 */
69604 SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt){
69605 Vdbe *pVm = (Vdbe *)pStmt;
69606 if( pVm==0 || pVm->pResultSet==0 ) return 0;
69607 return pVm->nResColumn;
69608 }
69609
@@ -69388,67 +69701,67 @@
69701
69702 /**************************** sqlite3_column_ *******************************
69703 ** The following routines are used to access elements of the current row
69704 ** in the result set.
69705 */
69706 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt *pStmt, int i){
69707 const void *val;
69708 val = sqlite3_value_blob( columnMem(pStmt,i) );
69709 /* Even though there is no encoding conversion, value_blob() might
69710 ** need to call malloc() to expand the result of a zeroblob()
69711 ** expression.
69712 */
69713 columnMallocFailure(pStmt);
69714 return val;
69715 }
69716 SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){
69717 int val = sqlite3_value_bytes( columnMem(pStmt,i) );
69718 columnMallocFailure(pStmt);
69719 return val;
69720 }
69721 SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){
69722 int val = sqlite3_value_bytes16( columnMem(pStmt,i) );
69723 columnMallocFailure(pStmt);
69724 return val;
69725 }
69726 SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt *pStmt, int i){
69727 double val = sqlite3_value_double( columnMem(pStmt,i) );
69728 columnMallocFailure(pStmt);
69729 return val;
69730 }
69731 SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt *pStmt, int i){
69732 int val = sqlite3_value_int( columnMem(pStmt,i) );
69733 columnMallocFailure(pStmt);
69734 return val;
69735 }
69736 SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt *pStmt, int i){
69737 sqlite_int64 val = sqlite3_value_int64( columnMem(pStmt,i) );
69738 columnMallocFailure(pStmt);
69739 return val;
69740 }
69741 SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt *pStmt, int i){
69742 const unsigned char *val = sqlite3_value_text( columnMem(pStmt,i) );
69743 columnMallocFailure(pStmt);
69744 return val;
69745 }
69746 SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt *pStmt, int i){
69747 Mem *pOut = columnMem(pStmt, i);
69748 if( pOut->flags&MEM_Static ){
69749 pOut->flags &= ~MEM_Static;
69750 pOut->flags |= MEM_Ephem;
69751 }
69752 columnMallocFailure(pStmt);
69753 return (sqlite3_value *)pOut;
69754 }
69755 #ifndef SQLITE_OMIT_UTF16
69756 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt *pStmt, int i){
69757 const void *val = sqlite3_value_text16( columnMem(pStmt,i) );
69758 columnMallocFailure(pStmt);
69759 return val;
69760 }
69761 #endif /* SQLITE_OMIT_UTF16 */
69762 SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt *pStmt, int i){
69763 int iType = sqlite3_value_type( columnMem(pStmt,i) );
69764 columnMallocFailure(pStmt);
69765 return iType;
69766 }
69767
@@ -69508,16 +69821,16 @@
69821
69822 /*
69823 ** Return the name of the Nth column of the result set returned by SQL
69824 ** statement pStmt.
69825 */
69826 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt *pStmt, int N){
69827 return columnName(
69828 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_NAME);
69829 }
69830 #ifndef SQLITE_OMIT_UTF16
69831 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
69832 return columnName(
69833 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_NAME);
69834 }
69835 #endif
69836
@@ -69533,16 +69846,16 @@
69846 #ifndef SQLITE_OMIT_DECLTYPE
69847 /*
69848 ** Return the column declaration type (if applicable) of the 'i'th column
69849 ** of the result set of SQL statement pStmt.
69850 */
69851 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){
69852 return columnName(
69853 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DECLTYPE);
69854 }
69855 #ifndef SQLITE_OMIT_UTF16
69856 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
69857 return columnName(
69858 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DECLTYPE);
69859 }
69860 #endif /* SQLITE_OMIT_UTF16 */
69861 #endif /* SQLITE_OMIT_DECLTYPE */
@@ -69551,16 +69864,16 @@
69864 /*
69865 ** Return the name of the database from which a result column derives.
69866 ** NULL is returned if the result column is an expression or constant or
69867 ** anything else which is not an unambiguous reference to a database column.
69868 */
69869 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){
69870 return columnName(
69871 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DATABASE);
69872 }
69873 #ifndef SQLITE_OMIT_UTF16
69874 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){
69875 return columnName(
69876 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DATABASE);
69877 }
69878 #endif /* SQLITE_OMIT_UTF16 */
69879
@@ -69567,16 +69880,16 @@
69880 /*
69881 ** Return the name of the table from which a result column derives.
69882 ** NULL is returned if the result column is an expression or constant or
69883 ** anything else which is not an unambiguous reference to a database column.
69884 */
69885 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){
69886 return columnName(
69887 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_TABLE);
69888 }
69889 #ifndef SQLITE_OMIT_UTF16
69890 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){
69891 return columnName(
69892 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_TABLE);
69893 }
69894 #endif /* SQLITE_OMIT_UTF16 */
69895
@@ -69583,16 +69896,16 @@
69896 /*
69897 ** Return the name of the table column from which a result column derives.
69898 ** NULL is returned if the result column is an expression or constant or
69899 ** anything else which is not an unambiguous reference to a database column.
69900 */
69901 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){
69902 return columnName(
69903 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_COLUMN);
69904 }
69905 #ifndef SQLITE_OMIT_UTF16
69906 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){
69907 return columnName(
69908 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN);
69909 }
69910 #endif /* SQLITE_OMIT_UTF16 */
69911 #endif /* SQLITE_ENABLE_COLUMN_METADATA */
@@ -69689,20 +70002,20 @@
70002
70003
70004 /*
70005 ** Bind a blob value to an SQL statement variable.
70006 */
70007 SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(
70008 sqlite3_stmt *pStmt,
70009 int i,
70010 const void *zData,
70011 int nData,
70012 void (*xDel)(void*)
70013 ){
70014 return bindText(pStmt, i, zData, nData, xDel, 0);
70015 }
70016 SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(
70017 sqlite3_stmt *pStmt,
70018 int i,
70019 const void *zData,
70020 sqlite3_uint64 nData,
70021 void (*xDel)(void*)
@@ -69712,52 +70025,52 @@
70025 return invokeValueDestructor(zData, xDel, 0);
70026 }else{
70027 return bindText(pStmt, i, zData, (int)nData, xDel, 0);
70028 }
70029 }
70030 SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
70031 int rc;
70032 Vdbe *p = (Vdbe *)pStmt;
70033 rc = vdbeUnbind(p, i);
70034 if( rc==SQLITE_OK ){
70035 sqlite3VdbeMemSetDouble(&p->aVar[i-1], rValue);
70036 sqlite3_mutex_leave(p->db->mutex);
70037 }
70038 return rc;
70039 }
70040 SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){
70041 return sqlite3_bind_int64(p, i, (i64)iValue);
70042 }
70043 SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){
70044 int rc;
70045 Vdbe *p = (Vdbe *)pStmt;
70046 rc = vdbeUnbind(p, i);
70047 if( rc==SQLITE_OK ){
70048 sqlite3VdbeMemSetInt64(&p->aVar[i-1], iValue);
70049 sqlite3_mutex_leave(p->db->mutex);
70050 }
70051 return rc;
70052 }
70053 SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
70054 int rc;
70055 Vdbe *p = (Vdbe*)pStmt;
70056 rc = vdbeUnbind(p, i);
70057 if( rc==SQLITE_OK ){
70058 sqlite3_mutex_leave(p->db->mutex);
70059 }
70060 return rc;
70061 }
70062 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(
70063 sqlite3_stmt *pStmt,
70064 int i,
70065 const char *zData,
70066 int nData,
70067 void (*xDel)(void*)
70068 ){
70069 return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);
70070 }
70071 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(
70072 sqlite3_stmt *pStmt,
70073 int i,
70074 const char *zData,
70075 sqlite3_uint64 nData,
70076 void (*xDel)(void*),
@@ -69770,21 +70083,21 @@
70083 if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
70084 return bindText(pStmt, i, zData, (int)nData, xDel, enc);
70085 }
70086 }
70087 #ifndef SQLITE_OMIT_UTF16
70088 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(
70089 sqlite3_stmt *pStmt,
70090 int i,
70091 const void *zData,
70092 int nData,
70093 void (*xDel)(void*)
70094 ){
70095 return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);
70096 }
70097 #endif /* SQLITE_OMIT_UTF16 */
70098 SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
70099 int rc;
70100 switch( sqlite3_value_type((sqlite3_value*)pValue) ){
70101 case SQLITE_INTEGER: {
70102 rc = sqlite3_bind_int64(pStmt, i, pValue->u.i);
70103 break;
@@ -69811,11 +70124,11 @@
70124 break;
70125 }
70126 }
70127 return rc;
70128 }
70129 SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
70130 int rc;
70131 Vdbe *p = (Vdbe *)pStmt;
70132 rc = vdbeUnbind(p, i);
70133 if( rc==SQLITE_OK ){
70134 sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n);
@@ -69826,11 +70139,11 @@
70139
70140 /*
70141 ** Return the number of wildcards that can be potentially bound to.
70142 ** This routine is added to support DBD::SQLite.
70143 */
70144 SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){
70145 Vdbe *p = (Vdbe*)pStmt;
70146 return p ? p->nVar : 0;
70147 }
70148
70149 /*
@@ -69837,11 +70150,11 @@
70150 ** Return the name of a wildcard parameter. Return NULL if the index
70151 ** is out of range or if the wildcard is unnamed.
70152 **
70153 ** The result is always UTF-8.
70154 */
70155 SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){
70156 Vdbe *p = (Vdbe*)pStmt;
70157 if( p==0 || i<1 || i>p->nzVar ){
70158 return 0;
70159 }
70160 return p->azVar[i-1];
@@ -69865,11 +70178,11 @@
70178 }
70179 }
70180 }
70181 return 0;
70182 }
70183 SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){
70184 return sqlite3VdbeParameterIndex((Vdbe*)pStmt, zName, sqlite3Strlen30(zName));
70185 }
70186
70187 /*
70188 ** Transfer all bindings from the first statement over to the second.
@@ -69899,11 +70212,11 @@
70212 **
70213 ** If the two statements contain a different number of bindings, then
70214 ** an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise
70215 ** SQLITE_OK is returned.
70216 */
70217 SQLITE_API int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
70218 Vdbe *pFrom = (Vdbe*)pFromStmt;
70219 Vdbe *pTo = (Vdbe*)pToStmt;
70220 if( pFrom->nVar!=pTo->nVar ){
70221 return SQLITE_ERROR;
70222 }
@@ -69921,26 +70234,26 @@
70234 ** Return the sqlite3* database handle to which the prepared statement given
70235 ** in the argument belongs. This is the same database handle that was
70236 ** the first argument to the sqlite3_prepare() that was used to create
70237 ** the statement in the first place.
70238 */
70239 SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt *pStmt){
70240 return pStmt ? ((Vdbe*)pStmt)->db : 0;
70241 }
70242
70243 /*
70244 ** Return true if the prepared statement is guaranteed to not modify the
70245 ** database.
70246 */
70247 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt){
70248 return pStmt ? ((Vdbe*)pStmt)->readOnly : 1;
70249 }
70250
70251 /*
70252 ** Return true if the prepared statement is in need of being reset.
70253 */
70254 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt *pStmt){
70255 Vdbe *v = (Vdbe*)pStmt;
70256 return v!=0 && v->pc>=0 && v->magic==VDBE_MAGIC_RUN;
70257 }
70258
70259 /*
@@ -69947,11 +70260,11 @@
70260 ** Return a pointer to the next prepared statement after pStmt associated
70261 ** with database connection pDb. If pStmt is NULL, return the first
70262 ** prepared statement for the database connection. Return NULL if there
70263 ** are no more.
70264 */
70265 SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){
70266 sqlite3_stmt *pNext;
70267 #ifdef SQLITE_ENABLE_API_ARMOR
70268 if( !sqlite3SafetyCheckOk(pDb) ){
70269 (void)SQLITE_MISUSE_BKPT;
70270 return 0;
@@ -69968,11 +70281,11 @@
70281 }
70282
70283 /*
70284 ** Return the value of a status counter for a prepared statement
70285 */
70286 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
70287 Vdbe *pVdbe = (Vdbe*)pStmt;
70288 u32 v;
70289 #ifdef SQLITE_ENABLE_API_ARMOR
70290 if( !pStmt ){
70291 (void)SQLITE_MISUSE_BKPT;
@@ -69986,11 +70299,11 @@
70299
70300 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
70301 /*
70302 ** Return status data for a single loop within query pStmt.
70303 */
70304 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_scanstatus(
70305 sqlite3_stmt *pStmt, /* Prepared statement being queried */
70306 int idx, /* Index of loop to report on */
70307 int iScanStatusOp, /* Which metric to return */
70308 void *pOut /* OUT: Write the answer here */
70309 ){
@@ -70045,11 +70358,11 @@
70358 }
70359
70360 /*
70361 ** Zero all counters associated with the sqlite3_stmt_scanstatus() data.
70362 */
70363 SQLITE_API void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){
70364 Vdbe *p = (Vdbe*)pStmt;
70365 memset(p->anExec, 0, p->nOp * sizeof(i64));
70366 }
70367 #endif /* SQLITE_ENABLE_STMT_SCANSTATUS */
70368
@@ -70544,11 +70857,11 @@
70857 ** Try to convert the type of a function argument or a result column
70858 ** into a numeric representation. Use either INTEGER or REAL whichever
70859 ** is appropriate. But only do the conversion if it is possible without
70860 ** loss of information and return the revised type of the argument.
70861 */
70862 SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value *pVal){
70863 int eType = sqlite3_value_type(pVal);
70864 if( eType==SQLITE_TEXT ){
70865 Mem *pMem = (Mem*)pVal;
70866 applyNumericAffinity(pMem, 0);
70867 eType = sqlite3_value_type(pVal);
@@ -71845,11 +72158,11 @@
72158 ** max() aggregate will set to 1 if the current row is not the minimum or
72159 ** maximum. The P1 register is initialized to 0 by this instruction.
72160 **
72161 ** The interface used by the implementation of the aforementioned functions
72162 ** to retrieve the collation sequence set by this opcode is not available
72163 ** publicly. Only built-in functions have access to this feature.
72164 */
72165 case OP_CollSeq: {
72166 assert( pOp->p4type==P4_COLLSEQ );
72167 if( pOp->p1 ){
72168 sqlite3VdbeMemSetInt64(&aMem[pOp->p1], 0);
@@ -73563,35 +73876,33 @@
73876 ** cursors or a single read/write cursor but not both.
73877 **
73878 ** See also OpenRead.
73879 */
73880 case OP_ReopenIdx: {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73881 int nField;
73882 KeyInfo *pKeyInfo;
73883 int p2;
73884 int iDb;
73885 int wrFlag;
73886 Btree *pX;
73887 VdbeCursor *pCur;
73888 Db *pDb;
73889
73890 assert( pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );
73891 assert( pOp->p4type==P4_KEYINFO );
73892 pCur = p->apCsr[pOp->p1];
73893 if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){
73894 assert( pCur->iDb==pOp->p3 ); /* Guaranteed by the code generator */
73895 goto open_cursor_set_hints;
73896 }
73897 /* If the cursor is not currently open or is open on a different
73898 ** index, then fall through into OP_OpenRead to force a reopen */
73899 case OP_OpenRead:
73900 case OP_OpenWrite:
73901
73902 assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR|OPFLAG_SEEKEQ))==pOp->p5 );
73903 assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );
73904 assert( p->bIsReader );
73905 assert( pOp->opcode==OP_OpenRead || pOp->opcode==OP_ReopenIdx
73906 || p->readOnly==0 );
73907
73908 if( p->expired ){
@@ -73650,18 +73961,21 @@
73961 pCur->nullRow = 1;
73962 pCur->isOrdered = 1;
73963 pCur->pgnoRoot = p2;
73964 rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur->pCursor);
73965 pCur->pKeyInfo = pKeyInfo;
 
 
 
73966 /* Set the VdbeCursor.isTable variable. Previous versions of
73967 ** SQLite used to check if the root-page flags were sane at this point
73968 ** and report database corruption if they were not, but this check has
73969 ** since moved into the btree layer. */
73970 pCur->isTable = pOp->p4type!=P4_KEYINFO;
73971
73972 open_cursor_set_hints:
73973 assert( OPFLAG_BULKCSR==BTREE_BULKLOAD );
73974 assert( OPFLAG_SEEKEQ==BTREE_SEEK_EQ );
73975 sqlite3BtreeCursorHints(pCur->pCursor,
73976 (pOp->p5 & (OPFLAG_BULKCSR|OPFLAG_SEEKEQ)));
73977 break;
73978 }
73979
73980 /* Opcode: OpenEphemeral P1 P2 * P4 P5
73981 ** Synopsis: nColumn=P2
@@ -73918,10 +74232,26 @@
74232 oc = pOp->opcode;
74233 pC->nullRow = 0;
74234 #ifdef SQLITE_DEBUG
74235 pC->seekOp = pOp->opcode;
74236 #endif
74237
74238 /* For a cursor with the BTREE_SEEK_EQ hint, only the OP_SeekGE and
74239 ** OP_SeekLE opcodes are allowed, and these must be immediately followed
74240 ** by an OP_IdxGT or OP_IdxLT opcode, respectively, with the same key.
74241 */
74242 #ifdef SQLITE_DEBUG
74243 if( sqlite3BtreeCursorHasHint(pC->pCursor, BTREE_SEEK_EQ) ){
74244 assert( pOp->opcode==OP_SeekGE || pOp->opcode==OP_SeekLE );
74245 assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
74246 assert( pOp[1].p1==pOp[0].p1 );
74247 assert( pOp[1].p2==pOp[0].p2 );
74248 assert( pOp[1].p3==pOp[0].p3 );
74249 assert( pOp[1].p4.i==pOp[0].p4.i );
74250 }
74251 #endif
74252
74253 if( pC->isTable ){
74254 /* The input value in P3 might be of any type: integer, real, string,
74255 ** blob, or NULL. But it needs to be an integer before we can do
74256 ** the seek, so convert it. */
74257 pIn3 = &aMem[pOp->p3];
@@ -75257,34 +75587,19 @@
75587 **
75588 ** See also: Clear
75589 */
75590 case OP_Destroy: { /* out2-prerelease */
75591 int iMoved;
 
 
75592 int iDb;
75593
75594 assert( p->readOnly==0 );
 
 
 
 
 
 
 
 
 
 
 
 
75595 pOut->flags = MEM_Null;
75596 if( db->nVdbeRead > db->nVDestroy+1 ){
75597 rc = SQLITE_LOCKED;
75598 p->errorAction = OE_Abort;
75599 }else{
75600 iDb = pOp->p3;
 
75601 assert( DbMaskTest(p->btreeMask, iDb) );
75602 iMoved = 0; /* Not needed. Only to silence a warning. */
75603 rc = sqlite3BtreeDropTable(db->aDb[iDb].pBt, pOp->p1, &iMoved);
75604 pOut->flags = MEM_Int;
75605 pOut->u.i = iMoved;
@@ -76337,17 +76652,33 @@
76652 break;
76653 }
76654 #endif /* SQLITE_OMIT_VIRTUALTABLE */
76655
76656 #ifndef SQLITE_OMIT_VIRTUALTABLE
76657 /* Opcode: VCreate P1 P2 * * *
76658 **
76659 ** P2 is a register that holds the name of a virtual table in database
76660 ** P1. Call the xCreate method for that table.
76661 */
76662 case OP_VCreate: {
76663 Mem sMem; /* For storing the record being decoded */
76664 const char *zTab; /* Name of the virtual table */
76665
76666 memset(&sMem, 0, sizeof(sMem));
76667 sMem.db = db;
76668 /* Because P2 is always a static string, it is impossible for the
76669 ** sqlite3VdbeMemCopy() to fail */
76670 assert( (aMem[pOp->p2].flags & MEM_Str)!=0 );
76671 assert( (aMem[pOp->p2].flags & MEM_Static)!=0 );
76672 rc = sqlite3VdbeMemCopy(&sMem, &aMem[pOp->p2]);
76673 assert( rc==SQLITE_OK );
76674 zTab = (const char*)sqlite3_value_text(&sMem);
76675 assert( zTab || db->mallocFailed );
76676 if( zTab ){
76677 rc = sqlite3VtabCallCreate(db, pOp->p1, zTab, &p->zErrMsg);
76678 }
76679 sqlite3VdbeMemRelease(&sMem);
76680 break;
76681 }
76682 #endif /* SQLITE_OMIT_VIRTUALTABLE */
76683
76684 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -76355,13 +76686,13 @@
76686 **
76687 ** P4 is the name of a virtual table in database P1. Call the xDestroy method
76688 ** of that table.
76689 */
76690 case OP_VDestroy: {
76691 db->nVDestroy++;
76692 rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z);
76693 db->nVDestroy--;
76694 break;
76695 }
76696 #endif /* SQLITE_OMIT_VIRTUALTABLE */
76697
76698 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -76373,18 +76704,21 @@
76704 */
76705 case OP_VOpen: {
76706 VdbeCursor *pCur;
76707 sqlite3_vtab_cursor *pVtabCursor;
76708 sqlite3_vtab *pVtab;
76709 const sqlite3_module *pModule;
76710
76711 assert( p->bIsReader );
76712 pCur = 0;
76713 pVtabCursor = 0;
76714 pVtab = pOp->p4.pVtab->pVtab;
76715 if( pVtab==0 || NEVER(pVtab->pModule==0) ){
76716 rc = SQLITE_LOCKED;
76717 break;
76718 }
76719 pModule = pVtab->pModule;
76720 rc = pModule->xOpen(pVtab, &pVtabCursor);
76721 sqlite3VtabImportErrmsg(p, pVtab);
76722 if( SQLITE_OK==rc ){
76723 /* Initialize sqlite3_vtab_cursor base class */
76724 pVtabCursor->pVtab = pVtab;
@@ -76391,10 +76725,11 @@
76725
76726 /* Initialize vdbe cursor object */
76727 pCur = allocateCursor(p, pOp->p1, 0, -1, 0);
76728 if( pCur ){
76729 pCur->pVtabCursor = pVtabCursor;
76730 pVtab->nRef++;
76731 }else{
76732 db->mallocFailed = 1;
76733 pModule->xClose(pVtabCursor);
76734 }
76735 }
@@ -76456,13 +76791,11 @@
76791 apArg = p->apArg;
76792 for(i = 0; i<nArg; i++){
76793 apArg[i] = &pArgc[i+1];
76794 }
76795
 
76796 rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg);
 
76797 sqlite3VtabImportErrmsg(p, pVtab);
76798 if( rc==SQLITE_OK ){
76799 res = pModule->xEof(pVtabCursor);
76800 }
76801 VdbeBranchTaken(res!=0,2);
@@ -76548,13 +76881,11 @@
76881 ** underlying implementation to return an error if one occurs during
76882 ** xNext(). Instead, if an error occurs, true is returned (indicating that
76883 ** data is available) and the error code returned when xColumn or
76884 ** some other method is next invoked on the save virtual table cursor.
76885 */
 
76886 rc = pModule->xNext(pCur->pVtabCursor);
 
76887 sqlite3VtabImportErrmsg(p, pVtab);
76888 if( rc==SQLITE_OK ){
76889 res = pModule->xEof(pCur->pVtabCursor);
76890 }
76891 VdbeBranchTaken(!res,2);
@@ -76625,11 +76956,11 @@
76956 ** P5 is the error actions (OE_Replace, OE_Fail, OE_Ignore, etc) to
76957 ** apply in the case of a constraint failure on an insert or update.
76958 */
76959 case OP_VUpdate: {
76960 sqlite3_vtab *pVtab;
76961 const sqlite3_module *pModule;
76962 int nArg;
76963 int i;
76964 sqlite_int64 rowid;
76965 Mem **apArg;
76966 Mem *pX;
@@ -76637,11 +76968,15 @@
76968 assert( pOp->p2==1 || pOp->p5==OE_Fail || pOp->p5==OE_Rollback
76969 || pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace
76970 );
76971 assert( p->readOnly==0 );
76972 pVtab = pOp->p4.pVtab->pVtab;
76973 if( pVtab==0 || NEVER(pVtab->pModule==0) ){
76974 rc = SQLITE_LOCKED;
76975 break;
76976 }
76977 pModule = pVtab->pModule;
76978 nArg = pOp->p2;
76979 assert( pOp->p4type==P4_VTAB );
76980 if( ALWAYS(pModule->xUpdate) ){
76981 u8 vtabOnConflict = db->vtabOnConflict;
76982 apArg = p->apArg;
@@ -76984,11 +77319,11 @@
77319 }
77320
77321 /*
77322 ** Open a blob handle.
77323 */
77324 SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
77325 sqlite3* db, /* The database connection */
77326 const char *zDb, /* The attached database containing the blob */
77327 const char *zTable, /* The table containing the blob */
77328 const char *zColumn, /* The column containing the blob */
77329 sqlite_int64 iRow, /* The row containing the glob */
@@ -77221,11 +77556,11 @@
77556
77557 /*
77558 ** Close a blob handle that was previously created using
77559 ** sqlite3_blob_open().
77560 */
77561 SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *pBlob){
77562 Incrblob *p = (Incrblob *)pBlob;
77563 int rc;
77564 sqlite3 *db;
77565
77566 if( p ){
@@ -77290,28 +77625,28 @@
77625 }
77626
77627 /*
77628 ** Read data from a blob handle.
77629 */
77630 SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){
77631 return blobReadWrite(pBlob, z, n, iOffset, sqlite3BtreeData);
77632 }
77633
77634 /*
77635 ** Write data to a blob handle.
77636 */
77637 SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){
77638 return blobReadWrite(pBlob, (void *)z, n, iOffset, sqlite3BtreePutData);
77639 }
77640
77641 /*
77642 ** Query a blob handle for the size of the data.
77643 **
77644 ** The Incrblob.nByte field is fixed for the lifetime of the Incrblob
77645 ** so no mutex is required for access.
77646 */
77647 SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *pBlob){
77648 Incrblob *p = (Incrblob *)pBlob;
77649 return (p && p->pStmt) ? p->nByte : 0;
77650 }
77651
77652 /*
@@ -77322,11 +77657,11 @@
77657 ** contain a blob or text value, then an error code is returned and the
77658 ** database handle error code and message set. If this happens, then all
77659 ** subsequent calls to sqlite3_blob_xxx() functions (except blob_close())
77660 ** immediately return SQLITE_ABORT.
77661 */
77662 SQLITE_API int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
77663 int rc;
77664 Incrblob *p = (Incrblob *)pBlob;
77665 sqlite3 *db;
77666
77667 if( p==0 ) return SQLITE_MISUSE_BKPT;
@@ -78507,10 +78842,11 @@
78842 sqlite3 *db, /* Database handle doing sort */
78843 i64 nExtend, /* Attempt to extend file to this size */
78844 sqlite3_file **ppFd
78845 ){
78846 int rc;
78847 if( sqlite3FaultSim(202) ) return SQLITE_IOERR_ACCESS;
78848 rc = sqlite3OsOpenMalloc(db->pVfs, 0, ppFd,
78849 SQLITE_OPEN_TEMP_JOURNAL |
78850 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |
78851 SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE, &rc
78852 );
@@ -82098,14 +82434,15 @@
82434 ** and the pExpr parameter is returned unchanged.
82435 */
82436 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(
82437 Parse *pParse, /* Parsing context */
82438 Expr *pExpr, /* Add the "COLLATE" clause to this expression */
82439 const Token *pCollName, /* Name of collating sequence */
82440 int dequote /* True to dequote pCollName */
82441 ){
82442 if( pCollName->n>0 ){
82443 Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote);
82444 if( pNew ){
82445 pNew->pLeft = pExpr;
82446 pNew->flags |= EP_Collate|EP_Skip;
82447 pExpr = pNew;
82448 }
@@ -82115,11 +82452,11 @@
82452 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse *pParse, Expr *pExpr, const char *zC){
82453 Token s;
82454 assert( zC!=0 );
82455 s.z = zC;
82456 s.n = sqlite3Strlen30(s.z);
82457 return sqlite3ExprAddCollateToken(pParse, pExpr, &s, 0);
82458 }
82459
82460 /*
82461 ** Skip over any TK_COLLATE or TK_AS operators and any unlikely()
82462 ** or likelihood() function at the root of an expression.
@@ -82425,10 +82762,11 @@
82762 **
82763 ** Also propagate all EP_Propagate flags from the Expr.x.pList into
82764 ** Expr.flags.
82765 */
82766 SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){
82767 if( pParse->nErr ) return;
82768 exprSetHeight(p);
82769 sqlite3ExprCheckHeight(pParse, p->nHeight);
82770 }
82771
82772 /*
@@ -87139,11 +87477,14 @@
87477 /* Ensure the default expression is something that sqlite3ValueFromExpr()
87478 ** can handle (i.e. not CURRENT_TIME etc.)
87479 */
87480 if( pDflt ){
87481 sqlite3_value *pVal = 0;
87482 int rc;
87483 rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal);
87484 assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
87485 if( rc!=SQLITE_OK ){
87486 db->mallocFailed = 1;
87487 return;
87488 }
87489 if( !pVal ){
87490 sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default");
@@ -89824,11 +90165,11 @@
90165 ** and attempts to write the column will be ignored.
90166 **
90167 ** Setting the auth function to NULL disables this hook. The default
90168 ** setting of the auth function is NULL.
90169 */
90170 SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
90171 sqlite3 *db,
90172 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
90173 void *pArg
90174 ){
90175 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -93202,10 +93543,11 @@
93543 }
93544 if( pIdx->onError==OE_Default ){
93545 pIdx->onError = pIndex->onError;
93546 }
93547 }
93548 pRet = pIdx;
93549 goto exit_create_index;
93550 }
93551 }
93552 }
93553
@@ -95661,11 +96003,13 @@
96003
96004 /*
96005 ** Return the collating function associated with a function.
96006 */
96007 static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){
96008 VdbeOp *pOp;
96009 assert( context->pVdbe!=0 );
96010 pOp = &context->pVdbe->aOp[context->iOp-1];
96011 assert( pOp->opcode==OP_CollSeq );
96012 assert( pOp->p4type==P4_COLLSEQ );
96013 return pOp->p4.pColl;
96014 }
96015
@@ -96399,11 +96743,11 @@
96743 }
96744
96745 /*
96746 ** The sqlite3_strglob() interface.
96747 */
96748 SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlobPattern, const char *zString){
96749 return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, 0)==0;
96750 }
96751
96752 /*
96753 ** Count the number of times that the LIKE operator (or GLOB which is
@@ -100894,11 +101238,11 @@
101238 ** If the SQL is a query, then for each row in the query result
101239 ** the xCallback() function is called. pArg becomes the first
101240 ** argument to xCallback(). If xCallback=NULL then no callback
101241 ** is invoked, even for queries.
101242 */
101243 SQLITE_API int SQLITE_STDCALL sqlite3_exec(
101244 sqlite3 *db, /* The database on which the SQL executes */
101245 const char *zSql, /* The SQL to be executed */
101246 sqlite3_callback xCallback, /* Invoke this callback routine */
101247 void *pArg, /* First argument to xCallback() */
101248 char **pzErrMsg /* Write error messages here */
@@ -102089,11 +102433,11 @@
102433 db->aExtension = aHandle;
102434
102435 db->aExtension[db->nExtension++] = handle;
102436 return SQLITE_OK;
102437 }
102438 SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
102439 sqlite3 *db, /* Load the extension into this database connection */
102440 const char *zFile, /* Name of the shared library containing extension */
102441 const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
102442 char **pzErrMsg /* Put error message here if not 0 */
102443 ){
@@ -102120,11 +102464,11 @@
102464
102465 /*
102466 ** Enable or disable extension loading. Extension loading is disabled by
102467 ** default so as not to open security holes in older applications.
102468 */
102469 SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff){
102470 sqlite3_mutex_enter(db->mutex);
102471 if( onoff ){
102472 db->flags |= SQLITE_LoadExtension;
102473 }else{
102474 db->flags &= ~SQLITE_LoadExtension;
@@ -102177,11 +102521,11 @@
102521
102522 /*
102523 ** Register a statically linked extension that is automatically
102524 ** loaded by every new database connection.
102525 */
102526 SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xInit)(void)){
102527 int rc = SQLITE_OK;
102528 #ifndef SQLITE_OMIT_AUTOINIT
102529 rc = sqlite3_initialize();
102530 if( rc ){
102531 return rc;
@@ -102222,11 +102566,11 @@
102566 ** routine is a no-op.
102567 **
102568 ** Return 1 if xInit was found on the list and removed. Return 0 if xInit
102569 ** was not on the list.
102570 */
102571 SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xInit)(void)){
102572 #if SQLITE_THREADSAFE
102573 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
102574 #endif
102575 int i;
102576 int n = 0;
@@ -102245,11 +102589,11 @@
102589 }
102590
102591 /*
102592 ** Reset the automatic extension loading mechanism.
102593 */
102594 SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void){
102595 #ifndef SQLITE_OMIT_AUTOINIT
102596 if( sqlite3_initialize()==SQLITE_OK )
102597 #endif
102598 {
102599 #if SQLITE_THREADSAFE
@@ -105525,11 +105869,11 @@
105869 ** and so if a schema change occurs, SQLITE_SCHEMA is returned by
105870 ** sqlite3_step(). In the new version, the original SQL text is retained
105871 ** and the statement is automatically recompiled if an schema change
105872 ** occurs.
105873 */
105874 SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
105875 sqlite3 *db, /* Database handle. */
105876 const char *zSql, /* UTF-8 encoded SQL statement. */
105877 int nBytes, /* Length of zSql in bytes. */
105878 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105879 const char **pzTail /* OUT: End of parsed string */
@@ -105537,11 +105881,11 @@
105881 int rc;
105882 rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,0,ppStmt,pzTail);
105883 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
105884 return rc;
105885 }
105886 SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
105887 sqlite3 *db, /* Database handle. */
105888 const char *zSql, /* UTF-8 encoded SQL statement. */
105889 int nBytes, /* Length of zSql in bytes. */
105890 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105891 const char **pzTail /* OUT: End of parsed string */
@@ -105613,11 +105957,11 @@
105957 ** and so if a schema change occurs, SQLITE_SCHEMA is returned by
105958 ** sqlite3_step(). In the new version, the original SQL text is retained
105959 ** and the statement is automatically recompiled if an schema change
105960 ** occurs.
105961 */
105962 SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
105963 sqlite3 *db, /* Database handle. */
105964 const void *zSql, /* UTF-16 encoded SQL statement. */
105965 int nBytes, /* Length of zSql in bytes. */
105966 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105967 const void **pzTail /* OUT: End of parsed string */
@@ -105625,11 +105969,11 @@
105969 int rc;
105970 rc = sqlite3Prepare16(db,zSql,nBytes,0,ppStmt,pzTail);
105971 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
105972 return rc;
105973 }
105974 SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
105975 sqlite3 *db, /* Database handle. */
105976 const void *zSql, /* UTF-16 encoded SQL statement. */
105977 int nBytes, /* Length of zSql in bytes. */
105978 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105979 const void **pzTail /* OUT: End of parsed string */
@@ -109678,11 +110022,11 @@
110022 sqlite3WalkSelect(pWalker, bMayRecursive ? pSel->pPrior : pSel);
110023
110024 for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior);
110025 pEList = pLeft->pEList;
110026 if( pCte->pCols ){
110027 if( pEList && pEList->nExpr!=pCte->pCols->nExpr ){
110028 sqlite3ErrorMsg(pParse, "table %s has %d values for %d columns",
110029 pCte->zName, pEList->nExpr, pCte->pCols->nExpr
110030 );
110031 pParse->pWith = pSavedWith;
110032 return SQLITE_ERROR;
@@ -111361,11 +111705,11 @@
111705 ** The result that is written to ***pazResult is held in memory obtained
111706 ** from malloc(). But the caller cannot free this memory directly.
111707 ** Instead, the entire table should be passed to sqlite3_free_table() when
111708 ** the calling procedure is finished using it.
111709 */
111710 SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
111711 sqlite3 *db, /* The database on which the SQL executes */
111712 const char *zSql, /* The SQL to be executed */
111713 char ***pazResult, /* Write the result table here */
111714 int *pnRow, /* Write the number of rows in the result here */
111715 int *pnColumn, /* Write the number of columns of result here */
@@ -111430,11 +111774,11 @@
111774 }
111775
111776 /*
111777 ** This routine frees the space the sqlite3_get_table() malloced.
111778 */
111779 SQLITE_API void SQLITE_STDCALL sqlite3_free_table(
111780 char **azResult /* Result returned from sqlite3_get_table() */
111781 ){
111782 if( azResult ){
111783 int i, n;
111784 azResult--;
@@ -113790,11 +114134,11 @@
114134
114135
114136 /*
114137 ** External API function used to create a new virtual-table module.
114138 */
114139 SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
114140 sqlite3 *db, /* Database in which module is registered */
114141 const char *zName, /* Name assigned to this module */
114142 const sqlite3_module *pModule, /* The definition of the module */
114143 void *pAux /* Context pointer for xCreate/xConnect */
114144 ){
@@ -113805,11 +114149,11 @@
114149 }
114150
114151 /*
114152 ** External API function used to create a new virtual-table module.
114153 */
114154 SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
114155 sqlite3 *db, /* Database in which module is registered */
114156 const char *zName, /* Name assigned to this module */
114157 const sqlite3_module *pModule, /* The definition of the module */
114158 void *pAux, /* Context pointer for xCreate/xConnect */
114159 void (*xDestroy)(void *) /* Module destructor function */
@@ -114104,10 +114448,11 @@
114448 */
114449 if( !db->init.busy ){
114450 char *zStmt;
114451 char *zWhere;
114452 int iDb;
114453 int iReg;
114454 Vdbe *v;
114455
114456 /* Compute the complete text of the CREATE VIRTUAL TABLE statement */
114457 if( pEnd ){
114458 pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n;
@@ -114138,12 +114483,14 @@
114483 sqlite3ChangeCookie(pParse, iDb);
114484
114485 sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
114486 zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
114487 sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
114488
114489 iReg = ++pParse->nMem;
114490 sqlite3VdbeAddOp4(v, OP_String8, 0, iReg, 0, pTab->zName, 0);
114491 sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg);
114492 }
114493
114494 /* If we are rereading the sqlite_master table create the in-memory
114495 ** record of the table. The xConnect() method is not called until
114496 ** the first time the virtual table is used in an SQL statement. This
@@ -114417,11 +114764,11 @@
114764 /*
114765 ** This function is used to set the schema of a virtual table. It is only
114766 ** valid to call this function from within the xCreate() or xConnect() of a
114767 ** virtual table module.
114768 */
114769 SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
114770 Parse *pParse;
114771
114772 int rc = SQLITE_OK;
114773 Table *pTab;
114774 char *zErr = 0;
@@ -114492,15 +114839,19 @@
114839 int rc = SQLITE_OK;
114840 Table *pTab;
114841
114842 pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
114843 if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){
114844 VTable *p;
114845 for(p=pTab->pVTable; p; p=p->pNext){
114846 assert( p->pVtab );
114847 if( p->pVtab->nRef>0 ){
114848 return SQLITE_LOCKED;
114849 }
114850 }
114851 p = vtabDisconnectAll(db, pTab);
114852 rc = p->pMod->pModule->xDestroy(p->pVtab);
 
114853 /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */
114854 if( rc==SQLITE_OK ){
114855 assert( pTab->pVTable==p && p->pNext==0 );
114856 p->pVtab = 0;
114857 pTab->pVTable = 0;
@@ -114781,11 +115132,11 @@
115132 ** table update operation currently in progress.
115133 **
115134 ** The results of this routine are undefined unless it is called from
115135 ** within an xUpdate method.
115136 */
115137 SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *db){
115138 static const unsigned char aMap[] = {
115139 SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE
115140 };
115141 #ifdef SQLITE_ENABLE_API_ARMOR
115142 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -114799,11 +115150,11 @@
115150 /*
115151 ** Call from within the xCreate() or xConnect() methods to provide
115152 ** the SQLite core with additional information about the behavior
115153 ** of the virtual table being implemented.
115154 */
115155 SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3 *db, int op, ...){
115156 va_list ap;
115157 int rc = SQLITE_OK;
115158
115159 #ifdef SQLITE_ENABLE_API_ARMOR
115160 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -116078,10 +116429,83 @@
116429 static void markTermAsChild(WhereClause *pWC, int iChild, int iParent){
116430 pWC->a[iChild].iParent = iParent;
116431 pWC->a[iChild].truthProb = pWC->a[iParent].truthProb;
116432 pWC->a[iParent].nChild++;
116433 }
116434
116435 /*
116436 ** Return the N-th AND-connected subterm of pTerm. Or if pTerm is not
116437 ** a conjunction, then return just pTerm when N==0. If N is exceeds
116438 ** the number of available subterms, return NULL.
116439 */
116440 static WhereTerm *whereNthSubterm(WhereTerm *pTerm, int N){
116441 if( pTerm->eOperator!=WO_AND ){
116442 return N==0 ? pTerm : 0;
116443 }
116444 if( N<pTerm->u.pAndInfo->wc.nTerm ){
116445 return &pTerm->u.pAndInfo->wc.a[N];
116446 }
116447 return 0;
116448 }
116449
116450 /*
116451 ** Subterms pOne and pTwo are contained within WHERE clause pWC. The
116452 ** two subterms are in disjunction - they are OR-ed together.
116453 **
116454 ** If these two terms are both of the form: "A op B" with the same
116455 ** A and B values but different operators and if the operators are
116456 ** compatible (if one is = and the other is <, for example) then
116457 ** add a new virtual AND term to pWC that is the combination of the
116458 ** two.
116459 **
116460 ** Some examples:
116461 **
116462 ** x<y OR x=y --> x<=y
116463 ** x=y OR x=y --> x=y
116464 ** x<=y OR x<y --> x<=y
116465 **
116466 ** The following is NOT generated:
116467 **
116468 ** x<y OR x>y --> x!=y
116469 */
116470 static void whereCombineDisjuncts(
116471 SrcList *pSrc, /* the FROM clause */
116472 WhereClause *pWC, /* The complete WHERE clause */
116473 WhereTerm *pOne, /* First disjunct */
116474 WhereTerm *pTwo /* Second disjunct */
116475 ){
116476 u16 eOp = pOne->eOperator | pTwo->eOperator;
116477 sqlite3 *db; /* Database connection (for malloc) */
116478 Expr *pNew; /* New virtual expression */
116479 int op; /* Operator for the combined expression */
116480 int idxNew; /* Index in pWC of the next virtual term */
116481
116482 if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
116483 if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
116484 if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
116485 && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;
116486 assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );
116487 assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );
116488 if( sqlite3ExprCompare(pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;
116489 if( sqlite3ExprCompare(pOne->pExpr->pRight, pTwo->pExpr->pRight, -1) )return;
116490 /* If we reach this point, it means the two subterms can be combined */
116491 if( (eOp & (eOp-1))!=0 ){
116492 if( eOp & (WO_LT|WO_LE) ){
116493 eOp = WO_LE;
116494 }else{
116495 assert( eOp & (WO_GT|WO_GE) );
116496 eOp = WO_GE;
116497 }
116498 }
116499 db = pWC->pWInfo->pParse->db;
116500 pNew = sqlite3ExprDup(db, pOne->pExpr, 0);
116501 if( pNew==0 ) return;
116502 for(op=TK_EQ; eOp!=(WO_EQ<<(op-TK_EQ)); op++){ assert( op<TK_GE ); }
116503 pNew->op = op;
116504 idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);
116505 exprAnalyze(pSrc, pWC, idxNew);
116506 }
116507
116508 #if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)
116509 /*
116510 ** Analyze a term that consists of two or more OR-connected
116511 ** subterms. So in:
@@ -116103,10 +116527,11 @@
116527 ** (A) t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5
116528 ** (B) x=expr1 OR expr2=x OR x=expr3
116529 ** (C) t1.x=t2.y OR (t1.x=t2.z AND t1.y=15)
116530 ** (D) x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*')
116531 ** (E) (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6)
116532 ** (F) x>A OR (x=A AND y>=B)
116533 **
116534 ** CASE 1:
116535 **
116536 ** If all subterms are of the form T.C=expr for some single column of C and
116537 ** a single table T (as shown in example B above) then create a new virtual
@@ -116118,10 +116543,20 @@
116543 ** then create a new virtual term like this:
116544 **
116545 ** x IN (expr1,expr2,expr3)
116546 **
116547 ** CASE 2:
116548 **
116549 ** If there are exactly two disjuncts one side has x>A and the other side
116550 ** has x=A (for the same x and A) then add a new virtual conjunct term to the
116551 ** WHERE clause of the form "x>=A". Example:
116552 **
116553 ** x>A OR (x=A AND y>B) adds: x>=A
116554 **
116555 ** The added conjunct can sometimes be helpful in query planning.
116556 **
116557 ** CASE 3:
116558 **
116559 ** If all subterms are indexable by a single table T, then set
116560 **
116561 ** WhereTerm.eOperator = WO_OR
116562 ** WhereTerm.u.pOrInfo->indexable |= the cursor number for table T
@@ -116245,15 +116680,29 @@
116680 }
116681 }
116682 }
116683
116684 /*
116685 ** Record the set of tables that satisfy case 3. The set might be
116686 ** empty.
116687 */
116688 pOrInfo->indexable = indexable;
116689 pTerm->eOperator = indexable==0 ? 0 : WO_OR;
116690
116691 /* For a two-way OR, attempt to implementation case 2.
116692 */
116693 if( indexable && pOrWc->nTerm==2 ){
116694 int iOne = 0;
116695 WhereTerm *pOne;
116696 while( (pOne = whereNthSubterm(&pOrWc->a[0],iOne++))!=0 ){
116697 int iTwo = 0;
116698 WhereTerm *pTwo;
116699 while( (pTwo = whereNthSubterm(&pOrWc->a[1],iTwo++))!=0 ){
116700 whereCombineDisjuncts(pSrc, pWC, pOne, pTwo);
116701 }
116702 }
116703 }
116704
116705 /*
116706 ** chngToIN holds a set of tables that *might* satisfy case 1. But
116707 ** we have to do some additional checking to see if case 1 really
116708 ** is satisfied.
@@ -116380,11 +116829,11 @@
116829 pTerm = &pWC->a[idxTerm];
116830 markTermAsChild(pWC, idxNew, idxTerm);
116831 }else{
116832 sqlite3ExprListDelete(db, pList);
116833 }
116834 pTerm->eOperator = WO_NOOP; /* case 1 trumps case 3 */
116835 }
116836 }
116837 }
116838 #endif /* !SQLITE_OMIT_OR_OPTIMIZATION && !SQLITE_OMIT_SUBQUERY */
116839
@@ -116575,11 +117024,11 @@
117024 Expr *pStr2; /* Copy of pStr1 - RHS of LIKE/GLOB operator */
117025 Expr *pNewExpr1;
117026 Expr *pNewExpr2;
117027 int idxNew1;
117028 int idxNew2;
117029 const char *zCollSeqName; /* Name of collating sequence */
117030 const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC;
117031
117032 pLeft = pExpr->x.pList->a[1].pExpr;
117033 pStr2 = sqlite3ExprDup(db, pStr1, 0);
117034
@@ -116611,23 +117060,22 @@
117060 if( c=='A'-1 ) isComplete = 0;
117061 c = sqlite3UpperToLower[c];
117062 }
117063 *pC = c + 1;
117064 }
117065 zCollSeqName = noCase ? "NOCASE" : "BINARY";
 
117066 pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);
117067 pNewExpr1 = sqlite3PExpr(pParse, TK_GE,
117068 sqlite3ExprAddCollateString(pParse,pNewExpr1,zCollSeqName),
117069 pStr1, 0);
117070 transferJoinMarkings(pNewExpr1, pExpr);
117071 idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags);
117072 testcase( idxNew1==0 );
117073 exprAnalyze(pSrc, pWC, idxNew1);
117074 pNewExpr2 = sqlite3ExprDup(db, pLeft, 0);
117075 pNewExpr2 = sqlite3PExpr(pParse, TK_LT,
117076 sqlite3ExprAddCollateString(pParse,pNewExpr2,zCollSeqName),
117077 pStr2, 0);
117078 transferJoinMarkings(pNewExpr2, pExpr);
117079 idxNew2 = whereClauseInsert(pWC, pNewExpr2, wtFlags);
117080 testcase( idxNew2==0 );
117081 exprAnalyze(pSrc, pWC, idxNew2);
@@ -117240,15 +117688,18 @@
117688 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
117689 /*
117690 ** Estimate the location of a particular key among all keys in an
117691 ** index. Store the results in aStat as follows:
117692 **
117693 ** aStat[0] Est. number of rows less than pRec
117694 ** aStat[1] Est. number of rows equal to pRec
117695 **
117696 ** Return the index of the sample that is the smallest sample that
117697 ** is greater than or equal to pRec. Note that this index is not an index
117698 ** into the aSample[] array - it is an index into a virtual set of samples
117699 ** based on the contents of aSample[] and the number of fields in record
117700 ** pRec.
117701 */
117702 static int whereKeyStats(
117703 Parse *pParse, /* Database connection */
117704 Index *pIdx, /* Index to consider domain of */
117705 UnpackedRecord *pRec, /* Vector of values to consider */
@@ -117255,71 +117706,162 @@
117706 int roundUp, /* Round up if true. Round down if false */
117707 tRowcnt *aStat /* OUT: stats written here */
117708 ){
117709 IndexSample *aSample = pIdx->aSample;
117710 int iCol; /* Index of required stats in anEq[] etc. */
117711 int i; /* Index of first sample >= pRec */
117712 int iSample; /* Smallest sample larger than or equal to pRec */
117713 int iMin = 0; /* Smallest sample not yet tested */
 
117714 int iTest; /* Next sample to test */
117715 int res; /* Result of comparison operation */
117716 int nField; /* Number of fields in pRec */
117717 tRowcnt iLower = 0; /* anLt[] + anEq[] of largest sample pRec is > */
117718
117719 #ifndef SQLITE_DEBUG
117720 UNUSED_PARAMETER( pParse );
117721 #endif
117722 assert( pRec!=0 );
 
117723 assert( pIdx->nSample>0 );
117724 assert( pRec->nField>0 && pRec->nField<=pIdx->nSampleCol );
117725
117726 /* Do a binary search to find the first sample greater than or equal
117727 ** to pRec. If pRec contains a single field, the set of samples to search
117728 ** is simply the aSample[] array. If the samples in aSample[] contain more
117729 ** than one fields, all fields following the first are ignored.
117730 **
117731 ** If pRec contains N fields, where N is more than one, then as well as the
117732 ** samples in aSample[] (truncated to N fields), the search also has to
117733 ** consider prefixes of those samples. For example, if the set of samples
117734 ** in aSample is:
117735 **
117736 ** aSample[0] = (a, 5)
117737 ** aSample[1] = (a, 10)
117738 ** aSample[2] = (b, 5)
117739 ** aSample[3] = (c, 100)
117740 ** aSample[4] = (c, 105)
117741 **
117742 ** Then the search space should ideally be the samples above and the
117743 ** unique prefixes [a], [b] and [c]. But since that is hard to organize,
117744 ** the code actually searches this set:
117745 **
117746 ** 0: (a)
117747 ** 1: (a, 5)
117748 ** 2: (a, 10)
117749 ** 3: (a, 10)
117750 ** 4: (b)
117751 ** 5: (b, 5)
117752 ** 6: (c)
117753 ** 7: (c, 100)
117754 ** 8: (c, 105)
117755 ** 9: (c, 105)
117756 **
117757 ** For each sample in the aSample[] array, N samples are present in the
117758 ** effective sample array. In the above, samples 0 and 1 are based on
117759 ** sample aSample[0]. Samples 2 and 3 on aSample[1] etc.
117760 **
117761 ** Often, sample i of each block of N effective samples has (i+1) fields.
117762 ** Except, each sample may be extended to ensure that it is greater than or
117763 ** equal to the previous sample in the array. For example, in the above,
117764 ** sample 2 is the first sample of a block of N samples, so at first it
117765 ** appears that it should be 1 field in size. However, that would make it
117766 ** smaller than sample 1, so the binary search would not work. As a result,
117767 ** it is extended to two fields. The duplicates that this creates do not
117768 ** cause any problems.
117769 */
117770 nField = pRec->nField;
117771 iCol = 0;
117772 iSample = pIdx->nSample * nField;
117773 do{
117774 int iSamp; /* Index in aSample[] of test sample */
117775 int n; /* Number of fields in test sample */
117776
117777 iTest = (iMin+iSample)/2;
117778 iSamp = iTest / nField;
117779 if( iSamp>0 ){
117780 /* The proposed effective sample is a prefix of sample aSample[iSamp].
117781 ** Specifically, the shortest prefix of at least (1 + iTest%nField)
117782 ** fields that is greater than the previous effective sample. */
117783 for(n=(iTest % nField) + 1; n<nField; n++){
117784 if( aSample[iSamp-1].anLt[n-1]!=aSample[iSamp].anLt[n-1] ) break;
117785 }
117786 }else{
117787 n = iTest + 1;
117788 }
117789
117790 pRec->nField = n;
117791 res = sqlite3VdbeRecordCompare(aSample[iSamp].n, aSample[iSamp].p, pRec);
117792 if( res<0 ){
117793 iLower = aSample[iSamp].anLt[n-1] + aSample[iSamp].anEq[n-1];
117794 iMin = iTest+1;
117795 }else if( res==0 && n<nField ){
117796 iLower = aSample[iSamp].anLt[n-1];
117797 iMin = iTest+1;
117798 res = -1;
117799 }else{
117800 iSample = iTest;
117801 iCol = n-1;
117802 }
117803 }while( res && iMin<iSample );
117804 i = iSample / nField;
117805
117806 #ifdef SQLITE_DEBUG
117807 /* The following assert statements check that the binary search code
117808 ** above found the right answer. This block serves no purpose other
117809 ** than to invoke the asserts. */
117810 if( pParse->db->mallocFailed==0 ){
117811 if( res==0 ){
117812 /* If (res==0) is true, then pRec must be equal to sample i. */
117813 assert( i<pIdx->nSample );
117814 assert( iCol==nField-1 );
117815 pRec->nField = nField;
117816 assert( 0==sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)
117817 || pParse->db->mallocFailed
117818 );
117819 }else{
117820 /* Unless i==pIdx->nSample, indicating that pRec is larger than
117821 ** all samples in the aSample[] array, pRec must be smaller than the
117822 ** (iCol+1) field prefix of sample i. */
117823 assert( i<=pIdx->nSample && i>=0 );
117824 pRec->nField = iCol+1;
117825 assert( i==pIdx->nSample
117826 || sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)>0
117827 || pParse->db->mallocFailed );
117828
117829 /* if i==0 and iCol==0, then record pRec is smaller than all samples
117830 ** in the aSample[] array. Otherwise, if (iCol>0) then pRec must
117831 ** be greater than or equal to the (iCol) field prefix of sample i.
117832 ** If (i>0), then pRec must also be greater than sample (i-1). */
117833 if( iCol>0 ){
117834 pRec->nField = iCol;
117835 assert( sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)<=0
117836 || pParse->db->mallocFailed );
117837 }
117838 if( i>0 ){
117839 pRec->nField = nField;
117840 assert( sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0
117841 || pParse->db->mallocFailed );
117842 }
117843 }
117844 }
117845 #endif /* ifdef SQLITE_DEBUG */
117846
 
 
 
 
117847 if( res==0 ){
117848 /* Record pRec is equal to sample i */
117849 assert( iCol==nField-1 );
117850 aStat[0] = aSample[i].anLt[iCol];
117851 aStat[1] = aSample[i].anEq[iCol];
117852 }else{
117853 /* At this point, the (iCol+1) field prefix of aSample[i] is the first
117854 ** sample that is greater than pRec. Or, if i==pIdx->nSample then pRec
117855 ** is larger than all samples in the array. */
117856 tRowcnt iUpper, iGap;
117857 if( i>=pIdx->nSample ){
117858 iUpper = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]);
117859 }else{
117860 iUpper = aSample[i].anLt[iCol];
 
 
117861 }
117862
117863 if( iLower>=iUpper ){
117864 iGap = 0;
117865 }else{
117866 iGap = iUpper - iLower;
117867 }
@@ -117327,11 +117869,15 @@
117869 iGap = (iGap*2)/3;
117870 }else{
117871 iGap = iGap/3;
117872 }
117873 aStat[0] = iLower + iGap;
117874 aStat[1] = pIdx->aAvgEq[iCol];
117875 }
117876
117877 /* Restore the pRec->nField value before returning. */
117878 pRec->nField = nField;
117879 return i;
117880 }
117881 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
117882
117883 /*
@@ -118322,25 +118868,33 @@
118868 #else
118869 # define addScanStatus(a, b, c, d) ((void)d)
118870 #endif
118871
118872 /*
118873 ** If the most recently coded instruction is a constant range contraint
118874 ** that originated from the LIKE optimization, then change the P3 to be
118875 ** pLoop->iLikeRepCntr and set P5.
118876 **
118877 ** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range
118878 ** expression: "x>='ABC' AND x<'abd'". But this requires that the range
118879 ** scan loop run twice, once for strings and a second time for BLOBs.
118880 ** The OP_String opcodes on the second pass convert the upper and lower
118881 ** bound string contants to blobs. This routine makes the necessary changes
118882 ** to the OP_String opcodes for that to happen.
118883 */
118884 static void whereLikeOptimizationStringFixup(
118885 Vdbe *v, /* prepared statement under construction */
118886 WhereLevel *pLevel, /* The loop that contains the LIKE operator */
118887 WhereTerm *pTerm /* The upper or lower bound just coded */
118888 ){
118889 if( pTerm->wtFlags & TERM_LIKEOPT ){
118890 VdbeOp *pOp;
118891 assert( pLevel->iLikeRepCntr>0 );
118892 pOp = sqlite3VdbeGetOp(v, -1);
118893 assert( pOp!=0 );
118894 assert( pOp->opcode==OP_String8
118895 || pTerm->pWC->pWInfo->pParse->db->mallocFailed );
118896 pOp->p3 = pLevel->iLikeRepCntr;
118897 pOp->p5 = 1;
118898 }
118899 }
118900
@@ -118670,18 +119224,20 @@
119224 */
119225 j = nEq;
119226 if( pLoop->wsFlags & WHERE_BTM_LIMIT ){
119227 pRangeStart = pLoop->aLTerm[j++];
119228 nExtraReg = 1;
119229 /* Like optimization range constraints always occur in pairs */
119230 assert( (pRangeStart->wtFlags & TERM_LIKEOPT)==0 ||
119231 (pLoop->wsFlags & WHERE_TOP_LIMIT)!=0 );
119232 }
119233 if( pLoop->wsFlags & WHERE_TOP_LIMIT ){
119234 pRangeEnd = pLoop->aLTerm[j++];
119235 nExtraReg = 1;
119236 if( (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 ){
119237 assert( pRangeStart!=0 ); /* LIKE opt constraints */
119238 assert( pRangeStart->wtFlags & TERM_LIKEOPT ); /* occur in pairs */
 
119239 pLevel->iLikeRepCntr = ++pParse->nMem;
119240 testcase( bRev );
119241 testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC );
119242 sqlite3VdbeAddOp2(v, OP_Integer,
119243 bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC),
@@ -118729,11 +119285,11 @@
119285 /* Seek the index cursor to the start of the range. */
119286 nConstraint = nEq;
119287 if( pRangeStart ){
119288 Expr *pRight = pRangeStart->pExpr->pRight;
119289 sqlite3ExprCode(pParse, pRight, regBase+nEq);
119290 whereLikeOptimizationStringFixup(v, pLevel, pRangeStart);
119291 if( (pRangeStart->wtFlags & TERM_VNULL)==0
119292 && sqlite3ExprCanBeNull(pRight)
119293 ){
119294 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
119295 VdbeCoverage(v);
@@ -118775,11 +119331,11 @@
119331 nConstraint = nEq;
119332 if( pRangeEnd ){
119333 Expr *pRight = pRangeEnd->pExpr->pRight;
119334 sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
119335 sqlite3ExprCode(pParse, pRight, regBase+nEq);
119336 whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);
119337 if( (pRangeEnd->wtFlags & TERM_VNULL)==0
119338 && sqlite3ExprCanBeNull(pRight)
119339 ){
119340 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
119341 VdbeCoverage(v);
@@ -119852,10 +120408,14 @@
120408 ){
120409 continue; /* ignore IS [NOT] NULL constraints on NOT NULL columns */
120410 }
120411 if( pTerm->prereqRight & pNew->maskSelf ) continue;
120412
120413 /* Do not allow the upper bound of a LIKE optimization range constraint
120414 ** to mix with a lower range bound from some other source */
120415 if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;
120416
120417 pNew->wsFlags = saved_wsFlags;
120418 pNew->u.btree.nEq = saved_nEq;
120419 pNew->nLTerm = saved_nLTerm;
120420 if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
120421 pNew->aLTerm[pNew->nLTerm++] = pTerm;
@@ -119895,10 +120455,21 @@
120455 testcase( eOp & WO_GT );
120456 testcase( eOp & WO_GE );
120457 pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT;
120458 pBtm = pTerm;
120459 pTop = 0;
120460 if( pTerm->wtFlags & TERM_LIKEOPT ){
120461 /* Range contraints that come from the LIKE optimization are
120462 ** always used in pairs. */
120463 pTop = &pTerm[1];
120464 assert( (pTop-(pTerm->pWC->a))<pTerm->pWC->nTerm );
120465 assert( pTop->wtFlags & TERM_LIKEOPT );
120466 assert( pTop->eOperator==WO_LT );
120467 if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
120468 pNew->aLTerm[pNew->nLTerm++] = pTop;
120469 pNew->wsFlags |= WHERE_TOP_LIMIT;
120470 }
120471 }else{
120472 assert( eOp & (WO_LT|WO_LE) );
120473 testcase( eOp & WO_LT );
120474 testcase( eOp & WO_LE );
120475 pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_TOP_LIMIT;
@@ -121089,14 +121660,14 @@
121660 assert( aSortCost==0 || &pSpace[nSpace]==(char*)&aSortCost[nOrderBy] );
121661 assert( aSortCost!=0 || &pSpace[nSpace]==(char*)pX );
121662
121663 /* Seed the search with a single WherePath containing zero WhereLoops.
121664 **
121665 ** TUNING: Do not let the number of iterations go above 28. If the cost
121666 ** of computing an automatic index is not paid back within the first 28
121667 ** rows, then do not use the automatic index. */
121668 aFrom[0].nRow = MIN(pParse->nQueryLoop, 48); assert( 48==sqlite3LogEst(28) );
121669 nFrom = 1;
121670 assert( aFrom[0].isOrdered==0 );
121671 if( nOrderBy ){
121672 /* If nLoop is zero, then there are no FROM terms in the query. Since
121673 ** in this case the query may return a maximum of one row, the results
@@ -121890,10 +122461,16 @@
122461 assert( pIx->pSchema==pTab->pSchema );
122462 assert( iIndexCur>=0 );
122463 if( op ){
122464 sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb);
122465 sqlite3VdbeSetP4KeyInfo(pParse, pIx);
122466 if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0
122467 && (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0
122468 && (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0
122469 ){
122470 sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ); /* Hint to COMDB2 */
122471 }
122472 VdbeComment((v, "%s", pIx->zName));
122473 }
122474 }
122475 if( iDb>=0 ) sqlite3CodeVerifySchema(pParse, iDb);
122476 notReady &= ~getMask(&pWInfo->sMaskSet, pTabItem->iCursor);
@@ -124891,11 +125468,11 @@
125468 spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
125469 }
125470 break;
125471 case 193: /* expr ::= expr COLLATE ID|STRING */
125472 {
125473 yygotominor.yy346.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0, 1);
125474 yygotominor.yy346.zStart = yymsp[-2].minor.yy346.zStart;
125475 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
125476 }
125477 break;
125478 case 194: /* expr ::= CAST LP expr AS typetoken RP */
@@ -125171,20 +125748,20 @@
125748 case 241: /* uniqueflag ::= */
125749 {yygotominor.yy328 = OE_None;}
125750 break;
125751 case 244: /* idxlist ::= idxlist COMMA nm collate sortorder */
125752 {
125753 Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0, 1);
125754 yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, p);
125755 sqlite3ExprListSetName(pParse,yygotominor.yy14,&yymsp[-2].minor.yy0,1);
125756 sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
125757 if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
125758 }
125759 break;
125760 case 245: /* idxlist ::= nm collate sortorder */
125761 {
125762 Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0, 1);
125763 yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, p);
125764 sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
125765 sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
125766 if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
125767 }
@@ -126439,13 +127016,15 @@
127016 pParse->zTail = &zSql[i];
127017 }
127018 sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);
127019 }
127020 #ifdef YYTRACKMAXSTACKDEPTH
127021 sqlite3_mutex_enter(sqlite3MallocMutex());
127022 sqlite3StatusSet(SQLITE_STATUS_PARSER_STACK,
127023 sqlite3ParserStackPeak(pEngine)
127024 );
127025 sqlite3_mutex_leave(sqlite3MallocMutex());
127026 #endif /* YYDEBUG */
127027 sqlite3ParserFree(pEngine, sqlite3_free);
127028 db->lookaside.bEnabled = enableLookaside;
127029 if( db->mallocFailed ){
127030 pParse->rc = SQLITE_NOMEM;
@@ -126605,11 +127184,11 @@
127184 **
127185 ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
127186 ** to recognize the end of a trigger can be omitted. All we have to do
127187 ** is look for a semicolon that is not part of an string or comment.
127188 */
127189 SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *zSql){
127190 u8 state = 0; /* Current state, using numbers defined in header comment */
127191 u8 token; /* Value of the next token */
127192
127193 #ifndef SQLITE_OMIT_TRIGGER
127194 /* A complex statement machine used to detect the end of a CREATE TRIGGER
@@ -126770,11 +127349,11 @@
127349 /*
127350 ** This routine is the same as the sqlite3_complete() routine described
127351 ** above, except that the parameter is required to be UTF-16 encoded, not
127352 ** UTF-8.
127353 */
127354 SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *zSql){
127355 sqlite3_value *pVal;
127356 char const *zSql8;
127357 int rc = SQLITE_NOMEM;
127358
127359 #ifndef SQLITE_OMIT_AUTOINIT
@@ -126920,37 +127499,37 @@
127499 #endif
127500
127501 /* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns
127502 ** a pointer to the to the sqlite3_version[] string constant.
127503 */
127504 SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void){ return sqlite3_version; }
127505
127506 /* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a
127507 ** pointer to a string constant whose value is the same as the
127508 ** SQLITE_SOURCE_ID C preprocessor macro.
127509 */
127510 SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
127511
127512 /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function
127513 ** returns an integer equal to SQLITE_VERSION_NUMBER.
127514 */
127515 SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
127516
127517 /* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns
127518 ** zero if and only if SQLite was compiled with mutexing code omitted due to
127519 ** the SQLITE_THREADSAFE compile-time option being set to 0.
127520 */
127521 SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
127522
127523 #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
127524 /*
127525 ** If the following function pointer is not NULL and if
127526 ** SQLITE_ENABLE_IOTRACE is enabled, then messages describing
127527 ** I/O active are written using this function. These messages
127528 ** are intended for debugging activity only.
127529 */
127530 SQLITE_API void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...) = 0;
127531 #endif
127532
127533 /*
127534 ** If the following global variable points to a string which is the
127535 ** name of a directory, then that directory will be used to store
@@ -126998,11 +127577,11 @@
127577 ** call by X completes.
127578 **
127579 ** * Recursive calls to this routine from thread X return immediately
127580 ** without blocking.
127581 */
127582 SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void){
127583 MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
127584 int rc; /* Result code */
127585 #ifdef SQLITE_EXTRA_INIT
127586 int bRunExtraInit = 0; /* Extra initialization needed */
127587 #endif
@@ -127011,10 +127590,15 @@
127590 rc = sqlite3_wsd_init(4096, 24);
127591 if( rc!=SQLITE_OK ){
127592 return rc;
127593 }
127594 #endif
127595
127596 /* If the following assert() fails on some obscure processor/compiler
127597 ** combination, the work-around is to set the correct pointer
127598 ** size at compile-time using -DSQLITE_PTRSIZE=n compile-time option */
127599 assert( SQLITE_PTRSIZE==sizeof(char*) );
127600
127601 /* If SQLite is already completely initialized, then this call
127602 ** to sqlite3_initialize() should be a no-op. But the initialization
127603 ** must be complete. So isInit must not be set until the very end
127604 ** of this routine.
@@ -127154,11 +127738,11 @@
127738 ** while any part of SQLite is otherwise in use in any thread. This
127739 ** routine is not threadsafe. But it is safe to invoke this routine
127740 ** on when SQLite is already shut down. If SQLite is already shut down
127741 ** when this routine is invoked, then this routine is a harmless no-op.
127742 */
127743 SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void){
127744 #ifdef SQLITE_OMIT_WSD
127745 int rc = sqlite3_wsd_init(4096, 24);
127746 if( rc!=SQLITE_OK ){
127747 return rc;
127748 }
@@ -127208,11 +127792,11 @@
127792 ** This routine should only be called when there are no outstanding
127793 ** database connections or memory allocations. This routine is not
127794 ** threadsafe. Failure to heed these warnings can lead to unpredictable
127795 ** behavior.
127796 */
127797 SQLITE_API int SQLITE_CDECL sqlite3_config(int op, ...){
127798 va_list ap;
127799 int rc = SQLITE_OK;
127800
127801 /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while
127802 ** the SQLite library is in use. */
@@ -127565,11 +128149,11 @@
128149 }
128150
128151 /*
128152 ** Return the mutex associated with a database connection.
128153 */
128154 SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3 *db){
128155 #ifdef SQLITE_ENABLE_API_ARMOR
128156 if( !sqlite3SafetyCheckOk(db) ){
128157 (void)SQLITE_MISUSE_BKPT;
128158 return 0;
128159 }
@@ -127579,11 +128163,11 @@
128163
128164 /*
128165 ** Free up as much memory as we can from the given database
128166 ** connection.
128167 */
128168 SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3 *db){
128169 int i;
128170
128171 #ifdef SQLITE_ENABLE_API_ARMOR
128172 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
128173 #endif
@@ -127602,11 +128186,11 @@
128186 }
128187
128188 /*
128189 ** Configuration settings for an individual database connection
128190 */
128191 SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3 *db, int op, ...){
128192 va_list ap;
128193 int rc;
128194 va_start(ap, op);
128195 switch( op ){
128196 case SQLITE_DBCONFIG_LOOKASIDE: {
@@ -127721,11 +128305,11 @@
128305 }
128306
128307 /*
128308 ** Return the ROWID of the most recent insert
128309 */
128310 SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3 *db){
128311 #ifdef SQLITE_ENABLE_API_ARMOR
128312 if( !sqlite3SafetyCheckOk(db) ){
128313 (void)SQLITE_MISUSE_BKPT;
128314 return 0;
128315 }
@@ -127734,11 +128318,11 @@
128318 }
128319
128320 /*
128321 ** Return the number of changes in the most recent call to sqlite3_exec().
128322 */
128323 SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3 *db){
128324 #ifdef SQLITE_ENABLE_API_ARMOR
128325 if( !sqlite3SafetyCheckOk(db) ){
128326 (void)SQLITE_MISUSE_BKPT;
128327 return 0;
128328 }
@@ -127747,11 +128331,11 @@
128331 }
128332
128333 /*
128334 ** Return the number of changes since the database handle was opened.
128335 */
128336 SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3 *db){
128337 #ifdef SQLITE_ENABLE_API_ARMOR
128338 if( !sqlite3SafetyCheckOk(db) ){
128339 (void)SQLITE_MISUSE_BKPT;
128340 return 0;
128341 }
@@ -127889,12 +128473,12 @@
128473 ** statements or unfinished sqlite3_backups. The sqlite3_close_v2()
128474 ** version forces the connection to become a zombie if there are
128475 ** unclosed resources, and arranges for deallocation when the last
128476 ** prepare statement or sqlite3_backup closes.
128477 */
128478 SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); }
128479 SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); }
128480
128481
128482 /*
128483 ** Close the mutex on database connection db.
128484 **
@@ -128297,11 +128881,11 @@
128881
128882 /*
128883 ** This routine sets the busy callback for an Sqlite database to the
128884 ** given callback function with the given argument.
128885 */
128886 SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(
128887 sqlite3 *db,
128888 int (*xBusy)(void*,int),
128889 void *pArg
128890 ){
128891 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -128320,11 +128904,11 @@
128904 /*
128905 ** This routine sets the progress callback for an Sqlite database to the
128906 ** given callback function with the given argument. The progress callback will
128907 ** be invoked every nOps opcodes.
128908 */
128909 SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(
128910 sqlite3 *db,
128911 int nOps,
128912 int (*xProgress)(void*),
128913 void *pArg
128914 ){
@@ -128351,11 +128935,11 @@
128935
128936 /*
128937 ** This routine installs a default busy handler that waits for the
128938 ** specified number of milliseconds before returning 0.
128939 */
128940 SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3 *db, int ms){
128941 #ifdef SQLITE_ENABLE_API_ARMOR
128942 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
128943 #endif
128944 if( ms>0 ){
128945 sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)db);
@@ -128367,11 +128951,11 @@
128951 }
128952
128953 /*
128954 ** Cause any pending operation to stop at its earliest opportunity.
128955 */
128956 SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3 *db){
128957 #ifdef SQLITE_ENABLE_API_ARMOR
128958 if( !sqlite3SafetyCheckOk(db) ){
128959 (void)SQLITE_MISUSE_BKPT;
128960 return;
128961 }
@@ -128484,11 +129068,11 @@
129068 }
129069
129070 /*
129071 ** Create new user functions.
129072 */
129073 SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
129074 sqlite3 *db,
129075 const char *zFunc,
129076 int nArg,
129077 int enc,
129078 void *p,
@@ -128498,11 +129082,11 @@
129082 ){
129083 return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xFunc, xStep,
129084 xFinal, 0);
129085 }
129086
129087 SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
129088 sqlite3 *db,
129089 const char *zFunc,
129090 int nArg,
129091 int enc,
129092 void *p,
@@ -128541,11 +129125,11 @@
129125 sqlite3_mutex_leave(db->mutex);
129126 return rc;
129127 }
129128
129129 #ifndef SQLITE_OMIT_UTF16
129130 SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
129131 sqlite3 *db,
129132 const void *zFunctionName,
129133 int nArg,
129134 int eTextRep,
129135 void *p,
@@ -128581,11 +129165,11 @@
129165 ** When virtual tables intend to provide an overloaded function, they
129166 ** should call this routine to make sure the global function exists.
129167 ** A global function must exist in order for name resolution to work
129168 ** properly.
129169 */
129170 SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(
129171 sqlite3 *db,
129172 const char *zName,
129173 int nArg
129174 ){
129175 int nName = sqlite3Strlen30(zName);
@@ -128613,11 +129197,11 @@
129197 **
129198 ** A NULL trace function means that no tracing is executes. A non-NULL
129199 ** trace is a pointer to a function that is invoked at the start of each
129200 ** SQL statement.
129201 */
129202 SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
129203 void *pOld;
129204
129205 #ifdef SQLITE_ENABLE_API_ARMOR
129206 if( !sqlite3SafetyCheckOk(db) ){
129207 (void)SQLITE_MISUSE_BKPT;
@@ -128637,11 +129221,11 @@
129221 **
129222 ** A NULL profile function means that no profiling is executes. A non-NULL
129223 ** profile is a pointer to a function that is invoked at the conclusion of
129224 ** each SQL statement that is run.
129225 */
129226 SQLITE_API void *SQLITE_STDCALL sqlite3_profile(
129227 sqlite3 *db,
129228 void (*xProfile)(void*,const char*,sqlite_uint64),
129229 void *pArg
129230 ){
129231 void *pOld;
@@ -128664,11 +129248,11 @@
129248 /*
129249 ** Register a function to be invoked when a transaction commits.
129250 ** If the invoked function returns non-zero, then the commit becomes a
129251 ** rollback.
129252 */
129253 SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(
129254 sqlite3 *db, /* Attach the hook to this database */
129255 int (*xCallback)(void*), /* Function to invoke on each commit */
129256 void *pArg /* Argument to the function */
129257 ){
129258 void *pOld;
@@ -128689,11 +129273,11 @@
129273
129274 /*
129275 ** Register a callback to be invoked each time a row is updated,
129276 ** inserted or deleted using this database connection.
129277 */
129278 SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
129279 sqlite3 *db, /* Attach the hook to this database */
129280 void (*xCallback)(void*,int,char const *,char const *,sqlite_int64),
129281 void *pArg /* Argument to the function */
129282 ){
129283 void *pRet;
@@ -128714,11 +129298,11 @@
129298
129299 /*
129300 ** Register a callback to be invoked each time a transaction is rolled
129301 ** back by this database connection.
129302 */
129303 SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(
129304 sqlite3 *db, /* Attach the hook to this database */
129305 void (*xCallback)(void*), /* Callback function */
129306 void *pArg /* Argument to the function */
129307 ){
129308 void *pRet;
@@ -128768,11 +129352,11 @@
129352 ** The callback registered by this function replaces any existing callback
129353 ** registered using sqlite3_wal_hook(). Likewise, registering a callback
129354 ** using sqlite3_wal_hook() disables the automatic checkpoint mechanism
129355 ** configured by this function.
129356 */
129357 SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
129358 #ifdef SQLITE_OMIT_WAL
129359 UNUSED_PARAMETER(db);
129360 UNUSED_PARAMETER(nFrame);
129361 #else
129362 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -128789,11 +129373,11 @@
129373
129374 /*
129375 ** Register a callback to be invoked each time a transaction is written
129376 ** into the write-ahead-log by this database connection.
129377 */
129378 SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
129379 sqlite3 *db, /* Attach the hook to this db handle */
129380 int(*xCallback)(void *, sqlite3*, const char*, int),
129381 void *pArg /* First argument passed to xCallback() */
129382 ){
129383 #ifndef SQLITE_OMIT_WAL
@@ -128816,11 +129400,11 @@
129400 }
129401
129402 /*
129403 ** Checkpoint database zDb.
129404 */
129405 SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
129406 sqlite3 *db, /* Database handle */
129407 const char *zDb, /* Name of attached database (or NULL) */
129408 int eMode, /* SQLITE_CHECKPOINT_* value */
129409 int *pnLog, /* OUT: Size of WAL log in frames */
129410 int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -128871,11 +129455,11 @@
129455 /*
129456 ** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points
129457 ** to contains a zero-length string, all attached databases are
129458 ** checkpointed.
129459 */
129460 SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
129461 /* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to
129462 ** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */
129463 return sqlite3_wal_checkpoint_v2(db,zDb,SQLITE_CHECKPOINT_PASSIVE,0,0);
129464 }
129465
@@ -128960,11 +129544,11 @@
129544
129545 /*
129546 ** Return UTF-8 encoded English language explanation of the most recent
129547 ** error.
129548 */
129549 SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3 *db){
129550 const char *z;
129551 if( !db ){
129552 return sqlite3ErrStr(SQLITE_NOMEM);
129553 }
129554 if( !sqlite3SafetyCheckSickOrOk(db) ){
@@ -128988,11 +129572,11 @@
129572 #ifndef SQLITE_OMIT_UTF16
129573 /*
129574 ** Return UTF-16 encoded English language explanation of the most recent
129575 ** error.
129576 */
129577 SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3 *db){
129578 static const u16 outOfMem[] = {
129579 'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
129580 };
129581 static const u16 misuse[] = {
129582 'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ',
@@ -129033,20 +129617,20 @@
129617
129618 /*
129619 ** Return the most recent error code generated by an SQLite routine. If NULL is
129620 ** passed to this function, we assume a malloc() failed during sqlite3_open().
129621 */
129622 SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db){
129623 if( db && !sqlite3SafetyCheckSickOrOk(db) ){
129624 return SQLITE_MISUSE_BKPT;
129625 }
129626 if( !db || db->mallocFailed ){
129627 return SQLITE_NOMEM;
129628 }
129629 return db->errCode & db->errMask;
129630 }
129631 SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db){
129632 if( db && !sqlite3SafetyCheckSickOrOk(db) ){
129633 return SQLITE_MISUSE_BKPT;
129634 }
129635 if( !db || db->mallocFailed ){
129636 return SQLITE_NOMEM;
@@ -129057,11 +129641,11 @@
129641 /*
129642 ** Return a string that describes the kind of error specified in the
129643 ** argument. For now, this simply calls the internal sqlite3ErrStr()
129644 ** function.
129645 */
129646 SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int rc){
129647 return sqlite3ErrStr(rc);
129648 }
129649
129650 /*
129651 ** Create a new collating function for database "db". The name is zName
@@ -129205,11 +129789,11 @@
129789 **
129790 ** A new lower limit does not shrink existing constructs.
129791 ** It merely prevents new constructs that exceed the limit
129792 ** from forming.
129793 */
129794 SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
129795 int oldLimit;
129796
129797 #ifdef SQLITE_ENABLE_API_ARMOR
129798 if( !sqlite3SafetyCheckOk(db) ){
129799 (void)SQLITE_MISUSE_BKPT;
@@ -129790,18 +130374,18 @@
130374 }
130375
130376 /*
130377 ** Open a new database handle.
130378 */
130379 SQLITE_API int SQLITE_STDCALL sqlite3_open(
130380 const char *zFilename,
130381 sqlite3 **ppDb
130382 ){
130383 return openDatabase(zFilename, ppDb,
130384 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
130385 }
130386 SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
130387 const char *filename, /* Database filename (UTF-8) */
130388 sqlite3 **ppDb, /* OUT: SQLite db handle */
130389 int flags, /* Flags */
130390 const char *zVfs /* Name of VFS module to use */
130391 ){
@@ -129810,11 +130394,11 @@
130394
130395 #ifndef SQLITE_OMIT_UTF16
130396 /*
130397 ** Open a new database handle.
130398 */
130399 SQLITE_API int SQLITE_STDCALL sqlite3_open16(
130400 const void *zFilename,
130401 sqlite3 **ppDb
130402 ){
130403 char const *zFilename8; /* zFilename encoded in UTF-8 instead of UTF-16 */
130404 sqlite3_value *pVal;
@@ -129849,11 +130433,11 @@
130433 #endif /* SQLITE_OMIT_UTF16 */
130434
130435 /*
130436 ** Register a new collation sequence with the database handle db.
130437 */
130438 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
130439 sqlite3* db,
130440 const char *zName,
130441 int enc,
130442 void* pCtx,
130443 int(*xCompare)(void*,int,const void*,int,const void*)
@@ -129862,11 +130446,11 @@
130446 }
130447
130448 /*
130449 ** Register a new collation sequence with the database handle db.
130450 */
130451 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
130452 sqlite3* db,
130453 const char *zName,
130454 int enc,
130455 void* pCtx,
130456 int(*xCompare)(void*,int,const void*,int,const void*),
@@ -129887,11 +130471,11 @@
130471
130472 #ifndef SQLITE_OMIT_UTF16
130473 /*
130474 ** Register a new collation sequence with the database handle db.
130475 */
130476 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
130477 sqlite3* db,
130478 const void *zName,
130479 int enc,
130480 void* pCtx,
130481 int(*xCompare)(void*,int,const void*,int,const void*)
@@ -129917,11 +130501,11 @@
130501
130502 /*
130503 ** Register a collation sequence factory callback with the database handle
130504 ** db. Replace any previously installed collation sequence factory.
130505 */
130506 SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
130507 sqlite3 *db,
130508 void *pCollNeededArg,
130509 void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*)
130510 ){
130511 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -129938,11 +130522,11 @@
130522 #ifndef SQLITE_OMIT_UTF16
130523 /*
130524 ** Register a collation sequence factory callback with the database handle
130525 ** db. Replace any previously installed collation sequence factory.
130526 */
130527 SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
130528 sqlite3 *db,
130529 void *pCollNeededArg,
130530 void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*)
130531 ){
130532 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -129960,11 +130544,11 @@
130544 #ifndef SQLITE_OMIT_DEPRECATED
130545 /*
130546 ** This function is now an anachronism. It used to be used to recover from a
130547 ** malloc() failure, but SQLite now does this automatically.
130548 */
130549 SQLITE_API int SQLITE_STDCALL sqlite3_global_recover(void){
130550 return SQLITE_OK;
130551 }
130552 #endif
130553
130554 /*
@@ -129971,11 +130555,11 @@
130555 ** Test to see whether or not the database connection is in autocommit
130556 ** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on
130557 ** by default. Autocommit is disabled by a BEGIN statement and reenabled
130558 ** by the next COMMIT or ROLLBACK.
130559 */
130560 SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3 *db){
130561 #ifdef SQLITE_ENABLE_API_ARMOR
130562 if( !sqlite3SafetyCheckOk(db) ){
130563 (void)SQLITE_MISUSE_BKPT;
130564 return 0;
130565 }
@@ -130023,19 +130607,19 @@
130607 ** data for this thread has been deallocated.
130608 **
130609 ** SQLite no longer uses thread-specific data so this routine is now a
130610 ** no-op. It is retained for historical compatibility.
130611 */
130612 SQLITE_API void SQLITE_STDCALL sqlite3_thread_cleanup(void){
130613 }
130614 #endif
130615
130616 /*
130617 ** Return meta information about a specific column of a database table.
130618 ** See comment in sqlite3.h (sqlite.h.in) for details.
130619 */
130620 SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
130621 sqlite3 *db, /* Connection handle */
130622 const char *zDbName, /* Database name or NULL */
130623 const char *zTableName, /* Table name */
130624 const char *zColumnName, /* Column name */
130625 char const **pzDataType, /* OUTPUT: Declared data type */
@@ -130149,11 +130733,11 @@
130733 }
130734
130735 /*
130736 ** Sleep for a little while. Return the amount of time slept.
130737 */
130738 SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int ms){
130739 sqlite3_vfs *pVfs;
130740 int rc;
130741 pVfs = sqlite3_vfs_find(0);
130742 if( pVfs==0 ) return 0;
130743
@@ -130165,11 +130749,11 @@
130749 }
130750
130751 /*
130752 ** Enable or disable the extended result codes.
130753 */
130754 SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3 *db, int onoff){
130755 #ifdef SQLITE_ENABLE_API_ARMOR
130756 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
130757 #endif
130758 sqlite3_mutex_enter(db->mutex);
130759 db->errMask = onoff ? 0xffffffff : 0xff;
@@ -130178,11 +130762,11 @@
130762 }
130763
130764 /*
130765 ** Invoke the xFileControl method on a particular database.
130766 */
130767 SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){
130768 int rc = SQLITE_ERROR;
130769 Btree *pBtree;
130770
130771 #ifdef SQLITE_ENABLE_API_ARMOR
130772 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -130212,11 +130796,11 @@
130796 }
130797
130798 /*
130799 ** Interface to the testing logic.
130800 */
130801 SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...){
130802 int rc = 0;
130803 #ifndef SQLITE_OMIT_BUILTIN_TEST
130804 va_list ap;
130805 va_start(ap, op);
130806 switch( op ){
@@ -130555,11 +131139,11 @@
131139 ** method of a VFS implementation. The zParam argument is the name of the
131140 ** query parameter we seek. This routine returns the value of the zParam
131141 ** parameter if it exists. If the parameter does not exist, this routine
131142 ** returns a NULL pointer.
131143 */
131144 SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam){
131145 if( zFilename==0 || zParam==0 ) return 0;
131146 zFilename += sqlite3Strlen30(zFilename) + 1;
131147 while( zFilename[0] ){
131148 int x = strcmp(zFilename, zParam);
131149 zFilename += sqlite3Strlen30(zFilename) + 1;
@@ -130570,20 +131154,20 @@
131154 }
131155
131156 /*
131157 ** Return a boolean value for a query parameter.
131158 */
131159 SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){
131160 const char *z = sqlite3_uri_parameter(zFilename, zParam);
131161 bDflt = bDflt!=0;
131162 return z ? sqlite3GetBoolean(z, bDflt) : bDflt;
131163 }
131164
131165 /*
131166 ** Return a 64-bit integer value for a query parameter.
131167 */
131168 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(
131169 const char *zFilename, /* Filename as passed to xOpen */
131170 const char *zParam, /* URI parameter sought */
131171 sqlite3_int64 bDflt /* return if parameter is missing */
131172 ){
131173 const char *z = sqlite3_uri_parameter(zFilename, zParam);
@@ -130611,11 +131195,11 @@
131195
131196 /*
131197 ** Return the filename of the database associated with a database
131198 ** connection.
131199 */
131200 SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName){
131201 Btree *pBt;
131202 #ifdef SQLITE_ENABLE_API_ARMOR
131203 if( !sqlite3SafetyCheckOk(db) ){
131204 (void)SQLITE_MISUSE_BKPT;
131205 return 0;
@@ -130627,11 +131211,11 @@
131211
131212 /*
131213 ** Return 1 if database is read-only or 0 if read/write. Return -1 if
131214 ** no such database exists.
131215 */
131216 SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName){
131217 Btree *pBt;
131218 #ifdef SQLITE_ENABLE_API_ARMOR
131219 if( !sqlite3SafetyCheckOk(db) ){
131220 (void)SQLITE_MISUSE_BKPT;
131221 return -1;
@@ -130786,11 +131370,11 @@
131370 **
131371 ** Each call to this routine overrides any prior callbacks registered
131372 ** on the same "db". If xNotify==0 then any prior callbacks are immediately
131373 ** cancelled.
131374 */
131375 SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
131376 sqlite3 *db,
131377 void (*xNotify)(void **, int),
131378 void *pArg
131379 ){
131380 int rc = SQLITE_OK;
@@ -132766,15 +133350,20 @@
133350 ** the output value undefined. Otherwise SQLITE_OK is returned.
133351 **
133352 ** This function is used when parsing the "prefix=" FTS4 parameter.
133353 */
133354 static int fts3GobbleInt(const char **pp, int *pnOut){
133355 const int MAX_NPREFIX = 10000000;
133356 const char *p; /* Iterator pointer */
133357 int nInt = 0; /* Output value */
133358
133359 for(p=*pp; p[0]>='0' && p[0]<='9'; p++){
133360 nInt = nInt * 10 + (p[0] - '0');
133361 if( nInt>MAX_NPREFIX ){
133362 nInt = 0;
133363 break;
133364 }
133365 }
133366 if( p==*pp ) return SQLITE_ERROR;
133367 *pnOut = nInt;
133368 *pp = p;
133369 return SQLITE_OK;
@@ -132813,27 +133402,33 @@
133402 }
133403 }
133404
133405 aIndex = sqlite3_malloc(sizeof(struct Fts3Index) * nIndex);
133406 *apIndex = aIndex;
 
133407 if( !aIndex ){
133408 return SQLITE_NOMEM;
133409 }
133410
133411 memset(aIndex, 0, sizeof(struct Fts3Index) * nIndex);
133412 if( zParam ){
133413 const char *p = zParam;
133414 int i;
133415 for(i=1; i<nIndex; i++){
133416 int nPrefix = 0;
133417 if( fts3GobbleInt(&p, &nPrefix) ) return SQLITE_ERROR;
133418 assert( nPrefix>=0 );
133419 if( nPrefix==0 ){
133420 nIndex--;
133421 i--;
133422 }else{
133423 aIndex[i].nPrefix = nPrefix;
133424 }
133425 p++;
133426 }
133427 }
133428
133429 *pnIndex = nIndex;
133430 return SQLITE_OK;
133431 }
133432
133433 /*
133434 ** This function is called when initializing an FTS4 table that uses the
@@ -132953,11 +133548,11 @@
133548 int nName; /* Bytes required to hold table name */
133549 int isFts4 = (argv[0][3]=='4'); /* True for FTS4, false for FTS3 */
133550 const char **aCol; /* Array of column names */
133551 sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
133552
133553 int nIndex = 0; /* Size of aIndex[] array */
133554 struct Fts3Index *aIndex = 0; /* Array of indexes for this table */
133555
133556 /* The results of parsing supported FTS4 key=value options: */
133557 int bNoDocsize = 0; /* True to omit %_docsize table */
133558 int bDescIdx = 0; /* True to store descending indexes */
@@ -137641,11 +138236,11 @@
138236 ** Initialize API pointer table, if required.
138237 */
138238 #ifdef _WIN32
138239 __declspec(dllexport)
138240 #endif
138241 SQLITE_API int SQLITE_STDCALL sqlite3_fts3_init(
138242 sqlite3 *db,
138243 char **pzErrMsg,
138244 const sqlite3_api_routines *pApi
138245 ){
138246 SQLITE_EXTENSION_INIT2(pApi)
@@ -140609,11 +141204,11 @@
141204 nName = sqlite3_value_bytes(argv[0])+1;
141205
141206 if( argc==2 ){
141207 void *pOld;
141208 int n = sqlite3_value_bytes(argv[1]);
141209 if( zName==0 || n!=sizeof(pPtr) ){
141210 sqlite3_result_error(context, "argument type mismatch", -1);
141211 return;
141212 }
141213 pPtr = *(void **)sqlite3_value_blob(argv[1]);
141214 pOld = sqlite3Fts3HashInsert(pHash, (void *)zName, nName, pPtr);
@@ -140620,11 +141215,13 @@
141215 if( pOld==pPtr ){
141216 sqlite3_result_error(context, "out of memory", -1);
141217 return;
141218 }
141219 }else{
141220 if( zName ){
141221 pPtr = sqlite3Fts3HashFind(pHash, zName, nName);
141222 }
141223 if( !pPtr ){
141224 char *zErr = sqlite3_mprintf("unknown tokenizer: %s", zName);
141225 sqlite3_result_error(context, zErr, -1);
141226 sqlite3_free(zErr);
141227 return;
@@ -140701,10 +141298,14 @@
141298 zCopy = sqlite3_mprintf("%s", zArg);
141299 if( !zCopy ) return SQLITE_NOMEM;
141300 zEnd = &zCopy[strlen(zCopy)];
141301
141302 z = (char *)sqlite3Fts3NextToken(zCopy, &n);
141303 if( z==0 ){
141304 assert( n==0 );
141305 z = zCopy;
141306 }
141307 z[n] = '\0';
141308 sqlite3Fts3Dequote(z);
141309
141310 m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash,z,(int)strlen(z)+1);
141311 if( !m ){
@@ -143346,11 +143947,14 @@
143947 /*
143948 ** This is a comparison function used as a qsort() callback when sorting
143949 ** an array of pending terms by term. This occurs as part of flushing
143950 ** the contents of the pending-terms hash table to the database.
143951 */
143952 static int SQLITE_CDECL fts3CompareElemByTerm(
143953 const void *lhs,
143954 const void *rhs
143955 ){
143956 char *z1 = fts3HashKey(*(Fts3HashElem **)lhs);
143957 char *z2 = fts3HashKey(*(Fts3HashElem **)rhs);
143958 int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs);
143959 int n2 = fts3HashKeysize(*(Fts3HashElem **)rhs);
143960
@@ -153079,11 +153683,11 @@
153683 }
153684
153685 /*
153686 ** Register a new geometry function for use with the r-tree MATCH operator.
153687 */
153688 SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
153689 sqlite3 *db, /* Register SQL function on this connection */
153690 const char *zGeom, /* Name of the new SQL function */
153691 int (*xGeom)(sqlite3_rtree_geometry*,int,RtreeDValue*,int*), /* Callback */
153692 void *pContext /* Extra data associated with the callback */
153693 ){
@@ -153103,11 +153707,11 @@
153707
153708 /*
153709 ** Register a new 2nd-generation geometry function for use with the
153710 ** r-tree MATCH operator.
153711 */
153712 SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
153713 sqlite3 *db, /* Register SQL function on this connection */
153714 const char *zQueryFunc, /* Name of new SQL function */
153715 int (*xQueryFunc)(sqlite3_rtree_query_info*), /* Callback */
153716 void *pContext, /* Extra data passed into the callback */
153717 void (*xDestructor)(void*) /* Destructor for the extra data */
@@ -153128,11 +153732,11 @@
153732
153733 #if !SQLITE_CORE
153734 #ifdef _WIN32
153735 __declspec(dllexport)
153736 #endif
153737 SQLITE_API int SQLITE_STDCALL sqlite3_rtree_init(
153738 sqlite3 *db,
153739 char **pzErrMsg,
153740 const sqlite3_api_routines *pApi
153741 ){
153742 SQLITE_EXTENSION_INIT2(pApi)
@@ -153633,11 +154237,11 @@
154237
154238 #if !SQLITE_CORE
154239 #ifdef _WIN32
154240 __declspec(dllexport)
154241 #endif
154242 SQLITE_API int SQLITE_STDCALL sqlite3_icu_init(
154243 sqlite3 *db,
154244 char **pzErrMsg,
154245 const sqlite3_api_routines *pApi
154246 ){
154247 SQLITE_EXTENSION_INIT2(pApi)
154248
+260 -243
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -41,20 +41,24 @@
4141
extern "C" {
4242
#endif
4343
4444
4545
/*
46
-** Add the ability to override 'extern'
46
+** Provide the ability to override linkage features of the interface.
4747
*/
4848
#ifndef SQLITE_EXTERN
4949
# define SQLITE_EXTERN extern
5050
#endif
51
-
5251
#ifndef SQLITE_API
5352
# define SQLITE_API
5453
#endif
55
-
54
+#ifndef SQLITE_CDECL
55
+# define SQLITE_CDECL
56
+#endif
57
+#ifndef SQLITE_STDCALL
58
+# define SQLITE_STDCALL
59
+#endif
5660
5761
/*
5862
** These no-op macros are used in front of interfaces to mark those
5963
** interfaces as either deprecated or experimental. New applications
6064
** should not use deprecated interfaces - they are supported for backwards
@@ -107,11 +111,11 @@
107111
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108112
** [sqlite_version()] and [sqlite_source_id()].
109113
*/
110114
#define SQLITE_VERSION "3.8.9"
111115
#define SQLITE_VERSION_NUMBER 3008009
112
-#define SQLITE_SOURCE_ID "2015-03-09 10:40:48 e5da5e7d5dc5a3438ced23f1ee83e695abc29c45"
116
+#define SQLITE_SOURCE_ID "2015-03-30 23:43:56 395bb3e677a6551b06ba96fc58c393132b93d1e8"
113117
114118
/*
115119
** CAPI3REF: Run-Time Library Version Numbers
116120
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117121
**
@@ -140,13 +144,13 @@
140144
** [SQLITE_SOURCE_ID] C preprocessor macro.
141145
**
142146
** See also: [sqlite_version()] and [sqlite_source_id()].
143147
*/
144148
SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
145
-SQLITE_API const char *sqlite3_libversion(void);
146
-SQLITE_API const char *sqlite3_sourceid(void);
147
-SQLITE_API int sqlite3_libversion_number(void);
149
+SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void);
150
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void);
151
+SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void);
148152
149153
/*
150154
** CAPI3REF: Run-Time Library Compilation Options Diagnostics
151155
**
152156
** ^The sqlite3_compileoption_used() function returns 0 or 1
@@ -167,12 +171,12 @@
167171
**
168172
** See also: SQL functions [sqlite_compileoption_used()] and
169173
** [sqlite_compileoption_get()] and the [compile_options pragma].
170174
*/
171175
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
172
-SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
173
-SQLITE_API const char *sqlite3_compileoption_get(int N);
176
+SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName);
177
+SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N);
174178
#endif
175179
176180
/*
177181
** CAPI3REF: Test To See If The Library Is Threadsafe
178182
**
@@ -207,11 +211,11 @@
207211
** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
208212
** is unchanged by calls to sqlite3_config().)^
209213
**
210214
** See the [threading mode] documentation for additional information.
211215
*/
212
-SQLITE_API int sqlite3_threadsafe(void);
216
+SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void);
213217
214218
/*
215219
** CAPI3REF: Database Connection Handle
216220
** KEYWORDS: {database connection} {database connections}
217221
**
@@ -303,12 +307,12 @@
303307
** from [sqlite3_open()], [sqlite3_open16()], or
304308
** [sqlite3_open_v2()], and not previously closed.
305309
** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
306310
** argument is a harmless no-op.
307311
*/
308
-SQLITE_API int sqlite3_close(sqlite3*);
309
-SQLITE_API int sqlite3_close_v2(sqlite3*);
312
+SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*);
313
+SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*);
310314
311315
/*
312316
** The type for a callback function.
313317
** This is legacy and deprecated. It is included for historical
314318
** compatibility and is not documented.
@@ -374,11 +378,11 @@
374378
** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
375379
** <li> The application must not modify the SQL statement text passed into
376380
** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
377381
** </ul>
378382
*/
379
-SQLITE_API int sqlite3_exec(
383
+SQLITE_API int SQLITE_STDCALL sqlite3_exec(
380384
sqlite3*, /* An open database */
381385
const char *sql, /* SQL to be evaluated */
382386
int (*callback)(void*,int,char**,char**), /* Callback function */
383387
void *, /* 1st argument to callback */
384388
char **errmsg /* Error msg written here */
@@ -948,10 +952,17 @@
948952
** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
949953
** opcode causes the xFileControl method to swap the file handle with the one
950954
** pointed to by the pArg argument. This capability is used during testing
951955
** and only needs to be supported when SQLITE_TEST is defined.
952956
**
957
+** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
958
+** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
959
+** be advantageous to block on the next WAL lock if the lock is not immediately
960
+** available. The WAL subsystem issues this signal during rare
961
+** circumstances in order to fix a problem with priority inversion.
962
+** Applications should <em>not</em> use this file-control.
963
+**
953964
** </ul>
954965
*/
955966
#define SQLITE_FCNTL_LOCKSTATE 1
956967
#define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
957968
#define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
@@ -972,10 +983,11 @@
972983
#define SQLITE_FCNTL_TRACE 19
973984
#define SQLITE_FCNTL_HAS_MOVED 20
974985
#define SQLITE_FCNTL_SYNC 21
975986
#define SQLITE_FCNTL_COMMIT_PHASETWO 22
976987
#define SQLITE_FCNTL_WIN32_SET_HANDLE 23
988
+#define SQLITE_FCNTL_WAL_BLOCK 24
977989
978990
/* deprecated names */
979991
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
980992
#define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
981993
#define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -1326,14 +1338,14 @@
13261338
** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
13271339
** implementation of sqlite3_os_init() or sqlite3_os_end()
13281340
** must return [SQLITE_OK] on success and some other [error code] upon
13291341
** failure.
13301342
*/
1331
-SQLITE_API int sqlite3_initialize(void);
1332
-SQLITE_API int sqlite3_shutdown(void);
1333
-SQLITE_API int sqlite3_os_init(void);
1334
-SQLITE_API int sqlite3_os_end(void);
1343
+SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void);
1344
+SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void);
1345
+SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void);
1346
+SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void);
13351347
13361348
/*
13371349
** CAPI3REF: Configuring The SQLite Library
13381350
**
13391351
** The sqlite3_config() interface is used to make global configuration
@@ -1360,11 +1372,11 @@
13601372
**
13611373
** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
13621374
** ^If the option is unknown or SQLite is unable to set the option
13631375
** then this routine returns a non-zero [error code].
13641376
*/
1365
-SQLITE_API int sqlite3_config(int, ...);
1377
+SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...);
13661378
13671379
/*
13681380
** CAPI3REF: Configure database connections
13691381
**
13701382
** The sqlite3_db_config() interface is used to make configuration
@@ -1378,11 +1390,11 @@
13781390
** Subsequent arguments vary depending on the configuration verb.
13791391
**
13801392
** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
13811393
** the call is considered successful.
13821394
*/
1383
-SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
1395
+SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...);
13841396
13851397
/*
13861398
** CAPI3REF: Memory Allocation Routines
13871399
**
13881400
** An instance of this object defines the interface between SQLite
@@ -1538,11 +1550,11 @@
15381550
** disabled, the following SQLite interfaces become non-operational:
15391551
** <ul>
15401552
** <li> [sqlite3_memory_used()]
15411553
** <li> [sqlite3_memory_highwater()]
15421554
** <li> [sqlite3_soft_heap_limit64()]
1543
-** <li> [sqlite3_status()]
1555
+** <li> [sqlite3_status64()]
15441556
** </ul>)^
15451557
** ^Memory allocation statistics are enabled by default unless SQLite is
15461558
** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
15471559
** allocation statistics are disabled by default.
15481560
** </dd>
@@ -1866,11 +1878,11 @@
18661878
**
18671879
** ^The sqlite3_extended_result_codes() routine enables or disables the
18681880
** [extended result codes] feature of SQLite. ^The extended result
18691881
** codes are disabled by default for historical compatibility.
18701882
*/
1871
-SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
1883
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff);
18721884
18731885
/*
18741886
** CAPI3REF: Last Insert Rowid
18751887
**
18761888
** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
@@ -1917,11 +1929,11 @@
19171929
** function is running and thus changes the last insert [rowid],
19181930
** then the value returned by [sqlite3_last_insert_rowid()] is
19191931
** unpredictable and might not equal either the old or the new
19201932
** last insert [rowid].
19211933
*/
1922
-SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
1934
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*);
19231935
19241936
/*
19251937
** CAPI3REF: Count The Number Of Rows Modified
19261938
**
19271939
** ^This function returns the number of rows modified, inserted or
@@ -1969,11 +1981,11 @@
19691981
**
19701982
** If a separate thread makes changes on the same database connection
19711983
** while [sqlite3_changes()] is running then the value returned
19721984
** is unpredictable and not meaningful.
19731985
*/
1974
-SQLITE_API int sqlite3_changes(sqlite3*);
1986
+SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*);
19751987
19761988
/*
19771989
** CAPI3REF: Total Number Of Rows Modified
19781990
**
19791991
** ^This function returns the total number of rows inserted, modified or
@@ -1992,11 +2004,11 @@
19922004
**
19932005
** If a separate thread makes changes on the same database connection
19942006
** while [sqlite3_total_changes()] is running then the value
19952007
** returned is unpredictable and not meaningful.
19962008
*/
1997
-SQLITE_API int sqlite3_total_changes(sqlite3*);
2009
+SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*);
19982010
19992011
/*
20002012
** CAPI3REF: Interrupt A Long-Running Query
20012013
**
20022014
** ^This function causes any pending database operation to abort and
@@ -2031,11 +2043,11 @@
20312043
** that are started after the sqlite3_interrupt() call returns.
20322044
**
20332045
** If the database connection closes while [sqlite3_interrupt()]
20342046
** is running then bad things will likely happen.
20352047
*/
2036
-SQLITE_API void sqlite3_interrupt(sqlite3*);
2048
+SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*);
20372049
20382050
/*
20392051
** CAPI3REF: Determine If An SQL Statement Is Complete
20402052
**
20412053
** These routines are useful during command-line input to determine if the
@@ -2066,12 +2078,12 @@
20662078
** UTF-8 string.
20672079
**
20682080
** The input to [sqlite3_complete16()] must be a zero-terminated
20692081
** UTF-16 string in native byte order.
20702082
*/
2071
-SQLITE_API int sqlite3_complete(const char *sql);
2072
-SQLITE_API int sqlite3_complete16(const void *sql);
2083
+SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql);
2084
+SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
20732085
20742086
/*
20752087
** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
20762088
** KEYWORDS: {busy-handler callback} {busy handler}
20772089
**
@@ -2127,11 +2139,11 @@
21272139
** result in undefined behavior.
21282140
**
21292141
** A busy handler must not close the database connection
21302142
** or [prepared statement] that invoked the busy handler.
21312143
*/
2132
-SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2144
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
21332145
21342146
/*
21352147
** CAPI3REF: Set A Busy Timeout
21362148
**
21372149
** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
@@ -2149,11 +2161,11 @@
21492161
** was defined (using [sqlite3_busy_handler()]) prior to calling
21502162
** this routine, that other busy handler is cleared.)^
21512163
**
21522164
** See also: [PRAGMA busy_timeout]
21532165
*/
2154
-SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
2166
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms);
21552167
21562168
/*
21572169
** CAPI3REF: Convenience Routines For Running Queries
21582170
**
21592171
** This is a legacy interface that is preserved for backwards compatibility.
@@ -2223,19 +2235,19 @@
22232235
** interface defined here. As a consequence, errors that occur in the
22242236
** wrapper layer outside of the internal [sqlite3_exec()] call are not
22252237
** reflected in subsequent calls to [sqlite3_errcode()] or
22262238
** [sqlite3_errmsg()].
22272239
*/
2228
-SQLITE_API int sqlite3_get_table(
2240
+SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
22292241
sqlite3 *db, /* An open database */
22302242
const char *zSql, /* SQL to be evaluated */
22312243
char ***pazResult, /* Results of the query */
22322244
int *pnRow, /* Number of result rows written here */
22332245
int *pnColumn, /* Number of result columns written here */
22342246
char **pzErrmsg /* Error msg written here */
22352247
);
2236
-SQLITE_API void sqlite3_free_table(char **result);
2248
+SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result);
22372249
22382250
/*
22392251
** CAPI3REF: Formatted String Printing Functions
22402252
**
22412253
** These routines are work-alikes of the "printf()" family of functions
@@ -2337,14 +2349,14 @@
23372349
**
23382350
** ^(The "%z" formatting option works like "%s" but with the
23392351
** addition that after the string has been read and copied into
23402352
** the result, [sqlite3_free()] is called on the input string.)^
23412353
*/
2342
-SQLITE_API char *sqlite3_mprintf(const char*,...);
2343
-SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
2344
-SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
2345
-SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
2354
+SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...);
2355
+SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list);
2356
+SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...);
2357
+SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list);
23462358
23472359
/*
23482360
** CAPI3REF: Memory Allocation Subsystem
23492361
**
23502362
** The SQLite core uses these three routines for all of its own
@@ -2430,16 +2442,16 @@
24302442
**
24312443
** The application must not read or write any part of
24322444
** a block of memory after it has been released using
24332445
** [sqlite3_free()] or [sqlite3_realloc()].
24342446
*/
2435
-SQLITE_API void *sqlite3_malloc(int);
2436
-SQLITE_API void *sqlite3_malloc64(sqlite3_uint64);
2437
-SQLITE_API void *sqlite3_realloc(void*, int);
2438
-SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);
2439
-SQLITE_API void sqlite3_free(void*);
2440
-SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
2447
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int);
2448
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64);
2449
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int);
2450
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64);
2451
+SQLITE_API void SQLITE_STDCALL sqlite3_free(void*);
2452
+SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*);
24412453
24422454
/*
24432455
** CAPI3REF: Memory Allocator Statistics
24442456
**
24452457
** SQLite provides these two interfaces for reporting on the status
@@ -2460,12 +2472,12 @@
24602472
** [sqlite3_memory_used()] if and only if the parameter to
24612473
** [sqlite3_memory_highwater()] is true. ^The value returned
24622474
** by [sqlite3_memory_highwater(1)] is the high-water mark
24632475
** prior to the reset.
24642476
*/
2465
-SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
2466
-SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
2477
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void);
2478
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag);
24672479
24682480
/*
24692481
** CAPI3REF: Pseudo-Random Number Generator
24702482
**
24712483
** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
@@ -2484,11 +2496,11 @@
24842496
** ^If the previous call to this routine had an N of 1 or more and a
24852497
** non-NULL P then the pseudo-randomness is generated
24862498
** internally and without recourse to the [sqlite3_vfs] xRandomness
24872499
** method.
24882500
*/
2489
-SQLITE_API void sqlite3_randomness(int N, void *P);
2501
+SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P);
24902502
24912503
/*
24922504
** CAPI3REF: Compile-Time Authorization Callbacks
24932505
**
24942506
** ^This routine registers an authorizer callback with a particular
@@ -2566,11 +2578,11 @@
25662578
** [sqlite3_prepare()] or its variants. Authorization is not
25672579
** performed during statement evaluation in [sqlite3_step()], unless
25682580
** as stated in the previous paragraph, sqlite3_step() invokes
25692581
** sqlite3_prepare_v2() to reprepare a statement after a schema change.
25702582
*/
2571
-SQLITE_API int sqlite3_set_authorizer(
2583
+SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
25722584
sqlite3*,
25732585
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
25742586
void *pUserData
25752587
);
25762588
@@ -2670,12 +2682,12 @@
26702682
** digits in the time are meaningless. Future versions of SQLite
26712683
** might provide greater resolution on the profiler callback. The
26722684
** sqlite3_profile() function is considered experimental and is
26732685
** subject to change in future versions of SQLite.
26742686
*/
2675
-SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2676
-SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
2687
+SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2688
+SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
26772689
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
26782690
26792691
/*
26802692
** CAPI3REF: Query Progress Callbacks
26812693
**
@@ -2705,11 +2717,11 @@
27052717
** the database connection that invoked the progress handler.
27062718
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
27072719
** database connections for the meaning of "modify" in this paragraph.
27082720
**
27092721
*/
2710
-SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2722
+SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
27112723
27122724
/*
27132725
** CAPI3REF: Opening A New Database Connection
27142726
**
27152727
** ^These routines open an SQLite database file as specified by the
@@ -2933,19 +2945,19 @@
29332945
** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various
29342946
** features that require the use of temporary files may fail.
29352947
**
29362948
** See also: [sqlite3_temp_directory]
29372949
*/
2938
-SQLITE_API int sqlite3_open(
2950
+SQLITE_API int SQLITE_STDCALL sqlite3_open(
29392951
const char *filename, /* Database filename (UTF-8) */
29402952
sqlite3 **ppDb /* OUT: SQLite db handle */
29412953
);
2942
-SQLITE_API int sqlite3_open16(
2954
+SQLITE_API int SQLITE_STDCALL sqlite3_open16(
29432955
const void *filename, /* Database filename (UTF-16) */
29442956
sqlite3 **ppDb /* OUT: SQLite db handle */
29452957
);
2946
-SQLITE_API int sqlite3_open_v2(
2958
+SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
29472959
const char *filename, /* Database filename (UTF-8) */
29482960
sqlite3 **ppDb, /* OUT: SQLite db handle */
29492961
int flags, /* Flags */
29502962
const char *zVfs /* Name of VFS module to use */
29512963
);
@@ -2987,23 +2999,25 @@
29872999
** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
29883000
** is not a database file pathname pointer that SQLite passed into the xOpen
29893001
** VFS method, then the behavior of this routine is undefined and probably
29903002
** undesirable.
29913003
*/
2992
-SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
2993
-SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
2994
-SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3004
+SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3005
+SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3006
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
29953007
29963008
29973009
/*
29983010
** CAPI3REF: Error Codes And Messages
29993011
**
3000
-** ^The sqlite3_errcode() interface returns the numeric [result code] or
3001
-** [extended result code] for the most recent failed sqlite3_* API call
3002
-** associated with a [database connection]. If a prior API call failed
3003
-** but the most recent API call succeeded, the return value from
3004
-** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode()
3012
+** ^If the most recent sqlite3_* API call associated with
3013
+** [database connection] D failed, then the sqlite3_errcode(D) interface
3014
+** returns the numeric [result code] or [extended result code] for that
3015
+** API call.
3016
+** If the most recent API call was successful,
3017
+** then the return value from sqlite3_errcode() is undefined.
3018
+** ^The sqlite3_extended_errcode()
30053019
** interface is the same except that it always returns the
30063020
** [extended result code] even when extended result codes are
30073021
** disabled.
30083022
**
30093023
** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -3030,15 +3044,15 @@
30303044
**
30313045
** If an interface fails with SQLITE_MISUSE, that means the interface
30323046
** was invoked incorrectly by the application. In that case, the
30333047
** error code and message may or may not be set.
30343048
*/
3035
-SQLITE_API int sqlite3_errcode(sqlite3 *db);
3036
-SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
3037
-SQLITE_API const char *sqlite3_errmsg(sqlite3*);
3038
-SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
3039
-SQLITE_API const char *sqlite3_errstr(int);
3049
+SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db);
3050
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db);
3051
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*);
3052
+SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*);
3053
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int);
30403054
30413055
/*
30423056
** CAPI3REF: SQL Statement Object
30433057
** KEYWORDS: {prepared statement} {prepared statements}
30443058
**
@@ -3101,11 +3115,11 @@
31013115
** created by an untrusted script can be contained using the
31023116
** [max_page_count] [PRAGMA].
31033117
**
31043118
** New run-time limit categories may be added in future releases.
31053119
*/
3106
-SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
3120
+SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal);
31073121
31083122
/*
31093123
** CAPI3REF: Run-Time Limit Categories
31103124
** KEYWORDS: {limit category} {*limit categories}
31113125
**
@@ -3251,32 +3265,32 @@
32513265
** or [GLOB] operator or if the parameter is compared to an indexed column
32523266
** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
32533267
** </li>
32543268
** </ol>
32553269
*/
3256
-SQLITE_API int sqlite3_prepare(
3270
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
32573271
sqlite3 *db, /* Database handle */
32583272
const char *zSql, /* SQL statement, UTF-8 encoded */
32593273
int nByte, /* Maximum length of zSql in bytes. */
32603274
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
32613275
const char **pzTail /* OUT: Pointer to unused portion of zSql */
32623276
);
3263
-SQLITE_API int sqlite3_prepare_v2(
3277
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
32643278
sqlite3 *db, /* Database handle */
32653279
const char *zSql, /* SQL statement, UTF-8 encoded */
32663280
int nByte, /* Maximum length of zSql in bytes. */
32673281
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
32683282
const char **pzTail /* OUT: Pointer to unused portion of zSql */
32693283
);
3270
-SQLITE_API int sqlite3_prepare16(
3284
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
32713285
sqlite3 *db, /* Database handle */
32723286
const void *zSql, /* SQL statement, UTF-16 encoded */
32733287
int nByte, /* Maximum length of zSql in bytes. */
32743288
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
32753289
const void **pzTail /* OUT: Pointer to unused portion of zSql */
32763290
);
3277
-SQLITE_API int sqlite3_prepare16_v2(
3291
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
32783292
sqlite3 *db, /* Database handle */
32793293
const void *zSql, /* SQL statement, UTF-16 encoded */
32803294
int nByte, /* Maximum length of zSql in bytes. */
32813295
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
32823296
const void **pzTail /* OUT: Pointer to unused portion of zSql */
@@ -3287,11 +3301,11 @@
32873301
**
32883302
** ^This interface can be used to retrieve a saved copy of the original
32893303
** SQL text used to create a [prepared statement] if that statement was
32903304
** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
32913305
*/
3292
-SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
3306
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
32933307
32943308
/*
32953309
** CAPI3REF: Determine If An SQL Statement Writes The Database
32963310
**
32973311
** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
@@ -3318,11 +3332,11 @@
33183332
** database. ^The [ATTACH] and [DETACH] statements also cause
33193333
** sqlite3_stmt_readonly() to return true since, while those statements
33203334
** change the configuration of a database connection, they do not make
33213335
** changes to the content of the database files on disk.
33223336
*/
3323
-SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
3337
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
33243338
33253339
/*
33263340
** CAPI3REF: Determine If A Prepared Statement Has Been Reset
33273341
**
33283342
** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
@@ -3337,11 +3351,11 @@
33373351
** to locate all prepared statements associated with a database
33383352
** connection that are in need of being reset. This can be used,
33393353
** for example, in diagnostic routines to search for prepared
33403354
** statements that are holding a transaction open.
33413355
*/
3342
-SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
3356
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*);
33433357
33443358
/*
33453359
** CAPI3REF: Dynamically Typed Value Object
33463360
** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
33473361
**
@@ -3498,23 +3512,23 @@
34983512
** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
34993513
**
35003514
** See also: [sqlite3_bind_parameter_count()],
35013515
** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
35023516
*/
3503
-SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3504
-SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
3517
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3518
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
35053519
void(*)(void*));
3506
-SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
3507
-SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
3508
-SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3509
-SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
3510
-SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3511
-SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3512
-SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3520
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double);
3521
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int);
3522
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3523
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int);
3524
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3525
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3526
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
35133527
void(*)(void*), unsigned char encoding);
3514
-SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3515
-SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3528
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3529
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
35163530
35173531
/*
35183532
** CAPI3REF: Number Of SQL Parameters
35193533
**
35203534
** ^This routine can be used to find the number of [SQL parameters]
@@ -3530,11 +3544,11 @@
35303544
**
35313545
** See also: [sqlite3_bind_blob|sqlite3_bind()],
35323546
** [sqlite3_bind_parameter_name()], and
35333547
** [sqlite3_bind_parameter_index()].
35343548
*/
3535
-SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
3549
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*);
35363550
35373551
/*
35383552
** CAPI3REF: Name Of A Host Parameter
35393553
**
35403554
** ^The sqlite3_bind_parameter_name(P,N) interface returns
@@ -3557,11 +3571,11 @@
35573571
**
35583572
** See also: [sqlite3_bind_blob|sqlite3_bind()],
35593573
** [sqlite3_bind_parameter_count()], and
35603574
** [sqlite3_bind_parameter_index()].
35613575
*/
3562
-SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3576
+SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int);
35633577
35643578
/*
35653579
** CAPI3REF: Index Of A Parameter With A Given Name
35663580
**
35673581
** ^Return the index of an SQL parameter given its name. ^The
@@ -3573,20 +3587,20 @@
35733587
**
35743588
** See also: [sqlite3_bind_blob|sqlite3_bind()],
35753589
** [sqlite3_bind_parameter_count()], and
35763590
** [sqlite3_bind_parameter_index()].
35773591
*/
3578
-SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3592
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
35793593
35803594
/*
35813595
** CAPI3REF: Reset All Bindings On A Prepared Statement
35823596
**
35833597
** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
35843598
** the [sqlite3_bind_blob | bindings] on a [prepared statement].
35853599
** ^Use this routine to reset all host parameters to NULL.
35863600
*/
3587
-SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
3601
+SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*);
35883602
35893603
/*
35903604
** CAPI3REF: Number Of Columns In A Result Set
35913605
**
35923606
** ^Return the number of columns in the result set returned by the
@@ -3593,11 +3607,11 @@
35933607
** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
35943608
** statement that does not return data (for example an [UPDATE]).
35953609
**
35963610
** See also: [sqlite3_data_count()]
35973611
*/
3598
-SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
3612
+SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt);
35993613
36003614
/*
36013615
** CAPI3REF: Column Names In A Result Set
36023616
**
36033617
** ^These routines return the name assigned to a particular column
@@ -3621,12 +3635,12 @@
36213635
** ^The name of a result column is the value of the "AS" clause for
36223636
** that column, if there is an AS clause. If there is no AS clause
36233637
** then the name of the column is unspecified and may change from
36243638
** one release of SQLite to the next.
36253639
*/
3626
-SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
3627
-SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
3640
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N);
3641
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N);
36283642
36293643
/*
36303644
** CAPI3REF: Source Of Data In A Query Result
36313645
**
36323646
** ^These routines provide a means to determine the database, table, and
@@ -3669,16 +3683,16 @@
36693683
** If two or more threads call one or more
36703684
** [sqlite3_column_database_name | column metadata interfaces]
36713685
** for the same [prepared statement] and result column
36723686
** at the same time then the results are undefined.
36733687
*/
3674
-SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
3675
-SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
3676
-SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
3677
-SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
3678
-SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
3679
-SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
3688
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int);
3689
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int);
3690
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int);
3691
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int);
3692
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int);
3693
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int);
36803694
36813695
/*
36823696
** CAPI3REF: Declared Datatype Of A Query Result
36833697
**
36843698
** ^(The first parameter is a [prepared statement].
@@ -3705,12 +3719,12 @@
37053719
** data stored in that column is of the declared type. SQLite is
37063720
** strongly typed, but the typing is dynamic not static. ^Type
37073721
** is associated with individual values, not with the containers
37083722
** used to hold those values.
37093723
*/
3710
-SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
3711
-SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
3724
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int);
3725
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int);
37123726
37133727
/*
37143728
** CAPI3REF: Evaluate An SQL Statement
37153729
**
37163730
** After a [prepared statement] has been prepared using either
@@ -3785,11 +3799,11 @@
37853799
** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
37863800
** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
37873801
** then the more specific [error codes] are returned directly
37883802
** by sqlite3_step(). The use of the "v2" interface is recommended.
37893803
*/
3790
-SQLITE_API int sqlite3_step(sqlite3_stmt*);
3804
+SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*);
37913805
37923806
/*
37933807
** CAPI3REF: Number of columns in a result set
37943808
**
37953809
** ^The sqlite3_data_count(P) interface returns the number of columns in the
@@ -3805,11 +3819,11 @@
38053819
** where it always returns zero since each step of that multi-step
38063820
** pragma returns 0 columns of data.
38073821
**
38083822
** See also: [sqlite3_column_count()]
38093823
*/
3810
-SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
3824
+SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt);
38113825
38123826
/*
38133827
** CAPI3REF: Fundamental Datatypes
38143828
** KEYWORDS: SQLITE_TEXT
38153829
**
@@ -4001,20 +4015,20 @@
40014015
** of these routines, a default value is returned. The default value
40024016
** is either the integer 0, the floating point number 0.0, or a NULL
40034017
** pointer. Subsequent calls to [sqlite3_errcode()] will return
40044018
** [SQLITE_NOMEM].)^
40054019
*/
4006
-SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
4007
-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4008
-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4009
-SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
4010
-SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
4011
-SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
4012
-SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
4013
-SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
4014
-SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
4015
-SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
4020
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol);
4021
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4022
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4023
+SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol);
4024
+SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol);
4025
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol);
4026
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol);
4027
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol);
4028
+SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol);
4029
+SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol);
40164030
40174031
/*
40184032
** CAPI3REF: Destroy A Prepared Statement Object
40194033
**
40204034
** ^The sqlite3_finalize() function is called to delete a [prepared statement].
@@ -4037,11 +4051,11 @@
40374051
** resource leaks. It is a grievous error for the application to try to use
40384052
** a prepared statement after it has been finalized. Any use of a prepared
40394053
** statement after it has been finalized can result in undefined and
40404054
** undesirable behavior such as segfaults and heap corruption.
40414055
*/
4042
-SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
4056
+SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt);
40434057
40444058
/*
40454059
** CAPI3REF: Reset A Prepared Statement Object
40464060
**
40474061
** The sqlite3_reset() function is called to reset a [prepared statement]
@@ -4063,11 +4077,11 @@
40634077
** [sqlite3_reset(S)] returns an appropriate [error code].
40644078
**
40654079
** ^The [sqlite3_reset(S)] interface does not change the values
40664080
** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
40674081
*/
4068
-SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
4082
+SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt);
40694083
40704084
/*
40714085
** CAPI3REF: Create Or Redefine SQL Functions
40724086
** KEYWORDS: {function creation routines}
40734087
** KEYWORDS: {application-defined SQL function}
@@ -4162,31 +4176,31 @@
41624176
** ^An application-defined function is permitted to call other
41634177
** SQLite interfaces. However, such calls must not
41644178
** close the database connection nor finalize or reset the prepared
41654179
** statement in which the function is running.
41664180
*/
4167
-SQLITE_API int sqlite3_create_function(
4181
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
41684182
sqlite3 *db,
41694183
const char *zFunctionName,
41704184
int nArg,
41714185
int eTextRep,
41724186
void *pApp,
41734187
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
41744188
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
41754189
void (*xFinal)(sqlite3_context*)
41764190
);
4177
-SQLITE_API int sqlite3_create_function16(
4191
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
41784192
sqlite3 *db,
41794193
const void *zFunctionName,
41804194
int nArg,
41814195
int eTextRep,
41824196
void *pApp,
41834197
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
41844198
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
41854199
void (*xFinal)(sqlite3_context*)
41864200
);
4187
-SQLITE_API int sqlite3_create_function_v2(
4201
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
41884202
sqlite3 *db,
41894203
const char *zFunctionName,
41904204
int nArg,
41914205
int eTextRep,
41924206
void *pApp,
@@ -4228,16 +4242,16 @@
42284242
** to be supported. However, new applications should avoid
42294243
** the use of these functions. To encourage programmers to avoid
42304244
** these functions, we will not explain what they do.
42314245
*/
42324246
#ifndef SQLITE_OMIT_DEPRECATED
4233
-SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
4234
-SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
4235
-SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4236
-SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
4237
-SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
4238
-SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4247
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*);
4248
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*);
4249
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4250
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void);
4251
+SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void);
4252
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
42394253
void*,sqlite3_int64);
42404254
#endif
42414255
42424256
/*
42434257
** CAPI3REF: Obtaining SQL Function Parameter Values
@@ -4282,22 +4296,22 @@
42824296
** or [sqlite3_value_text16()].
42834297
**
42844298
** These routines must be called from the same thread as
42854299
** the SQL function that supplied the [sqlite3_value*] parameters.
42864300
*/
4287
-SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4288
-SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
4289
-SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
4290
-SQLITE_API double sqlite3_value_double(sqlite3_value*);
4291
-SQLITE_API int sqlite3_value_int(sqlite3_value*);
4292
-SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4293
-SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
4294
-SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
4295
-SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
4296
-SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
4297
-SQLITE_API int sqlite3_value_type(sqlite3_value*);
4298
-SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
4301
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*);
4302
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*);
4303
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*);
4304
+SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*);
4305
+SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*);
4306
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*);
4307
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*);
4308
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*);
4309
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*);
4310
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*);
4311
+SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*);
4312
+SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*);
42994313
43004314
/*
43014315
** CAPI3REF: Obtain Aggregate Function Context
43024316
**
43034317
** Implementations of aggregate SQL functions use this
@@ -4337,11 +4351,11 @@
43374351
** function.
43384352
**
43394353
** This routine must be called from the same thread in which
43404354
** the aggregate SQL function is running.
43414355
*/
4342
-SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
4356
+SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes);
43434357
43444358
/*
43454359
** CAPI3REF: User Data For Functions
43464360
**
43474361
** ^The sqlite3_user_data() interface returns a copy of
@@ -4351,11 +4365,11 @@
43514365
** registered the application defined function.
43524366
**
43534367
** This routine must be called from the same thread in which
43544368
** the application-defined function is running.
43554369
*/
4356
-SQLITE_API void *sqlite3_user_data(sqlite3_context*);
4370
+SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*);
43574371
43584372
/*
43594373
** CAPI3REF: Database Connection For Functions
43604374
**
43614375
** ^The sqlite3_context_db_handle() interface returns a copy of
@@ -4362,11 +4376,11 @@
43624376
** the pointer to the [database connection] (the 1st parameter)
43634377
** of the [sqlite3_create_function()]
43644378
** and [sqlite3_create_function16()] routines that originally
43654379
** registered the application defined function.
43664380
*/
4367
-SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4381
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
43684382
43694383
/*
43704384
** CAPI3REF: Function Auxiliary Data
43714385
**
43724386
** These functions may be used by (non-aggregate) SQL functions to
@@ -4414,12 +4428,12 @@
44144428
** values and [parameters] and expressions composed from the same.)^
44154429
**
44164430
** These routines must be called from the same thread in which
44174431
** the SQL function is running.
44184432
*/
4419
-SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
4420
-SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
4433
+SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N);
4434
+SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
44214435
44224436
44234437
/*
44244438
** CAPI3REF: Constants Defining Special Destructor Behavior
44254439
**
@@ -4550,30 +4564,30 @@
45504564
**
45514565
** If these routines are called from within the different thread
45524566
** than the one containing the application-defined function that received
45534567
** the [sqlite3_context] pointer, the results are undefined.
45544568
*/
4555
-SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4556
-SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
4569
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4570
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*,
45574571
sqlite3_uint64,void(*)(void*));
4558
-SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
4559
-SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
4560
-SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
4561
-SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
4562
-SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
4563
-SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
4564
-SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
4565
-SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4566
-SQLITE_API void sqlite3_result_null(sqlite3_context*);
4567
-SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4568
-SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
4572
+SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double);
4573
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int);
4574
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int);
4575
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*);
4576
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*);
4577
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int);
4578
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int);
4579
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4580
+SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*);
4581
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4582
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
45694583
void(*)(void*), unsigned char encoding);
4570
-SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4571
-SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4572
-SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4573
-SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4574
-SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
4584
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4585
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4586
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4587
+SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4588
+SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n);
45754589
45764590
/*
45774591
** CAPI3REF: Define New Collating Sequences
45784592
**
45794593
** ^These functions add, remove, or modify a [collation] associated
@@ -4650,26 +4664,26 @@
46504664
** is unfortunate but cannot be changed without breaking backwards
46514665
** compatibility.
46524666
**
46534667
** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
46544668
*/
4655
-SQLITE_API int sqlite3_create_collation(
4669
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
46564670
sqlite3*,
46574671
const char *zName,
46584672
int eTextRep,
46594673
void *pArg,
46604674
int(*xCompare)(void*,int,const void*,int,const void*)
46614675
);
4662
-SQLITE_API int sqlite3_create_collation_v2(
4676
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
46634677
sqlite3*,
46644678
const char *zName,
46654679
int eTextRep,
46664680
void *pArg,
46674681
int(*xCompare)(void*,int,const void*,int,const void*),
46684682
void(*xDestroy)(void*)
46694683
);
4670
-SQLITE_API int sqlite3_create_collation16(
4684
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
46714685
sqlite3*,
46724686
const void *zName,
46734687
int eTextRep,
46744688
void *pArg,
46754689
int(*xCompare)(void*,int,const void*,int,const void*)
@@ -4699,16 +4713,16 @@
46994713
**
47004714
** The callback function should register the desired collation using
47014715
** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
47024716
** [sqlite3_create_collation_v2()].
47034717
*/
4704
-SQLITE_API int sqlite3_collation_needed(
4718
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
47054719
sqlite3*,
47064720
void*,
47074721
void(*)(void*,sqlite3*,int eTextRep,const char*)
47084722
);
4709
-SQLITE_API int sqlite3_collation_needed16(
4723
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
47104724
sqlite3*,
47114725
void*,
47124726
void(*)(void*,sqlite3*,int eTextRep,const void*)
47134727
);
47144728
@@ -4718,15 +4732,15 @@
47184732
** called right after sqlite3_open().
47194733
**
47204734
** The code to implement this API is not available in the public release
47214735
** of SQLite.
47224736
*/
4723
-SQLITE_API int sqlite3_key(
4737
+SQLITE_API int SQLITE_STDCALL sqlite3_key(
47244738
sqlite3 *db, /* Database to be rekeyed */
47254739
const void *pKey, int nKey /* The key */
47264740
);
4727
-SQLITE_API int sqlite3_key_v2(
4741
+SQLITE_API int SQLITE_STDCALL sqlite3_key_v2(
47284742
sqlite3 *db, /* Database to be rekeyed */
47294743
const char *zDbName, /* Name of the database */
47304744
const void *pKey, int nKey /* The key */
47314745
);
47324746
@@ -4736,35 +4750,35 @@
47364750
** database is decrypted.
47374751
**
47384752
** The code to implement this API is not available in the public release
47394753
** of SQLite.
47404754
*/
4741
-SQLITE_API int sqlite3_rekey(
4755
+SQLITE_API int SQLITE_STDCALL sqlite3_rekey(
47424756
sqlite3 *db, /* Database to be rekeyed */
47434757
const void *pKey, int nKey /* The new key */
47444758
);
4745
-SQLITE_API int sqlite3_rekey_v2(
4759
+SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2(
47464760
sqlite3 *db, /* Database to be rekeyed */
47474761
const char *zDbName, /* Name of the database */
47484762
const void *pKey, int nKey /* The new key */
47494763
);
47504764
47514765
/*
47524766
** Specify the activation key for a SEE database. Unless
47534767
** activated, none of the SEE routines will work.
47544768
*/
4755
-SQLITE_API void sqlite3_activate_see(
4769
+SQLITE_API void SQLITE_STDCALL sqlite3_activate_see(
47564770
const char *zPassPhrase /* Activation phrase */
47574771
);
47584772
#endif
47594773
47604774
#ifdef SQLITE_ENABLE_CEROD
47614775
/*
47624776
** Specify the activation key for a CEROD database. Unless
47634777
** activated, none of the CEROD routines will work.
47644778
*/
4765
-SQLITE_API void sqlite3_activate_cerod(
4779
+SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod(
47664780
const char *zPassPhrase /* Activation phrase */
47674781
);
47684782
#endif
47694783
47704784
/*
@@ -4782,11 +4796,11 @@
47824796
** method of the default [sqlite3_vfs] object. If the xSleep() method
47834797
** of the default VFS is not implemented correctly, or not implemented at
47844798
** all, then the behavior of sqlite3_sleep() may deviate from the description
47854799
** in the previous paragraphs.
47864800
*/
4787
-SQLITE_API int sqlite3_sleep(int);
4801
+SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int);
47884802
47894803
/*
47904804
** CAPI3REF: Name Of The Folder Holding Temporary Files
47914805
**
47924806
** ^(If this global variable is made to point to a string which is
@@ -4900,11 +4914,11 @@
49004914
**
49014915
** If another thread changes the autocommit status of the database
49024916
** connection while this routine is running, then the return value
49034917
** is undefined.
49044918
*/
4905
-SQLITE_API int sqlite3_get_autocommit(sqlite3*);
4919
+SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*);
49064920
49074921
/*
49084922
** CAPI3REF: Find The Database Handle Of A Prepared Statement
49094923
**
49104924
** ^The sqlite3_db_handle interface returns the [database connection] handle
@@ -4912,11 +4926,11 @@
49124926
** returned by sqlite3_db_handle is the same [database connection]
49134927
** that was the first argument
49144928
** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
49154929
** create the statement in the first place.
49164930
*/
4917
-SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
4931
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*);
49184932
49194933
/*
49204934
** CAPI3REF: Return The Filename For A Database Connection
49214935
**
49224936
** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
@@ -4928,20 +4942,20 @@
49284942
** ^The filename returned by this function is the output of the
49294943
** xFullPathname method of the [VFS]. ^In other words, the filename
49304944
** will be an absolute pathname, even if the filename used
49314945
** to open the database originally was a URI or relative pathname.
49324946
*/
4933
-SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
4947
+SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName);
49344948
49354949
/*
49364950
** CAPI3REF: Determine if a database is read-only
49374951
**
49384952
** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
49394953
** of connection D is read-only, 0 if it is read/write, or -1 if N is not
49404954
** the name of a database on connection D.
49414955
*/
4942
-SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
4956
+SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
49434957
49444958
/*
49454959
** CAPI3REF: Find the next prepared statement
49464960
**
49474961
** ^This interface returns a pointer to the next [prepared statement] after
@@ -4952,11 +4966,11 @@
49524966
**
49534967
** The [database connection] pointer D in a call to
49544968
** [sqlite3_next_stmt(D,S)] must refer to an open database
49554969
** connection and in particular must not be a NULL pointer.
49564970
*/
4957
-SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
4971
+SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
49584972
49594973
/*
49604974
** CAPI3REF: Commit And Rollback Notification Callbacks
49614975
**
49624976
** ^The sqlite3_commit_hook() interface registers a callback
@@ -5000,12 +5014,12 @@
50005014
** ^The rollback callback is not invoked if a transaction is
50015015
** automatically rolled back because the database connection is closed.
50025016
**
50035017
** See also the [sqlite3_update_hook()] interface.
50045018
*/
5005
-SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5006
-SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
5019
+SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5020
+SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
50075021
50085022
/*
50095023
** CAPI3REF: Data Change Notification Callbacks
50105024
**
50115025
** ^The sqlite3_update_hook() interface registers a callback function
@@ -5051,11 +5065,11 @@
50515065
** the first call on D.
50525066
**
50535067
** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
50545068
** interfaces.
50555069
*/
5056
-SQLITE_API void *sqlite3_update_hook(
5070
+SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
50575071
sqlite3*,
50585072
void(*)(void *,int ,char const *,char const *,sqlite3_int64),
50595073
void*
50605074
);
50615075
@@ -5091,11 +5105,11 @@
50915105
** This interface is threadsafe on processors where writing a
50925106
** 32-bit integer is atomic.
50935107
**
50945108
** See Also: [SQLite Shared-Cache Mode]
50955109
*/
5096
-SQLITE_API int sqlite3_enable_shared_cache(int);
5110
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int);
50975111
50985112
/*
50995113
** CAPI3REF: Attempt To Free Heap Memory
51005114
**
51015115
** ^The sqlite3_release_memory() interface attempts to free N bytes
@@ -5107,11 +5121,11 @@
51075121
** ^The sqlite3_release_memory() routine is a no-op returning zero
51085122
** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
51095123
**
51105124
** See also: [sqlite3_db_release_memory()]
51115125
*/
5112
-SQLITE_API int sqlite3_release_memory(int);
5126
+SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int);
51135127
51145128
/*
51155129
** CAPI3REF: Free Memory Used By A Database Connection
51165130
**
51175131
** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
@@ -5120,11 +5134,11 @@
51205134
** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
51215135
** omitted.
51225136
**
51235137
** See also: [sqlite3_release_memory()]
51245138
*/
5125
-SQLITE_API int sqlite3_db_release_memory(sqlite3*);
5139
+SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*);
51265140
51275141
/*
51285142
** CAPI3REF: Impose A Limit On Heap Size
51295143
**
51305144
** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
@@ -5172,11 +5186,11 @@
51725186
** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
51735187
**
51745188
** The circumstances under which SQLite will enforce the soft heap limit may
51755189
** changes in future releases of SQLite.
51765190
*/
5177
-SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
5191
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N);
51785192
51795193
/*
51805194
** CAPI3REF: Deprecated Soft Heap Limit Interface
51815195
** DEPRECATED
51825196
**
@@ -5183,11 +5197,11 @@
51835197
** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
51845198
** interface. This routine is provided for historical compatibility
51855199
** only. All new applications should use the
51865200
** [sqlite3_soft_heap_limit64()] interface rather than this one.
51875201
*/
5188
-SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
5202
+SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
51895203
51905204
51915205
/*
51925206
** CAPI3REF: Extract Metadata About A Column Of A Table
51935207
**
@@ -5252,11 +5266,11 @@
52525266
**
52535267
** ^This function causes all database schemas to be read from disk and
52545268
** parsed, if that has not already been done, and returns an error if
52555269
** any errors are encountered while loading the schema.
52565270
*/
5257
-SQLITE_API int sqlite3_table_column_metadata(
5271
+SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
52585272
sqlite3 *db, /* Connection handle */
52595273
const char *zDbName, /* Database name or NULL */
52605274
const char *zTableName, /* Table name */
52615275
const char *zColumnName, /* Column name */
52625276
char const **pzDataType, /* OUTPUT: Declared data type */
@@ -5298,11 +5312,11 @@
52985312
** [sqlite3_enable_load_extension()] prior to calling this API,
52995313
** otherwise an error will be returned.
53005314
**
53015315
** See also the [load_extension() SQL function].
53025316
*/
5303
-SQLITE_API int sqlite3_load_extension(
5317
+SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
53045318
sqlite3 *db, /* Load the extension into this database connection */
53055319
const char *zFile, /* Name of the shared library containing extension */
53065320
const char *zProc, /* Entry point. Derived from zFile if 0 */
53075321
char **pzErrMsg /* Put error message here if not 0 */
53085322
);
@@ -5318,11 +5332,11 @@
53185332
** ^Extension loading is off by default.
53195333
** ^Call the sqlite3_enable_load_extension() routine with onoff==1
53205334
** to turn extension loading on and call it with onoff==0 to turn
53215335
** it back off again.
53225336
*/
5323
-SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
5337
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
53245338
53255339
/*
53265340
** CAPI3REF: Automatically Load Statically Linked Extensions
53275341
**
53285342
** ^This interface causes the xEntryPoint() function to be invoked for
@@ -5356,11 +5370,11 @@
53565370
** will be called more than once for each database connection that is opened.
53575371
**
53585372
** See also: [sqlite3_reset_auto_extension()]
53595373
** and [sqlite3_cancel_auto_extension()]
53605374
*/
5361
-SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
5375
+SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
53625376
53635377
/*
53645378
** CAPI3REF: Cancel Automatic Extension Loading
53655379
**
53665380
** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5368,19 +5382,19 @@
53685382
** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
53695383
** routine returns 1 if initialization routine X was successfully
53705384
** unregistered and it returns 0 if X was not on the list of initialization
53715385
** routines.
53725386
*/
5373
-SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5387
+SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
53745388
53755389
/*
53765390
** CAPI3REF: Reset Automatic Extension Loading
53775391
**
53785392
** ^This interface disables all automatic extensions previously
53795393
** registered using [sqlite3_auto_extension()].
53805394
*/
5381
-SQLITE_API void sqlite3_reset_auto_extension(void);
5395
+SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void);
53825396
53835397
/*
53845398
** The interface to the virtual-table mechanism is currently considered
53855399
** to be experimental. The interface might change in incompatible ways.
53865400
** If this is a problem for you, do not use the interface at this time.
@@ -5579,17 +5593,17 @@
55795593
** be invoked if the call to sqlite3_create_module_v2() fails.
55805594
** ^The sqlite3_create_module()
55815595
** interface is equivalent to sqlite3_create_module_v2() with a NULL
55825596
** destructor.
55835597
*/
5584
-SQLITE_API int sqlite3_create_module(
5598
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
55855599
sqlite3 *db, /* SQLite connection to register module with */
55865600
const char *zName, /* Name of the module */
55875601
const sqlite3_module *p, /* Methods for the module */
55885602
void *pClientData /* Client data for xCreate/xConnect */
55895603
);
5590
-SQLITE_API int sqlite3_create_module_v2(
5604
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
55915605
sqlite3 *db, /* SQLite connection to register module with */
55925606
const char *zName, /* Name of the module */
55935607
const sqlite3_module *p, /* Methods for the module */
55945608
void *pClientData, /* Client data for xCreate/xConnect */
55955609
void(*xDestroy)(void*) /* Module destructor function */
@@ -5613,11 +5627,11 @@
56135627
** is delivered up to the client application, the string will be automatically
56145628
** freed by sqlite3_free() and the zErrMsg field will be zeroed.
56155629
*/
56165630
struct sqlite3_vtab {
56175631
const sqlite3_module *pModule; /* The module for this virtual table */
5618
- int nRef; /* NO LONGER USED */
5632
+ int nRef; /* Number of open cursors */
56195633
char *zErrMsg; /* Error message from sqlite3_mprintf() */
56205634
/* Virtual table implementations will typically add additional fields */
56215635
};
56225636
56235637
/*
@@ -5648,11 +5662,11 @@
56485662
** ^The [xCreate] and [xConnect] methods of a
56495663
** [virtual table module] call this interface
56505664
** to declare the format (the names and datatypes of the columns) of
56515665
** the virtual tables they implement.
56525666
*/
5653
-SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
5667
+SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL);
56545668
56555669
/*
56565670
** CAPI3REF: Overload A Function For A Virtual Table
56575671
**
56585672
** ^(Virtual tables can provide alternative implementations of functions
@@ -5666,11 +5680,11 @@
56665680
** of the new function always causes an exception to be thrown. So
56675681
** the new function is not good for anything by itself. Its only
56685682
** purpose is to be a placeholder function that can be overloaded
56695683
** by a [virtual table].
56705684
*/
5671
-SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
5685
+SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
56725686
56735687
/*
56745688
** The interface to the virtual-table mechanism defined above (back up
56755689
** to a comment remarkably similar to this one) is currently considered
56765690
** to be experimental. The interface might change in incompatible ways.
@@ -5763,11 +5777,11 @@
57635777
** zero-filled blob to read or write using the incremental-blob interface.
57645778
**
57655779
** To avoid a resource leak, every open [BLOB handle] should eventually
57665780
** be released by a call to [sqlite3_blob_close()].
57675781
*/
5768
-SQLITE_API int sqlite3_blob_open(
5782
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
57695783
sqlite3*,
57705784
const char *zDb,
57715785
const char *zTable,
57725786
const char *zColumn,
57735787
sqlite3_int64 iRow,
@@ -5795,11 +5809,11 @@
57955809
** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
57965810
** always returns zero.
57975811
**
57985812
** ^This function sets the database handle error code and message.
57995813
*/
5800
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
5814
+SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
58015815
58025816
/*
58035817
** CAPI3REF: Close A BLOB Handle
58045818
**
58055819
** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
@@ -5817,11 +5831,11 @@
58175831
** with a null pointer (such as would be returned by a failed call to
58185832
** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
58195833
** is passed a valid open blob handle, the values returned by the
58205834
** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
58215835
*/
5822
-SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
5836
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *);
58235837
58245838
/*
58255839
** CAPI3REF: Return The Size Of An Open BLOB
58265840
**
58275841
** ^Returns the size in bytes of the BLOB accessible via the
@@ -5832,11 +5846,11 @@
58325846
** This routine only works on a [BLOB handle] which has been created
58335847
** by a prior successful call to [sqlite3_blob_open()] and which has not
58345848
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
58355849
** to this routine results in undefined and probably undesirable behavior.
58365850
*/
5837
-SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
5851
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *);
58385852
58395853
/*
58405854
** CAPI3REF: Read Data From A BLOB Incrementally
58415855
**
58425856
** ^(This function is used to read data from an open [BLOB handle] into a
@@ -5860,11 +5874,11 @@
58605874
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
58615875
** to this routine results in undefined and probably undesirable behavior.
58625876
**
58635877
** See also: [sqlite3_blob_write()].
58645878
*/
5865
-SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
5879
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
58665880
58675881
/*
58685882
** CAPI3REF: Write Data Into A BLOB Incrementally
58695883
**
58705884
** ^(This function is used to write data into an open [BLOB handle] from a
@@ -5901,11 +5915,11 @@
59015915
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
59025916
** to this routine results in undefined and probably undesirable behavior.
59035917
**
59045918
** See also: [sqlite3_blob_read()].
59055919
*/
5906
-SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
5920
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
59075921
59085922
/*
59095923
** CAPI3REF: Virtual File System Objects
59105924
**
59115925
** A virtual filesystem (VFS) is an [sqlite3_vfs] object
@@ -5932,13 +5946,13 @@
59325946
**
59335947
** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
59345948
** ^(If the default VFS is unregistered, another VFS is chosen as
59355949
** the default. The choice for the new VFS is arbitrary.)^
59365950
*/
5937
-SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
5938
-SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
5939
-SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
5951
+SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName);
5952
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
5953
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*);
59405954
59415955
/*
59425956
** CAPI3REF: Mutexes
59435957
**
59445958
** The SQLite core uses these routines for thread
@@ -6047,15 +6061,15 @@
60476061
** sqlite3_mutex_leave() is a NULL pointer, then all three routines
60486062
** behave as no-ops.
60496063
**
60506064
** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
60516065
*/
6052
-SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
6053
-SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
6054
-SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
6055
-SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
6056
-SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
6066
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int);
6067
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*);
6068
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*);
6069
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*);
6070
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*);
60576071
60586072
/*
60596073
** CAPI3REF: Mutex Methods Object
60606074
**
60616075
** An instance of this structure defines the low-level routines
@@ -6161,12 +6175,12 @@
61616175
** call to sqlite3_mutex_held() to fail, so a non-zero return is
61626176
** the appropriate thing to do. The sqlite3_mutex_notheld()
61636177
** interface should also return 1 when given a NULL pointer.
61646178
*/
61656179
#ifndef NDEBUG
6166
-SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
6167
-SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
6180
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*);
6181
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*);
61686182
#endif
61696183
61706184
/*
61716185
** CAPI3REF: Mutex Types
61726186
**
@@ -6198,11 +6212,11 @@
61986212
** serializes access to the [database connection] given in the argument
61996213
** when the [threading mode] is Serialized.
62006214
** ^If the [threading mode] is Single-thread or Multi-thread then this
62016215
** routine returns a NULL pointer.
62026216
*/
6203
-SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
6217
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*);
62046218
62056219
/*
62066220
** CAPI3REF: Low-Level Control Of Database Files
62076221
**
62086222
** ^The [sqlite3_file_control()] interface makes a direct call to the
@@ -6232,11 +6246,11 @@
62326246
** an incorrect zDbName and an SQLITE_ERROR return from the underlying
62336247
** xFileControl method.
62346248
**
62356249
** See also: [SQLITE_FCNTL_LOCKSTATE]
62366250
*/
6237
-SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
6251
+SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
62386252
62396253
/*
62406254
** CAPI3REF: Testing Interface
62416255
**
62426256
** ^The sqlite3_test_control() interface is used to read out internal
@@ -6251,11 +6265,11 @@
62516265
** The details of the operation codes, their meanings, the parameters
62526266
** they take, and what they do are all subject to change without notice.
62536267
** Unlike most of the SQLite API, this function is not guaranteed to
62546268
** operate consistently from one release to the next.
62556269
*/
6256
-SQLITE_API int sqlite3_test_control(int op, ...);
6270
+SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...);
62576271
62586272
/*
62596273
** CAPI3REF: Testing Interface Operation Codes
62606274
**
62616275
** These constants are the valid operation code parameters used
@@ -6291,11 +6305,11 @@
62916305
#define SQLITE_TESTCTRL_LAST 25
62926306
62936307
/*
62946308
** CAPI3REF: SQLite Runtime Status
62956309
**
6296
-** ^This interface is used to retrieve runtime status information
6310
+** ^These interfaces are used to retrieve runtime status information
62976311
** about the performance of SQLite, and optionally to reset various
62986312
** highwater marks. ^The first argument is an integer code for
62996313
** the specific parameter to measure. ^(Recognized integer codes
63006314
** are of the form [status parameters | SQLITE_STATUS_...].)^
63016315
** ^The current value of the parameter is returned into *pCurrent.
@@ -6305,23 +6319,26 @@
63056319
** value. For those parameters
63066320
** nothing is written into *pHighwater and the resetFlag is ignored.)^
63076321
** ^(Other parameters record only the highwater mark and not the current
63086322
** value. For these latter parameters nothing is written into *pCurrent.)^
63096323
**
6310
-** ^The sqlite3_status() routine returns SQLITE_OK on success and a
6311
-** non-zero [error code] on failure.
6324
+** ^The sqlite3_status() and sqlite3_status64() routines return
6325
+** SQLITE_OK on success and a non-zero [error code] on failure.
63126326
**
6313
-** This routine is threadsafe but is not atomic. This routine can be
6314
-** called while other threads are running the same or different SQLite
6315
-** interfaces. However the values returned in *pCurrent and
6316
-** *pHighwater reflect the status of SQLite at different points in time
6317
-** and it is possible that another thread might change the parameter
6318
-** in between the times when *pCurrent and *pHighwater are written.
6327
+** If either the current value or the highwater mark is too large to
6328
+** be represented by a 32-bit integer, then the values returned by
6329
+** sqlite3_status() are undefined.
63196330
**
63206331
** See also: [sqlite3_db_status()]
63216332
*/
6322
-SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6333
+SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6334
+SQLITE_API int SQLITE_STDCALL sqlite3_status64(
6335
+ int op,
6336
+ sqlite3_int64 *pCurrent,
6337
+ sqlite3_int64 *pHighwater,
6338
+ int resetFlag
6339
+);
63236340
63246341
63256342
/*
63266343
** CAPI3REF: Status Parameters
63276344
** KEYWORDS: {status parameters}
@@ -6435,11 +6452,11 @@
64356452
** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
64366453
** non-zero [error code] on failure.
64376454
**
64386455
** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
64396456
*/
6440
-SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
6457
+SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
64416458
64426459
/*
64436460
** CAPI3REF: Status Parameters for database connections
64446461
** KEYWORDS: {SQLITE_DBSTATUS options}
64456462
**
@@ -6564,11 +6581,11 @@
65646581
** ^If the resetFlg is true, then the counter is reset to zero after this
65656582
** interface call returns.
65666583
**
65676584
** See also: [sqlite3_status()] and [sqlite3_db_status()].
65686585
*/
6569
-SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
6586
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
65706587
65716588
/*
65726589
** CAPI3REF: Status Parameters for prepared statements
65736590
** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}
65746591
**
@@ -7033,20 +7050,20 @@
70337050
** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
70347051
** APIs are not strictly speaking threadsafe. If they are invoked at the
70357052
** same time as another thread is invoking sqlite3_backup_step() it is
70367053
** possible that they return invalid values.
70377054
*/
7038
-SQLITE_API sqlite3_backup *sqlite3_backup_init(
7055
+SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
70397056
sqlite3 *pDest, /* Destination database handle */
70407057
const char *zDestName, /* Destination database name */
70417058
sqlite3 *pSource, /* Source database handle */
70427059
const char *zSourceName /* Source database name */
70437060
);
7044
-SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
7045
-SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
7046
-SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
7047
-SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
7061
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage);
7062
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p);
7063
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p);
7064
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p);
70487065
70497066
/*
70507067
** CAPI3REF: Unlock Notification
70517068
**
70527069
** ^When running in shared-cache mode, a database operation may fail with
@@ -7158,11 +7175,11 @@
71587175
** by an sqlite3_step() call. ^(If there is a blocking connection, then the
71597176
** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
71607177
** the special "DROP TABLE/INDEX" case, the extended error code is just
71617178
** SQLITE_LOCKED.)^
71627179
*/
7163
-SQLITE_API int sqlite3_unlock_notify(
7180
+SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
71647181
sqlite3 *pBlocked, /* Waiting connection */
71657182
void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
71667183
void *pNotifyArg /* Argument to pass to xNotify */
71677184
);
71687185
@@ -7173,12 +7190,12 @@
71737190
** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
71747191
** and extensions to compare the contents of two buffers containing UTF-8
71757192
** strings in a case-independent fashion, using the same definition of "case
71767193
** independence" that SQLite uses internally when comparing identifiers.
71777194
*/
7178
-SQLITE_API int sqlite3_stricmp(const char *, const char *);
7179
-SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
7195
+SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *);
7196
+SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
71807197
71817198
/*
71827199
** CAPI3REF: String Globbing
71837200
*
71847201
** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
@@ -7189,11 +7206,11 @@
71897206
** sensitive.
71907207
**
71917208
** Note that this routine returns zero on a match and non-zero if the strings
71927209
** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
71937210
*/
7194
-SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
7211
+SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
71957212
71967213
/*
71977214
** CAPI3REF: Error Logging Interface
71987215
**
71997216
** ^The [sqlite3_log()] interface writes a message into the [error log]
@@ -7212,11 +7229,11 @@
72127229
** will not use dynamically allocated memory. The log message is stored in
72137230
** a fixed-length buffer on the stack. If the log message is longer than
72147231
** a few hundred characters, it will be truncated to the length of the
72157232
** buffer.
72167233
*/
7217
-SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
7234
+SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...);
72187235
72197236
/*
72207237
** CAPI3REF: Write-Ahead Log Commit Hook
72217238
**
72227239
** ^The [sqlite3_wal_hook()] function is used to register a callback that
@@ -7247,11 +7264,11 @@
72477264
** previously registered write-ahead log callback. ^Note that the
72487265
** [sqlite3_wal_autocheckpoint()] interface and the
72497266
** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
72507267
** those overwrite any prior [sqlite3_wal_hook()] settings.
72517268
*/
7252
-SQLITE_API void *sqlite3_wal_hook(
7269
+SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
72537270
sqlite3*,
72547271
int(*)(void *,sqlite3*,const char*,int),
72557272
void*
72567273
);
72577274
@@ -7281,11 +7298,11 @@
72817298
** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
72827299
** pages. The use of this interface
72837300
** is only necessary if the default setting is found to be suboptimal
72847301
** for a particular application.
72857302
*/
7286
-SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
7303
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
72877304
72887305
/*
72897306
** CAPI3REF: Checkpoint a database
72907307
**
72917308
** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
@@ -7302,11 +7319,11 @@
73027319
** interface was added. This interface is retained for backwards
73037320
** compatibility and as a convenience for applications that need to manually
73047321
** start a callback but which do not need the full power (and corresponding
73057322
** complication) of [sqlite3_wal_checkpoint_v2()].
73067323
*/
7307
-SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
7324
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
73087325
73097326
/*
73107327
** CAPI3REF: Checkpoint a database
73117328
**
73127329
** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
@@ -7395,11 +7412,11 @@
73957412
** [sqlite3_errcode()] and [sqlite3_errmsg()].
73967413
**
73977414
** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
73987415
** from SQL.
73997416
*/
7400
-SQLITE_API int sqlite3_wal_checkpoint_v2(
7417
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
74017418
sqlite3 *db, /* Database handle */
74027419
const char *zDb, /* Name of attached database (or NULL) */
74037420
int eMode, /* SQLITE_CHECKPOINT_* value */
74047421
int *pnLog, /* OUT: Size of WAL log in frames */
74057422
int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -7431,11 +7448,11 @@
74317448
**
74327449
** At present, there is only one option that may be configured using
74337450
** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
74347451
** may be added in the future.
74357452
*/
7436
-SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
7453
+SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...);
74377454
74387455
/*
74397456
** CAPI3REF: Virtual Table Configuration Options
74407457
**
74417458
** These macros define the various options to the
@@ -7484,11 +7501,11 @@
74847501
** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],
74857502
** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode
74867503
** of the SQL statement that triggered the call to the [xUpdate] method of the
74877504
** [virtual table].
74887505
*/
7489
-SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
7506
+SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *);
74907507
74917508
/*
74927509
** CAPI3REF: Conflict resolution modes
74937510
** KEYWORDS: {conflict resolution mode}
74947511
**
@@ -7588,11 +7605,11 @@
75887605
** as if the loop did not exist - it returns non-zero and leave the variable
75897606
** that pOut points to unchanged.
75907607
**
75917608
** See also: [sqlite3_stmt_scanstatus_reset()]
75927609
*/
7593
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_scanstatus(
7610
+SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_stmt_scanstatus(
75947611
sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
75957612
int idx, /* Index of loop to report on */
75967613
int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
75977614
void *pOut /* Result written here */
75987615
);
@@ -7603,11 +7620,11 @@
76037620
** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
76047621
**
76057622
** This API is only available if the library is built with pre-processor
76067623
** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
76077624
*/
7608
-SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
7625
+SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
76097626
76107627
76117628
/*
76127629
** Undo the hack that converts floating point types to integer for
76137630
** builds on processors without floating point support.
@@ -7658,11 +7675,11 @@
76587675
** Register a geometry callback named zGeom that can be used as part of an
76597676
** R-Tree geometry query as follows:
76607677
**
76617678
** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
76627679
*/
7663
-SQLITE_API int sqlite3_rtree_geometry_callback(
7680
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
76647681
sqlite3 *db,
76657682
const char *zGeom,
76667683
int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
76677684
void *pContext
76687685
);
@@ -7684,11 +7701,11 @@
76847701
** Register a 2nd-generation geometry callback named zScore that can be
76857702
** used as part of an R-Tree geometry query as follows:
76867703
**
76877704
** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
76887705
*/
7689
-SQLITE_API int sqlite3_rtree_query_callback(
7706
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
76907707
sqlite3 *db,
76917708
const char *zQueryFunc,
76927709
int (*xQueryFunc)(sqlite3_rtree_query_info*),
76937710
void *pContext,
76947711
void (*xDestructor)(void*)
76957712
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -41,20 +41,24 @@
41 extern "C" {
42 #endif
43
44
45 /*
46 ** Add the ability to override 'extern'
47 */
48 #ifndef SQLITE_EXTERN
49 # define SQLITE_EXTERN extern
50 #endif
51
52 #ifndef SQLITE_API
53 # define SQLITE_API
54 #endif
55
 
 
 
 
 
56
57 /*
58 ** These no-op macros are used in front of interfaces to mark those
59 ** interfaces as either deprecated or experimental. New applications
60 ** should not use deprecated interfaces - they are supported for backwards
@@ -107,11 +111,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.9"
111 #define SQLITE_VERSION_NUMBER 3008009
112 #define SQLITE_SOURCE_ID "2015-03-09 10:40:48 e5da5e7d5dc5a3438ced23f1ee83e695abc29c45"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -140,13 +144,13 @@
140 ** [SQLITE_SOURCE_ID] C preprocessor macro.
141 **
142 ** See also: [sqlite_version()] and [sqlite_source_id()].
143 */
144 SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
145 SQLITE_API const char *sqlite3_libversion(void);
146 SQLITE_API const char *sqlite3_sourceid(void);
147 SQLITE_API int sqlite3_libversion_number(void);
148
149 /*
150 ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
151 **
152 ** ^The sqlite3_compileoption_used() function returns 0 or 1
@@ -167,12 +171,12 @@
167 **
168 ** See also: SQL functions [sqlite_compileoption_used()] and
169 ** [sqlite_compileoption_get()] and the [compile_options pragma].
170 */
171 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
172 SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
173 SQLITE_API const char *sqlite3_compileoption_get(int N);
174 #endif
175
176 /*
177 ** CAPI3REF: Test To See If The Library Is Threadsafe
178 **
@@ -207,11 +211,11 @@
207 ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
208 ** is unchanged by calls to sqlite3_config().)^
209 **
210 ** See the [threading mode] documentation for additional information.
211 */
212 SQLITE_API int sqlite3_threadsafe(void);
213
214 /*
215 ** CAPI3REF: Database Connection Handle
216 ** KEYWORDS: {database connection} {database connections}
217 **
@@ -303,12 +307,12 @@
303 ** from [sqlite3_open()], [sqlite3_open16()], or
304 ** [sqlite3_open_v2()], and not previously closed.
305 ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
306 ** argument is a harmless no-op.
307 */
308 SQLITE_API int sqlite3_close(sqlite3*);
309 SQLITE_API int sqlite3_close_v2(sqlite3*);
310
311 /*
312 ** The type for a callback function.
313 ** This is legacy and deprecated. It is included for historical
314 ** compatibility and is not documented.
@@ -374,11 +378,11 @@
374 ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
375 ** <li> The application must not modify the SQL statement text passed into
376 ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
377 ** </ul>
378 */
379 SQLITE_API int sqlite3_exec(
380 sqlite3*, /* An open database */
381 const char *sql, /* SQL to be evaluated */
382 int (*callback)(void*,int,char**,char**), /* Callback function */
383 void *, /* 1st argument to callback */
384 char **errmsg /* Error msg written here */
@@ -948,10 +952,17 @@
948 ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
949 ** opcode causes the xFileControl method to swap the file handle with the one
950 ** pointed to by the pArg argument. This capability is used during testing
951 ** and only needs to be supported when SQLITE_TEST is defined.
952 **
 
 
 
 
 
 
 
953 ** </ul>
954 */
955 #define SQLITE_FCNTL_LOCKSTATE 1
956 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
957 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
@@ -972,10 +983,11 @@
972 #define SQLITE_FCNTL_TRACE 19
973 #define SQLITE_FCNTL_HAS_MOVED 20
974 #define SQLITE_FCNTL_SYNC 21
975 #define SQLITE_FCNTL_COMMIT_PHASETWO 22
976 #define SQLITE_FCNTL_WIN32_SET_HANDLE 23
 
977
978 /* deprecated names */
979 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
980 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
981 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -1326,14 +1338,14 @@
1326 ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
1327 ** implementation of sqlite3_os_init() or sqlite3_os_end()
1328 ** must return [SQLITE_OK] on success and some other [error code] upon
1329 ** failure.
1330 */
1331 SQLITE_API int sqlite3_initialize(void);
1332 SQLITE_API int sqlite3_shutdown(void);
1333 SQLITE_API int sqlite3_os_init(void);
1334 SQLITE_API int sqlite3_os_end(void);
1335
1336 /*
1337 ** CAPI3REF: Configuring The SQLite Library
1338 **
1339 ** The sqlite3_config() interface is used to make global configuration
@@ -1360,11 +1372,11 @@
1360 **
1361 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1362 ** ^If the option is unknown or SQLite is unable to set the option
1363 ** then this routine returns a non-zero [error code].
1364 */
1365 SQLITE_API int sqlite3_config(int, ...);
1366
1367 /*
1368 ** CAPI3REF: Configure database connections
1369 **
1370 ** The sqlite3_db_config() interface is used to make configuration
@@ -1378,11 +1390,11 @@
1378 ** Subsequent arguments vary depending on the configuration verb.
1379 **
1380 ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
1381 ** the call is considered successful.
1382 */
1383 SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
1384
1385 /*
1386 ** CAPI3REF: Memory Allocation Routines
1387 **
1388 ** An instance of this object defines the interface between SQLite
@@ -1538,11 +1550,11 @@
1538 ** disabled, the following SQLite interfaces become non-operational:
1539 ** <ul>
1540 ** <li> [sqlite3_memory_used()]
1541 ** <li> [sqlite3_memory_highwater()]
1542 ** <li> [sqlite3_soft_heap_limit64()]
1543 ** <li> [sqlite3_status()]
1544 ** </ul>)^
1545 ** ^Memory allocation statistics are enabled by default unless SQLite is
1546 ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
1547 ** allocation statistics are disabled by default.
1548 ** </dd>
@@ -1866,11 +1878,11 @@
1866 **
1867 ** ^The sqlite3_extended_result_codes() routine enables or disables the
1868 ** [extended result codes] feature of SQLite. ^The extended result
1869 ** codes are disabled by default for historical compatibility.
1870 */
1871 SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
1872
1873 /*
1874 ** CAPI3REF: Last Insert Rowid
1875 **
1876 ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
@@ -1917,11 +1929,11 @@
1917 ** function is running and thus changes the last insert [rowid],
1918 ** then the value returned by [sqlite3_last_insert_rowid()] is
1919 ** unpredictable and might not equal either the old or the new
1920 ** last insert [rowid].
1921 */
1922 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
1923
1924 /*
1925 ** CAPI3REF: Count The Number Of Rows Modified
1926 **
1927 ** ^This function returns the number of rows modified, inserted or
@@ -1969,11 +1981,11 @@
1969 **
1970 ** If a separate thread makes changes on the same database connection
1971 ** while [sqlite3_changes()] is running then the value returned
1972 ** is unpredictable and not meaningful.
1973 */
1974 SQLITE_API int sqlite3_changes(sqlite3*);
1975
1976 /*
1977 ** CAPI3REF: Total Number Of Rows Modified
1978 **
1979 ** ^This function returns the total number of rows inserted, modified or
@@ -1992,11 +2004,11 @@
1992 **
1993 ** If a separate thread makes changes on the same database connection
1994 ** while [sqlite3_total_changes()] is running then the value
1995 ** returned is unpredictable and not meaningful.
1996 */
1997 SQLITE_API int sqlite3_total_changes(sqlite3*);
1998
1999 /*
2000 ** CAPI3REF: Interrupt A Long-Running Query
2001 **
2002 ** ^This function causes any pending database operation to abort and
@@ -2031,11 +2043,11 @@
2031 ** that are started after the sqlite3_interrupt() call returns.
2032 **
2033 ** If the database connection closes while [sqlite3_interrupt()]
2034 ** is running then bad things will likely happen.
2035 */
2036 SQLITE_API void sqlite3_interrupt(sqlite3*);
2037
2038 /*
2039 ** CAPI3REF: Determine If An SQL Statement Is Complete
2040 **
2041 ** These routines are useful during command-line input to determine if the
@@ -2066,12 +2078,12 @@
2066 ** UTF-8 string.
2067 **
2068 ** The input to [sqlite3_complete16()] must be a zero-terminated
2069 ** UTF-16 string in native byte order.
2070 */
2071 SQLITE_API int sqlite3_complete(const char *sql);
2072 SQLITE_API int sqlite3_complete16(const void *sql);
2073
2074 /*
2075 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
2076 ** KEYWORDS: {busy-handler callback} {busy handler}
2077 **
@@ -2127,11 +2139,11 @@
2127 ** result in undefined behavior.
2128 **
2129 ** A busy handler must not close the database connection
2130 ** or [prepared statement] that invoked the busy handler.
2131 */
2132 SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2133
2134 /*
2135 ** CAPI3REF: Set A Busy Timeout
2136 **
2137 ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
@@ -2149,11 +2161,11 @@
2149 ** was defined (using [sqlite3_busy_handler()]) prior to calling
2150 ** this routine, that other busy handler is cleared.)^
2151 **
2152 ** See also: [PRAGMA busy_timeout]
2153 */
2154 SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
2155
2156 /*
2157 ** CAPI3REF: Convenience Routines For Running Queries
2158 **
2159 ** This is a legacy interface that is preserved for backwards compatibility.
@@ -2223,19 +2235,19 @@
2223 ** interface defined here. As a consequence, errors that occur in the
2224 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
2225 ** reflected in subsequent calls to [sqlite3_errcode()] or
2226 ** [sqlite3_errmsg()].
2227 */
2228 SQLITE_API int sqlite3_get_table(
2229 sqlite3 *db, /* An open database */
2230 const char *zSql, /* SQL to be evaluated */
2231 char ***pazResult, /* Results of the query */
2232 int *pnRow, /* Number of result rows written here */
2233 int *pnColumn, /* Number of result columns written here */
2234 char **pzErrmsg /* Error msg written here */
2235 );
2236 SQLITE_API void sqlite3_free_table(char **result);
2237
2238 /*
2239 ** CAPI3REF: Formatted String Printing Functions
2240 **
2241 ** These routines are work-alikes of the "printf()" family of functions
@@ -2337,14 +2349,14 @@
2337 **
2338 ** ^(The "%z" formatting option works like "%s" but with the
2339 ** addition that after the string has been read and copied into
2340 ** the result, [sqlite3_free()] is called on the input string.)^
2341 */
2342 SQLITE_API char *sqlite3_mprintf(const char*,...);
2343 SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
2344 SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
2345 SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
2346
2347 /*
2348 ** CAPI3REF: Memory Allocation Subsystem
2349 **
2350 ** The SQLite core uses these three routines for all of its own
@@ -2430,16 +2442,16 @@
2430 **
2431 ** The application must not read or write any part of
2432 ** a block of memory after it has been released using
2433 ** [sqlite3_free()] or [sqlite3_realloc()].
2434 */
2435 SQLITE_API void *sqlite3_malloc(int);
2436 SQLITE_API void *sqlite3_malloc64(sqlite3_uint64);
2437 SQLITE_API void *sqlite3_realloc(void*, int);
2438 SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);
2439 SQLITE_API void sqlite3_free(void*);
2440 SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
2441
2442 /*
2443 ** CAPI3REF: Memory Allocator Statistics
2444 **
2445 ** SQLite provides these two interfaces for reporting on the status
@@ -2460,12 +2472,12 @@
2460 ** [sqlite3_memory_used()] if and only if the parameter to
2461 ** [sqlite3_memory_highwater()] is true. ^The value returned
2462 ** by [sqlite3_memory_highwater(1)] is the high-water mark
2463 ** prior to the reset.
2464 */
2465 SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
2466 SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
2467
2468 /*
2469 ** CAPI3REF: Pseudo-Random Number Generator
2470 **
2471 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
@@ -2484,11 +2496,11 @@
2484 ** ^If the previous call to this routine had an N of 1 or more and a
2485 ** non-NULL P then the pseudo-randomness is generated
2486 ** internally and without recourse to the [sqlite3_vfs] xRandomness
2487 ** method.
2488 */
2489 SQLITE_API void sqlite3_randomness(int N, void *P);
2490
2491 /*
2492 ** CAPI3REF: Compile-Time Authorization Callbacks
2493 **
2494 ** ^This routine registers an authorizer callback with a particular
@@ -2566,11 +2578,11 @@
2566 ** [sqlite3_prepare()] or its variants. Authorization is not
2567 ** performed during statement evaluation in [sqlite3_step()], unless
2568 ** as stated in the previous paragraph, sqlite3_step() invokes
2569 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
2570 */
2571 SQLITE_API int sqlite3_set_authorizer(
2572 sqlite3*,
2573 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2574 void *pUserData
2575 );
2576
@@ -2670,12 +2682,12 @@
2670 ** digits in the time are meaningless. Future versions of SQLite
2671 ** might provide greater resolution on the profiler callback. The
2672 ** sqlite3_profile() function is considered experimental and is
2673 ** subject to change in future versions of SQLite.
2674 */
2675 SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2676 SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
2677 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2678
2679 /*
2680 ** CAPI3REF: Query Progress Callbacks
2681 **
@@ -2705,11 +2717,11 @@
2705 ** the database connection that invoked the progress handler.
2706 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2707 ** database connections for the meaning of "modify" in this paragraph.
2708 **
2709 */
2710 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2711
2712 /*
2713 ** CAPI3REF: Opening A New Database Connection
2714 **
2715 ** ^These routines open an SQLite database file as specified by the
@@ -2933,19 +2945,19 @@
2933 ** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various
2934 ** features that require the use of temporary files may fail.
2935 **
2936 ** See also: [sqlite3_temp_directory]
2937 */
2938 SQLITE_API int sqlite3_open(
2939 const char *filename, /* Database filename (UTF-8) */
2940 sqlite3 **ppDb /* OUT: SQLite db handle */
2941 );
2942 SQLITE_API int sqlite3_open16(
2943 const void *filename, /* Database filename (UTF-16) */
2944 sqlite3 **ppDb /* OUT: SQLite db handle */
2945 );
2946 SQLITE_API int sqlite3_open_v2(
2947 const char *filename, /* Database filename (UTF-8) */
2948 sqlite3 **ppDb, /* OUT: SQLite db handle */
2949 int flags, /* Flags */
2950 const char *zVfs /* Name of VFS module to use */
2951 );
@@ -2987,23 +2999,25 @@
2987 ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
2988 ** is not a database file pathname pointer that SQLite passed into the xOpen
2989 ** VFS method, then the behavior of this routine is undefined and probably
2990 ** undesirable.
2991 */
2992 SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
2993 SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
2994 SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
2995
2996
2997 /*
2998 ** CAPI3REF: Error Codes And Messages
2999 **
3000 ** ^The sqlite3_errcode() interface returns the numeric [result code] or
3001 ** [extended result code] for the most recent failed sqlite3_* API call
3002 ** associated with a [database connection]. If a prior API call failed
3003 ** but the most recent API call succeeded, the return value from
3004 ** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode()
 
 
3005 ** interface is the same except that it always returns the
3006 ** [extended result code] even when extended result codes are
3007 ** disabled.
3008 **
3009 ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -3030,15 +3044,15 @@
3030 **
3031 ** If an interface fails with SQLITE_MISUSE, that means the interface
3032 ** was invoked incorrectly by the application. In that case, the
3033 ** error code and message may or may not be set.
3034 */
3035 SQLITE_API int sqlite3_errcode(sqlite3 *db);
3036 SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
3037 SQLITE_API const char *sqlite3_errmsg(sqlite3*);
3038 SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
3039 SQLITE_API const char *sqlite3_errstr(int);
3040
3041 /*
3042 ** CAPI3REF: SQL Statement Object
3043 ** KEYWORDS: {prepared statement} {prepared statements}
3044 **
@@ -3101,11 +3115,11 @@
3101 ** created by an untrusted script can be contained using the
3102 ** [max_page_count] [PRAGMA].
3103 **
3104 ** New run-time limit categories may be added in future releases.
3105 */
3106 SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
3107
3108 /*
3109 ** CAPI3REF: Run-Time Limit Categories
3110 ** KEYWORDS: {limit category} {*limit categories}
3111 **
@@ -3251,32 +3265,32 @@
3251 ** or [GLOB] operator or if the parameter is compared to an indexed column
3252 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3253 ** </li>
3254 ** </ol>
3255 */
3256 SQLITE_API int sqlite3_prepare(
3257 sqlite3 *db, /* Database handle */
3258 const char *zSql, /* SQL statement, UTF-8 encoded */
3259 int nByte, /* Maximum length of zSql in bytes. */
3260 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3261 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3262 );
3263 SQLITE_API int sqlite3_prepare_v2(
3264 sqlite3 *db, /* Database handle */
3265 const char *zSql, /* SQL statement, UTF-8 encoded */
3266 int nByte, /* Maximum length of zSql in bytes. */
3267 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3268 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3269 );
3270 SQLITE_API int sqlite3_prepare16(
3271 sqlite3 *db, /* Database handle */
3272 const void *zSql, /* SQL statement, UTF-16 encoded */
3273 int nByte, /* Maximum length of zSql in bytes. */
3274 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3275 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3276 );
3277 SQLITE_API int sqlite3_prepare16_v2(
3278 sqlite3 *db, /* Database handle */
3279 const void *zSql, /* SQL statement, UTF-16 encoded */
3280 int nByte, /* Maximum length of zSql in bytes. */
3281 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3282 const void **pzTail /* OUT: Pointer to unused portion of zSql */
@@ -3287,11 +3301,11 @@
3287 **
3288 ** ^This interface can be used to retrieve a saved copy of the original
3289 ** SQL text used to create a [prepared statement] if that statement was
3290 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3291 */
3292 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
3293
3294 /*
3295 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3296 **
3297 ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
@@ -3318,11 +3332,11 @@
3318 ** database. ^The [ATTACH] and [DETACH] statements also cause
3319 ** sqlite3_stmt_readonly() to return true since, while those statements
3320 ** change the configuration of a database connection, they do not make
3321 ** changes to the content of the database files on disk.
3322 */
3323 SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
3324
3325 /*
3326 ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
3327 **
3328 ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
@@ -3337,11 +3351,11 @@
3337 ** to locate all prepared statements associated with a database
3338 ** connection that are in need of being reset. This can be used,
3339 ** for example, in diagnostic routines to search for prepared
3340 ** statements that are holding a transaction open.
3341 */
3342 SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
3343
3344 /*
3345 ** CAPI3REF: Dynamically Typed Value Object
3346 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
3347 **
@@ -3498,23 +3512,23 @@
3498 ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
3499 **
3500 ** See also: [sqlite3_bind_parameter_count()],
3501 ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
3502 */
3503 SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3504 SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
3505 void(*)(void*));
3506 SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
3507 SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
3508 SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3509 SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
3510 SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3511 SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3512 SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3513 void(*)(void*), unsigned char encoding);
3514 SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3515 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3516
3517 /*
3518 ** CAPI3REF: Number Of SQL Parameters
3519 **
3520 ** ^This routine can be used to find the number of [SQL parameters]
@@ -3530,11 +3544,11 @@
3530 **
3531 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3532 ** [sqlite3_bind_parameter_name()], and
3533 ** [sqlite3_bind_parameter_index()].
3534 */
3535 SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
3536
3537 /*
3538 ** CAPI3REF: Name Of A Host Parameter
3539 **
3540 ** ^The sqlite3_bind_parameter_name(P,N) interface returns
@@ -3557,11 +3571,11 @@
3557 **
3558 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3559 ** [sqlite3_bind_parameter_count()], and
3560 ** [sqlite3_bind_parameter_index()].
3561 */
3562 SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3563
3564 /*
3565 ** CAPI3REF: Index Of A Parameter With A Given Name
3566 **
3567 ** ^Return the index of an SQL parameter given its name. ^The
@@ -3573,20 +3587,20 @@
3573 **
3574 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3575 ** [sqlite3_bind_parameter_count()], and
3576 ** [sqlite3_bind_parameter_index()].
3577 */
3578 SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3579
3580 /*
3581 ** CAPI3REF: Reset All Bindings On A Prepared Statement
3582 **
3583 ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
3584 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
3585 ** ^Use this routine to reset all host parameters to NULL.
3586 */
3587 SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
3588
3589 /*
3590 ** CAPI3REF: Number Of Columns In A Result Set
3591 **
3592 ** ^Return the number of columns in the result set returned by the
@@ -3593,11 +3607,11 @@
3593 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
3594 ** statement that does not return data (for example an [UPDATE]).
3595 **
3596 ** See also: [sqlite3_data_count()]
3597 */
3598 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
3599
3600 /*
3601 ** CAPI3REF: Column Names In A Result Set
3602 **
3603 ** ^These routines return the name assigned to a particular column
@@ -3621,12 +3635,12 @@
3621 ** ^The name of a result column is the value of the "AS" clause for
3622 ** that column, if there is an AS clause. If there is no AS clause
3623 ** then the name of the column is unspecified and may change from
3624 ** one release of SQLite to the next.
3625 */
3626 SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
3627 SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
3628
3629 /*
3630 ** CAPI3REF: Source Of Data In A Query Result
3631 **
3632 ** ^These routines provide a means to determine the database, table, and
@@ -3669,16 +3683,16 @@
3669 ** If two or more threads call one or more
3670 ** [sqlite3_column_database_name | column metadata interfaces]
3671 ** for the same [prepared statement] and result column
3672 ** at the same time then the results are undefined.
3673 */
3674 SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
3675 SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
3676 SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
3677 SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
3678 SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
3679 SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
3680
3681 /*
3682 ** CAPI3REF: Declared Datatype Of A Query Result
3683 **
3684 ** ^(The first parameter is a [prepared statement].
@@ -3705,12 +3719,12 @@
3705 ** data stored in that column is of the declared type. SQLite is
3706 ** strongly typed, but the typing is dynamic not static. ^Type
3707 ** is associated with individual values, not with the containers
3708 ** used to hold those values.
3709 */
3710 SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
3711 SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
3712
3713 /*
3714 ** CAPI3REF: Evaluate An SQL Statement
3715 **
3716 ** After a [prepared statement] has been prepared using either
@@ -3785,11 +3799,11 @@
3785 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
3786 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
3787 ** then the more specific [error codes] are returned directly
3788 ** by sqlite3_step(). The use of the "v2" interface is recommended.
3789 */
3790 SQLITE_API int sqlite3_step(sqlite3_stmt*);
3791
3792 /*
3793 ** CAPI3REF: Number of columns in a result set
3794 **
3795 ** ^The sqlite3_data_count(P) interface returns the number of columns in the
@@ -3805,11 +3819,11 @@
3805 ** where it always returns zero since each step of that multi-step
3806 ** pragma returns 0 columns of data.
3807 **
3808 ** See also: [sqlite3_column_count()]
3809 */
3810 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
3811
3812 /*
3813 ** CAPI3REF: Fundamental Datatypes
3814 ** KEYWORDS: SQLITE_TEXT
3815 **
@@ -4001,20 +4015,20 @@
4001 ** of these routines, a default value is returned. The default value
4002 ** is either the integer 0, the floating point number 0.0, or a NULL
4003 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
4004 ** [SQLITE_NOMEM].)^
4005 */
4006 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
4007 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4008 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4009 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
4010 SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
4011 SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
4012 SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
4013 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
4014 SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
4015 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
4016
4017 /*
4018 ** CAPI3REF: Destroy A Prepared Statement Object
4019 **
4020 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
@@ -4037,11 +4051,11 @@
4037 ** resource leaks. It is a grievous error for the application to try to use
4038 ** a prepared statement after it has been finalized. Any use of a prepared
4039 ** statement after it has been finalized can result in undefined and
4040 ** undesirable behavior such as segfaults and heap corruption.
4041 */
4042 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
4043
4044 /*
4045 ** CAPI3REF: Reset A Prepared Statement Object
4046 **
4047 ** The sqlite3_reset() function is called to reset a [prepared statement]
@@ -4063,11 +4077,11 @@
4063 ** [sqlite3_reset(S)] returns an appropriate [error code].
4064 **
4065 ** ^The [sqlite3_reset(S)] interface does not change the values
4066 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
4067 */
4068 SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
4069
4070 /*
4071 ** CAPI3REF: Create Or Redefine SQL Functions
4072 ** KEYWORDS: {function creation routines}
4073 ** KEYWORDS: {application-defined SQL function}
@@ -4162,31 +4176,31 @@
4162 ** ^An application-defined function is permitted to call other
4163 ** SQLite interfaces. However, such calls must not
4164 ** close the database connection nor finalize or reset the prepared
4165 ** statement in which the function is running.
4166 */
4167 SQLITE_API int sqlite3_create_function(
4168 sqlite3 *db,
4169 const char *zFunctionName,
4170 int nArg,
4171 int eTextRep,
4172 void *pApp,
4173 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4174 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4175 void (*xFinal)(sqlite3_context*)
4176 );
4177 SQLITE_API int sqlite3_create_function16(
4178 sqlite3 *db,
4179 const void *zFunctionName,
4180 int nArg,
4181 int eTextRep,
4182 void *pApp,
4183 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4184 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4185 void (*xFinal)(sqlite3_context*)
4186 );
4187 SQLITE_API int sqlite3_create_function_v2(
4188 sqlite3 *db,
4189 const char *zFunctionName,
4190 int nArg,
4191 int eTextRep,
4192 void *pApp,
@@ -4228,16 +4242,16 @@
4228 ** to be supported. However, new applications should avoid
4229 ** the use of these functions. To encourage programmers to avoid
4230 ** these functions, we will not explain what they do.
4231 */
4232 #ifndef SQLITE_OMIT_DEPRECATED
4233 SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
4234 SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
4235 SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4236 SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
4237 SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
4238 SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4239 void*,sqlite3_int64);
4240 #endif
4241
4242 /*
4243 ** CAPI3REF: Obtaining SQL Function Parameter Values
@@ -4282,22 +4296,22 @@
4282 ** or [sqlite3_value_text16()].
4283 **
4284 ** These routines must be called from the same thread as
4285 ** the SQL function that supplied the [sqlite3_value*] parameters.
4286 */
4287 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4288 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
4289 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
4290 SQLITE_API double sqlite3_value_double(sqlite3_value*);
4291 SQLITE_API int sqlite3_value_int(sqlite3_value*);
4292 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4293 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
4294 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
4295 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
4296 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
4297 SQLITE_API int sqlite3_value_type(sqlite3_value*);
4298 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
4299
4300 /*
4301 ** CAPI3REF: Obtain Aggregate Function Context
4302 **
4303 ** Implementations of aggregate SQL functions use this
@@ -4337,11 +4351,11 @@
4337 ** function.
4338 **
4339 ** This routine must be called from the same thread in which
4340 ** the aggregate SQL function is running.
4341 */
4342 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
4343
4344 /*
4345 ** CAPI3REF: User Data For Functions
4346 **
4347 ** ^The sqlite3_user_data() interface returns a copy of
@@ -4351,11 +4365,11 @@
4351 ** registered the application defined function.
4352 **
4353 ** This routine must be called from the same thread in which
4354 ** the application-defined function is running.
4355 */
4356 SQLITE_API void *sqlite3_user_data(sqlite3_context*);
4357
4358 /*
4359 ** CAPI3REF: Database Connection For Functions
4360 **
4361 ** ^The sqlite3_context_db_handle() interface returns a copy of
@@ -4362,11 +4376,11 @@
4362 ** the pointer to the [database connection] (the 1st parameter)
4363 ** of the [sqlite3_create_function()]
4364 ** and [sqlite3_create_function16()] routines that originally
4365 ** registered the application defined function.
4366 */
4367 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4368
4369 /*
4370 ** CAPI3REF: Function Auxiliary Data
4371 **
4372 ** These functions may be used by (non-aggregate) SQL functions to
@@ -4414,12 +4428,12 @@
4414 ** values and [parameters] and expressions composed from the same.)^
4415 **
4416 ** These routines must be called from the same thread in which
4417 ** the SQL function is running.
4418 */
4419 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
4420 SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
4421
4422
4423 /*
4424 ** CAPI3REF: Constants Defining Special Destructor Behavior
4425 **
@@ -4550,30 +4564,30 @@
4550 **
4551 ** If these routines are called from within the different thread
4552 ** than the one containing the application-defined function that received
4553 ** the [sqlite3_context] pointer, the results are undefined.
4554 */
4555 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4556 SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
4557 sqlite3_uint64,void(*)(void*));
4558 SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
4559 SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
4560 SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
4561 SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
4562 SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
4563 SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
4564 SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
4565 SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4566 SQLITE_API void sqlite3_result_null(sqlite3_context*);
4567 SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4568 SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
4569 void(*)(void*), unsigned char encoding);
4570 SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4571 SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4572 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4573 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4574 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
4575
4576 /*
4577 ** CAPI3REF: Define New Collating Sequences
4578 **
4579 ** ^These functions add, remove, or modify a [collation] associated
@@ -4650,26 +4664,26 @@
4650 ** is unfortunate but cannot be changed without breaking backwards
4651 ** compatibility.
4652 **
4653 ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
4654 */
4655 SQLITE_API int sqlite3_create_collation(
4656 sqlite3*,
4657 const char *zName,
4658 int eTextRep,
4659 void *pArg,
4660 int(*xCompare)(void*,int,const void*,int,const void*)
4661 );
4662 SQLITE_API int sqlite3_create_collation_v2(
4663 sqlite3*,
4664 const char *zName,
4665 int eTextRep,
4666 void *pArg,
4667 int(*xCompare)(void*,int,const void*,int,const void*),
4668 void(*xDestroy)(void*)
4669 );
4670 SQLITE_API int sqlite3_create_collation16(
4671 sqlite3*,
4672 const void *zName,
4673 int eTextRep,
4674 void *pArg,
4675 int(*xCompare)(void*,int,const void*,int,const void*)
@@ -4699,16 +4713,16 @@
4699 **
4700 ** The callback function should register the desired collation using
4701 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
4702 ** [sqlite3_create_collation_v2()].
4703 */
4704 SQLITE_API int sqlite3_collation_needed(
4705 sqlite3*,
4706 void*,
4707 void(*)(void*,sqlite3*,int eTextRep,const char*)
4708 );
4709 SQLITE_API int sqlite3_collation_needed16(
4710 sqlite3*,
4711 void*,
4712 void(*)(void*,sqlite3*,int eTextRep,const void*)
4713 );
4714
@@ -4718,15 +4732,15 @@
4718 ** called right after sqlite3_open().
4719 **
4720 ** The code to implement this API is not available in the public release
4721 ** of SQLite.
4722 */
4723 SQLITE_API int sqlite3_key(
4724 sqlite3 *db, /* Database to be rekeyed */
4725 const void *pKey, int nKey /* The key */
4726 );
4727 SQLITE_API int sqlite3_key_v2(
4728 sqlite3 *db, /* Database to be rekeyed */
4729 const char *zDbName, /* Name of the database */
4730 const void *pKey, int nKey /* The key */
4731 );
4732
@@ -4736,35 +4750,35 @@
4736 ** database is decrypted.
4737 **
4738 ** The code to implement this API is not available in the public release
4739 ** of SQLite.
4740 */
4741 SQLITE_API int sqlite3_rekey(
4742 sqlite3 *db, /* Database to be rekeyed */
4743 const void *pKey, int nKey /* The new key */
4744 );
4745 SQLITE_API int sqlite3_rekey_v2(
4746 sqlite3 *db, /* Database to be rekeyed */
4747 const char *zDbName, /* Name of the database */
4748 const void *pKey, int nKey /* The new key */
4749 );
4750
4751 /*
4752 ** Specify the activation key for a SEE database. Unless
4753 ** activated, none of the SEE routines will work.
4754 */
4755 SQLITE_API void sqlite3_activate_see(
4756 const char *zPassPhrase /* Activation phrase */
4757 );
4758 #endif
4759
4760 #ifdef SQLITE_ENABLE_CEROD
4761 /*
4762 ** Specify the activation key for a CEROD database. Unless
4763 ** activated, none of the CEROD routines will work.
4764 */
4765 SQLITE_API void sqlite3_activate_cerod(
4766 const char *zPassPhrase /* Activation phrase */
4767 );
4768 #endif
4769
4770 /*
@@ -4782,11 +4796,11 @@
4782 ** method of the default [sqlite3_vfs] object. If the xSleep() method
4783 ** of the default VFS is not implemented correctly, or not implemented at
4784 ** all, then the behavior of sqlite3_sleep() may deviate from the description
4785 ** in the previous paragraphs.
4786 */
4787 SQLITE_API int sqlite3_sleep(int);
4788
4789 /*
4790 ** CAPI3REF: Name Of The Folder Holding Temporary Files
4791 **
4792 ** ^(If this global variable is made to point to a string which is
@@ -4900,11 +4914,11 @@
4900 **
4901 ** If another thread changes the autocommit status of the database
4902 ** connection while this routine is running, then the return value
4903 ** is undefined.
4904 */
4905 SQLITE_API int sqlite3_get_autocommit(sqlite3*);
4906
4907 /*
4908 ** CAPI3REF: Find The Database Handle Of A Prepared Statement
4909 **
4910 ** ^The sqlite3_db_handle interface returns the [database connection] handle
@@ -4912,11 +4926,11 @@
4912 ** returned by sqlite3_db_handle is the same [database connection]
4913 ** that was the first argument
4914 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
4915 ** create the statement in the first place.
4916 */
4917 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
4918
4919 /*
4920 ** CAPI3REF: Return The Filename For A Database Connection
4921 **
4922 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
@@ -4928,20 +4942,20 @@
4928 ** ^The filename returned by this function is the output of the
4929 ** xFullPathname method of the [VFS]. ^In other words, the filename
4930 ** will be an absolute pathname, even if the filename used
4931 ** to open the database originally was a URI or relative pathname.
4932 */
4933 SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
4934
4935 /*
4936 ** CAPI3REF: Determine if a database is read-only
4937 **
4938 ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
4939 ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
4940 ** the name of a database on connection D.
4941 */
4942 SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
4943
4944 /*
4945 ** CAPI3REF: Find the next prepared statement
4946 **
4947 ** ^This interface returns a pointer to the next [prepared statement] after
@@ -4952,11 +4966,11 @@
4952 **
4953 ** The [database connection] pointer D in a call to
4954 ** [sqlite3_next_stmt(D,S)] must refer to an open database
4955 ** connection and in particular must not be a NULL pointer.
4956 */
4957 SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
4958
4959 /*
4960 ** CAPI3REF: Commit And Rollback Notification Callbacks
4961 **
4962 ** ^The sqlite3_commit_hook() interface registers a callback
@@ -5000,12 +5014,12 @@
5000 ** ^The rollback callback is not invoked if a transaction is
5001 ** automatically rolled back because the database connection is closed.
5002 **
5003 ** See also the [sqlite3_update_hook()] interface.
5004 */
5005 SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5006 SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
5007
5008 /*
5009 ** CAPI3REF: Data Change Notification Callbacks
5010 **
5011 ** ^The sqlite3_update_hook() interface registers a callback function
@@ -5051,11 +5065,11 @@
5051 ** the first call on D.
5052 **
5053 ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
5054 ** interfaces.
5055 */
5056 SQLITE_API void *sqlite3_update_hook(
5057 sqlite3*,
5058 void(*)(void *,int ,char const *,char const *,sqlite3_int64),
5059 void*
5060 );
5061
@@ -5091,11 +5105,11 @@
5091 ** This interface is threadsafe on processors where writing a
5092 ** 32-bit integer is atomic.
5093 **
5094 ** See Also: [SQLite Shared-Cache Mode]
5095 */
5096 SQLITE_API int sqlite3_enable_shared_cache(int);
5097
5098 /*
5099 ** CAPI3REF: Attempt To Free Heap Memory
5100 **
5101 ** ^The sqlite3_release_memory() interface attempts to free N bytes
@@ -5107,11 +5121,11 @@
5107 ** ^The sqlite3_release_memory() routine is a no-op returning zero
5108 ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5109 **
5110 ** See also: [sqlite3_db_release_memory()]
5111 */
5112 SQLITE_API int sqlite3_release_memory(int);
5113
5114 /*
5115 ** CAPI3REF: Free Memory Used By A Database Connection
5116 **
5117 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
@@ -5120,11 +5134,11 @@
5120 ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
5121 ** omitted.
5122 **
5123 ** See also: [sqlite3_release_memory()]
5124 */
5125 SQLITE_API int sqlite3_db_release_memory(sqlite3*);
5126
5127 /*
5128 ** CAPI3REF: Impose A Limit On Heap Size
5129 **
5130 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
@@ -5172,11 +5186,11 @@
5172 ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5173 **
5174 ** The circumstances under which SQLite will enforce the soft heap limit may
5175 ** changes in future releases of SQLite.
5176 */
5177 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
5178
5179 /*
5180 ** CAPI3REF: Deprecated Soft Heap Limit Interface
5181 ** DEPRECATED
5182 **
@@ -5183,11 +5197,11 @@
5183 ** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
5184 ** interface. This routine is provided for historical compatibility
5185 ** only. All new applications should use the
5186 ** [sqlite3_soft_heap_limit64()] interface rather than this one.
5187 */
5188 SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
5189
5190
5191 /*
5192 ** CAPI3REF: Extract Metadata About A Column Of A Table
5193 **
@@ -5252,11 +5266,11 @@
5252 **
5253 ** ^This function causes all database schemas to be read from disk and
5254 ** parsed, if that has not already been done, and returns an error if
5255 ** any errors are encountered while loading the schema.
5256 */
5257 SQLITE_API int sqlite3_table_column_metadata(
5258 sqlite3 *db, /* Connection handle */
5259 const char *zDbName, /* Database name or NULL */
5260 const char *zTableName, /* Table name */
5261 const char *zColumnName, /* Column name */
5262 char const **pzDataType, /* OUTPUT: Declared data type */
@@ -5298,11 +5312,11 @@
5298 ** [sqlite3_enable_load_extension()] prior to calling this API,
5299 ** otherwise an error will be returned.
5300 **
5301 ** See also the [load_extension() SQL function].
5302 */
5303 SQLITE_API int sqlite3_load_extension(
5304 sqlite3 *db, /* Load the extension into this database connection */
5305 const char *zFile, /* Name of the shared library containing extension */
5306 const char *zProc, /* Entry point. Derived from zFile if 0 */
5307 char **pzErrMsg /* Put error message here if not 0 */
5308 );
@@ -5318,11 +5332,11 @@
5318 ** ^Extension loading is off by default.
5319 ** ^Call the sqlite3_enable_load_extension() routine with onoff==1
5320 ** to turn extension loading on and call it with onoff==0 to turn
5321 ** it back off again.
5322 */
5323 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
5324
5325 /*
5326 ** CAPI3REF: Automatically Load Statically Linked Extensions
5327 **
5328 ** ^This interface causes the xEntryPoint() function to be invoked for
@@ -5356,11 +5370,11 @@
5356 ** will be called more than once for each database connection that is opened.
5357 **
5358 ** See also: [sqlite3_reset_auto_extension()]
5359 ** and [sqlite3_cancel_auto_extension()]
5360 */
5361 SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
5362
5363 /*
5364 ** CAPI3REF: Cancel Automatic Extension Loading
5365 **
5366 ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5368,19 +5382,19 @@
5368 ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
5369 ** routine returns 1 if initialization routine X was successfully
5370 ** unregistered and it returns 0 if X was not on the list of initialization
5371 ** routines.
5372 */
5373 SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5374
5375 /*
5376 ** CAPI3REF: Reset Automatic Extension Loading
5377 **
5378 ** ^This interface disables all automatic extensions previously
5379 ** registered using [sqlite3_auto_extension()].
5380 */
5381 SQLITE_API void sqlite3_reset_auto_extension(void);
5382
5383 /*
5384 ** The interface to the virtual-table mechanism is currently considered
5385 ** to be experimental. The interface might change in incompatible ways.
5386 ** If this is a problem for you, do not use the interface at this time.
@@ -5579,17 +5593,17 @@
5579 ** be invoked if the call to sqlite3_create_module_v2() fails.
5580 ** ^The sqlite3_create_module()
5581 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
5582 ** destructor.
5583 */
5584 SQLITE_API int sqlite3_create_module(
5585 sqlite3 *db, /* SQLite connection to register module with */
5586 const char *zName, /* Name of the module */
5587 const sqlite3_module *p, /* Methods for the module */
5588 void *pClientData /* Client data for xCreate/xConnect */
5589 );
5590 SQLITE_API int sqlite3_create_module_v2(
5591 sqlite3 *db, /* SQLite connection to register module with */
5592 const char *zName, /* Name of the module */
5593 const sqlite3_module *p, /* Methods for the module */
5594 void *pClientData, /* Client data for xCreate/xConnect */
5595 void(*xDestroy)(void*) /* Module destructor function */
@@ -5613,11 +5627,11 @@
5613 ** is delivered up to the client application, the string will be automatically
5614 ** freed by sqlite3_free() and the zErrMsg field will be zeroed.
5615 */
5616 struct sqlite3_vtab {
5617 const sqlite3_module *pModule; /* The module for this virtual table */
5618 int nRef; /* NO LONGER USED */
5619 char *zErrMsg; /* Error message from sqlite3_mprintf() */
5620 /* Virtual table implementations will typically add additional fields */
5621 };
5622
5623 /*
@@ -5648,11 +5662,11 @@
5648 ** ^The [xCreate] and [xConnect] methods of a
5649 ** [virtual table module] call this interface
5650 ** to declare the format (the names and datatypes of the columns) of
5651 ** the virtual tables they implement.
5652 */
5653 SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
5654
5655 /*
5656 ** CAPI3REF: Overload A Function For A Virtual Table
5657 **
5658 ** ^(Virtual tables can provide alternative implementations of functions
@@ -5666,11 +5680,11 @@
5666 ** of the new function always causes an exception to be thrown. So
5667 ** the new function is not good for anything by itself. Its only
5668 ** purpose is to be a placeholder function that can be overloaded
5669 ** by a [virtual table].
5670 */
5671 SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
5672
5673 /*
5674 ** The interface to the virtual-table mechanism defined above (back up
5675 ** to a comment remarkably similar to this one) is currently considered
5676 ** to be experimental. The interface might change in incompatible ways.
@@ -5763,11 +5777,11 @@
5763 ** zero-filled blob to read or write using the incremental-blob interface.
5764 **
5765 ** To avoid a resource leak, every open [BLOB handle] should eventually
5766 ** be released by a call to [sqlite3_blob_close()].
5767 */
5768 SQLITE_API int sqlite3_blob_open(
5769 sqlite3*,
5770 const char *zDb,
5771 const char *zTable,
5772 const char *zColumn,
5773 sqlite3_int64 iRow,
@@ -5795,11 +5809,11 @@
5795 ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
5796 ** always returns zero.
5797 **
5798 ** ^This function sets the database handle error code and message.
5799 */
5800 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
5801
5802 /*
5803 ** CAPI3REF: Close A BLOB Handle
5804 **
5805 ** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
@@ -5817,11 +5831,11 @@
5817 ** with a null pointer (such as would be returned by a failed call to
5818 ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
5819 ** is passed a valid open blob handle, the values returned by the
5820 ** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
5821 */
5822 SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
5823
5824 /*
5825 ** CAPI3REF: Return The Size Of An Open BLOB
5826 **
5827 ** ^Returns the size in bytes of the BLOB accessible via the
@@ -5832,11 +5846,11 @@
5832 ** This routine only works on a [BLOB handle] which has been created
5833 ** by a prior successful call to [sqlite3_blob_open()] and which has not
5834 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5835 ** to this routine results in undefined and probably undesirable behavior.
5836 */
5837 SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
5838
5839 /*
5840 ** CAPI3REF: Read Data From A BLOB Incrementally
5841 **
5842 ** ^(This function is used to read data from an open [BLOB handle] into a
@@ -5860,11 +5874,11 @@
5860 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5861 ** to this routine results in undefined and probably undesirable behavior.
5862 **
5863 ** See also: [sqlite3_blob_write()].
5864 */
5865 SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
5866
5867 /*
5868 ** CAPI3REF: Write Data Into A BLOB Incrementally
5869 **
5870 ** ^(This function is used to write data into an open [BLOB handle] from a
@@ -5901,11 +5915,11 @@
5901 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5902 ** to this routine results in undefined and probably undesirable behavior.
5903 **
5904 ** See also: [sqlite3_blob_read()].
5905 */
5906 SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
5907
5908 /*
5909 ** CAPI3REF: Virtual File System Objects
5910 **
5911 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
@@ -5932,13 +5946,13 @@
5932 **
5933 ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
5934 ** ^(If the default VFS is unregistered, another VFS is chosen as
5935 ** the default. The choice for the new VFS is arbitrary.)^
5936 */
5937 SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
5938 SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
5939 SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
5940
5941 /*
5942 ** CAPI3REF: Mutexes
5943 **
5944 ** The SQLite core uses these routines for thread
@@ -6047,15 +6061,15 @@
6047 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
6048 ** behave as no-ops.
6049 **
6050 ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
6051 */
6052 SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
6053 SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
6054 SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
6055 SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
6056 SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
6057
6058 /*
6059 ** CAPI3REF: Mutex Methods Object
6060 **
6061 ** An instance of this structure defines the low-level routines
@@ -6161,12 +6175,12 @@
6161 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
6162 ** the appropriate thing to do. The sqlite3_mutex_notheld()
6163 ** interface should also return 1 when given a NULL pointer.
6164 */
6165 #ifndef NDEBUG
6166 SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
6167 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
6168 #endif
6169
6170 /*
6171 ** CAPI3REF: Mutex Types
6172 **
@@ -6198,11 +6212,11 @@
6198 ** serializes access to the [database connection] given in the argument
6199 ** when the [threading mode] is Serialized.
6200 ** ^If the [threading mode] is Single-thread or Multi-thread then this
6201 ** routine returns a NULL pointer.
6202 */
6203 SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
6204
6205 /*
6206 ** CAPI3REF: Low-Level Control Of Database Files
6207 **
6208 ** ^The [sqlite3_file_control()] interface makes a direct call to the
@@ -6232,11 +6246,11 @@
6232 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
6233 ** xFileControl method.
6234 **
6235 ** See also: [SQLITE_FCNTL_LOCKSTATE]
6236 */
6237 SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
6238
6239 /*
6240 ** CAPI3REF: Testing Interface
6241 **
6242 ** ^The sqlite3_test_control() interface is used to read out internal
@@ -6251,11 +6265,11 @@
6251 ** The details of the operation codes, their meanings, the parameters
6252 ** they take, and what they do are all subject to change without notice.
6253 ** Unlike most of the SQLite API, this function is not guaranteed to
6254 ** operate consistently from one release to the next.
6255 */
6256 SQLITE_API int sqlite3_test_control(int op, ...);
6257
6258 /*
6259 ** CAPI3REF: Testing Interface Operation Codes
6260 **
6261 ** These constants are the valid operation code parameters used
@@ -6291,11 +6305,11 @@
6291 #define SQLITE_TESTCTRL_LAST 25
6292
6293 /*
6294 ** CAPI3REF: SQLite Runtime Status
6295 **
6296 ** ^This interface is used to retrieve runtime status information
6297 ** about the performance of SQLite, and optionally to reset various
6298 ** highwater marks. ^The first argument is an integer code for
6299 ** the specific parameter to measure. ^(Recognized integer codes
6300 ** are of the form [status parameters | SQLITE_STATUS_...].)^
6301 ** ^The current value of the parameter is returned into *pCurrent.
@@ -6305,23 +6319,26 @@
6305 ** value. For those parameters
6306 ** nothing is written into *pHighwater and the resetFlag is ignored.)^
6307 ** ^(Other parameters record only the highwater mark and not the current
6308 ** value. For these latter parameters nothing is written into *pCurrent.)^
6309 **
6310 ** ^The sqlite3_status() routine returns SQLITE_OK on success and a
6311 ** non-zero [error code] on failure.
6312 **
6313 ** This routine is threadsafe but is not atomic. This routine can be
6314 ** called while other threads are running the same or different SQLite
6315 ** interfaces. However the values returned in *pCurrent and
6316 ** *pHighwater reflect the status of SQLite at different points in time
6317 ** and it is possible that another thread might change the parameter
6318 ** in between the times when *pCurrent and *pHighwater are written.
6319 **
6320 ** See also: [sqlite3_db_status()]
6321 */
6322 SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
 
 
 
 
 
 
6323
6324
6325 /*
6326 ** CAPI3REF: Status Parameters
6327 ** KEYWORDS: {status parameters}
@@ -6435,11 +6452,11 @@
6435 ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
6436 ** non-zero [error code] on failure.
6437 **
6438 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
6439 */
6440 SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
6441
6442 /*
6443 ** CAPI3REF: Status Parameters for database connections
6444 ** KEYWORDS: {SQLITE_DBSTATUS options}
6445 **
@@ -6564,11 +6581,11 @@
6564 ** ^If the resetFlg is true, then the counter is reset to zero after this
6565 ** interface call returns.
6566 **
6567 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
6568 */
6569 SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
6570
6571 /*
6572 ** CAPI3REF: Status Parameters for prepared statements
6573 ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}
6574 **
@@ -7033,20 +7050,20 @@
7033 ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
7034 ** APIs are not strictly speaking threadsafe. If they are invoked at the
7035 ** same time as another thread is invoking sqlite3_backup_step() it is
7036 ** possible that they return invalid values.
7037 */
7038 SQLITE_API sqlite3_backup *sqlite3_backup_init(
7039 sqlite3 *pDest, /* Destination database handle */
7040 const char *zDestName, /* Destination database name */
7041 sqlite3 *pSource, /* Source database handle */
7042 const char *zSourceName /* Source database name */
7043 );
7044 SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
7045 SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
7046 SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
7047 SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
7048
7049 /*
7050 ** CAPI3REF: Unlock Notification
7051 **
7052 ** ^When running in shared-cache mode, a database operation may fail with
@@ -7158,11 +7175,11 @@
7158 ** by an sqlite3_step() call. ^(If there is a blocking connection, then the
7159 ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
7160 ** the special "DROP TABLE/INDEX" case, the extended error code is just
7161 ** SQLITE_LOCKED.)^
7162 */
7163 SQLITE_API int sqlite3_unlock_notify(
7164 sqlite3 *pBlocked, /* Waiting connection */
7165 void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
7166 void *pNotifyArg /* Argument to pass to xNotify */
7167 );
7168
@@ -7173,12 +7190,12 @@
7173 ** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
7174 ** and extensions to compare the contents of two buffers containing UTF-8
7175 ** strings in a case-independent fashion, using the same definition of "case
7176 ** independence" that SQLite uses internally when comparing identifiers.
7177 */
7178 SQLITE_API int sqlite3_stricmp(const char *, const char *);
7179 SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
7180
7181 /*
7182 ** CAPI3REF: String Globbing
7183 *
7184 ** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
@@ -7189,11 +7206,11 @@
7189 ** sensitive.
7190 **
7191 ** Note that this routine returns zero on a match and non-zero if the strings
7192 ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
7193 */
7194 SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
7195
7196 /*
7197 ** CAPI3REF: Error Logging Interface
7198 **
7199 ** ^The [sqlite3_log()] interface writes a message into the [error log]
@@ -7212,11 +7229,11 @@
7212 ** will not use dynamically allocated memory. The log message is stored in
7213 ** a fixed-length buffer on the stack. If the log message is longer than
7214 ** a few hundred characters, it will be truncated to the length of the
7215 ** buffer.
7216 */
7217 SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
7218
7219 /*
7220 ** CAPI3REF: Write-Ahead Log Commit Hook
7221 **
7222 ** ^The [sqlite3_wal_hook()] function is used to register a callback that
@@ -7247,11 +7264,11 @@
7247 ** previously registered write-ahead log callback. ^Note that the
7248 ** [sqlite3_wal_autocheckpoint()] interface and the
7249 ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
7250 ** those overwrite any prior [sqlite3_wal_hook()] settings.
7251 */
7252 SQLITE_API void *sqlite3_wal_hook(
7253 sqlite3*,
7254 int(*)(void *,sqlite3*,const char*,int),
7255 void*
7256 );
7257
@@ -7281,11 +7298,11 @@
7281 ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
7282 ** pages. The use of this interface
7283 ** is only necessary if the default setting is found to be suboptimal
7284 ** for a particular application.
7285 */
7286 SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
7287
7288 /*
7289 ** CAPI3REF: Checkpoint a database
7290 **
7291 ** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
@@ -7302,11 +7319,11 @@
7302 ** interface was added. This interface is retained for backwards
7303 ** compatibility and as a convenience for applications that need to manually
7304 ** start a callback but which do not need the full power (and corresponding
7305 ** complication) of [sqlite3_wal_checkpoint_v2()].
7306 */
7307 SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
7308
7309 /*
7310 ** CAPI3REF: Checkpoint a database
7311 **
7312 ** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
@@ -7395,11 +7412,11 @@
7395 ** [sqlite3_errcode()] and [sqlite3_errmsg()].
7396 **
7397 ** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
7398 ** from SQL.
7399 */
7400 SQLITE_API int sqlite3_wal_checkpoint_v2(
7401 sqlite3 *db, /* Database handle */
7402 const char *zDb, /* Name of attached database (or NULL) */
7403 int eMode, /* SQLITE_CHECKPOINT_* value */
7404 int *pnLog, /* OUT: Size of WAL log in frames */
7405 int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -7431,11 +7448,11 @@
7431 **
7432 ** At present, there is only one option that may be configured using
7433 ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
7434 ** may be added in the future.
7435 */
7436 SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
7437
7438 /*
7439 ** CAPI3REF: Virtual Table Configuration Options
7440 **
7441 ** These macros define the various options to the
@@ -7484,11 +7501,11 @@
7484 ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],
7485 ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode
7486 ** of the SQL statement that triggered the call to the [xUpdate] method of the
7487 ** [virtual table].
7488 */
7489 SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
7490
7491 /*
7492 ** CAPI3REF: Conflict resolution modes
7493 ** KEYWORDS: {conflict resolution mode}
7494 **
@@ -7588,11 +7605,11 @@
7588 ** as if the loop did not exist - it returns non-zero and leave the variable
7589 ** that pOut points to unchanged.
7590 **
7591 ** See also: [sqlite3_stmt_scanstatus_reset()]
7592 */
7593 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_scanstatus(
7594 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
7595 int idx, /* Index of loop to report on */
7596 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
7597 void *pOut /* Result written here */
7598 );
@@ -7603,11 +7620,11 @@
7603 ** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
7604 **
7605 ** This API is only available if the library is built with pre-processor
7606 ** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
7607 */
7608 SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
7609
7610
7611 /*
7612 ** Undo the hack that converts floating point types to integer for
7613 ** builds on processors without floating point support.
@@ -7658,11 +7675,11 @@
7658 ** Register a geometry callback named zGeom that can be used as part of an
7659 ** R-Tree geometry query as follows:
7660 **
7661 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
7662 */
7663 SQLITE_API int sqlite3_rtree_geometry_callback(
7664 sqlite3 *db,
7665 const char *zGeom,
7666 int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
7667 void *pContext
7668 );
@@ -7684,11 +7701,11 @@
7684 ** Register a 2nd-generation geometry callback named zScore that can be
7685 ** used as part of an R-Tree geometry query as follows:
7686 **
7687 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
7688 */
7689 SQLITE_API int sqlite3_rtree_query_callback(
7690 sqlite3 *db,
7691 const char *zQueryFunc,
7692 int (*xQueryFunc)(sqlite3_rtree_query_info*),
7693 void *pContext,
7694 void (*xDestructor)(void*)
7695
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -41,20 +41,24 @@
41 extern "C" {
42 #endif
43
44
45 /*
46 ** Provide the ability to override linkage features of the interface.
47 */
48 #ifndef SQLITE_EXTERN
49 # define SQLITE_EXTERN extern
50 #endif
 
51 #ifndef SQLITE_API
52 # define SQLITE_API
53 #endif
54 #ifndef SQLITE_CDECL
55 # define SQLITE_CDECL
56 #endif
57 #ifndef SQLITE_STDCALL
58 # define SQLITE_STDCALL
59 #endif
60
61 /*
62 ** These no-op macros are used in front of interfaces to mark those
63 ** interfaces as either deprecated or experimental. New applications
64 ** should not use deprecated interfaces - they are supported for backwards
@@ -107,11 +111,11 @@
111 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112 ** [sqlite_version()] and [sqlite_source_id()].
113 */
114 #define SQLITE_VERSION "3.8.9"
115 #define SQLITE_VERSION_NUMBER 3008009
116 #define SQLITE_SOURCE_ID "2015-03-30 23:43:56 395bb3e677a6551b06ba96fc58c393132b93d1e8"
117
118 /*
119 ** CAPI3REF: Run-Time Library Version Numbers
120 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
121 **
@@ -140,13 +144,13 @@
144 ** [SQLITE_SOURCE_ID] C preprocessor macro.
145 **
146 ** See also: [sqlite_version()] and [sqlite_source_id()].
147 */
148 SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
149 SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void);
150 SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void);
151 SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void);
152
153 /*
154 ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
155 **
156 ** ^The sqlite3_compileoption_used() function returns 0 or 1
@@ -167,12 +171,12 @@
171 **
172 ** See also: SQL functions [sqlite_compileoption_used()] and
173 ** [sqlite_compileoption_get()] and the [compile_options pragma].
174 */
175 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
176 SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName);
177 SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N);
178 #endif
179
180 /*
181 ** CAPI3REF: Test To See If The Library Is Threadsafe
182 **
@@ -207,11 +211,11 @@
211 ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
212 ** is unchanged by calls to sqlite3_config().)^
213 **
214 ** See the [threading mode] documentation for additional information.
215 */
216 SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void);
217
218 /*
219 ** CAPI3REF: Database Connection Handle
220 ** KEYWORDS: {database connection} {database connections}
221 **
@@ -303,12 +307,12 @@
307 ** from [sqlite3_open()], [sqlite3_open16()], or
308 ** [sqlite3_open_v2()], and not previously closed.
309 ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
310 ** argument is a harmless no-op.
311 */
312 SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*);
313 SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*);
314
315 /*
316 ** The type for a callback function.
317 ** This is legacy and deprecated. It is included for historical
318 ** compatibility and is not documented.
@@ -374,11 +378,11 @@
378 ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
379 ** <li> The application must not modify the SQL statement text passed into
380 ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
381 ** </ul>
382 */
383 SQLITE_API int SQLITE_STDCALL sqlite3_exec(
384 sqlite3*, /* An open database */
385 const char *sql, /* SQL to be evaluated */
386 int (*callback)(void*,int,char**,char**), /* Callback function */
387 void *, /* 1st argument to callback */
388 char **errmsg /* Error msg written here */
@@ -948,10 +952,17 @@
952 ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
953 ** opcode causes the xFileControl method to swap the file handle with the one
954 ** pointed to by the pArg argument. This capability is used during testing
955 ** and only needs to be supported when SQLITE_TEST is defined.
956 **
957 ** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
958 ** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
959 ** be advantageous to block on the next WAL lock if the lock is not immediately
960 ** available. The WAL subsystem issues this signal during rare
961 ** circumstances in order to fix a problem with priority inversion.
962 ** Applications should <em>not</em> use this file-control.
963 **
964 ** </ul>
965 */
966 #define SQLITE_FCNTL_LOCKSTATE 1
967 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
968 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
@@ -972,10 +983,11 @@
983 #define SQLITE_FCNTL_TRACE 19
984 #define SQLITE_FCNTL_HAS_MOVED 20
985 #define SQLITE_FCNTL_SYNC 21
986 #define SQLITE_FCNTL_COMMIT_PHASETWO 22
987 #define SQLITE_FCNTL_WIN32_SET_HANDLE 23
988 #define SQLITE_FCNTL_WAL_BLOCK 24
989
990 /* deprecated names */
991 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
992 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
993 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -1326,14 +1338,14 @@
1338 ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
1339 ** implementation of sqlite3_os_init() or sqlite3_os_end()
1340 ** must return [SQLITE_OK] on success and some other [error code] upon
1341 ** failure.
1342 */
1343 SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void);
1344 SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void);
1345 SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void);
1346 SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void);
1347
1348 /*
1349 ** CAPI3REF: Configuring The SQLite Library
1350 **
1351 ** The sqlite3_config() interface is used to make global configuration
@@ -1360,11 +1372,11 @@
1372 **
1373 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1374 ** ^If the option is unknown or SQLite is unable to set the option
1375 ** then this routine returns a non-zero [error code].
1376 */
1377 SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...);
1378
1379 /*
1380 ** CAPI3REF: Configure database connections
1381 **
1382 ** The sqlite3_db_config() interface is used to make configuration
@@ -1378,11 +1390,11 @@
1390 ** Subsequent arguments vary depending on the configuration verb.
1391 **
1392 ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
1393 ** the call is considered successful.
1394 */
1395 SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...);
1396
1397 /*
1398 ** CAPI3REF: Memory Allocation Routines
1399 **
1400 ** An instance of this object defines the interface between SQLite
@@ -1538,11 +1550,11 @@
1550 ** disabled, the following SQLite interfaces become non-operational:
1551 ** <ul>
1552 ** <li> [sqlite3_memory_used()]
1553 ** <li> [sqlite3_memory_highwater()]
1554 ** <li> [sqlite3_soft_heap_limit64()]
1555 ** <li> [sqlite3_status64()]
1556 ** </ul>)^
1557 ** ^Memory allocation statistics are enabled by default unless SQLite is
1558 ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
1559 ** allocation statistics are disabled by default.
1560 ** </dd>
@@ -1866,11 +1878,11 @@
1878 **
1879 ** ^The sqlite3_extended_result_codes() routine enables or disables the
1880 ** [extended result codes] feature of SQLite. ^The extended result
1881 ** codes are disabled by default for historical compatibility.
1882 */
1883 SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff);
1884
1885 /*
1886 ** CAPI3REF: Last Insert Rowid
1887 **
1888 ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
@@ -1917,11 +1929,11 @@
1929 ** function is running and thus changes the last insert [rowid],
1930 ** then the value returned by [sqlite3_last_insert_rowid()] is
1931 ** unpredictable and might not equal either the old or the new
1932 ** last insert [rowid].
1933 */
1934 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*);
1935
1936 /*
1937 ** CAPI3REF: Count The Number Of Rows Modified
1938 **
1939 ** ^This function returns the number of rows modified, inserted or
@@ -1969,11 +1981,11 @@
1981 **
1982 ** If a separate thread makes changes on the same database connection
1983 ** while [sqlite3_changes()] is running then the value returned
1984 ** is unpredictable and not meaningful.
1985 */
1986 SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*);
1987
1988 /*
1989 ** CAPI3REF: Total Number Of Rows Modified
1990 **
1991 ** ^This function returns the total number of rows inserted, modified or
@@ -1992,11 +2004,11 @@
2004 **
2005 ** If a separate thread makes changes on the same database connection
2006 ** while [sqlite3_total_changes()] is running then the value
2007 ** returned is unpredictable and not meaningful.
2008 */
2009 SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*);
2010
2011 /*
2012 ** CAPI3REF: Interrupt A Long-Running Query
2013 **
2014 ** ^This function causes any pending database operation to abort and
@@ -2031,11 +2043,11 @@
2043 ** that are started after the sqlite3_interrupt() call returns.
2044 **
2045 ** If the database connection closes while [sqlite3_interrupt()]
2046 ** is running then bad things will likely happen.
2047 */
2048 SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*);
2049
2050 /*
2051 ** CAPI3REF: Determine If An SQL Statement Is Complete
2052 **
2053 ** These routines are useful during command-line input to determine if the
@@ -2066,12 +2078,12 @@
2078 ** UTF-8 string.
2079 **
2080 ** The input to [sqlite3_complete16()] must be a zero-terminated
2081 ** UTF-16 string in native byte order.
2082 */
2083 SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql);
2084 SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
2085
2086 /*
2087 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
2088 ** KEYWORDS: {busy-handler callback} {busy handler}
2089 **
@@ -2127,11 +2139,11 @@
2139 ** result in undefined behavior.
2140 **
2141 ** A busy handler must not close the database connection
2142 ** or [prepared statement] that invoked the busy handler.
2143 */
2144 SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2145
2146 /*
2147 ** CAPI3REF: Set A Busy Timeout
2148 **
2149 ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
@@ -2149,11 +2161,11 @@
2161 ** was defined (using [sqlite3_busy_handler()]) prior to calling
2162 ** this routine, that other busy handler is cleared.)^
2163 **
2164 ** See also: [PRAGMA busy_timeout]
2165 */
2166 SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms);
2167
2168 /*
2169 ** CAPI3REF: Convenience Routines For Running Queries
2170 **
2171 ** This is a legacy interface that is preserved for backwards compatibility.
@@ -2223,19 +2235,19 @@
2235 ** interface defined here. As a consequence, errors that occur in the
2236 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
2237 ** reflected in subsequent calls to [sqlite3_errcode()] or
2238 ** [sqlite3_errmsg()].
2239 */
2240 SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
2241 sqlite3 *db, /* An open database */
2242 const char *zSql, /* SQL to be evaluated */
2243 char ***pazResult, /* Results of the query */
2244 int *pnRow, /* Number of result rows written here */
2245 int *pnColumn, /* Number of result columns written here */
2246 char **pzErrmsg /* Error msg written here */
2247 );
2248 SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result);
2249
2250 /*
2251 ** CAPI3REF: Formatted String Printing Functions
2252 **
2253 ** These routines are work-alikes of the "printf()" family of functions
@@ -2337,14 +2349,14 @@
2349 **
2350 ** ^(The "%z" formatting option works like "%s" but with the
2351 ** addition that after the string has been read and copied into
2352 ** the result, [sqlite3_free()] is called on the input string.)^
2353 */
2354 SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...);
2355 SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list);
2356 SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...);
2357 SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list);
2358
2359 /*
2360 ** CAPI3REF: Memory Allocation Subsystem
2361 **
2362 ** The SQLite core uses these three routines for all of its own
@@ -2430,16 +2442,16 @@
2442 **
2443 ** The application must not read or write any part of
2444 ** a block of memory after it has been released using
2445 ** [sqlite3_free()] or [sqlite3_realloc()].
2446 */
2447 SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int);
2448 SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64);
2449 SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int);
2450 SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64);
2451 SQLITE_API void SQLITE_STDCALL sqlite3_free(void*);
2452 SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*);
2453
2454 /*
2455 ** CAPI3REF: Memory Allocator Statistics
2456 **
2457 ** SQLite provides these two interfaces for reporting on the status
@@ -2460,12 +2472,12 @@
2472 ** [sqlite3_memory_used()] if and only if the parameter to
2473 ** [sqlite3_memory_highwater()] is true. ^The value returned
2474 ** by [sqlite3_memory_highwater(1)] is the high-water mark
2475 ** prior to the reset.
2476 */
2477 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void);
2478 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag);
2479
2480 /*
2481 ** CAPI3REF: Pseudo-Random Number Generator
2482 **
2483 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
@@ -2484,11 +2496,11 @@
2496 ** ^If the previous call to this routine had an N of 1 or more and a
2497 ** non-NULL P then the pseudo-randomness is generated
2498 ** internally and without recourse to the [sqlite3_vfs] xRandomness
2499 ** method.
2500 */
2501 SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P);
2502
2503 /*
2504 ** CAPI3REF: Compile-Time Authorization Callbacks
2505 **
2506 ** ^This routine registers an authorizer callback with a particular
@@ -2566,11 +2578,11 @@
2578 ** [sqlite3_prepare()] or its variants. Authorization is not
2579 ** performed during statement evaluation in [sqlite3_step()], unless
2580 ** as stated in the previous paragraph, sqlite3_step() invokes
2581 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
2582 */
2583 SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
2584 sqlite3*,
2585 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2586 void *pUserData
2587 );
2588
@@ -2670,12 +2682,12 @@
2682 ** digits in the time are meaningless. Future versions of SQLite
2683 ** might provide greater resolution on the profiler callback. The
2684 ** sqlite3_profile() function is considered experimental and is
2685 ** subject to change in future versions of SQLite.
2686 */
2687 SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2688 SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
2689 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2690
2691 /*
2692 ** CAPI3REF: Query Progress Callbacks
2693 **
@@ -2705,11 +2717,11 @@
2717 ** the database connection that invoked the progress handler.
2718 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2719 ** database connections for the meaning of "modify" in this paragraph.
2720 **
2721 */
2722 SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2723
2724 /*
2725 ** CAPI3REF: Opening A New Database Connection
2726 **
2727 ** ^These routines open an SQLite database file as specified by the
@@ -2933,19 +2945,19 @@
2945 ** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various
2946 ** features that require the use of temporary files may fail.
2947 **
2948 ** See also: [sqlite3_temp_directory]
2949 */
2950 SQLITE_API int SQLITE_STDCALL sqlite3_open(
2951 const char *filename, /* Database filename (UTF-8) */
2952 sqlite3 **ppDb /* OUT: SQLite db handle */
2953 );
2954 SQLITE_API int SQLITE_STDCALL sqlite3_open16(
2955 const void *filename, /* Database filename (UTF-16) */
2956 sqlite3 **ppDb /* OUT: SQLite db handle */
2957 );
2958 SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
2959 const char *filename, /* Database filename (UTF-8) */
2960 sqlite3 **ppDb, /* OUT: SQLite db handle */
2961 int flags, /* Flags */
2962 const char *zVfs /* Name of VFS module to use */
2963 );
@@ -2987,23 +2999,25 @@
2999 ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
3000 ** is not a database file pathname pointer that SQLite passed into the xOpen
3001 ** VFS method, then the behavior of this routine is undefined and probably
3002 ** undesirable.
3003 */
3004 SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3005 SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3006 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3007
3008
3009 /*
3010 ** CAPI3REF: Error Codes And Messages
3011 **
3012 ** ^If the most recent sqlite3_* API call associated with
3013 ** [database connection] D failed, then the sqlite3_errcode(D) interface
3014 ** returns the numeric [result code] or [extended result code] for that
3015 ** API call.
3016 ** If the most recent API call was successful,
3017 ** then the return value from sqlite3_errcode() is undefined.
3018 ** ^The sqlite3_extended_errcode()
3019 ** interface is the same except that it always returns the
3020 ** [extended result code] even when extended result codes are
3021 ** disabled.
3022 **
3023 ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -3030,15 +3044,15 @@
3044 **
3045 ** If an interface fails with SQLITE_MISUSE, that means the interface
3046 ** was invoked incorrectly by the application. In that case, the
3047 ** error code and message may or may not be set.
3048 */
3049 SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db);
3050 SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db);
3051 SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*);
3052 SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*);
3053 SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int);
3054
3055 /*
3056 ** CAPI3REF: SQL Statement Object
3057 ** KEYWORDS: {prepared statement} {prepared statements}
3058 **
@@ -3101,11 +3115,11 @@
3115 ** created by an untrusted script can be contained using the
3116 ** [max_page_count] [PRAGMA].
3117 **
3118 ** New run-time limit categories may be added in future releases.
3119 */
3120 SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal);
3121
3122 /*
3123 ** CAPI3REF: Run-Time Limit Categories
3124 ** KEYWORDS: {limit category} {*limit categories}
3125 **
@@ -3251,32 +3265,32 @@
3265 ** or [GLOB] operator or if the parameter is compared to an indexed column
3266 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3267 ** </li>
3268 ** </ol>
3269 */
3270 SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
3271 sqlite3 *db, /* Database handle */
3272 const char *zSql, /* SQL statement, UTF-8 encoded */
3273 int nByte, /* Maximum length of zSql in bytes. */
3274 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3275 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3276 );
3277 SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
3278 sqlite3 *db, /* Database handle */
3279 const char *zSql, /* SQL statement, UTF-8 encoded */
3280 int nByte, /* Maximum length of zSql in bytes. */
3281 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3282 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3283 );
3284 SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
3285 sqlite3 *db, /* Database handle */
3286 const void *zSql, /* SQL statement, UTF-16 encoded */
3287 int nByte, /* Maximum length of zSql in bytes. */
3288 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3289 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3290 );
3291 SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
3292 sqlite3 *db, /* Database handle */
3293 const void *zSql, /* SQL statement, UTF-16 encoded */
3294 int nByte, /* Maximum length of zSql in bytes. */
3295 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3296 const void **pzTail /* OUT: Pointer to unused portion of zSql */
@@ -3287,11 +3301,11 @@
3301 **
3302 ** ^This interface can be used to retrieve a saved copy of the original
3303 ** SQL text used to create a [prepared statement] if that statement was
3304 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3305 */
3306 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
3307
3308 /*
3309 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3310 **
3311 ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
@@ -3318,11 +3332,11 @@
3332 ** database. ^The [ATTACH] and [DETACH] statements also cause
3333 ** sqlite3_stmt_readonly() to return true since, while those statements
3334 ** change the configuration of a database connection, they do not make
3335 ** changes to the content of the database files on disk.
3336 */
3337 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
3338
3339 /*
3340 ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
3341 **
3342 ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
@@ -3337,11 +3351,11 @@
3351 ** to locate all prepared statements associated with a database
3352 ** connection that are in need of being reset. This can be used,
3353 ** for example, in diagnostic routines to search for prepared
3354 ** statements that are holding a transaction open.
3355 */
3356 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*);
3357
3358 /*
3359 ** CAPI3REF: Dynamically Typed Value Object
3360 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
3361 **
@@ -3498,23 +3512,23 @@
3512 ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
3513 **
3514 ** See also: [sqlite3_bind_parameter_count()],
3515 ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
3516 */
3517 SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3518 SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
3519 void(*)(void*));
3520 SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double);
3521 SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int);
3522 SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3523 SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int);
3524 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3525 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3526 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3527 void(*)(void*), unsigned char encoding);
3528 SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3529 SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3530
3531 /*
3532 ** CAPI3REF: Number Of SQL Parameters
3533 **
3534 ** ^This routine can be used to find the number of [SQL parameters]
@@ -3530,11 +3544,11 @@
3544 **
3545 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3546 ** [sqlite3_bind_parameter_name()], and
3547 ** [sqlite3_bind_parameter_index()].
3548 */
3549 SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*);
3550
3551 /*
3552 ** CAPI3REF: Name Of A Host Parameter
3553 **
3554 ** ^The sqlite3_bind_parameter_name(P,N) interface returns
@@ -3557,11 +3571,11 @@
3571 **
3572 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3573 ** [sqlite3_bind_parameter_count()], and
3574 ** [sqlite3_bind_parameter_index()].
3575 */
3576 SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3577
3578 /*
3579 ** CAPI3REF: Index Of A Parameter With A Given Name
3580 **
3581 ** ^Return the index of an SQL parameter given its name. ^The
@@ -3573,20 +3587,20 @@
3587 **
3588 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3589 ** [sqlite3_bind_parameter_count()], and
3590 ** [sqlite3_bind_parameter_index()].
3591 */
3592 SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3593
3594 /*
3595 ** CAPI3REF: Reset All Bindings On A Prepared Statement
3596 **
3597 ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
3598 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
3599 ** ^Use this routine to reset all host parameters to NULL.
3600 */
3601 SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*);
3602
3603 /*
3604 ** CAPI3REF: Number Of Columns In A Result Set
3605 **
3606 ** ^Return the number of columns in the result set returned by the
@@ -3593,11 +3607,11 @@
3607 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
3608 ** statement that does not return data (for example an [UPDATE]).
3609 **
3610 ** See also: [sqlite3_data_count()]
3611 */
3612 SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt);
3613
3614 /*
3615 ** CAPI3REF: Column Names In A Result Set
3616 **
3617 ** ^These routines return the name assigned to a particular column
@@ -3621,12 +3635,12 @@
3635 ** ^The name of a result column is the value of the "AS" clause for
3636 ** that column, if there is an AS clause. If there is no AS clause
3637 ** then the name of the column is unspecified and may change from
3638 ** one release of SQLite to the next.
3639 */
3640 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N);
3641 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N);
3642
3643 /*
3644 ** CAPI3REF: Source Of Data In A Query Result
3645 **
3646 ** ^These routines provide a means to determine the database, table, and
@@ -3669,16 +3683,16 @@
3683 ** If two or more threads call one or more
3684 ** [sqlite3_column_database_name | column metadata interfaces]
3685 ** for the same [prepared statement] and result column
3686 ** at the same time then the results are undefined.
3687 */
3688 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int);
3689 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int);
3690 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int);
3691 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int);
3692 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int);
3693 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int);
3694
3695 /*
3696 ** CAPI3REF: Declared Datatype Of A Query Result
3697 **
3698 ** ^(The first parameter is a [prepared statement].
@@ -3705,12 +3719,12 @@
3719 ** data stored in that column is of the declared type. SQLite is
3720 ** strongly typed, but the typing is dynamic not static. ^Type
3721 ** is associated with individual values, not with the containers
3722 ** used to hold those values.
3723 */
3724 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int);
3725 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int);
3726
3727 /*
3728 ** CAPI3REF: Evaluate An SQL Statement
3729 **
3730 ** After a [prepared statement] has been prepared using either
@@ -3785,11 +3799,11 @@
3799 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
3800 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
3801 ** then the more specific [error codes] are returned directly
3802 ** by sqlite3_step(). The use of the "v2" interface is recommended.
3803 */
3804 SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*);
3805
3806 /*
3807 ** CAPI3REF: Number of columns in a result set
3808 **
3809 ** ^The sqlite3_data_count(P) interface returns the number of columns in the
@@ -3805,11 +3819,11 @@
3819 ** where it always returns zero since each step of that multi-step
3820 ** pragma returns 0 columns of data.
3821 **
3822 ** See also: [sqlite3_column_count()]
3823 */
3824 SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt);
3825
3826 /*
3827 ** CAPI3REF: Fundamental Datatypes
3828 ** KEYWORDS: SQLITE_TEXT
3829 **
@@ -4001,20 +4015,20 @@
4015 ** of these routines, a default value is returned. The default value
4016 ** is either the integer 0, the floating point number 0.0, or a NULL
4017 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
4018 ** [SQLITE_NOMEM].)^
4019 */
4020 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol);
4021 SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4022 SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4023 SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol);
4024 SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol);
4025 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol);
4026 SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol);
4027 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol);
4028 SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol);
4029 SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol);
4030
4031 /*
4032 ** CAPI3REF: Destroy A Prepared Statement Object
4033 **
4034 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
@@ -4037,11 +4051,11 @@
4051 ** resource leaks. It is a grievous error for the application to try to use
4052 ** a prepared statement after it has been finalized. Any use of a prepared
4053 ** statement after it has been finalized can result in undefined and
4054 ** undesirable behavior such as segfaults and heap corruption.
4055 */
4056 SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt);
4057
4058 /*
4059 ** CAPI3REF: Reset A Prepared Statement Object
4060 **
4061 ** The sqlite3_reset() function is called to reset a [prepared statement]
@@ -4063,11 +4077,11 @@
4077 ** [sqlite3_reset(S)] returns an appropriate [error code].
4078 **
4079 ** ^The [sqlite3_reset(S)] interface does not change the values
4080 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
4081 */
4082 SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt);
4083
4084 /*
4085 ** CAPI3REF: Create Or Redefine SQL Functions
4086 ** KEYWORDS: {function creation routines}
4087 ** KEYWORDS: {application-defined SQL function}
@@ -4162,31 +4176,31 @@
4176 ** ^An application-defined function is permitted to call other
4177 ** SQLite interfaces. However, such calls must not
4178 ** close the database connection nor finalize or reset the prepared
4179 ** statement in which the function is running.
4180 */
4181 SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
4182 sqlite3 *db,
4183 const char *zFunctionName,
4184 int nArg,
4185 int eTextRep,
4186 void *pApp,
4187 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4188 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4189 void (*xFinal)(sqlite3_context*)
4190 );
4191 SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
4192 sqlite3 *db,
4193 const void *zFunctionName,
4194 int nArg,
4195 int eTextRep,
4196 void *pApp,
4197 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4198 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4199 void (*xFinal)(sqlite3_context*)
4200 );
4201 SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
4202 sqlite3 *db,
4203 const char *zFunctionName,
4204 int nArg,
4205 int eTextRep,
4206 void *pApp,
@@ -4228,16 +4242,16 @@
4242 ** to be supported. However, new applications should avoid
4243 ** the use of these functions. To encourage programmers to avoid
4244 ** these functions, we will not explain what they do.
4245 */
4246 #ifndef SQLITE_OMIT_DEPRECATED
4247 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*);
4248 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*);
4249 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4250 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void);
4251 SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void);
4252 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4253 void*,sqlite3_int64);
4254 #endif
4255
4256 /*
4257 ** CAPI3REF: Obtaining SQL Function Parameter Values
@@ -4282,22 +4296,22 @@
4296 ** or [sqlite3_value_text16()].
4297 **
4298 ** These routines must be called from the same thread as
4299 ** the SQL function that supplied the [sqlite3_value*] parameters.
4300 */
4301 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*);
4302 SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*);
4303 SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*);
4304 SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*);
4305 SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*);
4306 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*);
4307 SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*);
4308 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*);
4309 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*);
4310 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*);
4311 SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*);
4312 SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*);
4313
4314 /*
4315 ** CAPI3REF: Obtain Aggregate Function Context
4316 **
4317 ** Implementations of aggregate SQL functions use this
@@ -4337,11 +4351,11 @@
4351 ** function.
4352 **
4353 ** This routine must be called from the same thread in which
4354 ** the aggregate SQL function is running.
4355 */
4356 SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes);
4357
4358 /*
4359 ** CAPI3REF: User Data For Functions
4360 **
4361 ** ^The sqlite3_user_data() interface returns a copy of
@@ -4351,11 +4365,11 @@
4365 ** registered the application defined function.
4366 **
4367 ** This routine must be called from the same thread in which
4368 ** the application-defined function is running.
4369 */
4370 SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*);
4371
4372 /*
4373 ** CAPI3REF: Database Connection For Functions
4374 **
4375 ** ^The sqlite3_context_db_handle() interface returns a copy of
@@ -4362,11 +4376,11 @@
4376 ** the pointer to the [database connection] (the 1st parameter)
4377 ** of the [sqlite3_create_function()]
4378 ** and [sqlite3_create_function16()] routines that originally
4379 ** registered the application defined function.
4380 */
4381 SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
4382
4383 /*
4384 ** CAPI3REF: Function Auxiliary Data
4385 **
4386 ** These functions may be used by (non-aggregate) SQL functions to
@@ -4414,12 +4428,12 @@
4428 ** values and [parameters] and expressions composed from the same.)^
4429 **
4430 ** These routines must be called from the same thread in which
4431 ** the SQL function is running.
4432 */
4433 SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N);
4434 SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
4435
4436
4437 /*
4438 ** CAPI3REF: Constants Defining Special Destructor Behavior
4439 **
@@ -4550,30 +4564,30 @@
4564 **
4565 ** If these routines are called from within the different thread
4566 ** than the one containing the application-defined function that received
4567 ** the [sqlite3_context] pointer, the results are undefined.
4568 */
4569 SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4570 SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*,
4571 sqlite3_uint64,void(*)(void*));
4572 SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double);
4573 SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int);
4574 SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int);
4575 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*);
4576 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*);
4577 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int);
4578 SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int);
4579 SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4580 SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*);
4581 SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4582 SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
4583 void(*)(void*), unsigned char encoding);
4584 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4585 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4586 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4587 SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4588 SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n);
4589
4590 /*
4591 ** CAPI3REF: Define New Collating Sequences
4592 **
4593 ** ^These functions add, remove, or modify a [collation] associated
@@ -4650,26 +4664,26 @@
4664 ** is unfortunate but cannot be changed without breaking backwards
4665 ** compatibility.
4666 **
4667 ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
4668 */
4669 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
4670 sqlite3*,
4671 const char *zName,
4672 int eTextRep,
4673 void *pArg,
4674 int(*xCompare)(void*,int,const void*,int,const void*)
4675 );
4676 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
4677 sqlite3*,
4678 const char *zName,
4679 int eTextRep,
4680 void *pArg,
4681 int(*xCompare)(void*,int,const void*,int,const void*),
4682 void(*xDestroy)(void*)
4683 );
4684 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
4685 sqlite3*,
4686 const void *zName,
4687 int eTextRep,
4688 void *pArg,
4689 int(*xCompare)(void*,int,const void*,int,const void*)
@@ -4699,16 +4713,16 @@
4713 **
4714 ** The callback function should register the desired collation using
4715 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
4716 ** [sqlite3_create_collation_v2()].
4717 */
4718 SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
4719 sqlite3*,
4720 void*,
4721 void(*)(void*,sqlite3*,int eTextRep,const char*)
4722 );
4723 SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
4724 sqlite3*,
4725 void*,
4726 void(*)(void*,sqlite3*,int eTextRep,const void*)
4727 );
4728
@@ -4718,15 +4732,15 @@
4732 ** called right after sqlite3_open().
4733 **
4734 ** The code to implement this API is not available in the public release
4735 ** of SQLite.
4736 */
4737 SQLITE_API int SQLITE_STDCALL sqlite3_key(
4738 sqlite3 *db, /* Database to be rekeyed */
4739 const void *pKey, int nKey /* The key */
4740 );
4741 SQLITE_API int SQLITE_STDCALL sqlite3_key_v2(
4742 sqlite3 *db, /* Database to be rekeyed */
4743 const char *zDbName, /* Name of the database */
4744 const void *pKey, int nKey /* The key */
4745 );
4746
@@ -4736,35 +4750,35 @@
4750 ** database is decrypted.
4751 **
4752 ** The code to implement this API is not available in the public release
4753 ** of SQLite.
4754 */
4755 SQLITE_API int SQLITE_STDCALL sqlite3_rekey(
4756 sqlite3 *db, /* Database to be rekeyed */
4757 const void *pKey, int nKey /* The new key */
4758 );
4759 SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2(
4760 sqlite3 *db, /* Database to be rekeyed */
4761 const char *zDbName, /* Name of the database */
4762 const void *pKey, int nKey /* The new key */
4763 );
4764
4765 /*
4766 ** Specify the activation key for a SEE database. Unless
4767 ** activated, none of the SEE routines will work.
4768 */
4769 SQLITE_API void SQLITE_STDCALL sqlite3_activate_see(
4770 const char *zPassPhrase /* Activation phrase */
4771 );
4772 #endif
4773
4774 #ifdef SQLITE_ENABLE_CEROD
4775 /*
4776 ** Specify the activation key for a CEROD database. Unless
4777 ** activated, none of the CEROD routines will work.
4778 */
4779 SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod(
4780 const char *zPassPhrase /* Activation phrase */
4781 );
4782 #endif
4783
4784 /*
@@ -4782,11 +4796,11 @@
4796 ** method of the default [sqlite3_vfs] object. If the xSleep() method
4797 ** of the default VFS is not implemented correctly, or not implemented at
4798 ** all, then the behavior of sqlite3_sleep() may deviate from the description
4799 ** in the previous paragraphs.
4800 */
4801 SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int);
4802
4803 /*
4804 ** CAPI3REF: Name Of The Folder Holding Temporary Files
4805 **
4806 ** ^(If this global variable is made to point to a string which is
@@ -4900,11 +4914,11 @@
4914 **
4915 ** If another thread changes the autocommit status of the database
4916 ** connection while this routine is running, then the return value
4917 ** is undefined.
4918 */
4919 SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*);
4920
4921 /*
4922 ** CAPI3REF: Find The Database Handle Of A Prepared Statement
4923 **
4924 ** ^The sqlite3_db_handle interface returns the [database connection] handle
@@ -4912,11 +4926,11 @@
4926 ** returned by sqlite3_db_handle is the same [database connection]
4927 ** that was the first argument
4928 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
4929 ** create the statement in the first place.
4930 */
4931 SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*);
4932
4933 /*
4934 ** CAPI3REF: Return The Filename For A Database Connection
4935 **
4936 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
@@ -4928,20 +4942,20 @@
4942 ** ^The filename returned by this function is the output of the
4943 ** xFullPathname method of the [VFS]. ^In other words, the filename
4944 ** will be an absolute pathname, even if the filename used
4945 ** to open the database originally was a URI or relative pathname.
4946 */
4947 SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName);
4948
4949 /*
4950 ** CAPI3REF: Determine if a database is read-only
4951 **
4952 ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
4953 ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
4954 ** the name of a database on connection D.
4955 */
4956 SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
4957
4958 /*
4959 ** CAPI3REF: Find the next prepared statement
4960 **
4961 ** ^This interface returns a pointer to the next [prepared statement] after
@@ -4952,11 +4966,11 @@
4966 **
4967 ** The [database connection] pointer D in a call to
4968 ** [sqlite3_next_stmt(D,S)] must refer to an open database
4969 ** connection and in particular must not be a NULL pointer.
4970 */
4971 SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
4972
4973 /*
4974 ** CAPI3REF: Commit And Rollback Notification Callbacks
4975 **
4976 ** ^The sqlite3_commit_hook() interface registers a callback
@@ -5000,12 +5014,12 @@
5014 ** ^The rollback callback is not invoked if a transaction is
5015 ** automatically rolled back because the database connection is closed.
5016 **
5017 ** See also the [sqlite3_update_hook()] interface.
5018 */
5019 SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5020 SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
5021
5022 /*
5023 ** CAPI3REF: Data Change Notification Callbacks
5024 **
5025 ** ^The sqlite3_update_hook() interface registers a callback function
@@ -5051,11 +5065,11 @@
5065 ** the first call on D.
5066 **
5067 ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
5068 ** interfaces.
5069 */
5070 SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
5071 sqlite3*,
5072 void(*)(void *,int ,char const *,char const *,sqlite3_int64),
5073 void*
5074 );
5075
@@ -5091,11 +5105,11 @@
5105 ** This interface is threadsafe on processors where writing a
5106 ** 32-bit integer is atomic.
5107 **
5108 ** See Also: [SQLite Shared-Cache Mode]
5109 */
5110 SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int);
5111
5112 /*
5113 ** CAPI3REF: Attempt To Free Heap Memory
5114 **
5115 ** ^The sqlite3_release_memory() interface attempts to free N bytes
@@ -5107,11 +5121,11 @@
5121 ** ^The sqlite3_release_memory() routine is a no-op returning zero
5122 ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5123 **
5124 ** See also: [sqlite3_db_release_memory()]
5125 */
5126 SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int);
5127
5128 /*
5129 ** CAPI3REF: Free Memory Used By A Database Connection
5130 **
5131 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
@@ -5120,11 +5134,11 @@
5134 ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
5135 ** omitted.
5136 **
5137 ** See also: [sqlite3_release_memory()]
5138 */
5139 SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*);
5140
5141 /*
5142 ** CAPI3REF: Impose A Limit On Heap Size
5143 **
5144 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
@@ -5172,11 +5186,11 @@
5186 ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5187 **
5188 ** The circumstances under which SQLite will enforce the soft heap limit may
5189 ** changes in future releases of SQLite.
5190 */
5191 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N);
5192
5193 /*
5194 ** CAPI3REF: Deprecated Soft Heap Limit Interface
5195 ** DEPRECATED
5196 **
@@ -5183,11 +5197,11 @@
5197 ** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
5198 ** interface. This routine is provided for historical compatibility
5199 ** only. All new applications should use the
5200 ** [sqlite3_soft_heap_limit64()] interface rather than this one.
5201 */
5202 SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
5203
5204
5205 /*
5206 ** CAPI3REF: Extract Metadata About A Column Of A Table
5207 **
@@ -5252,11 +5266,11 @@
5266 **
5267 ** ^This function causes all database schemas to be read from disk and
5268 ** parsed, if that has not already been done, and returns an error if
5269 ** any errors are encountered while loading the schema.
5270 */
5271 SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
5272 sqlite3 *db, /* Connection handle */
5273 const char *zDbName, /* Database name or NULL */
5274 const char *zTableName, /* Table name */
5275 const char *zColumnName, /* Column name */
5276 char const **pzDataType, /* OUTPUT: Declared data type */
@@ -5298,11 +5312,11 @@
5312 ** [sqlite3_enable_load_extension()] prior to calling this API,
5313 ** otherwise an error will be returned.
5314 **
5315 ** See also the [load_extension() SQL function].
5316 */
5317 SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
5318 sqlite3 *db, /* Load the extension into this database connection */
5319 const char *zFile, /* Name of the shared library containing extension */
5320 const char *zProc, /* Entry point. Derived from zFile if 0 */
5321 char **pzErrMsg /* Put error message here if not 0 */
5322 );
@@ -5318,11 +5332,11 @@
5332 ** ^Extension loading is off by default.
5333 ** ^Call the sqlite3_enable_load_extension() routine with onoff==1
5334 ** to turn extension loading on and call it with onoff==0 to turn
5335 ** it back off again.
5336 */
5337 SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
5338
5339 /*
5340 ** CAPI3REF: Automatically Load Statically Linked Extensions
5341 **
5342 ** ^This interface causes the xEntryPoint() function to be invoked for
@@ -5356,11 +5370,11 @@
5370 ** will be called more than once for each database connection that is opened.
5371 **
5372 ** See also: [sqlite3_reset_auto_extension()]
5373 ** and [sqlite3_cancel_auto_extension()]
5374 */
5375 SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
5376
5377 /*
5378 ** CAPI3REF: Cancel Automatic Extension Loading
5379 **
5380 ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5368,19 +5382,19 @@
5382 ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
5383 ** routine returns 1 if initialization routine X was successfully
5384 ** unregistered and it returns 0 if X was not on the list of initialization
5385 ** routines.
5386 */
5387 SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5388
5389 /*
5390 ** CAPI3REF: Reset Automatic Extension Loading
5391 **
5392 ** ^This interface disables all automatic extensions previously
5393 ** registered using [sqlite3_auto_extension()].
5394 */
5395 SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void);
5396
5397 /*
5398 ** The interface to the virtual-table mechanism is currently considered
5399 ** to be experimental. The interface might change in incompatible ways.
5400 ** If this is a problem for you, do not use the interface at this time.
@@ -5579,17 +5593,17 @@
5593 ** be invoked if the call to sqlite3_create_module_v2() fails.
5594 ** ^The sqlite3_create_module()
5595 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
5596 ** destructor.
5597 */
5598 SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
5599 sqlite3 *db, /* SQLite connection to register module with */
5600 const char *zName, /* Name of the module */
5601 const sqlite3_module *p, /* Methods for the module */
5602 void *pClientData /* Client data for xCreate/xConnect */
5603 );
5604 SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
5605 sqlite3 *db, /* SQLite connection to register module with */
5606 const char *zName, /* Name of the module */
5607 const sqlite3_module *p, /* Methods for the module */
5608 void *pClientData, /* Client data for xCreate/xConnect */
5609 void(*xDestroy)(void*) /* Module destructor function */
@@ -5613,11 +5627,11 @@
5627 ** is delivered up to the client application, the string will be automatically
5628 ** freed by sqlite3_free() and the zErrMsg field will be zeroed.
5629 */
5630 struct sqlite3_vtab {
5631 const sqlite3_module *pModule; /* The module for this virtual table */
5632 int nRef; /* Number of open cursors */
5633 char *zErrMsg; /* Error message from sqlite3_mprintf() */
5634 /* Virtual table implementations will typically add additional fields */
5635 };
5636
5637 /*
@@ -5648,11 +5662,11 @@
5662 ** ^The [xCreate] and [xConnect] methods of a
5663 ** [virtual table module] call this interface
5664 ** to declare the format (the names and datatypes of the columns) of
5665 ** the virtual tables they implement.
5666 */
5667 SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL);
5668
5669 /*
5670 ** CAPI3REF: Overload A Function For A Virtual Table
5671 **
5672 ** ^(Virtual tables can provide alternative implementations of functions
@@ -5666,11 +5680,11 @@
5680 ** of the new function always causes an exception to be thrown. So
5681 ** the new function is not good for anything by itself. Its only
5682 ** purpose is to be a placeholder function that can be overloaded
5683 ** by a [virtual table].
5684 */
5685 SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
5686
5687 /*
5688 ** The interface to the virtual-table mechanism defined above (back up
5689 ** to a comment remarkably similar to this one) is currently considered
5690 ** to be experimental. The interface might change in incompatible ways.
@@ -5763,11 +5777,11 @@
5777 ** zero-filled blob to read or write using the incremental-blob interface.
5778 **
5779 ** To avoid a resource leak, every open [BLOB handle] should eventually
5780 ** be released by a call to [sqlite3_blob_close()].
5781 */
5782 SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
5783 sqlite3*,
5784 const char *zDb,
5785 const char *zTable,
5786 const char *zColumn,
5787 sqlite3_int64 iRow,
@@ -5795,11 +5809,11 @@
5809 ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
5810 ** always returns zero.
5811 **
5812 ** ^This function sets the database handle error code and message.
5813 */
5814 SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
5815
5816 /*
5817 ** CAPI3REF: Close A BLOB Handle
5818 **
5819 ** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
@@ -5817,11 +5831,11 @@
5831 ** with a null pointer (such as would be returned by a failed call to
5832 ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
5833 ** is passed a valid open blob handle, the values returned by the
5834 ** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
5835 */
5836 SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *);
5837
5838 /*
5839 ** CAPI3REF: Return The Size Of An Open BLOB
5840 **
5841 ** ^Returns the size in bytes of the BLOB accessible via the
@@ -5832,11 +5846,11 @@
5846 ** This routine only works on a [BLOB handle] which has been created
5847 ** by a prior successful call to [sqlite3_blob_open()] and which has not
5848 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5849 ** to this routine results in undefined and probably undesirable behavior.
5850 */
5851 SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *);
5852
5853 /*
5854 ** CAPI3REF: Read Data From A BLOB Incrementally
5855 **
5856 ** ^(This function is used to read data from an open [BLOB handle] into a
@@ -5860,11 +5874,11 @@
5874 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5875 ** to this routine results in undefined and probably undesirable behavior.
5876 **
5877 ** See also: [sqlite3_blob_write()].
5878 */
5879 SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
5880
5881 /*
5882 ** CAPI3REF: Write Data Into A BLOB Incrementally
5883 **
5884 ** ^(This function is used to write data into an open [BLOB handle] from a
@@ -5901,11 +5915,11 @@
5915 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5916 ** to this routine results in undefined and probably undesirable behavior.
5917 **
5918 ** See also: [sqlite3_blob_read()].
5919 */
5920 SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
5921
5922 /*
5923 ** CAPI3REF: Virtual File System Objects
5924 **
5925 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
@@ -5932,13 +5946,13 @@
5946 **
5947 ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
5948 ** ^(If the default VFS is unregistered, another VFS is chosen as
5949 ** the default. The choice for the new VFS is arbitrary.)^
5950 */
5951 SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName);
5952 SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
5953 SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*);
5954
5955 /*
5956 ** CAPI3REF: Mutexes
5957 **
5958 ** The SQLite core uses these routines for thread
@@ -6047,15 +6061,15 @@
6061 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
6062 ** behave as no-ops.
6063 **
6064 ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
6065 */
6066 SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int);
6067 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*);
6068 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*);
6069 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*);
6070 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*);
6071
6072 /*
6073 ** CAPI3REF: Mutex Methods Object
6074 **
6075 ** An instance of this structure defines the low-level routines
@@ -6161,12 +6175,12 @@
6175 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
6176 ** the appropriate thing to do. The sqlite3_mutex_notheld()
6177 ** interface should also return 1 when given a NULL pointer.
6178 */
6179 #ifndef NDEBUG
6180 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*);
6181 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*);
6182 #endif
6183
6184 /*
6185 ** CAPI3REF: Mutex Types
6186 **
@@ -6198,11 +6212,11 @@
6212 ** serializes access to the [database connection] given in the argument
6213 ** when the [threading mode] is Serialized.
6214 ** ^If the [threading mode] is Single-thread or Multi-thread then this
6215 ** routine returns a NULL pointer.
6216 */
6217 SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*);
6218
6219 /*
6220 ** CAPI3REF: Low-Level Control Of Database Files
6221 **
6222 ** ^The [sqlite3_file_control()] interface makes a direct call to the
@@ -6232,11 +6246,11 @@
6246 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
6247 ** xFileControl method.
6248 **
6249 ** See also: [SQLITE_FCNTL_LOCKSTATE]
6250 */
6251 SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
6252
6253 /*
6254 ** CAPI3REF: Testing Interface
6255 **
6256 ** ^The sqlite3_test_control() interface is used to read out internal
@@ -6251,11 +6265,11 @@
6265 ** The details of the operation codes, their meanings, the parameters
6266 ** they take, and what they do are all subject to change without notice.
6267 ** Unlike most of the SQLite API, this function is not guaranteed to
6268 ** operate consistently from one release to the next.
6269 */
6270 SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...);
6271
6272 /*
6273 ** CAPI3REF: Testing Interface Operation Codes
6274 **
6275 ** These constants are the valid operation code parameters used
@@ -6291,11 +6305,11 @@
6305 #define SQLITE_TESTCTRL_LAST 25
6306
6307 /*
6308 ** CAPI3REF: SQLite Runtime Status
6309 **
6310 ** ^These interfaces are used to retrieve runtime status information
6311 ** about the performance of SQLite, and optionally to reset various
6312 ** highwater marks. ^The first argument is an integer code for
6313 ** the specific parameter to measure. ^(Recognized integer codes
6314 ** are of the form [status parameters | SQLITE_STATUS_...].)^
6315 ** ^The current value of the parameter is returned into *pCurrent.
@@ -6305,23 +6319,26 @@
6319 ** value. For those parameters
6320 ** nothing is written into *pHighwater and the resetFlag is ignored.)^
6321 ** ^(Other parameters record only the highwater mark and not the current
6322 ** value. For these latter parameters nothing is written into *pCurrent.)^
6323 **
6324 ** ^The sqlite3_status() and sqlite3_status64() routines return
6325 ** SQLITE_OK on success and a non-zero [error code] on failure.
6326 **
6327 ** If either the current value or the highwater mark is too large to
6328 ** be represented by a 32-bit integer, then the values returned by
6329 ** sqlite3_status() are undefined.
 
 
 
6330 **
6331 ** See also: [sqlite3_db_status()]
6332 */
6333 SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6334 SQLITE_API int SQLITE_STDCALL sqlite3_status64(
6335 int op,
6336 sqlite3_int64 *pCurrent,
6337 sqlite3_int64 *pHighwater,
6338 int resetFlag
6339 );
6340
6341
6342 /*
6343 ** CAPI3REF: Status Parameters
6344 ** KEYWORDS: {status parameters}
@@ -6435,11 +6452,11 @@
6452 ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
6453 ** non-zero [error code] on failure.
6454 **
6455 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
6456 */
6457 SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
6458
6459 /*
6460 ** CAPI3REF: Status Parameters for database connections
6461 ** KEYWORDS: {SQLITE_DBSTATUS options}
6462 **
@@ -6564,11 +6581,11 @@
6581 ** ^If the resetFlg is true, then the counter is reset to zero after this
6582 ** interface call returns.
6583 **
6584 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
6585 */
6586 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
6587
6588 /*
6589 ** CAPI3REF: Status Parameters for prepared statements
6590 ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}
6591 **
@@ -7033,20 +7050,20 @@
7050 ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
7051 ** APIs are not strictly speaking threadsafe. If they are invoked at the
7052 ** same time as another thread is invoking sqlite3_backup_step() it is
7053 ** possible that they return invalid values.
7054 */
7055 SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
7056 sqlite3 *pDest, /* Destination database handle */
7057 const char *zDestName, /* Destination database name */
7058 sqlite3 *pSource, /* Source database handle */
7059 const char *zSourceName /* Source database name */
7060 );
7061 SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage);
7062 SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p);
7063 SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p);
7064 SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p);
7065
7066 /*
7067 ** CAPI3REF: Unlock Notification
7068 **
7069 ** ^When running in shared-cache mode, a database operation may fail with
@@ -7158,11 +7175,11 @@
7175 ** by an sqlite3_step() call. ^(If there is a blocking connection, then the
7176 ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
7177 ** the special "DROP TABLE/INDEX" case, the extended error code is just
7178 ** SQLITE_LOCKED.)^
7179 */
7180 SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
7181 sqlite3 *pBlocked, /* Waiting connection */
7182 void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
7183 void *pNotifyArg /* Argument to pass to xNotify */
7184 );
7185
@@ -7173,12 +7190,12 @@
7190 ** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
7191 ** and extensions to compare the contents of two buffers containing UTF-8
7192 ** strings in a case-independent fashion, using the same definition of "case
7193 ** independence" that SQLite uses internally when comparing identifiers.
7194 */
7195 SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *);
7196 SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
7197
7198 /*
7199 ** CAPI3REF: String Globbing
7200 *
7201 ** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
@@ -7189,11 +7206,11 @@
7206 ** sensitive.
7207 **
7208 ** Note that this routine returns zero on a match and non-zero if the strings
7209 ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
7210 */
7211 SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
7212
7213 /*
7214 ** CAPI3REF: Error Logging Interface
7215 **
7216 ** ^The [sqlite3_log()] interface writes a message into the [error log]
@@ -7212,11 +7229,11 @@
7229 ** will not use dynamically allocated memory. The log message is stored in
7230 ** a fixed-length buffer on the stack. If the log message is longer than
7231 ** a few hundred characters, it will be truncated to the length of the
7232 ** buffer.
7233 */
7234 SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...);
7235
7236 /*
7237 ** CAPI3REF: Write-Ahead Log Commit Hook
7238 **
7239 ** ^The [sqlite3_wal_hook()] function is used to register a callback that
@@ -7247,11 +7264,11 @@
7264 ** previously registered write-ahead log callback. ^Note that the
7265 ** [sqlite3_wal_autocheckpoint()] interface and the
7266 ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
7267 ** those overwrite any prior [sqlite3_wal_hook()] settings.
7268 */
7269 SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
7270 sqlite3*,
7271 int(*)(void *,sqlite3*,const char*,int),
7272 void*
7273 );
7274
@@ -7281,11 +7298,11 @@
7298 ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
7299 ** pages. The use of this interface
7300 ** is only necessary if the default setting is found to be suboptimal
7301 ** for a particular application.
7302 */
7303 SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
7304
7305 /*
7306 ** CAPI3REF: Checkpoint a database
7307 **
7308 ** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
@@ -7302,11 +7319,11 @@
7319 ** interface was added. This interface is retained for backwards
7320 ** compatibility and as a convenience for applications that need to manually
7321 ** start a callback but which do not need the full power (and corresponding
7322 ** complication) of [sqlite3_wal_checkpoint_v2()].
7323 */
7324 SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
7325
7326 /*
7327 ** CAPI3REF: Checkpoint a database
7328 **
7329 ** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
@@ -7395,11 +7412,11 @@
7412 ** [sqlite3_errcode()] and [sqlite3_errmsg()].
7413 **
7414 ** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
7415 ** from SQL.
7416 */
7417 SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
7418 sqlite3 *db, /* Database handle */
7419 const char *zDb, /* Name of attached database (or NULL) */
7420 int eMode, /* SQLITE_CHECKPOINT_* value */
7421 int *pnLog, /* OUT: Size of WAL log in frames */
7422 int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -7431,11 +7448,11 @@
7448 **
7449 ** At present, there is only one option that may be configured using
7450 ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
7451 ** may be added in the future.
7452 */
7453 SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...);
7454
7455 /*
7456 ** CAPI3REF: Virtual Table Configuration Options
7457 **
7458 ** These macros define the various options to the
@@ -7484,11 +7501,11 @@
7501 ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],
7502 ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode
7503 ** of the SQL statement that triggered the call to the [xUpdate] method of the
7504 ** [virtual table].
7505 */
7506 SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *);
7507
7508 /*
7509 ** CAPI3REF: Conflict resolution modes
7510 ** KEYWORDS: {conflict resolution mode}
7511 **
@@ -7588,11 +7605,11 @@
7605 ** as if the loop did not exist - it returns non-zero and leave the variable
7606 ** that pOut points to unchanged.
7607 **
7608 ** See also: [sqlite3_stmt_scanstatus_reset()]
7609 */
7610 SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_stmt_scanstatus(
7611 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
7612 int idx, /* Index of loop to report on */
7613 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
7614 void *pOut /* Result written here */
7615 );
@@ -7603,11 +7620,11 @@
7620 ** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
7621 **
7622 ** This API is only available if the library is built with pre-processor
7623 ** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
7624 */
7625 SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
7626
7627
7628 /*
7629 ** Undo the hack that converts floating point types to integer for
7630 ** builds on processors without floating point support.
@@ -7658,11 +7675,11 @@
7675 ** Register a geometry callback named zGeom that can be used as part of an
7676 ** R-Tree geometry query as follows:
7677 **
7678 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
7679 */
7680 SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
7681 sqlite3 *db,
7682 const char *zGeom,
7683 int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
7684 void *pContext
7685 );
@@ -7684,11 +7701,11 @@
7701 ** Register a 2nd-generation geometry callback named zScore that can be
7702 ** used as part of an R-Tree geometry query as follows:
7703 **
7704 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
7705 */
7706 SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
7707 sqlite3 *db,
7708 const char *zQueryFunc,
7709 int (*xQueryFunc)(sqlite3_rtree_query_info*),
7710 void *pContext,
7711 void (*xDestructor)(void*)
7712
+30 -21
--- src/th.c
+++ src/th.c
@@ -2227,18 +2227,29 @@
22272227
default: {
22282228
int j;
22292229
const char *zOp;
22302230
for(j=0; (zOp=aOperator[j].zOp); j++){
22312231
int nOp = aOperator[j].nOp;
2232
+ int nRemain = nExpr - i;
22322233
int isMatch = 0;
2233
- if( (nExpr-i)>=nOp && 0==memcmp(zOp, &zExpr[i], nOp) ){
2234
+ if( nRemain>=nOp && 0==memcmp(zOp, &zExpr[i], nOp) ){
22342235
isMatch = 1;
22352236
}
2236
- if( isMatch && aOperator[j].eOp==OP_OPEN_BRACKET ){
2237
- nNest++;
2238
- }else if( isMatch && aOperator[j].eOp==OP_CLOSE_BRACKET ){
2239
- nNest--;
2237
+ if( isMatch ){
2238
+ if( aOperator[j].eOp==OP_CLOSE_BRACKET ){
2239
+ nNest--;
2240
+ }else if( nRemain>nOp ){
2241
+ if( aOperator[j].eOp==OP_OPEN_BRACKET ){
2242
+ nNest++;
2243
+ }
2244
+ }else{
2245
+ /*
2246
+ ** This is not really a match because this operator cannot
2247
+ ** legally appear at the end of the string.
2248
+ */
2249
+ isMatch = 0;
2250
+ }
22402251
}
22412252
if( nToken>0 && aOperator[j].iPrecedence==1 ){
22422253
Expr *pPrev = apToken[nToken-1];
22432254
if( !pPrev->pOp || pPrev->pOp->eOp==OP_CLOSE_BRACKET ){
22442255
continue;
@@ -2646,28 +2657,26 @@
26462657
26472658
if( n<0 ){
26482659
n = th_strlen(z);
26492660
}
26502661
2651
- if( n>0 && (z[0]=='-' || z[0]=='+') ){
2662
+ if( n>1 && (z[0]=='-' || z[0]=='+') ){
26522663
i = 1;
26532664
}
2654
- if( n>2 ){
2655
- if( z[i]=='0' ){
2656
- if( z[i+1]=='x' || z[i+1]=='X' ){
2657
- i += 2;
2658
- base = 16;
2659
- isdigit = th_ishexdig;
2660
- }else if( z[i+1]=='o' || z[i+1]=='O' ){
2661
- i += 2;
2662
- base = 8;
2663
- isdigit = th_isoctdig;
2664
- }else if( z[i+1]=='b' || z[i+1]=='B' ){
2665
- i += 2;
2666
- base = 2;
2667
- isdigit = th_isbindig;
2668
- }
2665
+ if( (n-i)>2 && z[i]=='0' ){
2666
+ if( z[i+1]=='x' || z[i+1]=='X' ){
2667
+ i += 2;
2668
+ base = 16;
2669
+ isdigit = th_ishexdig;
2670
+ }else if( z[i+1]=='o' || z[i+1]=='O' ){
2671
+ i += 2;
2672
+ base = 8;
2673
+ isdigit = th_isoctdig;
2674
+ }else if( z[i+1]=='b' || z[i+1]=='B' ){
2675
+ i += 2;
2676
+ base = 2;
2677
+ isdigit = th_isbindig;
26692678
}
26702679
}
26712680
for(; i<n; i++){
26722681
char c = z[i];
26732682
if( !isdigit(c) ){
26742683
--- src/th.c
+++ src/th.c
@@ -2227,18 +2227,29 @@
2227 default: {
2228 int j;
2229 const char *zOp;
2230 for(j=0; (zOp=aOperator[j].zOp); j++){
2231 int nOp = aOperator[j].nOp;
 
2232 int isMatch = 0;
2233 if( (nExpr-i)>=nOp && 0==memcmp(zOp, &zExpr[i], nOp) ){
2234 isMatch = 1;
2235 }
2236 if( isMatch && aOperator[j].eOp==OP_OPEN_BRACKET ){
2237 nNest++;
2238 }else if( isMatch && aOperator[j].eOp==OP_CLOSE_BRACKET ){
2239 nNest--;
 
 
 
 
 
 
 
 
 
 
2240 }
2241 if( nToken>0 && aOperator[j].iPrecedence==1 ){
2242 Expr *pPrev = apToken[nToken-1];
2243 if( !pPrev->pOp || pPrev->pOp->eOp==OP_CLOSE_BRACKET ){
2244 continue;
@@ -2646,28 +2657,26 @@
2646
2647 if( n<0 ){
2648 n = th_strlen(z);
2649 }
2650
2651 if( n>0 && (z[0]=='-' || z[0]=='+') ){
2652 i = 1;
2653 }
2654 if( n>2 ){
2655 if( z[i]=='0' ){
2656 if( z[i+1]=='x' || z[i+1]=='X' ){
2657 i += 2;
2658 base = 16;
2659 isdigit = th_ishexdig;
2660 }else if( z[i+1]=='o' || z[i+1]=='O' ){
2661 i += 2;
2662 base = 8;
2663 isdigit = th_isoctdig;
2664 }else if( z[i+1]=='b' || z[i+1]=='B' ){
2665 i += 2;
2666 base = 2;
2667 isdigit = th_isbindig;
2668 }
2669 }
2670 }
2671 for(; i<n; i++){
2672 char c = z[i];
2673 if( !isdigit(c) ){
2674
--- src/th.c
+++ src/th.c
@@ -2227,18 +2227,29 @@
2227 default: {
2228 int j;
2229 const char *zOp;
2230 for(j=0; (zOp=aOperator[j].zOp); j++){
2231 int nOp = aOperator[j].nOp;
2232 int nRemain = nExpr - i;
2233 int isMatch = 0;
2234 if( nRemain>=nOp && 0==memcmp(zOp, &zExpr[i], nOp) ){
2235 isMatch = 1;
2236 }
2237 if( isMatch ){
2238 if( aOperator[j].eOp==OP_CLOSE_BRACKET ){
2239 nNest--;
2240 }else if( nRemain>nOp ){
2241 if( aOperator[j].eOp==OP_OPEN_BRACKET ){
2242 nNest++;
2243 }
2244 }else{
2245 /*
2246 ** This is not really a match because this operator cannot
2247 ** legally appear at the end of the string.
2248 */
2249 isMatch = 0;
2250 }
2251 }
2252 if( nToken>0 && aOperator[j].iPrecedence==1 ){
2253 Expr *pPrev = apToken[nToken-1];
2254 if( !pPrev->pOp || pPrev->pOp->eOp==OP_CLOSE_BRACKET ){
2255 continue;
@@ -2646,28 +2657,26 @@
2657
2658 if( n<0 ){
2659 n = th_strlen(z);
2660 }
2661
2662 if( n>1 && (z[0]=='-' || z[0]=='+') ){
2663 i = 1;
2664 }
2665 if( (n-i)>2 && z[i]=='0' ){
2666 if( z[i+1]=='x' || z[i+1]=='X' ){
2667 i += 2;
2668 base = 16;
2669 isdigit = th_ishexdig;
2670 }else if( z[i+1]=='o' || z[i+1]=='O' ){
2671 i += 2;
2672 base = 8;
2673 isdigit = th_isoctdig;
2674 }else if( z[i+1]=='b' || z[i+1]=='B' ){
2675 i += 2;
2676 base = 2;
2677 isdigit = th_isbindig;
 
 
2678 }
2679 }
2680 for(; i<n; i++){
2681 char c = z[i];
2682 if( !isdigit(c) ){
2683
+87 -32
--- src/timeline.c
+++ src/timeline.c
@@ -108,11 +108,11 @@
108108
int mx, mn; /* Components of HSV */
109109
static char zColor[10]; /* The resulting color */
110110
static int ix[2] = {0,0}; /* Color chooser parameters */
111111
112112
if( ix[0]==0 ){
113
- if( db_get_boolean("white-foreground", 0) ){
113
+ if( skin_detail_boolean("white-foreground") ){
114114
ix[0] = 140;
115115
ix[1] = 40;
116116
}else{
117117
ix[0] = 216;
118118
ix[1] = 16;
@@ -596,10 +596,41 @@
596596
}
597597
@ </table>
598598
if( fchngQueryInit ) db_finalize(&fchngQuery);
599599
timeline_output_graph_javascript(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0, 0);
600600
}
601
+
602
+/*
603
+** Change the RGB background color given in the argument in a foreground
604
+** color with the same hue.
605
+*/
606
+static const char *bg_to_fg(const char *zIn){
607
+ int i;
608
+ unsigned int x[3];
609
+ unsigned int mx = 0;
610
+ static int whiteFg = -1;
611
+ static char zRes[10];
612
+ if( strlen(zIn)!=7 || zIn[0]!='#' ) return zIn;
613
+ zIn++;
614
+ for(i=0; i<3; i++){
615
+ x[i] = hex_digit_value(zIn[0])*16 + hex_digit_value(zIn[1]);
616
+ zIn += 2;
617
+ if( x[i]>mx ) mx = x[i];
618
+ }
619
+ if( whiteFg<0 ) whiteFg = skin_detail_boolean("white-foreground");
620
+ if( whiteFg ){
621
+ /* Make the color lighter */
622
+ static const unsigned int t = 215;
623
+ if( mx<t ) for(i=0; i<3; i++) x[i] += t - mx;
624
+ }else{
625
+ /* Make the color darker */
626
+ static const unsigned int t = 128;
627
+ if( mx>t ) for(i=0; i<3; i++) x[i] -= mx - t;
628
+ }
629
+ sqlite3_snprintf(sizeof(zRes),zRes,"#%02x%02x%02x",x[0],x[1],x[2]);
630
+ return zRes;
631
+}
601632
602633
/*
603634
** Generate all of the necessary javascript to generate a timeline
604635
** graph.
605636
*/
@@ -612,11 +643,18 @@
612643
GraphRow *pRow;
613644
int i;
614645
char cSep;
615646
int mergeOffset; /* Pixel offset from rail to merge riser */
616647
int iRailPitch; /* Pixels between consecutive rails */
648
+ int showArrowheads; /* True to draw arrowheads. False to omit. */
649
+ int circleNodes; /* True for circle nodes. False for square nodes */
650
+ int colorGraph; /* Use colors for graph lines */
651
+
617652
iRailPitch = pGraph->iRailPitch;
653
+ showArrowheads = skin_detail_boolean("timeline-arrowheads");
654
+ circleNodes = skin_detail_boolean("timeline-circle-nodes");
655
+ colorGraph = skin_detail_boolean("timeline-color-graph-lines");
618656
619657
/* Number of pixels that the thin merge lines are offset from the
620658
** the center of the think rail lines. If zero, then the vertical
621659
** merge lines overlap with the thicker rail lines.
622660
*/
@@ -689,12 +727,16 @@
689727
cgi_printf("%c%d,%d", cSep, i, pRow->aiRiser[i]);
690728
cSep = ',';
691729
}
692730
}
693731
if( cSep=='[' ) cgi_printf("[");
694
- cgi_printf("],mi:");
732
+ cgi_printf("],");
733
+ if( colorGraph && pRow->zBgClr[0]=='#' ){
734
+ cgi_printf("fg:\"%s\",", bg_to_fg(pRow->zBgClr));
735
+ }
695736
/* mi */
737
+ cgi_printf("mi:");
696738
cSep = '[';
697739
for(i=0; i<GR_MAX_RAIL; i++){
698740
if( pRow->mergeIn[i] ){
699741
int mi = i*iRailPitch;
700742
if( pRow->mergeIn[i]==1 ) mi -= mergeOffset-1;
@@ -751,34 +793,40 @@
751793
@ left += obj.offsetLeft;
752794
@ }while( obj = obj.offsetParent );
753795
@ }
754796
@ return left;
755797
@ }
756
- @ function drawUpArrow(x,y0,y1){
757
- @ drawBox(lineClr,x,y0+4,x+1,y1);
758
- @ var n = document.createElement("div"),
759
- @ l = x-2,
760
- @ t = y0;
761
- @ n.style.position = "absolute";
762
- @ n.style.left = l+"px";
763
- @ n.style.top = t+"px";
764
- @ n.style.width = 0;
765
- @ n.style.height = 0;
766
- @ n.style.transform = "scale(.999)";
767
- @ n.style.borderWidth = 0;
768
- @ n.style.borderStyle = "solid";
769
- @ n.style.borderColor = "transparent";
770
- @ n.style.borderRightWidth = "3px";
771
- @ n.style.borderBottomColor = lineClr;
772
- @ n.style.borderLeftWidth = "3px";
773
- @ if( y0+10>=y1 ){
774
- @ n.style.borderBottomWidth = "5px";
775
- @ } else {
776
- @ n.style.borderBottomWidth = "7px";
777
- @ }
778
- @ cDiv.appendChild(n);
779
- @ }
798
+ if( showArrowheads ){
799
+ @ function drawUpArrow(x,y0,y1,clr){
800
+ @ drawBox(clr,x,y0+4,x+1,y1);
801
+ @ var n = document.createElement("div"),
802
+ @ l = x-2,
803
+ @ t = y0;
804
+ @ n.style.position = "absolute";
805
+ @ n.style.left = l+"px";
806
+ @ n.style.top = t+"px";
807
+ @ n.style.width = 0;
808
+ @ n.style.height = 0;
809
+ @ n.style.transform = "scale(.999)";
810
+ @ n.style.borderWidth = 0;
811
+ @ n.style.borderStyle = "solid";
812
+ @ n.style.borderColor = "transparent";
813
+ @ n.style.borderRightWidth = "3px";
814
+ @ n.style.borderBottomColor = clr;
815
+ @ n.style.borderLeftWidth = "3px";
816
+ @ if( y0+10>=y1 ){
817
+ @ n.style.borderBottomWidth = "5px";
818
+ @ } else {
819
+ @ n.style.borderBottomWidth = "7px";
820
+ @ }
821
+ @ cDiv.appendChild(n);
822
+ @ }
823
+ }else{
824
+ @ function drawUpArrow(x,y0,y1,clr){
825
+ @ drawBox(clr,x,y0+1,x+1,y1);
826
+ @ }
827
+ }
780828
@ function drawThinArrow(y,xFrom,xTo){
781829
@ var n = document.createElement("div"),
782830
@ t = y-2;
783831
@ n.style.position = "absolute";
784832
@ n.style.top = t+"px";
@@ -805,20 +853,24 @@
805853
@ }
806854
@ function drawThinLine(x0,y0,x1,y1){
807855
@ drawBox(lineClr,x0,y0,x1,y1);
808856
@ }
809857
@ function drawNodeBox(color,x0,y0,x1,y1){
810
- @ drawBox(color,x0,y0,x1,y1).style.cursor = "pointer";
858
+ @ var n = drawBox(color,x0,y0,x1,y1);
859
+ @ n.style.cursor = "pointer";
860
+ if( circleNodes ){
861
+ @ n.style.borderRadius = "6px";
862
+ }
811863
@ }
812864
@ function drawNode(p, left, btm){
813865
@ drawNodeBox(boxColor,p.x-5,p.y-5,p.x+6,p.y+6);
814866
@ drawNodeBox(p.bg||bgClr,p.x-4,p.y-4,p.x+5,p.y+5);
815
- @ if( p.u>0 ) drawUpArrow(p.x, rowinfo[p.u-1].y+6, p.y-5);
867
+ @ if( p.u>0 ) drawUpArrow(p.x,rowinfo[p.u-1].y+6,p.y-6,p.fg||lineClr);
816868
@ if( p.f&1 ) drawNodeBox(boxColor,p.x-1,p.y-1,p.x+2,p.y+2);
817869
if( !omitDescenders ){
818
- @ if( p.u==0 ) drawUpArrow(p.x, 0, p.y-5);
819
- @ if( p.d ) drawUpArrow(p.x, p.y+6, btm);
870
+ @ if( p.u==0 ) drawUpArrow(p.x,0,p.y-6,p.fg||lineClr);
871
+ @ if( p.d ) drawUpArrow(p.x,p.y+6,btm,p.fg||lineClr);
820872
}
821873
@ if( p.mo>0 ){
822874
@ var x1 = p.mo + left - 1;
823875
@ var y1 = p.y-3;
824876
@ var x0 = x1>p.x ? p.x+7 : p.x-6;
@@ -836,12 +888,12 @@
836888
@ for(var i=0; i<n; i+=2){
837889
@ var x1 = p.au[i]*railPitch + left;
838890
@ var x0 = x1>p.x ? p.x+7 : p.x-6;
839891
@ var u = rowinfo[p.au[i+1]-1];
840892
@ if(u.id<p.id){
841
- @ drawBox(lineClr,x0,p.y,x1+1,p.y+1);
842
- @ drawUpArrow(x1, u.y+6, p.y);
893
+ @ drawBox(u.fg||lineClr,x0,p.y,x1+1,p.y+1);
894
+ @ drawUpArrow(x1,u.y+6,p.y,u.fg||lineClr);
843895
@ }else{
844896
@ drawBox("#600000",x0,p.y,x1,p.y+1);
845897
@ drawBox("#600000",x1-1,p.y,x1,u.y+1);
846898
@ drawBox("#600000",x1,u.y,u.x-10,u.y+1);
847899
@ var n = document.createElement("div"),
@@ -924,10 +976,13 @@
924976
@ }
925977
@ }
926978
@ function clickOnRow(p){
927979
@ if( selRow==null ){
928980
@ selBox = drawBox("red",p.x-2,p.y-2,p.x+3,p.y+3);
981
+ if( circleNodes ){
982
+ @ selBox.style.borderRadius="6px";
983
+ }
929984
@ selRow = p;
930985
@ }else if( selRow==p ){
931986
@ var canvasDiv = gebi("canvas");
932987
@ canvasDiv.removeChild(selBox);
933988
@ selBox = null;
934989
--- src/timeline.c
+++ src/timeline.c
@@ -108,11 +108,11 @@
108 int mx, mn; /* Components of HSV */
109 static char zColor[10]; /* The resulting color */
110 static int ix[2] = {0,0}; /* Color chooser parameters */
111
112 if( ix[0]==0 ){
113 if( db_get_boolean("white-foreground", 0) ){
114 ix[0] = 140;
115 ix[1] = 40;
116 }else{
117 ix[0] = 216;
118 ix[1] = 16;
@@ -596,10 +596,41 @@
596 }
597 @ </table>
598 if( fchngQueryInit ) db_finalize(&fchngQuery);
599 timeline_output_graph_javascript(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0, 0);
600 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
601
602 /*
603 ** Generate all of the necessary javascript to generate a timeline
604 ** graph.
605 */
@@ -612,11 +643,18 @@
612 GraphRow *pRow;
613 int i;
614 char cSep;
615 int mergeOffset; /* Pixel offset from rail to merge riser */
616 int iRailPitch; /* Pixels between consecutive rails */
 
 
 
 
617 iRailPitch = pGraph->iRailPitch;
 
 
 
618
619 /* Number of pixels that the thin merge lines are offset from the
620 ** the center of the think rail lines. If zero, then the vertical
621 ** merge lines overlap with the thicker rail lines.
622 */
@@ -689,12 +727,16 @@
689 cgi_printf("%c%d,%d", cSep, i, pRow->aiRiser[i]);
690 cSep = ',';
691 }
692 }
693 if( cSep=='[' ) cgi_printf("[");
694 cgi_printf("],mi:");
 
 
 
695 /* mi */
 
696 cSep = '[';
697 for(i=0; i<GR_MAX_RAIL; i++){
698 if( pRow->mergeIn[i] ){
699 int mi = i*iRailPitch;
700 if( pRow->mergeIn[i]==1 ) mi -= mergeOffset-1;
@@ -751,34 +793,40 @@
751 @ left += obj.offsetLeft;
752 @ }while( obj = obj.offsetParent );
753 @ }
754 @ return left;
755 @ }
756 @ function drawUpArrow(x,y0,y1){
757 @ drawBox(lineClr,x,y0+4,x+1,y1);
758 @ var n = document.createElement("div"),
759 @ l = x-2,
760 @ t = y0;
761 @ n.style.position = "absolute";
762 @ n.style.left = l+"px";
763 @ n.style.top = t+"px";
764 @ n.style.width = 0;
765 @ n.style.height = 0;
766 @ n.style.transform = "scale(.999)";
767 @ n.style.borderWidth = 0;
768 @ n.style.borderStyle = "solid";
769 @ n.style.borderColor = "transparent";
770 @ n.style.borderRightWidth = "3px";
771 @ n.style.borderBottomColor = lineClr;
772 @ n.style.borderLeftWidth = "3px";
773 @ if( y0+10>=y1 ){
774 @ n.style.borderBottomWidth = "5px";
775 @ } else {
776 @ n.style.borderBottomWidth = "7px";
777 @ }
778 @ cDiv.appendChild(n);
779 @ }
 
 
 
 
 
 
780 @ function drawThinArrow(y,xFrom,xTo){
781 @ var n = document.createElement("div"),
782 @ t = y-2;
783 @ n.style.position = "absolute";
784 @ n.style.top = t+"px";
@@ -805,20 +853,24 @@
805 @ }
806 @ function drawThinLine(x0,y0,x1,y1){
807 @ drawBox(lineClr,x0,y0,x1,y1);
808 @ }
809 @ function drawNodeBox(color,x0,y0,x1,y1){
810 @ drawBox(color,x0,y0,x1,y1).style.cursor = "pointer";
 
 
 
 
811 @ }
812 @ function drawNode(p, left, btm){
813 @ drawNodeBox(boxColor,p.x-5,p.y-5,p.x+6,p.y+6);
814 @ drawNodeBox(p.bg||bgClr,p.x-4,p.y-4,p.x+5,p.y+5);
815 @ if( p.u>0 ) drawUpArrow(p.x, rowinfo[p.u-1].y+6, p.y-5);
816 @ if( p.f&1 ) drawNodeBox(boxColor,p.x-1,p.y-1,p.x+2,p.y+2);
817 if( !omitDescenders ){
818 @ if( p.u==0 ) drawUpArrow(p.x, 0, p.y-5);
819 @ if( p.d ) drawUpArrow(p.x, p.y+6, btm);
820 }
821 @ if( p.mo>0 ){
822 @ var x1 = p.mo + left - 1;
823 @ var y1 = p.y-3;
824 @ var x0 = x1>p.x ? p.x+7 : p.x-6;
@@ -836,12 +888,12 @@
836 @ for(var i=0; i<n; i+=2){
837 @ var x1 = p.au[i]*railPitch + left;
838 @ var x0 = x1>p.x ? p.x+7 : p.x-6;
839 @ var u = rowinfo[p.au[i+1]-1];
840 @ if(u.id<p.id){
841 @ drawBox(lineClr,x0,p.y,x1+1,p.y+1);
842 @ drawUpArrow(x1, u.y+6, p.y);
843 @ }else{
844 @ drawBox("#600000",x0,p.y,x1,p.y+1);
845 @ drawBox("#600000",x1-1,p.y,x1,u.y+1);
846 @ drawBox("#600000",x1,u.y,u.x-10,u.y+1);
847 @ var n = document.createElement("div"),
@@ -924,10 +976,13 @@
924 @ }
925 @ }
926 @ function clickOnRow(p){
927 @ if( selRow==null ){
928 @ selBox = drawBox("red",p.x-2,p.y-2,p.x+3,p.y+3);
 
 
 
929 @ selRow = p;
930 @ }else if( selRow==p ){
931 @ var canvasDiv = gebi("canvas");
932 @ canvasDiv.removeChild(selBox);
933 @ selBox = null;
934
--- src/timeline.c
+++ src/timeline.c
@@ -108,11 +108,11 @@
108 int mx, mn; /* Components of HSV */
109 static char zColor[10]; /* The resulting color */
110 static int ix[2] = {0,0}; /* Color chooser parameters */
111
112 if( ix[0]==0 ){
113 if( skin_detail_boolean("white-foreground") ){
114 ix[0] = 140;
115 ix[1] = 40;
116 }else{
117 ix[0] = 216;
118 ix[1] = 16;
@@ -596,10 +596,41 @@
596 }
597 @ </table>
598 if( fchngQueryInit ) db_finalize(&fchngQuery);
599 timeline_output_graph_javascript(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0, 0);
600 }
601
602 /*
603 ** Change the RGB background color given in the argument in a foreground
604 ** color with the same hue.
605 */
606 static const char *bg_to_fg(const char *zIn){
607 int i;
608 unsigned int x[3];
609 unsigned int mx = 0;
610 static int whiteFg = -1;
611 static char zRes[10];
612 if( strlen(zIn)!=7 || zIn[0]!='#' ) return zIn;
613 zIn++;
614 for(i=0; i<3; i++){
615 x[i] = hex_digit_value(zIn[0])*16 + hex_digit_value(zIn[1]);
616 zIn += 2;
617 if( x[i]>mx ) mx = x[i];
618 }
619 if( whiteFg<0 ) whiteFg = skin_detail_boolean("white-foreground");
620 if( whiteFg ){
621 /* Make the color lighter */
622 static const unsigned int t = 215;
623 if( mx<t ) for(i=0; i<3; i++) x[i] += t - mx;
624 }else{
625 /* Make the color darker */
626 static const unsigned int t = 128;
627 if( mx>t ) for(i=0; i<3; i++) x[i] -= mx - t;
628 }
629 sqlite3_snprintf(sizeof(zRes),zRes,"#%02x%02x%02x",x[0],x[1],x[2]);
630 return zRes;
631 }
632
633 /*
634 ** Generate all of the necessary javascript to generate a timeline
635 ** graph.
636 */
@@ -612,11 +643,18 @@
643 GraphRow *pRow;
644 int i;
645 char cSep;
646 int mergeOffset; /* Pixel offset from rail to merge riser */
647 int iRailPitch; /* Pixels between consecutive rails */
648 int showArrowheads; /* True to draw arrowheads. False to omit. */
649 int circleNodes; /* True for circle nodes. False for square nodes */
650 int colorGraph; /* Use colors for graph lines */
651
652 iRailPitch = pGraph->iRailPitch;
653 showArrowheads = skin_detail_boolean("timeline-arrowheads");
654 circleNodes = skin_detail_boolean("timeline-circle-nodes");
655 colorGraph = skin_detail_boolean("timeline-color-graph-lines");
656
657 /* Number of pixels that the thin merge lines are offset from the
658 ** the center of the think rail lines. If zero, then the vertical
659 ** merge lines overlap with the thicker rail lines.
660 */
@@ -689,12 +727,16 @@
727 cgi_printf("%c%d,%d", cSep, i, pRow->aiRiser[i]);
728 cSep = ',';
729 }
730 }
731 if( cSep=='[' ) cgi_printf("[");
732 cgi_printf("],");
733 if( colorGraph && pRow->zBgClr[0]=='#' ){
734 cgi_printf("fg:\"%s\",", bg_to_fg(pRow->zBgClr));
735 }
736 /* mi */
737 cgi_printf("mi:");
738 cSep = '[';
739 for(i=0; i<GR_MAX_RAIL; i++){
740 if( pRow->mergeIn[i] ){
741 int mi = i*iRailPitch;
742 if( pRow->mergeIn[i]==1 ) mi -= mergeOffset-1;
@@ -751,34 +793,40 @@
793 @ left += obj.offsetLeft;
794 @ }while( obj = obj.offsetParent );
795 @ }
796 @ return left;
797 @ }
798 if( showArrowheads ){
799 @ function drawUpArrow(x,y0,y1,clr){
800 @ drawBox(clr,x,y0+4,x+1,y1);
801 @ var n = document.createElement("div"),
802 @ l = x-2,
803 @ t = y0;
804 @ n.style.position = "absolute";
805 @ n.style.left = l+"px";
806 @ n.style.top = t+"px";
807 @ n.style.width = 0;
808 @ n.style.height = 0;
809 @ n.style.transform = "scale(.999)";
810 @ n.style.borderWidth = 0;
811 @ n.style.borderStyle = "solid";
812 @ n.style.borderColor = "transparent";
813 @ n.style.borderRightWidth = "3px";
814 @ n.style.borderBottomColor = clr;
815 @ n.style.borderLeftWidth = "3px";
816 @ if( y0+10>=y1 ){
817 @ n.style.borderBottomWidth = "5px";
818 @ } else {
819 @ n.style.borderBottomWidth = "7px";
820 @ }
821 @ cDiv.appendChild(n);
822 @ }
823 }else{
824 @ function drawUpArrow(x,y0,y1,clr){
825 @ drawBox(clr,x,y0+1,x+1,y1);
826 @ }
827 }
828 @ function drawThinArrow(y,xFrom,xTo){
829 @ var n = document.createElement("div"),
830 @ t = y-2;
831 @ n.style.position = "absolute";
832 @ n.style.top = t+"px";
@@ -805,20 +853,24 @@
853 @ }
854 @ function drawThinLine(x0,y0,x1,y1){
855 @ drawBox(lineClr,x0,y0,x1,y1);
856 @ }
857 @ function drawNodeBox(color,x0,y0,x1,y1){
858 @ var n = drawBox(color,x0,y0,x1,y1);
859 @ n.style.cursor = "pointer";
860 if( circleNodes ){
861 @ n.style.borderRadius = "6px";
862 }
863 @ }
864 @ function drawNode(p, left, btm){
865 @ drawNodeBox(boxColor,p.x-5,p.y-5,p.x+6,p.y+6);
866 @ drawNodeBox(p.bg||bgClr,p.x-4,p.y-4,p.x+5,p.y+5);
867 @ if( p.u>0 ) drawUpArrow(p.x,rowinfo[p.u-1].y+6,p.y-6,p.fg||lineClr);
868 @ if( p.f&1 ) drawNodeBox(boxColor,p.x-1,p.y-1,p.x+2,p.y+2);
869 if( !omitDescenders ){
870 @ if( p.u==0 ) drawUpArrow(p.x,0,p.y-6,p.fg||lineClr);
871 @ if( p.d ) drawUpArrow(p.x,p.y+6,btm,p.fg||lineClr);
872 }
873 @ if( p.mo>0 ){
874 @ var x1 = p.mo + left - 1;
875 @ var y1 = p.y-3;
876 @ var x0 = x1>p.x ? p.x+7 : p.x-6;
@@ -836,12 +888,12 @@
888 @ for(var i=0; i<n; i+=2){
889 @ var x1 = p.au[i]*railPitch + left;
890 @ var x0 = x1>p.x ? p.x+7 : p.x-6;
891 @ var u = rowinfo[p.au[i+1]-1];
892 @ if(u.id<p.id){
893 @ drawBox(u.fg||lineClr,x0,p.y,x1+1,p.y+1);
894 @ drawUpArrow(x1,u.y+6,p.y,u.fg||lineClr);
895 @ }else{
896 @ drawBox("#600000",x0,p.y,x1,p.y+1);
897 @ drawBox("#600000",x1-1,p.y,x1,u.y+1);
898 @ drawBox("#600000",x1,u.y,u.x-10,u.y+1);
899 @ var n = document.createElement("div"),
@@ -924,10 +976,13 @@
976 @ }
977 @ }
978 @ function clickOnRow(p){
979 @ if( selRow==null ){
980 @ selBox = drawBox("red",p.x-2,p.y-2,p.x+3,p.y+3);
981 if( circleNodes ){
982 @ selBox.style.borderRadius="6px";
983 }
984 @ selRow = p;
985 @ }else if( selRow==p ){
986 @ var canvasDiv = gebi("canvas");
987 @ canvasDiv.removeChild(selBox);
988 @ selBox = null;
989
-4
--- src/xfer.c
+++ src/xfer.c
@@ -1735,16 +1735,12 @@
17351735
** the client what product to use for the new database.
17361736
*/
17371737
if( blob_eq(&xfer.aToken[0],"push")
17381738
&& xfer.nToken==3
17391739
&& (syncFlags & SYNC_CLONE)!=0
1740
- && blob_is_uuid(&xfer.aToken[1])
17411740
&& blob_is_uuid(&xfer.aToken[2])
17421741
){
1743
- if( blob_eq_str(&xfer.aToken[1], zSCode, -1) ){
1744
- fossil_fatal("server loop");
1745
- }
17461742
if( zPCode==0 ){
17471743
zPCode = mprintf("%b", &xfer.aToken[2]);
17481744
db_set("project-code", zPCode, 0);
17491745
}
17501746
if( cloneSeqno>0 ) blob_appendf(&send, "clone 3 %d\n", cloneSeqno);
17511747
--- src/xfer.c
+++ src/xfer.c
@@ -1735,16 +1735,12 @@
1735 ** the client what product to use for the new database.
1736 */
1737 if( blob_eq(&xfer.aToken[0],"push")
1738 && xfer.nToken==3
1739 && (syncFlags & SYNC_CLONE)!=0
1740 && blob_is_uuid(&xfer.aToken[1])
1741 && blob_is_uuid(&xfer.aToken[2])
1742 ){
1743 if( blob_eq_str(&xfer.aToken[1], zSCode, -1) ){
1744 fossil_fatal("server loop");
1745 }
1746 if( zPCode==0 ){
1747 zPCode = mprintf("%b", &xfer.aToken[2]);
1748 db_set("project-code", zPCode, 0);
1749 }
1750 if( cloneSeqno>0 ) blob_appendf(&send, "clone 3 %d\n", cloneSeqno);
1751
--- src/xfer.c
+++ src/xfer.c
@@ -1735,16 +1735,12 @@
1735 ** the client what product to use for the new database.
1736 */
1737 if( blob_eq(&xfer.aToken[0],"push")
1738 && xfer.nToken==3
1739 && (syncFlags & SYNC_CLONE)!=0
 
1740 && blob_is_uuid(&xfer.aToken[2])
1741 ){
 
 
 
1742 if( zPCode==0 ){
1743 zPCode = mprintf("%b", &xfer.aToken[2]);
1744 db_set("project-code", zPCode, 0);
1745 }
1746 if( cloneSeqno>0 ) blob_appendf(&send, "clone 3 %d\n", cloneSeqno);
1747
--- test/th1.test
+++ test/th1.test
@@ -507,10 +507,50 @@
507507
508508
###############################################################################
509509
510510
fossil test-th-eval "expr (((1)*2)*2)"
511511
test th1-expr-41 {$RESULT eq {4}}
512
+
513
+###############################################################################
514
+
515
+fossil test-th-eval "expr +"
516
+test th1-expr-42 {$RESULT eq {TH_ERROR: syntax error in expression: "+"}}
517
+
518
+###############################################################################
519
+
520
+fossil test-th-eval "expr -"
521
+test th1-expr-43 {$RESULT eq {TH_ERROR: syntax error in expression: "-"}}
522
+
523
+###############################################################################
524
+
525
+fossil test-th-eval "expr ++"
526
+test th1-expr-44 {$RESULT eq {TH_ERROR: syntax error in expression: "++"}}
527
+
528
+###############################################################################
529
+
530
+fossil test-th-eval "expr --"
531
+test th1-expr-45 {$RESULT eq {TH_ERROR: syntax error in expression: "--"}}
532
+
533
+###############################################################################
534
+
535
+fossil test-th-eval "lindex list +"
536
+test th1-expr-46 {$RESULT eq {TH_ERROR: expected integer, got: "+"}}
537
+
538
+###############################################################################
539
+
540
+fossil test-th-eval "lindex list -"
541
+test th1-expr-47 {$RESULT eq {TH_ERROR: expected integer, got: "-"}}
542
+
543
+###############################################################################
544
+
545
+fossil test-th-eval "lindex list +0x"
546
+test th1-expr-48 {$RESULT eq {TH_ERROR: expected integer, got: "+0x"}}
547
+
548
+###############################################################################
549
+
550
+fossil test-th-eval "lindex list -0x"
551
+test th1-expr-49 {$RESULT eq {TH_ERROR: expected integer, got: "-0x"}}
512552
513553
###############################################################################
514554
515555
fossil test-th-eval "checkout 1"; # NOTE: Assumes running "in tree".
516556
test th1-checkout-1 {[string length $RESULT] > 0}
517557
--- test/th1.test
+++ test/th1.test
@@ -507,10 +507,50 @@
507
508 ###############################################################################
509
510 fossil test-th-eval "expr (((1)*2)*2)"
511 test th1-expr-41 {$RESULT eq {4}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512
513 ###############################################################################
514
515 fossil test-th-eval "checkout 1"; # NOTE: Assumes running "in tree".
516 test th1-checkout-1 {[string length $RESULT] > 0}
517
--- test/th1.test
+++ test/th1.test
@@ -507,10 +507,50 @@
507
508 ###############################################################################
509
510 fossil test-th-eval "expr (((1)*2)*2)"
511 test th1-expr-41 {$RESULT eq {4}}
512
513 ###############################################################################
514
515 fossil test-th-eval "expr +"
516 test th1-expr-42 {$RESULT eq {TH_ERROR: syntax error in expression: "+"}}
517
518 ###############################################################################
519
520 fossil test-th-eval "expr -"
521 test th1-expr-43 {$RESULT eq {TH_ERROR: syntax error in expression: "-"}}
522
523 ###############################################################################
524
525 fossil test-th-eval "expr ++"
526 test th1-expr-44 {$RESULT eq {TH_ERROR: syntax error in expression: "++"}}
527
528 ###############################################################################
529
530 fossil test-th-eval "expr --"
531 test th1-expr-45 {$RESULT eq {TH_ERROR: syntax error in expression: "--"}}
532
533 ###############################################################################
534
535 fossil test-th-eval "lindex list +"
536 test th1-expr-46 {$RESULT eq {TH_ERROR: expected integer, got: "+"}}
537
538 ###############################################################################
539
540 fossil test-th-eval "lindex list -"
541 test th1-expr-47 {$RESULT eq {TH_ERROR: expected integer, got: "-"}}
542
543 ###############################################################################
544
545 fossil test-th-eval "lindex list +0x"
546 test th1-expr-48 {$RESULT eq {TH_ERROR: expected integer, got: "+0x"}}
547
548 ###############################################################################
549
550 fossil test-th-eval "lindex list -0x"
551 test th1-expr-49 {$RESULT eq {TH_ERROR: expected integer, got: "-0x"}}
552
553 ###############################################################################
554
555 fossil test-th-eval "checkout 1"; # NOTE: Assumes running "in tree".
556 test th1-checkout-1 {[string length $RESULT] > 0}
557
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -495,43 +495,55 @@
495495
$(SRCDIR)/xfer.c \
496496
$(SRCDIR)/xfersetup.c \
497497
$(SRCDIR)/zip.c
498498
499499
EXTRA_FILES = \
500
+ $(SRCDIR)/../skins/aht/details.txt \
500501
$(SRCDIR)/../skins/black_and_white/css.txt \
502
+ $(SRCDIR)/../skins/black_and_white/details.txt \
501503
$(SRCDIR)/../skins/black_and_white/footer.txt \
502504
$(SRCDIR)/../skins/black_and_white/header.txt \
503505
$(SRCDIR)/../skins/blitz/css.txt \
506
+ $(SRCDIR)/../skins/blitz/details.txt \
504507
$(SRCDIR)/../skins/blitz/footer.txt \
505508
$(SRCDIR)/../skins/blitz/header.txt \
506509
$(SRCDIR)/../skins/blitz/ticket.txt \
507510
$(SRCDIR)/../skins/blitz_no_logo/css.txt \
511
+ $(SRCDIR)/../skins/blitz_no_logo/details.txt \
508512
$(SRCDIR)/../skins/blitz_no_logo/footer.txt \
509513
$(SRCDIR)/../skins/blitz_no_logo/header.txt \
510514
$(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
511515
$(SRCDIR)/../skins/default/css.txt \
516
+ $(SRCDIR)/../skins/default/details.txt \
512517
$(SRCDIR)/../skins/default/footer.txt \
513518
$(SRCDIR)/../skins/default/header.txt \
514519
$(SRCDIR)/../skins/eagle/css.txt \
520
+ $(SRCDIR)/../skins/eagle/details.txt \
515521
$(SRCDIR)/../skins/eagle/footer.txt \
516522
$(SRCDIR)/../skins/eagle/header.txt \
517523
$(SRCDIR)/../skins/enhanced1/css.txt \
524
+ $(SRCDIR)/../skins/enhanced1/details.txt \
518525
$(SRCDIR)/../skins/enhanced1/footer.txt \
519526
$(SRCDIR)/../skins/enhanced1/header.txt \
520527
$(SRCDIR)/../skins/khaki/css.txt \
528
+ $(SRCDIR)/../skins/khaki/details.txt \
521529
$(SRCDIR)/../skins/khaki/footer.txt \
522530
$(SRCDIR)/../skins/khaki/header.txt \
523531
$(SRCDIR)/../skins/original/css.txt \
532
+ $(SRCDIR)/../skins/original/details.txt \
524533
$(SRCDIR)/../skins/original/footer.txt \
525534
$(SRCDIR)/../skins/original/header.txt \
526535
$(SRCDIR)/../skins/plain_gray/css.txt \
536
+ $(SRCDIR)/../skins/plain_gray/details.txt \
527537
$(SRCDIR)/../skins/plain_gray/footer.txt \
528538
$(SRCDIR)/../skins/plain_gray/header.txt \
529539
$(SRCDIR)/../skins/rounded1/css.txt \
540
+ $(SRCDIR)/../skins/rounded1/details.txt \
530541
$(SRCDIR)/../skins/rounded1/footer.txt \
531542
$(SRCDIR)/../skins/rounded1/header.txt \
532543
$(SRCDIR)/../skins/xekri/css.txt \
544
+ $(SRCDIR)/../skins/xekri/details.txt \
533545
$(SRCDIR)/../skins/xekri/footer.txt \
534546
$(SRCDIR)/../skins/xekri/header.txt \
535547
$(SRCDIR)/diff.tcl \
536548
$(SRCDIR)/markdown.md
537549
538550
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -495,43 +495,55 @@
495 $(SRCDIR)/xfer.c \
496 $(SRCDIR)/xfersetup.c \
497 $(SRCDIR)/zip.c
498
499 EXTRA_FILES = \
 
500 $(SRCDIR)/../skins/black_and_white/css.txt \
 
501 $(SRCDIR)/../skins/black_and_white/footer.txt \
502 $(SRCDIR)/../skins/black_and_white/header.txt \
503 $(SRCDIR)/../skins/blitz/css.txt \
 
504 $(SRCDIR)/../skins/blitz/footer.txt \
505 $(SRCDIR)/../skins/blitz/header.txt \
506 $(SRCDIR)/../skins/blitz/ticket.txt \
507 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
 
508 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
509 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
510 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
511 $(SRCDIR)/../skins/default/css.txt \
 
512 $(SRCDIR)/../skins/default/footer.txt \
513 $(SRCDIR)/../skins/default/header.txt \
514 $(SRCDIR)/../skins/eagle/css.txt \
 
515 $(SRCDIR)/../skins/eagle/footer.txt \
516 $(SRCDIR)/../skins/eagle/header.txt \
517 $(SRCDIR)/../skins/enhanced1/css.txt \
 
518 $(SRCDIR)/../skins/enhanced1/footer.txt \
519 $(SRCDIR)/../skins/enhanced1/header.txt \
520 $(SRCDIR)/../skins/khaki/css.txt \
 
521 $(SRCDIR)/../skins/khaki/footer.txt \
522 $(SRCDIR)/../skins/khaki/header.txt \
523 $(SRCDIR)/../skins/original/css.txt \
 
524 $(SRCDIR)/../skins/original/footer.txt \
525 $(SRCDIR)/../skins/original/header.txt \
526 $(SRCDIR)/../skins/plain_gray/css.txt \
 
527 $(SRCDIR)/../skins/plain_gray/footer.txt \
528 $(SRCDIR)/../skins/plain_gray/header.txt \
529 $(SRCDIR)/../skins/rounded1/css.txt \
 
530 $(SRCDIR)/../skins/rounded1/footer.txt \
531 $(SRCDIR)/../skins/rounded1/header.txt \
532 $(SRCDIR)/../skins/xekri/css.txt \
 
533 $(SRCDIR)/../skins/xekri/footer.txt \
534 $(SRCDIR)/../skins/xekri/header.txt \
535 $(SRCDIR)/diff.tcl \
536 $(SRCDIR)/markdown.md
537
538
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -495,43 +495,55 @@
495 $(SRCDIR)/xfer.c \
496 $(SRCDIR)/xfersetup.c \
497 $(SRCDIR)/zip.c
498
499 EXTRA_FILES = \
500 $(SRCDIR)/../skins/aht/details.txt \
501 $(SRCDIR)/../skins/black_and_white/css.txt \
502 $(SRCDIR)/../skins/black_and_white/details.txt \
503 $(SRCDIR)/../skins/black_and_white/footer.txt \
504 $(SRCDIR)/../skins/black_and_white/header.txt \
505 $(SRCDIR)/../skins/blitz/css.txt \
506 $(SRCDIR)/../skins/blitz/details.txt \
507 $(SRCDIR)/../skins/blitz/footer.txt \
508 $(SRCDIR)/../skins/blitz/header.txt \
509 $(SRCDIR)/../skins/blitz/ticket.txt \
510 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
511 $(SRCDIR)/../skins/blitz_no_logo/details.txt \
512 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
513 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
514 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
515 $(SRCDIR)/../skins/default/css.txt \
516 $(SRCDIR)/../skins/default/details.txt \
517 $(SRCDIR)/../skins/default/footer.txt \
518 $(SRCDIR)/../skins/default/header.txt \
519 $(SRCDIR)/../skins/eagle/css.txt \
520 $(SRCDIR)/../skins/eagle/details.txt \
521 $(SRCDIR)/../skins/eagle/footer.txt \
522 $(SRCDIR)/../skins/eagle/header.txt \
523 $(SRCDIR)/../skins/enhanced1/css.txt \
524 $(SRCDIR)/../skins/enhanced1/details.txt \
525 $(SRCDIR)/../skins/enhanced1/footer.txt \
526 $(SRCDIR)/../skins/enhanced1/header.txt \
527 $(SRCDIR)/../skins/khaki/css.txt \
528 $(SRCDIR)/../skins/khaki/details.txt \
529 $(SRCDIR)/../skins/khaki/footer.txt \
530 $(SRCDIR)/../skins/khaki/header.txt \
531 $(SRCDIR)/../skins/original/css.txt \
532 $(SRCDIR)/../skins/original/details.txt \
533 $(SRCDIR)/../skins/original/footer.txt \
534 $(SRCDIR)/../skins/original/header.txt \
535 $(SRCDIR)/../skins/plain_gray/css.txt \
536 $(SRCDIR)/../skins/plain_gray/details.txt \
537 $(SRCDIR)/../skins/plain_gray/footer.txt \
538 $(SRCDIR)/../skins/plain_gray/header.txt \
539 $(SRCDIR)/../skins/rounded1/css.txt \
540 $(SRCDIR)/../skins/rounded1/details.txt \
541 $(SRCDIR)/../skins/rounded1/footer.txt \
542 $(SRCDIR)/../skins/rounded1/header.txt \
543 $(SRCDIR)/../skins/xekri/css.txt \
544 $(SRCDIR)/../skins/xekri/details.txt \
545 $(SRCDIR)/../skins/xekri/footer.txt \
546 $(SRCDIR)/../skins/xekri/header.txt \
547 $(SRCDIR)/diff.tcl \
548 $(SRCDIR)/markdown.md
549
550
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -495,43 +495,55 @@
495495
$(SRCDIR)/xfer.c \
496496
$(SRCDIR)/xfersetup.c \
497497
$(SRCDIR)/zip.c
498498
499499
EXTRA_FILES = \
500
+ $(SRCDIR)/../skins/aht/details.txt \
500501
$(SRCDIR)/../skins/black_and_white/css.txt \
502
+ $(SRCDIR)/../skins/black_and_white/details.txt \
501503
$(SRCDIR)/../skins/black_and_white/footer.txt \
502504
$(SRCDIR)/../skins/black_and_white/header.txt \
503505
$(SRCDIR)/../skins/blitz/css.txt \
506
+ $(SRCDIR)/../skins/blitz/details.txt \
504507
$(SRCDIR)/../skins/blitz/footer.txt \
505508
$(SRCDIR)/../skins/blitz/header.txt \
506509
$(SRCDIR)/../skins/blitz/ticket.txt \
507510
$(SRCDIR)/../skins/blitz_no_logo/css.txt \
511
+ $(SRCDIR)/../skins/blitz_no_logo/details.txt \
508512
$(SRCDIR)/../skins/blitz_no_logo/footer.txt \
509513
$(SRCDIR)/../skins/blitz_no_logo/header.txt \
510514
$(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
511515
$(SRCDIR)/../skins/default/css.txt \
516
+ $(SRCDIR)/../skins/default/details.txt \
512517
$(SRCDIR)/../skins/default/footer.txt \
513518
$(SRCDIR)/../skins/default/header.txt \
514519
$(SRCDIR)/../skins/eagle/css.txt \
520
+ $(SRCDIR)/../skins/eagle/details.txt \
515521
$(SRCDIR)/../skins/eagle/footer.txt \
516522
$(SRCDIR)/../skins/eagle/header.txt \
517523
$(SRCDIR)/../skins/enhanced1/css.txt \
524
+ $(SRCDIR)/../skins/enhanced1/details.txt \
518525
$(SRCDIR)/../skins/enhanced1/footer.txt \
519526
$(SRCDIR)/../skins/enhanced1/header.txt \
520527
$(SRCDIR)/../skins/khaki/css.txt \
528
+ $(SRCDIR)/../skins/khaki/details.txt \
521529
$(SRCDIR)/../skins/khaki/footer.txt \
522530
$(SRCDIR)/../skins/khaki/header.txt \
523531
$(SRCDIR)/../skins/original/css.txt \
532
+ $(SRCDIR)/../skins/original/details.txt \
524533
$(SRCDIR)/../skins/original/footer.txt \
525534
$(SRCDIR)/../skins/original/header.txt \
526535
$(SRCDIR)/../skins/plain_gray/css.txt \
536
+ $(SRCDIR)/../skins/plain_gray/details.txt \
527537
$(SRCDIR)/../skins/plain_gray/footer.txt \
528538
$(SRCDIR)/../skins/plain_gray/header.txt \
529539
$(SRCDIR)/../skins/rounded1/css.txt \
540
+ $(SRCDIR)/../skins/rounded1/details.txt \
530541
$(SRCDIR)/../skins/rounded1/footer.txt \
531542
$(SRCDIR)/../skins/rounded1/header.txt \
532543
$(SRCDIR)/../skins/xekri/css.txt \
544
+ $(SRCDIR)/../skins/xekri/details.txt \
533545
$(SRCDIR)/../skins/xekri/footer.txt \
534546
$(SRCDIR)/../skins/xekri/header.txt \
535547
$(SRCDIR)/diff.tcl \
536548
$(SRCDIR)/markdown.md
537549
538550
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -495,43 +495,55 @@
495 $(SRCDIR)/xfer.c \
496 $(SRCDIR)/xfersetup.c \
497 $(SRCDIR)/zip.c
498
499 EXTRA_FILES = \
 
500 $(SRCDIR)/../skins/black_and_white/css.txt \
 
501 $(SRCDIR)/../skins/black_and_white/footer.txt \
502 $(SRCDIR)/../skins/black_and_white/header.txt \
503 $(SRCDIR)/../skins/blitz/css.txt \
 
504 $(SRCDIR)/../skins/blitz/footer.txt \
505 $(SRCDIR)/../skins/blitz/header.txt \
506 $(SRCDIR)/../skins/blitz/ticket.txt \
507 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
 
508 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
509 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
510 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
511 $(SRCDIR)/../skins/default/css.txt \
 
512 $(SRCDIR)/../skins/default/footer.txt \
513 $(SRCDIR)/../skins/default/header.txt \
514 $(SRCDIR)/../skins/eagle/css.txt \
 
515 $(SRCDIR)/../skins/eagle/footer.txt \
516 $(SRCDIR)/../skins/eagle/header.txt \
517 $(SRCDIR)/../skins/enhanced1/css.txt \
 
518 $(SRCDIR)/../skins/enhanced1/footer.txt \
519 $(SRCDIR)/../skins/enhanced1/header.txt \
520 $(SRCDIR)/../skins/khaki/css.txt \
 
521 $(SRCDIR)/../skins/khaki/footer.txt \
522 $(SRCDIR)/../skins/khaki/header.txt \
523 $(SRCDIR)/../skins/original/css.txt \
 
524 $(SRCDIR)/../skins/original/footer.txt \
525 $(SRCDIR)/../skins/original/header.txt \
526 $(SRCDIR)/../skins/plain_gray/css.txt \
 
527 $(SRCDIR)/../skins/plain_gray/footer.txt \
528 $(SRCDIR)/../skins/plain_gray/header.txt \
529 $(SRCDIR)/../skins/rounded1/css.txt \
 
530 $(SRCDIR)/../skins/rounded1/footer.txt \
531 $(SRCDIR)/../skins/rounded1/header.txt \
532 $(SRCDIR)/../skins/xekri/css.txt \
 
533 $(SRCDIR)/../skins/xekri/footer.txt \
534 $(SRCDIR)/../skins/xekri/header.txt \
535 $(SRCDIR)/diff.tcl \
536 $(SRCDIR)/markdown.md
537
538
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -495,43 +495,55 @@
495 $(SRCDIR)/xfer.c \
496 $(SRCDIR)/xfersetup.c \
497 $(SRCDIR)/zip.c
498
499 EXTRA_FILES = \
500 $(SRCDIR)/../skins/aht/details.txt \
501 $(SRCDIR)/../skins/black_and_white/css.txt \
502 $(SRCDIR)/../skins/black_and_white/details.txt \
503 $(SRCDIR)/../skins/black_and_white/footer.txt \
504 $(SRCDIR)/../skins/black_and_white/header.txt \
505 $(SRCDIR)/../skins/blitz/css.txt \
506 $(SRCDIR)/../skins/blitz/details.txt \
507 $(SRCDIR)/../skins/blitz/footer.txt \
508 $(SRCDIR)/../skins/blitz/header.txt \
509 $(SRCDIR)/../skins/blitz/ticket.txt \
510 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
511 $(SRCDIR)/../skins/blitz_no_logo/details.txt \
512 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
513 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
514 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
515 $(SRCDIR)/../skins/default/css.txt \
516 $(SRCDIR)/../skins/default/details.txt \
517 $(SRCDIR)/../skins/default/footer.txt \
518 $(SRCDIR)/../skins/default/header.txt \
519 $(SRCDIR)/../skins/eagle/css.txt \
520 $(SRCDIR)/../skins/eagle/details.txt \
521 $(SRCDIR)/../skins/eagle/footer.txt \
522 $(SRCDIR)/../skins/eagle/header.txt \
523 $(SRCDIR)/../skins/enhanced1/css.txt \
524 $(SRCDIR)/../skins/enhanced1/details.txt \
525 $(SRCDIR)/../skins/enhanced1/footer.txt \
526 $(SRCDIR)/../skins/enhanced1/header.txt \
527 $(SRCDIR)/../skins/khaki/css.txt \
528 $(SRCDIR)/../skins/khaki/details.txt \
529 $(SRCDIR)/../skins/khaki/footer.txt \
530 $(SRCDIR)/../skins/khaki/header.txt \
531 $(SRCDIR)/../skins/original/css.txt \
532 $(SRCDIR)/../skins/original/details.txt \
533 $(SRCDIR)/../skins/original/footer.txt \
534 $(SRCDIR)/../skins/original/header.txt \
535 $(SRCDIR)/../skins/plain_gray/css.txt \
536 $(SRCDIR)/../skins/plain_gray/details.txt \
537 $(SRCDIR)/../skins/plain_gray/footer.txt \
538 $(SRCDIR)/../skins/plain_gray/header.txt \
539 $(SRCDIR)/../skins/rounded1/css.txt \
540 $(SRCDIR)/../skins/rounded1/details.txt \
541 $(SRCDIR)/../skins/rounded1/footer.txt \
542 $(SRCDIR)/../skins/rounded1/header.txt \
543 $(SRCDIR)/../skins/xekri/css.txt \
544 $(SRCDIR)/../skins/xekri/details.txt \
545 $(SRCDIR)/../skins/xekri/footer.txt \
546 $(SRCDIR)/../skins/xekri/header.txt \
547 $(SRCDIR)/diff.tcl \
548 $(SRCDIR)/markdown.md
549
550
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -495,43 +495,55 @@
495495
$(SRCDIR)/xfer.c \
496496
$(SRCDIR)/xfersetup.c \
497497
$(SRCDIR)/zip.c
498498
499499
EXTRA_FILES = \
500
+ $(SRCDIR)/../skins/aht/details.txt \
500501
$(SRCDIR)/../skins/black_and_white/css.txt \
502
+ $(SRCDIR)/../skins/black_and_white/details.txt \
501503
$(SRCDIR)/../skins/black_and_white/footer.txt \
502504
$(SRCDIR)/../skins/black_and_white/header.txt \
503505
$(SRCDIR)/../skins/blitz/css.txt \
506
+ $(SRCDIR)/../skins/blitz/details.txt \
504507
$(SRCDIR)/../skins/blitz/footer.txt \
505508
$(SRCDIR)/../skins/blitz/header.txt \
506509
$(SRCDIR)/../skins/blitz/ticket.txt \
507510
$(SRCDIR)/../skins/blitz_no_logo/css.txt \
511
+ $(SRCDIR)/../skins/blitz_no_logo/details.txt \
508512
$(SRCDIR)/../skins/blitz_no_logo/footer.txt \
509513
$(SRCDIR)/../skins/blitz_no_logo/header.txt \
510514
$(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
511515
$(SRCDIR)/../skins/default/css.txt \
516
+ $(SRCDIR)/../skins/default/details.txt \
512517
$(SRCDIR)/../skins/default/footer.txt \
513518
$(SRCDIR)/../skins/default/header.txt \
514519
$(SRCDIR)/../skins/eagle/css.txt \
520
+ $(SRCDIR)/../skins/eagle/details.txt \
515521
$(SRCDIR)/../skins/eagle/footer.txt \
516522
$(SRCDIR)/../skins/eagle/header.txt \
517523
$(SRCDIR)/../skins/enhanced1/css.txt \
524
+ $(SRCDIR)/../skins/enhanced1/details.txt \
518525
$(SRCDIR)/../skins/enhanced1/footer.txt \
519526
$(SRCDIR)/../skins/enhanced1/header.txt \
520527
$(SRCDIR)/../skins/khaki/css.txt \
528
+ $(SRCDIR)/../skins/khaki/details.txt \
521529
$(SRCDIR)/../skins/khaki/footer.txt \
522530
$(SRCDIR)/../skins/khaki/header.txt \
523531
$(SRCDIR)/../skins/original/css.txt \
532
+ $(SRCDIR)/../skins/original/details.txt \
524533
$(SRCDIR)/../skins/original/footer.txt \
525534
$(SRCDIR)/../skins/original/header.txt \
526535
$(SRCDIR)/../skins/plain_gray/css.txt \
536
+ $(SRCDIR)/../skins/plain_gray/details.txt \
527537
$(SRCDIR)/../skins/plain_gray/footer.txt \
528538
$(SRCDIR)/../skins/plain_gray/header.txt \
529539
$(SRCDIR)/../skins/rounded1/css.txt \
540
+ $(SRCDIR)/../skins/rounded1/details.txt \
530541
$(SRCDIR)/../skins/rounded1/footer.txt \
531542
$(SRCDIR)/../skins/rounded1/header.txt \
532543
$(SRCDIR)/../skins/xekri/css.txt \
544
+ $(SRCDIR)/../skins/xekri/details.txt \
533545
$(SRCDIR)/../skins/xekri/footer.txt \
534546
$(SRCDIR)/../skins/xekri/header.txt \
535547
$(SRCDIR)/diff.tcl \
536548
$(SRCDIR)/markdown.md
537549
538550
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -495,43 +495,55 @@
495 $(SRCDIR)/xfer.c \
496 $(SRCDIR)/xfersetup.c \
497 $(SRCDIR)/zip.c
498
499 EXTRA_FILES = \
 
500 $(SRCDIR)/../skins/black_and_white/css.txt \
 
501 $(SRCDIR)/../skins/black_and_white/footer.txt \
502 $(SRCDIR)/../skins/black_and_white/header.txt \
503 $(SRCDIR)/../skins/blitz/css.txt \
 
504 $(SRCDIR)/../skins/blitz/footer.txt \
505 $(SRCDIR)/../skins/blitz/header.txt \
506 $(SRCDIR)/../skins/blitz/ticket.txt \
507 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
 
508 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
509 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
510 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
511 $(SRCDIR)/../skins/default/css.txt \
 
512 $(SRCDIR)/../skins/default/footer.txt \
513 $(SRCDIR)/../skins/default/header.txt \
514 $(SRCDIR)/../skins/eagle/css.txt \
 
515 $(SRCDIR)/../skins/eagle/footer.txt \
516 $(SRCDIR)/../skins/eagle/header.txt \
517 $(SRCDIR)/../skins/enhanced1/css.txt \
 
518 $(SRCDIR)/../skins/enhanced1/footer.txt \
519 $(SRCDIR)/../skins/enhanced1/header.txt \
520 $(SRCDIR)/../skins/khaki/css.txt \
 
521 $(SRCDIR)/../skins/khaki/footer.txt \
522 $(SRCDIR)/../skins/khaki/header.txt \
523 $(SRCDIR)/../skins/original/css.txt \
 
524 $(SRCDIR)/../skins/original/footer.txt \
525 $(SRCDIR)/../skins/original/header.txt \
526 $(SRCDIR)/../skins/plain_gray/css.txt \
 
527 $(SRCDIR)/../skins/plain_gray/footer.txt \
528 $(SRCDIR)/../skins/plain_gray/header.txt \
529 $(SRCDIR)/../skins/rounded1/css.txt \
 
530 $(SRCDIR)/../skins/rounded1/footer.txt \
531 $(SRCDIR)/../skins/rounded1/header.txt \
532 $(SRCDIR)/../skins/xekri/css.txt \
 
533 $(SRCDIR)/../skins/xekri/footer.txt \
534 $(SRCDIR)/../skins/xekri/header.txt \
535 $(SRCDIR)/diff.tcl \
536 $(SRCDIR)/markdown.md
537
538
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -495,43 +495,55 @@
495 $(SRCDIR)/xfer.c \
496 $(SRCDIR)/xfersetup.c \
497 $(SRCDIR)/zip.c
498
499 EXTRA_FILES = \
500 $(SRCDIR)/../skins/aht/details.txt \
501 $(SRCDIR)/../skins/black_and_white/css.txt \
502 $(SRCDIR)/../skins/black_and_white/details.txt \
503 $(SRCDIR)/../skins/black_and_white/footer.txt \
504 $(SRCDIR)/../skins/black_and_white/header.txt \
505 $(SRCDIR)/../skins/blitz/css.txt \
506 $(SRCDIR)/../skins/blitz/details.txt \
507 $(SRCDIR)/../skins/blitz/footer.txt \
508 $(SRCDIR)/../skins/blitz/header.txt \
509 $(SRCDIR)/../skins/blitz/ticket.txt \
510 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
511 $(SRCDIR)/../skins/blitz_no_logo/details.txt \
512 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
513 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
514 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
515 $(SRCDIR)/../skins/default/css.txt \
516 $(SRCDIR)/../skins/default/details.txt \
517 $(SRCDIR)/../skins/default/footer.txt \
518 $(SRCDIR)/../skins/default/header.txt \
519 $(SRCDIR)/../skins/eagle/css.txt \
520 $(SRCDIR)/../skins/eagle/details.txt \
521 $(SRCDIR)/../skins/eagle/footer.txt \
522 $(SRCDIR)/../skins/eagle/header.txt \
523 $(SRCDIR)/../skins/enhanced1/css.txt \
524 $(SRCDIR)/../skins/enhanced1/details.txt \
525 $(SRCDIR)/../skins/enhanced1/footer.txt \
526 $(SRCDIR)/../skins/enhanced1/header.txt \
527 $(SRCDIR)/../skins/khaki/css.txt \
528 $(SRCDIR)/../skins/khaki/details.txt \
529 $(SRCDIR)/../skins/khaki/footer.txt \
530 $(SRCDIR)/../skins/khaki/header.txt \
531 $(SRCDIR)/../skins/original/css.txt \
532 $(SRCDIR)/../skins/original/details.txt \
533 $(SRCDIR)/../skins/original/footer.txt \
534 $(SRCDIR)/../skins/original/header.txt \
535 $(SRCDIR)/../skins/plain_gray/css.txt \
536 $(SRCDIR)/../skins/plain_gray/details.txt \
537 $(SRCDIR)/../skins/plain_gray/footer.txt \
538 $(SRCDIR)/../skins/plain_gray/header.txt \
539 $(SRCDIR)/../skins/rounded1/css.txt \
540 $(SRCDIR)/../skins/rounded1/details.txt \
541 $(SRCDIR)/../skins/rounded1/footer.txt \
542 $(SRCDIR)/../skins/rounded1/header.txt \
543 $(SRCDIR)/../skins/xekri/css.txt \
544 $(SRCDIR)/../skins/xekri/details.txt \
545 $(SRCDIR)/../skins/xekri/footer.txt \
546 $(SRCDIR)/../skins/xekri/header.txt \
547 $(SRCDIR)/diff.tcl \
548 $(SRCDIR)/markdown.md
549
550
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -495,43 +495,55 @@
495495
$(SRCDIR)/xfer.c \
496496
$(SRCDIR)/xfersetup.c \
497497
$(SRCDIR)/zip.c
498498
499499
EXTRA_FILES = \
500
+ $(SRCDIR)/../skins/aht/details.txt \
500501
$(SRCDIR)/../skins/black_and_white/css.txt \
502
+ $(SRCDIR)/../skins/black_and_white/details.txt \
501503
$(SRCDIR)/../skins/black_and_white/footer.txt \
502504
$(SRCDIR)/../skins/black_and_white/header.txt \
503505
$(SRCDIR)/../skins/blitz/css.txt \
506
+ $(SRCDIR)/../skins/blitz/details.txt \
504507
$(SRCDIR)/../skins/blitz/footer.txt \
505508
$(SRCDIR)/../skins/blitz/header.txt \
506509
$(SRCDIR)/../skins/blitz/ticket.txt \
507510
$(SRCDIR)/../skins/blitz_no_logo/css.txt \
511
+ $(SRCDIR)/../skins/blitz_no_logo/details.txt \
508512
$(SRCDIR)/../skins/blitz_no_logo/footer.txt \
509513
$(SRCDIR)/../skins/blitz_no_logo/header.txt \
510514
$(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
511515
$(SRCDIR)/../skins/default/css.txt \
516
+ $(SRCDIR)/../skins/default/details.txt \
512517
$(SRCDIR)/../skins/default/footer.txt \
513518
$(SRCDIR)/../skins/default/header.txt \
514519
$(SRCDIR)/../skins/eagle/css.txt \
520
+ $(SRCDIR)/../skins/eagle/details.txt \
515521
$(SRCDIR)/../skins/eagle/footer.txt \
516522
$(SRCDIR)/../skins/eagle/header.txt \
517523
$(SRCDIR)/../skins/enhanced1/css.txt \
524
+ $(SRCDIR)/../skins/enhanced1/details.txt \
518525
$(SRCDIR)/../skins/enhanced1/footer.txt \
519526
$(SRCDIR)/../skins/enhanced1/header.txt \
520527
$(SRCDIR)/../skins/khaki/css.txt \
528
+ $(SRCDIR)/../skins/khaki/details.txt \
521529
$(SRCDIR)/../skins/khaki/footer.txt \
522530
$(SRCDIR)/../skins/khaki/header.txt \
523531
$(SRCDIR)/../skins/original/css.txt \
532
+ $(SRCDIR)/../skins/original/details.txt \
524533
$(SRCDIR)/../skins/original/footer.txt \
525534
$(SRCDIR)/../skins/original/header.txt \
526535
$(SRCDIR)/../skins/plain_gray/css.txt \
536
+ $(SRCDIR)/../skins/plain_gray/details.txt \
527537
$(SRCDIR)/../skins/plain_gray/footer.txt \
528538
$(SRCDIR)/../skins/plain_gray/header.txt \
529539
$(SRCDIR)/../skins/rounded1/css.txt \
540
+ $(SRCDIR)/../skins/rounded1/details.txt \
530541
$(SRCDIR)/../skins/rounded1/footer.txt \
531542
$(SRCDIR)/../skins/rounded1/header.txt \
532543
$(SRCDIR)/../skins/xekri/css.txt \
544
+ $(SRCDIR)/../skins/xekri/details.txt \
533545
$(SRCDIR)/../skins/xekri/footer.txt \
534546
$(SRCDIR)/../skins/xekri/header.txt \
535547
$(SRCDIR)/diff.tcl \
536548
$(SRCDIR)/markdown.md
537549
538550
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -495,43 +495,55 @@
495 $(SRCDIR)/xfer.c \
496 $(SRCDIR)/xfersetup.c \
497 $(SRCDIR)/zip.c
498
499 EXTRA_FILES = \
 
500 $(SRCDIR)/../skins/black_and_white/css.txt \
 
501 $(SRCDIR)/../skins/black_and_white/footer.txt \
502 $(SRCDIR)/../skins/black_and_white/header.txt \
503 $(SRCDIR)/../skins/blitz/css.txt \
 
504 $(SRCDIR)/../skins/blitz/footer.txt \
505 $(SRCDIR)/../skins/blitz/header.txt \
506 $(SRCDIR)/../skins/blitz/ticket.txt \
507 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
 
508 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
509 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
510 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
511 $(SRCDIR)/../skins/default/css.txt \
 
512 $(SRCDIR)/../skins/default/footer.txt \
513 $(SRCDIR)/../skins/default/header.txt \
514 $(SRCDIR)/../skins/eagle/css.txt \
 
515 $(SRCDIR)/../skins/eagle/footer.txt \
516 $(SRCDIR)/../skins/eagle/header.txt \
517 $(SRCDIR)/../skins/enhanced1/css.txt \
 
518 $(SRCDIR)/../skins/enhanced1/footer.txt \
519 $(SRCDIR)/../skins/enhanced1/header.txt \
520 $(SRCDIR)/../skins/khaki/css.txt \
 
521 $(SRCDIR)/../skins/khaki/footer.txt \
522 $(SRCDIR)/../skins/khaki/header.txt \
523 $(SRCDIR)/../skins/original/css.txt \
 
524 $(SRCDIR)/../skins/original/footer.txt \
525 $(SRCDIR)/../skins/original/header.txt \
526 $(SRCDIR)/../skins/plain_gray/css.txt \
 
527 $(SRCDIR)/../skins/plain_gray/footer.txt \
528 $(SRCDIR)/../skins/plain_gray/header.txt \
529 $(SRCDIR)/../skins/rounded1/css.txt \
 
530 $(SRCDIR)/../skins/rounded1/footer.txt \
531 $(SRCDIR)/../skins/rounded1/header.txt \
532 $(SRCDIR)/../skins/xekri/css.txt \
 
533 $(SRCDIR)/../skins/xekri/footer.txt \
534 $(SRCDIR)/../skins/xekri/header.txt \
535 $(SRCDIR)/diff.tcl \
536 $(SRCDIR)/markdown.md
537
538
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -495,43 +495,55 @@
495 $(SRCDIR)/xfer.c \
496 $(SRCDIR)/xfersetup.c \
497 $(SRCDIR)/zip.c
498
499 EXTRA_FILES = \
500 $(SRCDIR)/../skins/aht/details.txt \
501 $(SRCDIR)/../skins/black_and_white/css.txt \
502 $(SRCDIR)/../skins/black_and_white/details.txt \
503 $(SRCDIR)/../skins/black_and_white/footer.txt \
504 $(SRCDIR)/../skins/black_and_white/header.txt \
505 $(SRCDIR)/../skins/blitz/css.txt \
506 $(SRCDIR)/../skins/blitz/details.txt \
507 $(SRCDIR)/../skins/blitz/footer.txt \
508 $(SRCDIR)/../skins/blitz/header.txt \
509 $(SRCDIR)/../skins/blitz/ticket.txt \
510 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
511 $(SRCDIR)/../skins/blitz_no_logo/details.txt \
512 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
513 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
514 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
515 $(SRCDIR)/../skins/default/css.txt \
516 $(SRCDIR)/../skins/default/details.txt \
517 $(SRCDIR)/../skins/default/footer.txt \
518 $(SRCDIR)/../skins/default/header.txt \
519 $(SRCDIR)/../skins/eagle/css.txt \
520 $(SRCDIR)/../skins/eagle/details.txt \
521 $(SRCDIR)/../skins/eagle/footer.txt \
522 $(SRCDIR)/../skins/eagle/header.txt \
523 $(SRCDIR)/../skins/enhanced1/css.txt \
524 $(SRCDIR)/../skins/enhanced1/details.txt \
525 $(SRCDIR)/../skins/enhanced1/footer.txt \
526 $(SRCDIR)/../skins/enhanced1/header.txt \
527 $(SRCDIR)/../skins/khaki/css.txt \
528 $(SRCDIR)/../skins/khaki/details.txt \
529 $(SRCDIR)/../skins/khaki/footer.txt \
530 $(SRCDIR)/../skins/khaki/header.txt \
531 $(SRCDIR)/../skins/original/css.txt \
532 $(SRCDIR)/../skins/original/details.txt \
533 $(SRCDIR)/../skins/original/footer.txt \
534 $(SRCDIR)/../skins/original/header.txt \
535 $(SRCDIR)/../skins/plain_gray/css.txt \
536 $(SRCDIR)/../skins/plain_gray/details.txt \
537 $(SRCDIR)/../skins/plain_gray/footer.txt \
538 $(SRCDIR)/../skins/plain_gray/header.txt \
539 $(SRCDIR)/../skins/rounded1/css.txt \
540 $(SRCDIR)/../skins/rounded1/details.txt \
541 $(SRCDIR)/../skins/rounded1/footer.txt \
542 $(SRCDIR)/../skins/rounded1/header.txt \
543 $(SRCDIR)/../skins/xekri/css.txt \
544 $(SRCDIR)/../skins/xekri/details.txt \
545 $(SRCDIR)/../skins/xekri/footer.txt \
546 $(SRCDIR)/../skins/xekri/header.txt \
547 $(SRCDIR)/diff.tcl \
548 $(SRCDIR)/markdown.md
549
550
+13 -1
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -333,43 +333,55 @@
333333
wysiwyg_.c \
334334
xfer_.c \
335335
xfersetup_.c \
336336
zip_.c
337337
338
-EXTRA_FILES = $(SRCDIR)\../skins/black_and_white/css.txt \
338
+EXTRA_FILES = $(SRCDIR)\../skins/aht/details.txt \
339
+ $(SRCDIR)\../skins/black_and_white/css.txt \
340
+ $(SRCDIR)\../skins/black_and_white/details.txt \
339341
$(SRCDIR)\../skins/black_and_white/footer.txt \
340342
$(SRCDIR)\../skins/black_and_white/header.txt \
341343
$(SRCDIR)\../skins/blitz/css.txt \
344
+ $(SRCDIR)\../skins/blitz/details.txt \
342345
$(SRCDIR)\../skins/blitz/footer.txt \
343346
$(SRCDIR)\../skins/blitz/header.txt \
344347
$(SRCDIR)\../skins/blitz/ticket.txt \
345348
$(SRCDIR)\../skins/blitz_no_logo/css.txt \
349
+ $(SRCDIR)\../skins/blitz_no_logo/details.txt \
346350
$(SRCDIR)\../skins/blitz_no_logo/footer.txt \
347351
$(SRCDIR)\../skins/blitz_no_logo/header.txt \
348352
$(SRCDIR)\../skins/blitz_no_logo/ticket.txt \
349353
$(SRCDIR)\../skins/default/css.txt \
354
+ $(SRCDIR)\../skins/default/details.txt \
350355
$(SRCDIR)\../skins/default/footer.txt \
351356
$(SRCDIR)\../skins/default/header.txt \
352357
$(SRCDIR)\../skins/eagle/css.txt \
358
+ $(SRCDIR)\../skins/eagle/details.txt \
353359
$(SRCDIR)\../skins/eagle/footer.txt \
354360
$(SRCDIR)\../skins/eagle/header.txt \
355361
$(SRCDIR)\../skins/enhanced1/css.txt \
362
+ $(SRCDIR)\../skins/enhanced1/details.txt \
356363
$(SRCDIR)\../skins/enhanced1/footer.txt \
357364
$(SRCDIR)\../skins/enhanced1/header.txt \
358365
$(SRCDIR)\../skins/khaki/css.txt \
366
+ $(SRCDIR)\../skins/khaki/details.txt \
359367
$(SRCDIR)\../skins/khaki/footer.txt \
360368
$(SRCDIR)\../skins/khaki/header.txt \
361369
$(SRCDIR)\../skins/original/css.txt \
370
+ $(SRCDIR)\../skins/original/details.txt \
362371
$(SRCDIR)\../skins/original/footer.txt \
363372
$(SRCDIR)\../skins/original/header.txt \
364373
$(SRCDIR)\../skins/plain_gray/css.txt \
374
+ $(SRCDIR)\../skins/plain_gray/details.txt \
365375
$(SRCDIR)\../skins/plain_gray/footer.txt \
366376
$(SRCDIR)\../skins/plain_gray/header.txt \
367377
$(SRCDIR)\../skins/rounded1/css.txt \
378
+ $(SRCDIR)\../skins/rounded1/details.txt \
368379
$(SRCDIR)\../skins/rounded1/footer.txt \
369380
$(SRCDIR)\../skins/rounded1/header.txt \
370381
$(SRCDIR)\../skins/xekri/css.txt \
382
+ $(SRCDIR)\../skins/xekri/details.txt \
371383
$(SRCDIR)\../skins/xekri/footer.txt \
372384
$(SRCDIR)\../skins/xekri/header.txt \
373385
$(SRCDIR)\diff.tcl \
374386
$(SRCDIR)\markdown.md
375387
376388
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -333,43 +333,55 @@
333 wysiwyg_.c \
334 xfer_.c \
335 xfersetup_.c \
336 zip_.c
337
338 EXTRA_FILES = $(SRCDIR)\../skins/black_and_white/css.txt \
 
 
339 $(SRCDIR)\../skins/black_and_white/footer.txt \
340 $(SRCDIR)\../skins/black_and_white/header.txt \
341 $(SRCDIR)\../skins/blitz/css.txt \
 
342 $(SRCDIR)\../skins/blitz/footer.txt \
343 $(SRCDIR)\../skins/blitz/header.txt \
344 $(SRCDIR)\../skins/blitz/ticket.txt \
345 $(SRCDIR)\../skins/blitz_no_logo/css.txt \
 
346 $(SRCDIR)\../skins/blitz_no_logo/footer.txt \
347 $(SRCDIR)\../skins/blitz_no_logo/header.txt \
348 $(SRCDIR)\../skins/blitz_no_logo/ticket.txt \
349 $(SRCDIR)\../skins/default/css.txt \
 
350 $(SRCDIR)\../skins/default/footer.txt \
351 $(SRCDIR)\../skins/default/header.txt \
352 $(SRCDIR)\../skins/eagle/css.txt \
 
353 $(SRCDIR)\../skins/eagle/footer.txt \
354 $(SRCDIR)\../skins/eagle/header.txt \
355 $(SRCDIR)\../skins/enhanced1/css.txt \
 
356 $(SRCDIR)\../skins/enhanced1/footer.txt \
357 $(SRCDIR)\../skins/enhanced1/header.txt \
358 $(SRCDIR)\../skins/khaki/css.txt \
 
359 $(SRCDIR)\../skins/khaki/footer.txt \
360 $(SRCDIR)\../skins/khaki/header.txt \
361 $(SRCDIR)\../skins/original/css.txt \
 
362 $(SRCDIR)\../skins/original/footer.txt \
363 $(SRCDIR)\../skins/original/header.txt \
364 $(SRCDIR)\../skins/plain_gray/css.txt \
 
365 $(SRCDIR)\../skins/plain_gray/footer.txt \
366 $(SRCDIR)\../skins/plain_gray/header.txt \
367 $(SRCDIR)\../skins/rounded1/css.txt \
 
368 $(SRCDIR)\../skins/rounded1/footer.txt \
369 $(SRCDIR)\../skins/rounded1/header.txt \
370 $(SRCDIR)\../skins/xekri/css.txt \
 
371 $(SRCDIR)\../skins/xekri/footer.txt \
372 $(SRCDIR)\../skins/xekri/header.txt \
373 $(SRCDIR)\diff.tcl \
374 $(SRCDIR)\markdown.md
375
376
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -333,43 +333,55 @@
333 wysiwyg_.c \
334 xfer_.c \
335 xfersetup_.c \
336 zip_.c
337
338 EXTRA_FILES = $(SRCDIR)\../skins/aht/details.txt \
339 $(SRCDIR)\../skins/black_and_white/css.txt \
340 $(SRCDIR)\../skins/black_and_white/details.txt \
341 $(SRCDIR)\../skins/black_and_white/footer.txt \
342 $(SRCDIR)\../skins/black_and_white/header.txt \
343 $(SRCDIR)\../skins/blitz/css.txt \
344 $(SRCDIR)\../skins/blitz/details.txt \
345 $(SRCDIR)\../skins/blitz/footer.txt \
346 $(SRCDIR)\../skins/blitz/header.txt \
347 $(SRCDIR)\../skins/blitz/ticket.txt \
348 $(SRCDIR)\../skins/blitz_no_logo/css.txt \
349 $(SRCDIR)\../skins/blitz_no_logo/details.txt \
350 $(SRCDIR)\../skins/blitz_no_logo/footer.txt \
351 $(SRCDIR)\../skins/blitz_no_logo/header.txt \
352 $(SRCDIR)\../skins/blitz_no_logo/ticket.txt \
353 $(SRCDIR)\../skins/default/css.txt \
354 $(SRCDIR)\../skins/default/details.txt \
355 $(SRCDIR)\../skins/default/footer.txt \
356 $(SRCDIR)\../skins/default/header.txt \
357 $(SRCDIR)\../skins/eagle/css.txt \
358 $(SRCDIR)\../skins/eagle/details.txt \
359 $(SRCDIR)\../skins/eagle/footer.txt \
360 $(SRCDIR)\../skins/eagle/header.txt \
361 $(SRCDIR)\../skins/enhanced1/css.txt \
362 $(SRCDIR)\../skins/enhanced1/details.txt \
363 $(SRCDIR)\../skins/enhanced1/footer.txt \
364 $(SRCDIR)\../skins/enhanced1/header.txt \
365 $(SRCDIR)\../skins/khaki/css.txt \
366 $(SRCDIR)\../skins/khaki/details.txt \
367 $(SRCDIR)\../skins/khaki/footer.txt \
368 $(SRCDIR)\../skins/khaki/header.txt \
369 $(SRCDIR)\../skins/original/css.txt \
370 $(SRCDIR)\../skins/original/details.txt \
371 $(SRCDIR)\../skins/original/footer.txt \
372 $(SRCDIR)\../skins/original/header.txt \
373 $(SRCDIR)\../skins/plain_gray/css.txt \
374 $(SRCDIR)\../skins/plain_gray/details.txt \
375 $(SRCDIR)\../skins/plain_gray/footer.txt \
376 $(SRCDIR)\../skins/plain_gray/header.txt \
377 $(SRCDIR)\../skins/rounded1/css.txt \
378 $(SRCDIR)\../skins/rounded1/details.txt \
379 $(SRCDIR)\../skins/rounded1/footer.txt \
380 $(SRCDIR)\../skins/rounded1/header.txt \
381 $(SRCDIR)\../skins/xekri/css.txt \
382 $(SRCDIR)\../skins/xekri/details.txt \
383 $(SRCDIR)\../skins/xekri/footer.txt \
384 $(SRCDIR)\../skins/xekri/header.txt \
385 $(SRCDIR)\diff.tcl \
386 $(SRCDIR)\markdown.md
387
388
+13 -1
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -333,43 +333,55 @@
333333
wysiwyg_.c \
334334
xfer_.c \
335335
xfersetup_.c \
336336
zip_.c
337337
338
-EXTRA_FILES = $(SRCDIR)\../skins/black_and_white/css.txt \
338
+EXTRA_FILES = $(SRCDIR)\../skins/aht/details.txt \
339
+ $(SRCDIR)\../skins/black_and_white/css.txt \
340
+ $(SRCDIR)\../skins/black_and_white/details.txt \
339341
$(SRCDIR)\../skins/black_and_white/footer.txt \
340342
$(SRCDIR)\../skins/black_and_white/header.txt \
341343
$(SRCDIR)\../skins/blitz/css.txt \
344
+ $(SRCDIR)\../skins/blitz/details.txt \
342345
$(SRCDIR)\../skins/blitz/footer.txt \
343346
$(SRCDIR)\../skins/blitz/header.txt \
344347
$(SRCDIR)\../skins/blitz/ticket.txt \
345348
$(SRCDIR)\../skins/blitz_no_logo/css.txt \
349
+ $(SRCDIR)\../skins/blitz_no_logo/details.txt \
346350
$(SRCDIR)\../skins/blitz_no_logo/footer.txt \
347351
$(SRCDIR)\../skins/blitz_no_logo/header.txt \
348352
$(SRCDIR)\../skins/blitz_no_logo/ticket.txt \
349353
$(SRCDIR)\../skins/default/css.txt \
354
+ $(SRCDIR)\../skins/default/details.txt \
350355
$(SRCDIR)\../skins/default/footer.txt \
351356
$(SRCDIR)\../skins/default/header.txt \
352357
$(SRCDIR)\../skins/eagle/css.txt \
358
+ $(SRCDIR)\../skins/eagle/details.txt \
353359
$(SRCDIR)\../skins/eagle/footer.txt \
354360
$(SRCDIR)\../skins/eagle/header.txt \
355361
$(SRCDIR)\../skins/enhanced1/css.txt \
362
+ $(SRCDIR)\../skins/enhanced1/details.txt \
356363
$(SRCDIR)\../skins/enhanced1/footer.txt \
357364
$(SRCDIR)\../skins/enhanced1/header.txt \
358365
$(SRCDIR)\../skins/khaki/css.txt \
366
+ $(SRCDIR)\../skins/khaki/details.txt \
359367
$(SRCDIR)\../skins/khaki/footer.txt \
360368
$(SRCDIR)\../skins/khaki/header.txt \
361369
$(SRCDIR)\../skins/original/css.txt \
370
+ $(SRCDIR)\../skins/original/details.txt \
362371
$(SRCDIR)\../skins/original/footer.txt \
363372
$(SRCDIR)\../skins/original/header.txt \
364373
$(SRCDIR)\../skins/plain_gray/css.txt \
374
+ $(SRCDIR)\../skins/plain_gray/details.txt \
365375
$(SRCDIR)\../skins/plain_gray/footer.txt \
366376
$(SRCDIR)\../skins/plain_gray/header.txt \
367377
$(SRCDIR)\../skins/rounded1/css.txt \
378
+ $(SRCDIR)\../skins/rounded1/details.txt \
368379
$(SRCDIR)\../skins/rounded1/footer.txt \
369380
$(SRCDIR)\../skins/rounded1/header.txt \
370381
$(SRCDIR)\../skins/xekri/css.txt \
382
+ $(SRCDIR)\../skins/xekri/details.txt \
371383
$(SRCDIR)\../skins/xekri/footer.txt \
372384
$(SRCDIR)\../skins/xekri/header.txt \
373385
$(SRCDIR)\diff.tcl \
374386
$(SRCDIR)\markdown.md
375387
376388
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -333,43 +333,55 @@
333 wysiwyg_.c \
334 xfer_.c \
335 xfersetup_.c \
336 zip_.c
337
338 EXTRA_FILES = $(SRCDIR)\../skins/black_and_white/css.txt \
 
 
339 $(SRCDIR)\../skins/black_and_white/footer.txt \
340 $(SRCDIR)\../skins/black_and_white/header.txt \
341 $(SRCDIR)\../skins/blitz/css.txt \
 
342 $(SRCDIR)\../skins/blitz/footer.txt \
343 $(SRCDIR)\../skins/blitz/header.txt \
344 $(SRCDIR)\../skins/blitz/ticket.txt \
345 $(SRCDIR)\../skins/blitz_no_logo/css.txt \
 
346 $(SRCDIR)\../skins/blitz_no_logo/footer.txt \
347 $(SRCDIR)\../skins/blitz_no_logo/header.txt \
348 $(SRCDIR)\../skins/blitz_no_logo/ticket.txt \
349 $(SRCDIR)\../skins/default/css.txt \
 
350 $(SRCDIR)\../skins/default/footer.txt \
351 $(SRCDIR)\../skins/default/header.txt \
352 $(SRCDIR)\../skins/eagle/css.txt \
 
353 $(SRCDIR)\../skins/eagle/footer.txt \
354 $(SRCDIR)\../skins/eagle/header.txt \
355 $(SRCDIR)\../skins/enhanced1/css.txt \
 
356 $(SRCDIR)\../skins/enhanced1/footer.txt \
357 $(SRCDIR)\../skins/enhanced1/header.txt \
358 $(SRCDIR)\../skins/khaki/css.txt \
 
359 $(SRCDIR)\../skins/khaki/footer.txt \
360 $(SRCDIR)\../skins/khaki/header.txt \
361 $(SRCDIR)\../skins/original/css.txt \
 
362 $(SRCDIR)\../skins/original/footer.txt \
363 $(SRCDIR)\../skins/original/header.txt \
364 $(SRCDIR)\../skins/plain_gray/css.txt \
 
365 $(SRCDIR)\../skins/plain_gray/footer.txt \
366 $(SRCDIR)\../skins/plain_gray/header.txt \
367 $(SRCDIR)\../skins/rounded1/css.txt \
 
368 $(SRCDIR)\../skins/rounded1/footer.txt \
369 $(SRCDIR)\../skins/rounded1/header.txt \
370 $(SRCDIR)\../skins/xekri/css.txt \
 
371 $(SRCDIR)\../skins/xekri/footer.txt \
372 $(SRCDIR)\../skins/xekri/header.txt \
373 $(SRCDIR)\diff.tcl \
374 $(SRCDIR)\markdown.md
375
376
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -333,43 +333,55 @@
333 wysiwyg_.c \
334 xfer_.c \
335 xfersetup_.c \
336 zip_.c
337
338 EXTRA_FILES = $(SRCDIR)\../skins/aht/details.txt \
339 $(SRCDIR)\../skins/black_and_white/css.txt \
340 $(SRCDIR)\../skins/black_and_white/details.txt \
341 $(SRCDIR)\../skins/black_and_white/footer.txt \
342 $(SRCDIR)\../skins/black_and_white/header.txt \
343 $(SRCDIR)\../skins/blitz/css.txt \
344 $(SRCDIR)\../skins/blitz/details.txt \
345 $(SRCDIR)\../skins/blitz/footer.txt \
346 $(SRCDIR)\../skins/blitz/header.txt \
347 $(SRCDIR)\../skins/blitz/ticket.txt \
348 $(SRCDIR)\../skins/blitz_no_logo/css.txt \
349 $(SRCDIR)\../skins/blitz_no_logo/details.txt \
350 $(SRCDIR)\../skins/blitz_no_logo/footer.txt \
351 $(SRCDIR)\../skins/blitz_no_logo/header.txt \
352 $(SRCDIR)\../skins/blitz_no_logo/ticket.txt \
353 $(SRCDIR)\../skins/default/css.txt \
354 $(SRCDIR)\../skins/default/details.txt \
355 $(SRCDIR)\../skins/default/footer.txt \
356 $(SRCDIR)\../skins/default/header.txt \
357 $(SRCDIR)\../skins/eagle/css.txt \
358 $(SRCDIR)\../skins/eagle/details.txt \
359 $(SRCDIR)\../skins/eagle/footer.txt \
360 $(SRCDIR)\../skins/eagle/header.txt \
361 $(SRCDIR)\../skins/enhanced1/css.txt \
362 $(SRCDIR)\../skins/enhanced1/details.txt \
363 $(SRCDIR)\../skins/enhanced1/footer.txt \
364 $(SRCDIR)\../skins/enhanced1/header.txt \
365 $(SRCDIR)\../skins/khaki/css.txt \
366 $(SRCDIR)\../skins/khaki/details.txt \
367 $(SRCDIR)\../skins/khaki/footer.txt \
368 $(SRCDIR)\../skins/khaki/header.txt \
369 $(SRCDIR)\../skins/original/css.txt \
370 $(SRCDIR)\../skins/original/details.txt \
371 $(SRCDIR)\../skins/original/footer.txt \
372 $(SRCDIR)\../skins/original/header.txt \
373 $(SRCDIR)\../skins/plain_gray/css.txt \
374 $(SRCDIR)\../skins/plain_gray/details.txt \
375 $(SRCDIR)\../skins/plain_gray/footer.txt \
376 $(SRCDIR)\../skins/plain_gray/header.txt \
377 $(SRCDIR)\../skins/rounded1/css.txt \
378 $(SRCDIR)\../skins/rounded1/details.txt \
379 $(SRCDIR)\../skins/rounded1/footer.txt \
380 $(SRCDIR)\../skins/rounded1/header.txt \
381 $(SRCDIR)\../skins/xekri/css.txt \
382 $(SRCDIR)\../skins/xekri/details.txt \
383 $(SRCDIR)\../skins/xekri/footer.txt \
384 $(SRCDIR)\../skins/xekri/header.txt \
385 $(SRCDIR)\diff.tcl \
386 $(SRCDIR)\markdown.md
387
388
--- www/customskin.md
+++ www/customskin.md
@@ -46,12 +46,14 @@
4646
--------------
4747
4848
Fossil comes with several built-in skins. The sources to these built-ins can
4949
be found in the Fossil source tree under the skins/ folder. The skins/
5050
folder contains a separate subfolder for each built-in skin, with each
51
-subfolders holding three files, "css.txt", "footer.txt", and "header.txt",
52
-that describe the CSS, footer, and header for that skin, respectively.
51
+subfolders holding four files, "css.txt", "details.txt",
52
+"footer.txt", and "header.txt",
53
+that describe the CSS, rendering options,
54
+footer, and header for that skin, respectively.
5355
5456
The skin of a repository can be changed to any of the built-in skins using
5557
the web interface by going to the /setup_skin web page (requires Admin
5658
privileges) and clicking the appropriate button. Or, the --skin command
5759
line option can be used for the
@@ -206,10 +208,11 @@
206208
want, but the following is a technique that has worked well in the past and
207209
can serve as a starting point for future work:
208210
209211
1. Select a built-in skin that is closest to the desired look. Make
210212
copies of the css, footer, and header into files name "css.txt",
213
+ "details.txt",
211214
"footer.txt", and "header.txt" in some temporary directory.
212215
213216
If the Fossil source code is available, then these three files can
214217
be copied directly out of one of the subdirectories under skins. If
215218
sources are not easily at hand, then a copy/paste out of the
@@ -221,12 +224,13 @@
221224
2. Run the [fossil ui](../../../help?cmd=ui) command with an extra
222225
option "--skin SKINDIR" where SKINDIR is the name of the directory
223226
in which the three txt files were stored in step 1. This will bring
224227
up the Fossil website using the tree files in SKINDIR.
225228
226
- 3. Edit the three txt files in SKINDIR. After making each small change,
229
+ 3. Edit the four txt files in SKINDIR. After making each small change,
227230
press Reload on the web browser to see the effect of that change.
228231
Iterate until the desired look is achieved.
229232
230
- 4. Copy/paste the resulting css.txt, header.txt, and footer.txt files
231
- into the CSS, header, and footer configuration screens under the
232
- Admin menu.
233
+ 4. Copy/paste the resulting css.txt, details.txt,
234
+ header.txt, and footer.txt files
235
+ into the CSS, details, header, and footer configuration screens
236
+ under the Admin/Skins menu.
233237
--- www/customskin.md
+++ www/customskin.md
@@ -46,12 +46,14 @@
46 --------------
47
48 Fossil comes with several built-in skins. The sources to these built-ins can
49 be found in the Fossil source tree under the skins/ folder. The skins/
50 folder contains a separate subfolder for each built-in skin, with each
51 subfolders holding three files, "css.txt", "footer.txt", and "header.txt",
52 that describe the CSS, footer, and header for that skin, respectively.
 
 
53
54 The skin of a repository can be changed to any of the built-in skins using
55 the web interface by going to the /setup_skin web page (requires Admin
56 privileges) and clicking the appropriate button. Or, the --skin command
57 line option can be used for the
@@ -206,10 +208,11 @@
206 want, but the following is a technique that has worked well in the past and
207 can serve as a starting point for future work:
208
209 1. Select a built-in skin that is closest to the desired look. Make
210 copies of the css, footer, and header into files name "css.txt",
 
211 "footer.txt", and "header.txt" in some temporary directory.
212
213 If the Fossil source code is available, then these three files can
214 be copied directly out of one of the subdirectories under skins. If
215 sources are not easily at hand, then a copy/paste out of the
@@ -221,12 +224,13 @@
221 2. Run the [fossil ui](../../../help?cmd=ui) command with an extra
222 option "--skin SKINDIR" where SKINDIR is the name of the directory
223 in which the three txt files were stored in step 1. This will bring
224 up the Fossil website using the tree files in SKINDIR.
225
226 3. Edit the three txt files in SKINDIR. After making each small change,
227 press Reload on the web browser to see the effect of that change.
228 Iterate until the desired look is achieved.
229
230 4. Copy/paste the resulting css.txt, header.txt, and footer.txt files
231 into the CSS, header, and footer configuration screens under the
232 Admin menu.
 
233
--- www/customskin.md
+++ www/customskin.md
@@ -46,12 +46,14 @@
46 --------------
47
48 Fossil comes with several built-in skins. The sources to these built-ins can
49 be found in the Fossil source tree under the skins/ folder. The skins/
50 folder contains a separate subfolder for each built-in skin, with each
51 subfolders holding four files, "css.txt", "details.txt",
52 "footer.txt", and "header.txt",
53 that describe the CSS, rendering options,
54 footer, and header for that skin, respectively.
55
56 The skin of a repository can be changed to any of the built-in skins using
57 the web interface by going to the /setup_skin web page (requires Admin
58 privileges) and clicking the appropriate button. Or, the --skin command
59 line option can be used for the
@@ -206,10 +208,11 @@
208 want, but the following is a technique that has worked well in the past and
209 can serve as a starting point for future work:
210
211 1. Select a built-in skin that is closest to the desired look. Make
212 copies of the css, footer, and header into files name "css.txt",
213 "details.txt",
214 "footer.txt", and "header.txt" in some temporary directory.
215
216 If the Fossil source code is available, then these three files can
217 be copied directly out of one of the subdirectories under skins. If
218 sources are not easily at hand, then a copy/paste out of the
@@ -221,12 +224,13 @@
224 2. Run the [fossil ui](../../../help?cmd=ui) command with an extra
225 option "--skin SKINDIR" where SKINDIR is the name of the directory
226 in which the three txt files were stored in step 1. This will bring
227 up the Fossil website using the tree files in SKINDIR.
228
229 3. Edit the four txt files in SKINDIR. After making each small change,
230 press Reload on the web browser to see the effect of that change.
231 Iterate until the desired look is achieved.
232
233 4. Copy/paste the resulting css.txt, details.txt,
234 header.txt, and footer.txt files
235 into the CSS, details, header, and footer configuration screens
236 under the Admin/Skins menu.
237
+9 -9
--- www/event.wiki
+++ www/event.wiki
@@ -7,54 +7,54 @@
77
that is associated with a point in time rather than having a page name.
88
Each technote causes a single entry to appear on the
99
[/timeline?y=e | Timeline Page].
1010
Clicking on the timeline link will display the text of the technote.
1111
The wiki content, the timeline entry text, the
12
-time of the event, and the timeline background color can all be edited.
12
+time of the technote, and the timeline background color can all be edited.
1313
1414
As with check-ins, wiki, and tickets, all technotes automatically synchronize
1515
to other repositories. Hence, technotes can be viewed, created, and edited
1616
off-line. And the complete edit history for technotes is maintained
1717
for auditing purposes.
1818
19
-Possible uses for events include:
19
+Possible uses for technotes include:
2020
2121
* <b>Milestones</b>. Project milestones, such as releases or beta-test
22
- cycles, can be recorded as events. The timeline entry for the event
22
+ cycles, can be recorded as technotes. The timeline entry for the technote
2323
can be something simple like "Version 1.2.3" perhaps with a bright
2424
color background to draw attention to the entry and the wiki content
2525
can contain release notes, for example.
2626
2727
* <b>Blog Entries</b>. Blog entries from developers describing the current
2828
state of a project, or rational for various design decisions, or
29
- roadmaps for future development, can be entered as events.
29
+ roadmaps for future development, can be entered as technotes.
3030
3131
* <b>Process Checkpoints</b>. For projects that have a formal process,
32
- events can be used to record the completion or the initiation of
33
- various process steps. For example, an event can be used to record
32
+ technotes can be used to record the completion or the initiation of
33
+ various process steps. For example, a technote can be used to record
3434
the successful completion of a long-running test, perhaps with
3535
performance results and details of where the test was run and who
3636
ran it recorded in the wiki content.
3737
3838
* <b>News Articles</b>. Significant occurrences in the lifecycle of
39
- a project can be recorded as news articles using events. Perhaps the
39
+ a project can be recorded as news articles using technotes. Perhaps the
4040
domain name of the canonical website for a project changes, or new
4141
server hardware is obtained. Such happenings are appropriate for
4242
reporting as news.
4343
4444
* <b>Announcements</b>. Changes to the composition of the development
4545
team or acquisition of new project sponsors can be communicated as
46
- announcements which can be implemented as events.
46
+ announcements which can be implemented as technotes.
4747
4848
No project is required to use technotes. But technotes can help many projects
4949
stay better organized and provide a better historical record of the
5050
development progress.
5151
5252
<h2>Viewing Technotes</h2>
5353
5454
Because technotes are considered a special kind of wiki,
55
-users must have permission to read wiki in order read events.
55
+users must have permission to read wiki in order read technotes.
5656
Enable the "j" permission under the /Setup/Users menu in order
5757
to give specific users or user classes the ability to view wiki
5858
and technotes.
5959
6060
Technotes show up on the timeline. Click on the hyperlink beside the
6161
--- www/event.wiki
+++ www/event.wiki
@@ -7,54 +7,54 @@
7 that is associated with a point in time rather than having a page name.
8 Each technote causes a single entry to appear on the
9 [/timeline?y=e | Timeline Page].
10 Clicking on the timeline link will display the text of the technote.
11 The wiki content, the timeline entry text, the
12 time of the event, and the timeline background color can all be edited.
13
14 As with check-ins, wiki, and tickets, all technotes automatically synchronize
15 to other repositories. Hence, technotes can be viewed, created, and edited
16 off-line. And the complete edit history for technotes is maintained
17 for auditing purposes.
18
19 Possible uses for events include:
20
21 * <b>Milestones</b>. Project milestones, such as releases or beta-test
22 cycles, can be recorded as events. The timeline entry for the event
23 can be something simple like "Version 1.2.3" perhaps with a bright
24 color background to draw attention to the entry and the wiki content
25 can contain release notes, for example.
26
27 * <b>Blog Entries</b>. Blog entries from developers describing the current
28 state of a project, or rational for various design decisions, or
29 roadmaps for future development, can be entered as events.
30
31 * <b>Process Checkpoints</b>. For projects that have a formal process,
32 events can be used to record the completion or the initiation of
33 various process steps. For example, an event can be used to record
34 the successful completion of a long-running test, perhaps with
35 performance results and details of where the test was run and who
36 ran it recorded in the wiki content.
37
38 * <b>News Articles</b>. Significant occurrences in the lifecycle of
39 a project can be recorded as news articles using events. Perhaps the
40 domain name of the canonical website for a project changes, or new
41 server hardware is obtained. Such happenings are appropriate for
42 reporting as news.
43
44 * <b>Announcements</b>. Changes to the composition of the development
45 team or acquisition of new project sponsors can be communicated as
46 announcements which can be implemented as events.
47
48 No project is required to use technotes. But technotes can help many projects
49 stay better organized and provide a better historical record of the
50 development progress.
51
52 <h2>Viewing Technotes</h2>
53
54 Because technotes are considered a special kind of wiki,
55 users must have permission to read wiki in order read events.
56 Enable the "j" permission under the /Setup/Users menu in order
57 to give specific users or user classes the ability to view wiki
58 and technotes.
59
60 Technotes show up on the timeline. Click on the hyperlink beside the
61
--- www/event.wiki
+++ www/event.wiki
@@ -7,54 +7,54 @@
7 that is associated with a point in time rather than having a page name.
8 Each technote causes a single entry to appear on the
9 [/timeline?y=e | Timeline Page].
10 Clicking on the timeline link will display the text of the technote.
11 The wiki content, the timeline entry text, the
12 time of the technote, and the timeline background color can all be edited.
13
14 As with check-ins, wiki, and tickets, all technotes automatically synchronize
15 to other repositories. Hence, technotes can be viewed, created, and edited
16 off-line. And the complete edit history for technotes is maintained
17 for auditing purposes.
18
19 Possible uses for technotes include:
20
21 * <b>Milestones</b>. Project milestones, such as releases or beta-test
22 cycles, can be recorded as technotes. The timeline entry for the technote
23 can be something simple like "Version 1.2.3" perhaps with a bright
24 color background to draw attention to the entry and the wiki content
25 can contain release notes, for example.
26
27 * <b>Blog Entries</b>. Blog entries from developers describing the current
28 state of a project, or rational for various design decisions, or
29 roadmaps for future development, can be entered as technotes.
30
31 * <b>Process Checkpoints</b>. For projects that have a formal process,
32 technotes can be used to record the completion or the initiation of
33 various process steps. For example, a technote can be used to record
34 the successful completion of a long-running test, perhaps with
35 performance results and details of where the test was run and who
36 ran it recorded in the wiki content.
37
38 * <b>News Articles</b>. Significant occurrences in the lifecycle of
39 a project can be recorded as news articles using technotes. Perhaps the
40 domain name of the canonical website for a project changes, or new
41 server hardware is obtained. Such happenings are appropriate for
42 reporting as news.
43
44 * <b>Announcements</b>. Changes to the composition of the development
45 team or acquisition of new project sponsors can be communicated as
46 announcements which can be implemented as technotes.
47
48 No project is required to use technotes. But technotes can help many projects
49 stay better organized and provide a better historical record of the
50 development progress.
51
52 <h2>Viewing Technotes</h2>
53
54 Because technotes are considered a special kind of wiki,
55 users must have permission to read wiki in order read technotes.
56 Enable the "j" permission under the /Setup/Users menu in order
57 to give specific users or user classes the ability to view wiki
58 and technotes.
59
60 Technotes show up on the timeline. Click on the hyperlink beside the
61

Keyboard Shortcuts

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